Can I record 2 separate audios at the same time?

If I start a recording at t=0 and record for 2 seconds, is it possible to start another recording at t=1 for another 2 seconds? I tried it this way:
Fs = 8000;
recorder = audiorecorder(Fs,16,1); %record
recordblocking(recorder,2); %record function, number of seconds recording for
pause(1);
signal1 = getaudiodata(recorder);
recordblocking(recorder,2); %record function, number of seconds recording for
signal2 = getaudiodata(recorder);
pause(3);
soundsc(signal1,Fs);
pause(2);
soundsc(signal2,Fs);
But this does a recording from 0,2 and then from 3,5. Any help is appreciated.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Nov. de 2017
Editada: Walter Roberson el 23 de Nov. de 2017

0 votos

Not with recordblocking(). recordblocking() says not to give back control until the recording is done, and since you start at 0 and record for 2 seconds, that means that it is not going to be giving up control at t = 1 in order to start another recording.
If you did a non-blocking record, then you cannot record two on the same device at the same time.
It is possible to record on two different devices at the same time.
What you should probably do is record from 0 to 3 and then split the recorded signal up according to your needs.

3 comentarios

Well what I'm trying to do is have some overlap because I need continuous recording. And we aren't allowed to use toolboxes.
Walter Roberson
Walter Roberson el 23 de Nov. de 2017
You have a limited number of options:
  • Use multiple recording devices, since two different devices can record at the same time but no one device can have multiple recordings active
  • Find an ActiveX control that allows you to do continuous recording and communicate with it by using actxserver(). Technically this is not using a toolkit, but it probably violates the spirit of the restrictions.
  • Find some Java library that allows you to do continuous recording and communicate with it through the java interface. Technically this is not using a toolkit, but it probably violates the spirit of the restrictions.
  • Find some Python library that allows you to do continuous recording and communicate with it through the python interface. Technically this is not using a toolkit, but it probably violates the spirit of the restrictions.
  • Write some C code that allows you to do continuous recording and interface with it through the mex API. Technically this is not using a toolkit, but it probably violates the spirit of the restrictions.
  • Find a C or C++ library that allows you to do continuous recording and use loadlibrary() to link to it. Technically this is not using a toolkit, but it probably violates the spirit of the restrictions.
  • Drop out of the class
  • File a complaint that the teacher has requested that you do something that Mathworks specifically says not to do
  • Disobey the instructions to not use a toolkit and use https://www.mathworks.com/help/audio/ref/audiodevicereader-system-object.html which is designed for this purpose.
I like the third from the bottom. Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Audio I/O and Waveform Generation en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by