You can use audioread
and sound
functions in Matlab to read and play audio files at their original sample rate.
Here's an example code:
main.m82 chars6 lines
In the code above, y
is the audio signal, and Fs
is the sample rate of the file. The audioread
function returns these two variables. The sound
function takes the audio signal and the sample rate as inputs and plays the sound.
Note that you can also modify the playback speed by changing the frequency of the audio signal. This can be done by resampling the audio signal at a different sample rate. Here's an example code:
main.m202 chars12 lines
In this example, the audio signal is resampled at a new sample rate of 1.5 times the original sample rate. This changes the frequency of the audio signal, effectively changing its playback speed. The resample
function performs the resampling. Note that this can introduce artifacts in the signal, especially if the resampled sample rate is not an integer factor of the original sample rate.
gistlibby LogSnag