필터 지우기
필터 지우기

Record audio and serial data simultaneously

조회 수: 3 (최근 30일)
Angus Joyce
Angus Joyce 2019년 9월 12일
답변: Walter Roberson 2019년 9월 12일
Hi there,
Is it possible to record serial data from a USB connection and audio from an audio object simultaneously in MATLAB? I'm looking to sync the audio input with an event that happens which will be captured by a sensor attached to an arduino hence why I need them to be recording at the same time.
Thanks in advance!
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 9월 12일
How good does the synchronization have to be?
Also is it feasible for you to use the Audio Systems Toolbox instead of audiorecorder?
Angus Joyce
Angus Joyce 2019년 9월 12일
I've just started downloading the audio systems toolbox but the synchronisation doesn't need to be perfect, ballpark is fine (within a half second or so)

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

답변 (1개)

Walter Roberson
Walter Roberson 2019년 9월 12일
Construct the data packets from the Arduino to either be fixed data length (binary) or else to be text that ends in a terminator (newline is recommended.) Then create a serial port object and configure its Terminator property and BytesAvailableFcnMode property, and configure a BytesAvailableFcn callback to be a function that will trigger when data is available.
The callback that you configure should read the packet of serial data and take note of the time.
In the meanwhile, use Audio Systems Toolbox and configure audioDeviceReader https://www.mathworks.com/help/audio/ref/audiodevicereader-system-object.html to loop reading audio information. As each burst of audio arrives, read it and take note of the time.
You now have two sources of data, one from serial and one from audio, both of which you are timestamping. At worst that permits you to synchronize the two sources after you are finished recording the data; at best it might be practical to synchronize on-the-fly.

카테고리

Help CenterFile Exchange에서 Audio Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by