Search code examples
matlabaudio-recordingaudio-processing

Matlab real time audio processing


I'm trying to record my microphone input and process it at the same time.

I tried with a loop with this inside:

recordblocking(recorder, 1);
y = getaudiodata(recorder);
% any processing on y

But while I'm doing something with y, I'm losing information since not recording continuously.

Is there something I could do to continuously record sound coming in my microphone, store it in some kind of buffer, and process chunks of it at the same time?

A delay isn't a problem, but I really need the recording and processing done simultaneously.

Thanks in advance for any help.


Solution

  • I think that you should use Stream processing like this:

    % Visualization of audio spectrum frame by frame
    Microphone = dsp.AudioRecorder;
    Speaker = dsp.AudioPlayer;
    SpecAnalyzer = dsp.SpectrumAnalyzer;
    tic;
    while(toc<30)
    
    audio = step(Microphone);
    step(SpecAnalyzer,audio);
    step(Speaker, audio);
    end
    

    you can find more information here and also in this presentation