-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get supported sample rates for devices #216
Comments
I figured out roughly how to do this on android: import android.content.Context
import android.media.AudioDeviceInfo
import android.media.AudioManager
// ...
"listInputDevices" -> {
val audioManager: AudioManager = activity!!.getSystemService(Context.AUDIO_SERVICE) as AudioManager;
val devices: Array<AudioDeviceInfo> = audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
val mapped = devices
.filter({it.isSource})
.map({mapOf(
"id" to it.getId().toString(),
"label" to it.getType().toString(),
"sampleRate" to it.getSampleRates().first(),
)});
result.success(mapped)
} This is a work in progress - I don't really know Kotlin or Android native and I don't have a dev environment set up for it or anything, so sorry for the ugly/unidiomatic code lol Problems so far:
I can finish this feature and make a PR for it (and then look at ios, but separately I guess), just wondering if you have any thoughts first. There is also this: https://developer.android.com/reference/android/media/AudioManager#PROPERTY_OUTPUT_SAMPLE_RATE |
Thanks for the try. So yeah, there's room for improvements to include Android capabilities in further versions. I let this issue opened to track |
Is your feature request related to a problem? Please describe.
When recording, I need to specify a sample rate. In most cases, we want to use 48khz, but this isn't supported by bluetooth mics which seem to be limited to 8khz or 16khz depending on the platform. We don't know whether the user has a bluetooth mic or not (although if we had this method, we could sort of determine it).
Describe the solution you'd like
Either the devices returned by
listInputDevices()
contains a sample rate (and obviously needs to not return null on android), or some other method that gives me a sample rate that is guaranteed to work. Or alternatively, a way of knowing whether the user is using a bluetooth device.Describe alternatives you've considered
Using 8khz all the time, but this obviously isn't great.
Additional context
To be clear, I'm talking about android/ios here. I've been looking mostly at ios because that's where our main problems are, and it seems like the problem is
AVCaptureDevice
doesn't have any information about supported sample rates. I'm gonna keep looking into this and will update this if I find anything out.The text was updated successfully, but these errors were encountered: