From b3e2a5420ef1528fe982dab222cb999e1d3ff865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hock?= Date: Fri, 7 Jun 2024 01:16:10 +0200 Subject: [PATCH] Dump available audio features --- voicesmith/src/main/AndroidManifest.xml | 3 ++- .../cpp/de/jurihock/voicesmith/io/AudioStream.cpp | 7 +++++-- .../main/java/de/jurihock/voicesmith/Defaults.kt | 2 +- .../src/main/java/de/jurihock/voicesmith/Main.kt | 4 +++- .../de/jurihock/voicesmith/io/AudioFeatures.kt | 15 ++++++++++++--- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/voicesmith/src/main/AndroidManifest.xml b/voicesmith/src/main/AndroidManifest.xml index 861d36e..39bf7a0 100644 --- a/voicesmith/src/main/AndroidManifest.xml +++ b/voicesmith/src/main/AndroidManifest.xml @@ -14,7 +14,8 @@ + android:icon="@drawable/voicesmith" + android:appCategory="audio"> diff --git a/voicesmith/src/main/cpp/de/jurihock/voicesmith/io/AudioStream.cpp b/voicesmith/src/main/cpp/de/jurihock/voicesmith/io/AudioStream.cpp index 25a4361..38521cd 100644 --- a/voicesmith/src/main/cpp/de/jurihock/voicesmith/io/AudioStream.cpp +++ b/voicesmith/src/main/cpp/de/jurihock/voicesmith/io/AudioStream.cpp @@ -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(); } diff --git a/voicesmith/src/main/java/de/jurihock/voicesmith/Defaults.kt b/voicesmith/src/main/java/de/jurihock/voicesmith/Defaults.kt index 7257071..250121b 100644 --- a/voicesmith/src/main/java/de/jurihock/voicesmith/Defaults.kt +++ b/voicesmith/src/main/java/de/jurihock/voicesmith/Defaults.kt @@ -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 } diff --git a/voicesmith/src/main/java/de/jurihock/voicesmith/Main.kt b/voicesmith/src/main/java/de/jurihock/voicesmith/Main.kt index 0224ff1..7ea809e 100644 --- a/voicesmith/src/main/java/de/jurihock/voicesmith/Main.kt +++ b/voicesmith/src/main/java/de/jurihock/voicesmith/Main.kt @@ -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 ":("}") } diff --git a/voicesmith/src/main/java/de/jurihock/voicesmith/io/AudioFeatures.kt b/voicesmith/src/main/java/de/jurihock/voicesmith/io/AudioFeatures.kt index 0ee0966..3f19aa5 100644 --- a/voicesmith/src/main/java/de/jurihock/voicesmith/io/AudioFeatures.kt +++ b/voicesmith/src/main/java/de/jurihock/voicesmith/io/AudioFeatures.kt @@ -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) }