Can I record 2 separate audios at the same time?

1 回表示 (過去 30 日間)
Nathaniel Sweeney
Nathaniel Sweeney 2017 年 11 月 23 日
コメント済み: Nathaniel Sweeney 2017 年 11 月 23 日
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.

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 23 日
編集済み: Walter Roberson 2017 年 11 月 23 日
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 件のコメント
Walter Roberson
Walter Roberson 2017 年 11 月 23 日
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.
Nathaniel Sweeney
Nathaniel Sweeney 2017 年 11 月 23 日
I like the third from the bottom. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by