Jay
Jay

Reputation: 1422

Audiorecorder in matlab

I'm new to matlab. Essentially i want to get audio signal of fixed length (10 seconds) from microphone, perform some operations and play output sound. I was trying to use audiorecorder something like this:

y = audiorecorder(44100, 16, 1)
record(y, 10);
% signal processing;
play(output);

The problem is it's asking for a user prompt to stop recording first and then go to next stage. I just want it to record (on user prompt) whatever it gets for 10 sec and stop automatically. Then proceed to next stages and play final output, all without further user prompt. Is there any way to get around this?

Upvotes: 1

Views: 1613

Answers (1)

Nick Haddad
Nick Haddad

Reputation: 8927

You can use audiorecorders recordblocking method to record for a specfied amount of time, and wait until that time has elapsed.

So, your new code would look like:

a = audiorecorder(44100, 16, 1)

% record for 10 seconds before moving on    
recordblocking(a, 10);

% signal processing;

play(a);

Upvotes: 5

Related Questions