Skip to content

Commit

Permalink
Dump available audio features
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Jun 6, 2024
1 parent bc08929 commit b3e2a54
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion voicesmith/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

<application android:name="de.jurihock.voicesmith.Main"
android:label="@string/title"
android:icon="@drawable/voicesmith">
android:icon="@drawable/voicesmith"
android:appCategory="audio">

<activity android:name="de.jurihock.voicesmith.MainActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ void AudioStream::open() {
else if (direction == oboe::Direction::Output) {
LOG(DEBUG) << "Usage " << oboe::convertToText(state.stream->getUsage());
}
LOG(DEBUG) << "PerformanceHintEnabled " << (state.stream->isPerformanceHintEnabled() ? "true" : "false");
LOG(DEBUG) << "XRunCountSupported " << (state.stream->isXRunCountSupported() ? "true" : "false");
LOG(DEBUG) << "SampleRate " << state.stream->getSampleRate();
LOG(DEBUG) << "HardwareSampleRate " << state.stream->getHardwareSampleRate();
LOG(DEBUG) << "ChannelCount " << state.stream->getChannelCount();
LOG(DEBUG) << "HardwareChannelCount " << state.stream->getHardwareChannelCount();
LOG(DEBUG) << "Format " << oboe::convertToText(state.stream->getFormat());
LOG(DEBUG) << "HardwareFormat " << oboe::convertToText(state.stream->getHardwareFormat());
LOG(DEBUG) << "BufferCapacityInFrames " << state.stream->getBufferCapacityInFrames();
LOG(DEBUG) << "BufferSizeInFrames " << state.stream->getBufferSizeInFrames();
LOG(DEBUG) << "FramesPerBurst " << state.stream->getFramesPerBurst();
LOG(DEBUG) << "FramesPerDataCallback " << state.stream->getFramesPerDataCallback();
LOG(DEBUG) << "Timeout " << config.timeout.value().count() << " ms";
LOG(DEBUG) << "PerformanceHintEnabled " << (state.stream->isPerformanceHintEnabled() ? "true" : "false");
LOG(DEBUG) << "XRunCountSupported " << (state.stream->isXRunCountSupported() ? "true" : "false");

onopen();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ object Defaults {
const val INPUT: Int = 0
const val OUTPUT: Int = 0
const val SAMPLERATE: Int = 48000
const val BLOCKSIZE: Int = 64
const val BLOCKSIZE: Int = 256
}
4 changes: 3 additions & 1 deletion voicesmith/src/main/java/de/jurihock/voicesmith/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class Main : Application() {
private fun features() {
val features = AudioFeatures(this)
Log.i("~ Features ~")
Log.i("Low Latency Feature ${if (features.hasLowLatencyFeature) ":)" else ":("} ")
Log.i("Default Samplerate ${features.samplerate}")
Log.i("Default Blocksize ${features.blocksize}")
Log.i("Low Latency Feature ${if (features.hasLowLatencyFeature) ":)" else ":("}")
Log.i("Pro Feature ${if (features.hasProFeature) ":)" else ":("}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ package de.jurihock.voicesmith.io

import android.content.Context
import android.content.pm.PackageManager
import android.media.AudioManager

class AudioFeatures(val context: Context) {
class AudioFeatures(context: Context) {

val hasLowLatencyFeature = context.packageManager.hasSystemFeature(
private val audio: AudioManager? = context.getSystemService(AudioManager::class.java)

val samplerate : Int
get() = audio?.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE)?.toInt() ?: 0

val blocksize : Int
get() = audio?.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER)?.toInt() ?: 0

val hasLowLatencyFeature : Boolean = context.packageManager.hasSystemFeature(
PackageManager.FEATURE_AUDIO_LOW_LATENCY)

val hasProFeature = context.packageManager.hasSystemFeature(
val hasProFeature : Boolean = context.packageManager.hasSystemFeature(
PackageManager.FEATURE_AUDIO_PRO)

}

0 comments on commit b3e2a54

Please sign in to comment.