Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we're going to learn about acquiring audio signals using MATLAB. To start, does anyone know what audiorecorder does?
Isn’t it used to record audio in MATLAB?
Exactly! The audiorecorder function creates an object that can record audio. You can specify parameters like sample rate and bit depth. For instance, you might write: recObj = audiorecorder(44100, 16, 1);. Can someone explain what 44100 means?
Is that the sample rate?
Yes! 44100 Hz is a standard sample rate for audio. Now, after you've recorded audio, you can retrieve the data using getaudiodata(recObj). Can anyone share how this data might look?
It would be an array of amplitude values, right?
Correct! This array can be plotted to analyze the signal. Let's summarize: audiorecorder is for capturing audio; sample rate defines the quality of the audio, and getaudiodata gives you the recorded sound.
Having acquired the audio, how do we visualize it?
We can use the plot() function!
Exactly! You can plot the audio signal with plot(myRecording);. What added information can we provide to our plot?
We can add labels and a title!
Right! Adding a title and labels helps identify what we are looking at. For example, we can use: title('Real-Time Audio Signal'); and add labels for axes.
So this helps us analyze the amplitude over time?
Exactly! Analyzing amplitude changes over time gives valuable insights into the audio signal. Always remember to visualize your results.
Now, let’s dive into dsp.AudioRecorder. Why do you think we might choose this over audiorecorder?
It can record audio in real-time without blocking?
Exactly! It allows continuous recording and playback. The audioIn object captures audio, while audioOut plays it back. Can anyone explain the loop structure used here?
It runs indefinitely to continuously capture and play back audio?
Great job! Using a while true construct is essential for real-time processing. So the main components are audioIn, audioOut, and the loop. Always ensure your processing is efficient to maintain performance.
To record my sound, I hit record, / Then plot my signals without a hoard.
Imagine you are at a concert recording the music with a device, the audiorecorder, capturing each note. As you play it back, you use plot() to visualize the rhythm and melody in real-time.
Remember, 'A.P.C' - Audio, Plot, Capture. This helps recall the steps: acquire audio, plot it, and capture it using the right tools.
RAP - Record, Analyze, Playback. This helps to remember that the process involves recording audio, analyzing it through plotting, and then playing it back.
Term
Function to create an audio recording object?
Click to flip
Term
How to visualize audio data?
Click to flip
Term
Continuous audio recording tool in DSP Toolbox?
Click to flip
The process of capturing sound waves using devices like microphones and converting them into a digital format.
A MATLAB function to create an object that can record audio data.
The process of visualizing data as it is being collected or processed.
A MATLAB System object that allows continuous real-time audio recording.
This section discusses how to acquire and plot audio input in MATLAB, emphasizing real-time signal processing techniques.
The section covers methods for acquiring audio signals using MATLAB's audiorecorder and dsp.AudioRecorder, along with real-time plotting of the acquired audio signals. It highlights the structure of the code needed to implement these functionalities in a MATLAB environment.
Signal acquisition is a fundamental aspect of real-time signal processing applications. In MATLAB, users can utilize several built-in functions to capture audio data effectively. This section focuses on two primary methods:
Audio Input using MATLAB: The basic audio recording can be initiated using the audiorecorder function. This allows users to define parameters such as sample rate, bit depth, and the number of channels. After recording, the audio data can be accessed with getaudiodata().
Example Code:
recObj = audiorecorder(44100, 16, 1);
recordblocking(recObj, 5);
myRecording = getaudiodata(recObj);
Real-Time Plotting: Once the audio data is captured, users can visualize it in real-time using the plot() function, which helps in analyzing the waveform. This step can be crucial for applications requiring immediate feedback on the input signal's characteristics.
Example Code:
plot(myRecording);
title('Real-Time Audio Signal');
xlabel('Sample Index');
ylabel('Amplitude');
Using dsp.AudioRecorder: For more advanced applications, MATLAB's DSP System Toolbox provides the dsp.AudioRecorder object for capturing audio in frames. This method allows for continuous audio acquisition and playback in real-time, facilitating more sophisticated signal processing tasks.
Example Code:
audioIn = dsp.AudioRecorder('SamplesPerFrame', 1024);
audioOut = dsp.AudioPlayer('SampleRate', 44100);
while true
audio = step(audioIn);
step(audioOut, audio);
end
Overall, this section underlines the ease with which MATLAB allows users to acquire audio signals and process them in real-time, which is essential for many applications in the fields of signal processing and audio engineering.