Skip to content

Commit

Permalink
Build 1.4.2 : SoundMaster supports multiple audio outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
legendsayantan committed Jun 13, 2024
1 parent f1927b9 commit 0446b02
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Contains some easy-to-use tools to go beyond the level of control allowed by And
- [x] **Debloater** - Uninstall system apps and bloatware, with app information from [UAD](https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation).
- [x] **ThemePatcher** - Unlocks premium content for free, from the Oppo/Realme/Oneplus theme store.
- [x] **MixedAudio** - Allows multiple media apps to play at the same time, or mute audio of specific apps.
- [x] **SoundMaster** - Independent volume control for every app, and more! Requires Android 10 or later.
- [x] **SoundMaster** - Independent volume control for every app, play on multiple audio outputs simultaneously, and more! Requires Android 10 or later.

⚠ SoundMaster may not work on apps with strong copyright protection, like Spotify. In case SoundMaster crashes and some apps lose sound output, use MixedAudio to unmute them.

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 27
targetSdk 34
versionCode 1
versionName "1.4.1"
versionName "1.4.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.4.1",
"versionName": "1.4.2",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class VolumeBarAdapter(
val data: List<AudioOutputBase>,
val onVolumeChanged: (Int, Float) -> Unit,
val onItemDetached: (Int) -> Unit,
val onSliderGet:(Int, Int)->Float,
val onSliderSet:(Int, Int, Float)->Unit,
val getDevices: ()->List<AudioDeviceInfo>,
val setDeviceFor: (Int, AudioDeviceInfo)->Unit
val onSliderGet: (Int, Int) -> Float,
val onSliderSet: (Int, Int, Float) -> Unit,
val getDevices: () -> List<AudioDeviceInfo>,
val setDeviceFor: (Int, AudioDeviceInfo) -> Unit
) : RecyclerView.Adapter<VolumeBarAdapter.VolumeBarHolder>() {
val devices = getDevices()

inner class VolumeBarHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val image = itemView.findViewById<ImageView>(R.id.image)
val volumeBar = itemView.findViewById<Slider>(R.id.volume)
Expand Down Expand Up @@ -77,8 +79,8 @@ class VolumeBarAdapter(
holder.volumeBar.addOnChangeListener { _, value, _ ->
onVolumeChanged(position, value)
}
getDevices().find { it.id==currentItem.outputDevice }?.let {
showDevice(holder.outputName,it)
devices.find { it.id == currentItem.outputDevice }?.let {
showDevice(holder.outputName, it)
}
holder.switchOutput.setOnClickListener {
if (holder.outputExpanded.visibility == View.VISIBLE) {
Expand All @@ -88,12 +90,12 @@ class VolumeBarAdapter(
holder.outputExpanded.visibility = View.VISIBLE
//spawn radiobuttons
holder.outputGroup.removeAllViews()
getDevices().forEachIndexed { index, device ->
getDevices().forEach { device ->
val rButton = RadioButton(context)
showDevice(rButton,device)
showDevice(rButton, device)
rButton.setOnClickListener {
setDeviceFor(position,device)
showDevice(holder.outputName,device)
setDeviceFor(position, device)
showDevice(holder.outputName, device)
}
holder.outputGroup.addView(rButton)
}
Expand All @@ -108,9 +110,9 @@ class VolumeBarAdapter(
holder.expanded.visibility = View.VISIBLE
holder.expand.animate().rotationX(180f)
holder.otherSliders.forEachIndexed { index, slider ->
slider.value = onSliderGet(position,index)
slider.value = onSliderGet(position, index)
slider.addOnChangeListener { s, value, fromUser ->
onSliderSet(position,index,value)
onSliderSet(position, index, value)
}
}
}
Expand All @@ -120,7 +122,6 @@ class VolumeBarAdapter(
holder.expanded.visibility = View.GONE



//reset
holder.resetBtns.forEachIndexed { index, imageView ->
imageView.setOnClickListener {
Expand All @@ -133,7 +134,8 @@ class VolumeBarAdapter(


}
private fun showDevice(v:TextView, d:AudioDeviceInfo){

private fun showDevice(v: TextView, d: AudioDeviceInfo) {
v.text = "${d.productName} (${AudioOutputMap.getName(d.type)})"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PlayBackThread(
var targetVolume: Float = 100f
val dataBuffer = ByteArray(BUF_SIZE)
var loadedCycles = 0
var latencyUpdate: (Int) -> Unit = {}

lateinit var mCapture: AudioRecord
var mPlayers = (hashMapOf <Int, AudioPlayer>())
Expand Down Expand Up @@ -70,20 +69,14 @@ class PlayBackThread(
.addMatchingUid(Utils.getAppUidFromPackage(context, pkg))
.build()
val audioFormat = AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setEncoding(ENCODING)
.setSampleRate(SAMPLE_RATE)
.setChannelMask(CHANNEL)
.build()

mCapture = AudioRecord.Builder()
.setAudioFormat(audioFormat)
.setBufferSizeInBytes(
AudioRecord.getMinBufferSize(
SAMPLE_RATE,
CHANNEL,
AudioFormat.ENCODING_PCM_16BIT
)
)
.setBufferSizeInBytes(BUF_SIZE)
.setAudioPlaybackCaptureConfig(config)
.build()

Expand Down Expand Up @@ -113,7 +106,7 @@ class PlayBackThread(
mPlayers[device?.id?:-1] = AudioPlayer(
AudioManager.STREAM_MUSIC,
SAMPLE_RATE, CHANNEL,
AudioFormat.ENCODING_PCM_16BIT, BUF_SIZE,
ENCODING, BUF_SIZE,
AudioTrack.MODE_STREAM
).also {
it.setCurrentVolume(targetVolume)
Expand Down Expand Up @@ -186,10 +179,11 @@ class PlayBackThread(
}

companion object{
const val SAMPLE_RATE = 44100
const val LOG_TAG = "SoundMaster"
const val CHANNEL = AudioFormat.CHANNEL_IN_STEREO
const val SAMPLE_RATE = 44100
const val CHANNEL = AudioFormat.CHANNEL_IN_STEREO or AudioFormat.CHANNEL_OUT_STEREO
const val ENCODING = AudioFormat.ENCODING_PCM_16BIT
val BUF_SIZE =
AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL, AudioFormat.ENCODING_PCM_16BIT)
AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL, ENCODING)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import android.content.pm.PackageManager
import android.content.pm.ServiceInfo
import android.database.ContentObserver
import android.media.AudioDeviceInfo
import android.media.AudioFormat
import android.media.AudioManager
import android.media.AudioRecord
import android.media.projection.MediaProjection
import android.media.projection.MediaProjectionManager
import android.os.Build
Expand All @@ -26,7 +24,6 @@ import com.legendsayantan.adbtools.SoundMasterActivity
import com.legendsayantan.adbtools.data.AudioOutputKey
import com.legendsayantan.adbtools.lib.PlayBackThread
import com.legendsayantan.adbtools.lib.ShizukuRunner
import java.lang.Byte
import java.util.Timer
import kotlin.Boolean
import kotlin.Float
Expand All @@ -35,6 +32,8 @@ import kotlin.String
import kotlin.Unit
import kotlin.arrayOf
import kotlin.concurrent.timerTask
import kotlin.getValue
import kotlin.lazy
import kotlin.let


Expand Down Expand Up @@ -140,9 +139,6 @@ class SoundMasterService : Service() {
mediaProjection!!
)
mThread.targetVolume = volumeTemp[key] ?: 100f
mThread.latencyUpdate = { value ->
latency.add(value)
}
packageThreads[key.pkg] = mThread
mThread.start()
}
Expand Down Expand Up @@ -232,7 +228,6 @@ class SoundMasterService : Service() {
const val NOTI_ID = 1
const val notiUpdateTime = 30000L

val zeroByte = Byte.valueOf(0)
lateinit var uiIntent: Intent
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_volumebar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/expanded"
android:visibility="gone"
android:animateLayoutChanges="true"
android:paddingVertical="5dp"
android:paddingHorizontal="25dp"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<string name="app_name">ShizuTools</string>
<string name="this_app_requires_u_shizuku">This app requires <u>Shizuku</u>.\nPlease make sure you have shizuku installed and running.</string>
<string name="force_applying_mixedaudio_may_crash">Force applying MixedAudio may crash some apps, and doing so on system apps may crash your entire system.</string>
Expand All @@ -16,13 +16,13 @@
<string name="desc_debloater">Uninstall unnecessary system apps to remove ads, save battery and improve performance.</string>
<string name="_100">100</string>
<string name="percentage_sign">%</string>
<string name="soundmaster">SoundMaster</string>
<string name="desc_soundmaster">Control audio output of individual apps, on Android 10 or newer device.</string>
<string name="soundmaster">SoundMaster beta</string>
<string name="desc_soundmaster">Control audio output of individual apps, play on multiple outputs simultaneously, and more! </string>
<string name="new_slider_for">Select which app to control :</string>
<string name="no_sliders_added">No sliders added</string>
<string name="new_slider">New Slider</string>
<string name="removable_apps">Removable apps -</string>
<string name="please_wait">Please wait...</string>
<string name="please_wait">Please wait</string>
<string name="welcome">Welcome!</string>
<string name="ensure_no_adb_restrictions">Ensure you do not have any adb restrictions, from developer options.</string>
<string name="directions_lookback">Select an apk file to be installed as a downgrade.</string>
Expand All @@ -41,7 +41,7 @@
<string name="switch_output_device">Switch Output Device:</string>
<string name="default_">Default</string>
<string name="run">Run</string>
<string name="enter_command">Enter Command...</string>
<string name="enter_command">Enter Command</string>
<string name="accept_adb_intents">Accept adb intents</string>
<string name="intent_shell_security">Intent shell locks for 5 minutes after usage of a wrong access key, to prevent brute force attempts.</string>
<string name="access_key">Access key</string>
Expand Down

0 comments on commit 0446b02

Please sign in to comment.