How can I change sampling frequency when I use audiowrite function?

19 visualizaciones (últimos 30 días)
Hi, I have an mp3 file that I upload to matlab using audioread function, which gives me an audio signal which is stored in a 25392x1 matrix with the sampling frequency of 22050 which is stored in a variable called 'Fs'. I am trying to save this audio signal in a 'mp4' format using the audiowrite function. When I try using the variable Fs or 22050 is gives the error following error:
Error using audiowrite (line 203)
Unsupported SampleRate value.
Error in audio_signal (line 90)
audiowrite('reconstructed_computer_male.mp4', a, 22050);
Intresting thing is, when I put in Fs*2 or 44100, the function works just fine. The problem with that is the mp4 file that is saved is not an accurate representation of the audio signal because it is twice as fast as it should be. I checked the type of the variable which is double in both cases but only one of the cases work. How can I save this audio signal with the right sampling frequency, which is 22050?

Respuesta aceptada

Star Strider
Star Strider el 9 de Jul. de 2020
From the audowrite documentation for Fs:
‘When writing to .m4a or .mp4 files on Windows platforms, audiowrite supports only samples rates of 44100 and 48000’
Consider using the Signal Processing Toolbox resample funciton to resample it to one of those frequencies.
.

Más respuestas (0)

Categorías

Más información sobre Audio Plugin Creation and Hosting en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by