Filter löschen
Filter löschen

Record audio and serial data simultaneously

3 Ansichten (letzte 30 Tage)
Angus Joyce
Angus Joyce am 12 Sep. 2019
Beantwortet: Walter Roberson am 12 Sep. 2019
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 Kommentare
Walter Roberson
Walter Roberson am 12 Sep. 2019
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 am 12 Sep. 2019
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)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 12 Sep. 2019
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.

Kategorien

Mehr zu Audio Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by