Android Question Oscilloscope from Mic Input

klaus

Expert
Licensed User
Longtime User
I have never tried this.
I don't know if it's possible to acquire directly the mic voltage.
For sound signals the frequency is probably too high for the Oscilloscope application.
 
Upvote 0

daniedb

Active Member
Licensed User
Longtime User
Hi Klaus
Thank you for the reply. I believe it should be possible, because there are a few apps in Play store, doing just that, But none of them has nice interfaces.
Your app interface looks really good, and could be nice to implement in your oscilloscope

With a Voltage divider, 1k and 10k ohm resistors you can have a 30v input voltage and it drop down to about 3v, which is good for the mic input. Max on the MIC input voltage is around 3v.

99% of the arduino guys including myself, can use something like this when doing arduino testing on serial, sensors, i2c etc.

I had a look at the audiorecorder library from stevel05, and connect to a signal on the arduino via the mic input and a voltage divider, and do get some "level" feedback.
But have NO idea what to do or process that...

Cherio
Danie
 
Upvote 0

Jack Howard

Member
Licensed User
Longtime User
Nokia3.jpg
Hi Klaus
Thank you for the reply. I believe it should be possible, because there are a few apps in Play store, doing just that, But none of them has nice interfaces.
Your app interface looks really good, and could be nice to implement in your oscilloscope

It can be done.

The attached picture is Serial 9600 Baud through the Mic.

My phone (Nokia) is AC coupled, so the stream is distorted slightly.

But even so I can decode the data and show the signal and bit decoding on the scope in real time.

Hello World is coming from a PIC Microcontroller with 2 resistors to turn on external Mic and drop the voltage to 1V

The code could be modified for Klaus scope rather than my crude version.
 
Last edited:
Upvote 0

Jack Howard

Member
Licensed User
Longtime User
Hi Jack
Great Job. Are you willing to share the code?

Thanks
Danie
Hi Daniel,

Of course. Shall I remove all the serial decoding, and just leave the basic scope, so its easier to understand.

My software writing is a bit basic, but the code to detect the samples and draw it is very straight forward.

I could also help you add it to Claus scope
 
Upvote 0

Jack Howard

Member
Licensed User
Longtime User
Here is the project showing MIC input on basic scope.
It is setup for Internal Mic
my first APP posting. So PM me if does not work, or files are missing and I will resolve any issues
 

Attachments

  • Audio from mic with scope.zip
    12.3 KB · Views: 324
Upvote 0

daniedb

Active Member
Licensed User
Longtime User
Thanks Jack , really appreciate
I want to use External Mic, cause I have an arduino circuit that wil link to the mic input for various testing purposed
Like a Automatic/Smartphone multimeter

Keep you guys posted

My email address. danieATleznadsoftwareDOTcoDOTza

Cherio
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
I'm receiving an error on running the "Audio from mic" (Mic_Scope) app:

An error has occurred in sub:main_start_watch (java line: 695) java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.

The code includes the initialization line: AR.Initialize(Rec_AudioSource, Rec_SampleRate, Rec_ChannelConfig, Rec_AudioFormat, Rec_BufferSize) and so what could be the cause of this error?
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Don't know why, but I have the "Audio from mic" (Mic_Scope) app now running OK.

I ran this code based on this thread to check for valid parameter:

B4X:
Sub Scan_Audio_Configs
    Dim AudioSource As Int
    Dim BufferSize As Int
    Dim SampleRate() As Int
    Dim AudioFormat() As Int
    Dim ChannelConfig() As Int
    Dim AudioFormats() As String
    Dim ChannelConfigs() As String
    
    AudioSource = AR.A_Src_Mic
    SampleRate =  Array As Int(8000, 11025, 22050, 44100)
    ChannelConfig = Array As Int(AR.CH_CONF_MONO, AR.CH_CONF_STEREO)
    ChannelConfigs = Array As String("CH_CONF_MONO", "CH_CONF_STEREO")
    AudioFormat = Array As Int(AR.AF_PCM_8, AR.AF_PCM_16)
    AudioFormats = Array As String("AF_PCM_8", "AF_PCM_16")
    
    Dim i, ii, iii As Int
    For i = 0 To SampleRate.Length - 1
        For ii = 0 To ChannelConfig.Length - 1
            For iii = 0 To AudioFormat.Length - 1
                BufferSize = AR.GetMinBufferSize(SampleRate(i), ChannelConfig(ii), AudioFormat(iii))
                If BufferSize <> AR.ERROR_BAD_VALUE Then
                    AR.Initialize(AudioSource, SampleRate(i), ChannelConfig(ii), AudioFormat(iii), BufferSize)
                    If AR.GetState = AR.STATE_INITIALIZED Then
                        Log(SampleRate(i) & ", " & ChannelConfigs(ii) & ", " & AudioFormats(iii) & ", " & BufferSize)
                        ''                     AR.StartRecording
                    End If
                End If
            Next
        Next
    Next
End Sub

and then the original code began to function OK!

I must have changed something, but I can't pinpoint what, however the end result is success.
 
Upvote 0

Jack Howard

Member
Licensed User
Longtime User
Don't know why, but I have the "Audio from mic" (Mic_Scope) app now running OK.

I ran this code based on this thread to check for valid parameter:

B4X:
Sub Scan_Audio_Configs
    Dim AudioSource As Int
    Dim BufferSize As Int
    Dim SampleRate() As Int
    Dim AudioFormat() As Int
    Dim ChannelConfig() As Int
    Dim AudioFormats() As String
    Dim ChannelConfigs() As String
   
    AudioSource = AR.A_Src_Mic
    SampleRate =  Array As Int(8000, 11025, 22050, 44100)
    ChannelConfig = Array As Int(AR.CH_CONF_MONO, AR.CH_CONF_STEREO)
    ChannelConfigs = Array As String("CH_CONF_MONO", "CH_CONF_STEREO")
    AudioFormat = Array As Int(AR.AF_PCM_8, AR.AF_PCM_16)
    AudioFormats = Array As String("AF_PCM_8", "AF_PCM_16")
   
    Dim i, ii, iii As Int
    For i = 0 To SampleRate.Length - 1
        For ii = 0 To ChannelConfig.Length - 1
            For iii = 0 To AudioFormat.Length - 1
                BufferSize = AR.GetMinBufferSize(SampleRate(i), ChannelConfig(ii), AudioFormat(iii))
                If BufferSize <> AR.ERROR_BAD_VALUE Then
                    AR.Initialize(AudioSource, SampleRate(i), ChannelConfig(ii), AudioFormat(iii), BufferSize)
                    If AR.GetState = AR.STATE_INITIALIZED Then
                        Log(SampleRate(i) & ", " & ChannelConfigs(ii) & ", " & AudioFormats(iii) & ", " & BufferSize)
                        ''                     AR.StartRecording
                    End If
                End If
            Next
        Next
    Next
End Sub

and then the original code began to function OK!

I must have changed something, but I can't pinpoint what, however the end result is success.
 
Upvote 0
Top