Introduce sound into matlab

1 次查看(过去 30 天)
Daniel
Daniel 2012-1-12
I have created a game using the cogent toolbox. I want to introduce an audio file (30 minutes) into the game that will run throughout the game. The file is 30 minutes long, however, it can be shortened to 10 minutes. It has beeps in random time intervals so cutting it shorter than 10 minutes would be problematic. When the person starts to play the game I want, the audio file begins playing as well. I have downloaded the mp3 versions of wavread and wavwrite.
My questions are as follows:
1) Is it possible to have the audio file play simultaneously with the game?
2) If I have to break it up, which I do since as a wav file it is 150mb and a mp3 is 8mb when it is 30 minutes long. Is there a way that I can get it to repeat 3 times?

回答(1 个)

Jan
Jan 2012-1-12
See audioplayer It can play asynchronously and you can define the StopFcn such that it restarts the sound three times.
There is a bug in Matlab 2011b (but not in 2009a), which crashs Matlab (restart required, not just an error), when the audioplayer object is deleted from inside the StopFcn. If the audioplayer-object is not cleared, a crash appears when exitting Matlab.
  1 个评论
Daniel
Daniel 2012-1-12
That works for a sample audio. However, when I try to load my own audio file, either in the code or in the command line, it says that it cannot find the file. When I try to import it, MATLAB runs out of memory. Any idea how to fix those problems?

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by