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

조회 수: 3 (최근 30일)
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
Richard K Collins
Richard K Collins 2021년 3월 13일
편집: Richard K Collins 2021년 3월 13일
Is there any way to have multiple threads? In Javascript, I would set up a schedule, tick periodically but not too fast, to open the schedule handler, check if anything needs to be done, do it, and record the precise times for later processing.
There does not seem too be any precision timer in MatLab. There is one in Javascript now.
I thought of offloading the sound ticks to Raspberry Pi Zero Wireless, or Arduino wirelss, or STM32 or other small device, but then how have them play the proper sounds at precise times? Too many clocks. MatLab and Windows has enough capability to do things, but the syntax and searching for any examples is laborious.
Richard K Collins
Richard K Collins 2021년 3월 13일
편집: Richard K Collins 2021년 3월 13일
There does not seem to be an 'int32' for "record()". You can set it for 24 bit digital recording, but it will only store 16 bit digital.
"single" is 4 byte floating point. Please, someone be consistent.
Is there any way to get MatLab to use the real capabilities of devices, not arbitrary settings?
If you ever save days of data for millions of users, you cannot waste time converting to floating point. and you NEVER use a lossy format or transform.
Record() should be generic to all sensors.
Record.audio(Mic1, 5 ms) should not kill you compiler/parser
Mic1.record(5 ms) would be better
If the compiler writers and data compilers cooperate, you can get a clean and mean language that is concise, easy to learn and use. If the compiler/parser group is smart they can allow aliases and different languages for people coming from different backgrounds.
mic1 at 1.236 632 337 for 5.012 us
All my global Internet projects require global submicrosecond coordination, working to nanosecond and sub for special projects.

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei
Andrei 2021년 4월 30일
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
Richard K Collins
Richard K Collins 2021년 5월 1일
Thank you for taking the time to answer. I read over that example. It requires specialized hardware, renting two more modules, and lots of time to figure out. Plus the distraction of having still more things that almost work, and have to be sorted through.
The MathWorks design concept always requires purchasing more modules. It benefits the company, not the users. They have programmed into every solution, every product - how can we make people more dependent, how can we extract more money and rent. The core product is not being refined and improved to reduce cost and time, but every new features gets stuffed into yet another module. They cannot seem to help themselves.
That sounds pretty cynical early in the morning, on a dark and rainy and gloomy day. But every example I tried on my own with MatLab. Every example like this - user-contributed time is being used to sell more modules, to support them, to find new markets. It is not a sustainable strategy, even if it lets the company grow to large size in the short term. (20 years is the short term)
Thanks for thinking of this. What really bothers me, is that none of the functions show which library they come from, and all the functions require human readers for their explanation.
The core system should be constantly aware of all sensors and devices, their capabilities and behaviors. In the 1960's the software was this poorly integrated, the documentation on paper that required massive amounts of reading and memorization or page turning. It has not changed at all.
site:mathworks.com ("audio" OR "sound" OR "ultrasound") has 51,200 entry points. MathWorks and its community has not learned how to consolidate, simplify, organize, save time of users, save time for society as a whole.
I guess I will have to find a way to buy the pieces to run https://www.mathworks.com/help/audio/ref/impulseresponsemeasurer-app.html if I could just find out what hardware and software it requires. And what that requires. And what that requires.
Richard Collins, Director, The Internet Foundation

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by