Real time sound loop playing

4 Ansichten (letzte 30 Tage)
Jimbo
Jimbo am 20 Aug. 2011
Hello,
I need to play some audio loops seamlessly in real time. That is, keep playing the same loop until the next one is composed. I used the "sound" command, but it does not play them seamlessly. I guess I need to use a buffer, but I can't see how I can implement that with "sound". I'm beginning to think that matlab might not be the right tool for what I'm trying to do. Is it really the case that matlab sound support is not good and I should look for something else to use, or I can manage to do this with matlab?
Please help & many thanks, Jimbo

Akzeptierte Antwort

Daniel Shub
Daniel Shub am 20 Aug. 2011
With standard MATLAB you cannot do this easily. Both the sound and audioplayer functions require the entire array before starting to play the sound. If you look into the guts of audioplayer, it is based on the relatively undocumented (and I think relatively new) asyncio. It looks like if you pound on the underlying code enough, you might be able to stream data to the soundcard.
If you are running windows and have the data acquisition toolbox, you probably can write some code to get it done.
The best solution in my opinion is to use one of the MATLAB based implementations of port audio (e.g., pawavplay, playrec). Even though it comes with more overhead I recommend the implementation included in psychtoolbox. These all let you stream to the soundcard.
You are also going to have some minimum latency. The smaller you make your frame, the more likely you are to drop frames.
  4 Kommentare
Daniel Shub
Daniel Shub am 28 Aug. 2011
This is why I recomend the psychtoolbox implementation. I know it works on 64-bit Linux with 64-bit MATLAB (I use it) and I would guess that it will work on 64-bit Windows with 64-bit MATLAB. It is unclear to me what happens with mex files on a 64-bit OS running 32-bit MATLAB.
Jimbo
Jimbo am 2 Sep. 2011
I am actually running MATLAB64 on win 7 64.
psychtoolbox instalation throws me an error:
"Tried to install on a 64 bit version
of Matlab or Octave, which is not
supported."
Is there anything else I can use on Matlab64? I

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jimbo
Jimbo am 20 Aug. 2011
Thank you very much for your answers. I will try pawavplay, playrec and see how it goes. One of the reasons I used matlab was for the fast vectorising and the fast fft. If I have to use something else to program because of the sound, I wouldn't know where to start. The only gui languages I know is matlb, visualbasic, action script. Not sure I can get vectorising and fst fft in any of those.
Any suggestions will be much appreciated.
james

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by