Hello, I'm trying to access the getBufferSizeInFrames using java object. Here 's the code:
But I got the following error:
java.lang.IllegalArgumentException: Expected receiver of type android.media.AudioRecord, but got java.lang.Class<android.media.AudioRecord>
Although I tried to get the getMinBufferSize method same way and It worked. Here's the code:
Why am I getting such error and how can I avoid it?
Thank you,
Nataly
getBufferSizeInFrames:
Dim joAudioRecord As JavaObject
joAudioRecord = joAudioRecord.InitializeStatic("android.media.AudioRecord")
Dim frames As Int = joAudioRecord.RunMethodJO("getBufferSizeInFrames", Null)
Log(frames)
But I got the following error:
java.lang.IllegalArgumentException: Expected receiver of type android.media.AudioRecord, but got java.lang.Class<android.media.AudioRecord>
Although I tried to get the getMinBufferSize method same way and It worked. Here's the code:
getMinBufferSize:
Dim joAudioFormat As JavaObject
joAudioFormat = joAudioFormat.InitializeStatic("android.media.AudioFormat")
Dim joAudioRecord As JavaObject
joAudioRecord = joAudioRecord.InitializeStatic("android.media.AudioRecord")
Dim SampleRate As Int = 8000
Dim channelConfig As Int = joAudioFormat.GetField("CHANNEL_IN_MONO")
'Dim channelConfig as Int = joAudioFormat.GetField("CHANNEL_IN_STEREO")
Dim audioFormat As Int = joAudioFormat.GetField("ENCODING_PCM_16BIT")
'Dim audioFormat as Int = joAudioFormat.GetField("ENCODING_PCM_8BIT")
Dim buffSize As Int = joAudioRecord.RunMethod("getMinBufferSize", Array As Object (SampleRate, channelConfig, audioFormat))
Log(buffSize)
Why am I getting such error and how can I avoid it?
Thank you,
Nataly