Would like to measure the speed of sound in Windows MatLab by timed sounds from the speaker with simultaneous recording. Run measurements continuously for days
Show older comments
I have a 24 bit, 96000 sps, single channel microphone. I can record it with
- Mic1 = audiorecorder(96000,24,1)
- recordblocking(Mic1,1)
- S1 = getaudiodata(Mic1,'int16')
but using record(Mic1,1) goes immediately to getaudiodata. It needs a delay or wait or schedule
- Mic1 = audiorecorder(96000,24,1)
- record(Mic1,1)
- play sound after 50 milliseconds (the recorder will probably be slow to start
- wait to almost one second so I can store results at exactly one sample per second. Yes it takes fiddling
- S1 = getaudiodata(Mic1,'int16')
I want to start the recorder and then at a precisely known moment generate a short pulse sound (tick or click or chirp or pulse) to the speaker. After one second total Stop the recorder and then look at the recorded signal and see if I can calibrate somehow.
Once I can get it to make one measurement, I want to just let it run continuously and store the raw data and summary data.
T = timer( some stuff )
T.StartFcn = MyStart;
T.StopFcn = MyStop;
T.start();
function MyStart()
Start recording with record(Mi1, 1)
-- I have a small room The distance is about 3 meters at 340 m/s so time = distance/speed = 8823.5 microSecs
-- in sample units I would expect the first bit of sound to come at (3/340)*96000 = 847 samples into the recording
Play the sound -- how do I build a 96000 Hz sound with 100 amplitudes?
end
function MyStop()
Process the recorded sound, mark down the exact times, save everything, and then do it again
T.Start(); -- this is not the current syntax but it is a good object practice to put the methods inside and just refer to one object name
end
2 Comments
Richard K Collins
on 13 Mar 2021
Edited: Richard K Collins
on 13 Mar 2021
Richard K Collins
on 13 Mar 2021
Edited: Richard K Collins
on 13 Mar 2021
Answers (1)
Andrei
on 30 Apr 2021
0 votes
Richard, you might find the following example useful. It's using functions in Data Acquisition Toolbox (rather than audiorecorder) and Signal Processing Toolbox.
Andrei
1 Comment
Richard K Collins
on 1 May 2021
Categories
Find more on Multichannel Audio Input and Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!