Writing an audio file

3 visualizaciones (últimos 30 días)
Grant Wallis
Grant Wallis el 16 de Mzo. de 2021
Comentada: Christopher McCausland el 16 de Mzo. de 2021
I have to read an audio file and then change the audio data, after changing the audio data i have to write the new audio. I am having trouble getting the audiowrite function to work.
clc
clear all;
fileName = 'PA6.wav';
audioread('PA6.wav'); %read the file
[y,Fs] = audioread('PA6.wav');
y1 = y / 20; %change the volume
sound(y1,Fs) %play back the new volume, which works
%these are some failed attempts
%audiowrite('PA6.wav', y1,Fs);
%audiowrite(fileName,'YourName_PA6_Problem2');
%then i need to write this new audio into "YourName_PA6_Problem2"

Respuestas (1)

Christopher McCausland
Christopher McCausland el 16 de Mzo. de 2021
Hi Grant,
It's been a while from I have used .wav files for ECG recorings. I think you are on the right track with your first attempt however the filename parameter should be the new file name rather than the orignal file name. I'll include a line below. Let me know if this helps, if not please include any error messages to allow for replication.
Christopher
audiowrite('YourName_PA6_Problem2',y1,Fs);
  2 comentarios
Grant Wallis
Grant Wallis el 16 de Mzo. de 2021
I received the error
"Error using audiowrite>validateFilename
Cannot create file YourName_PA6_Problem2.wav. Permission denied"
Christopher McCausland
Christopher McCausland el 16 de Mzo. de 2021
Hi Grant,
If this was the same issue for the previous file name then I think you are either trying to overwrite files of the same name which MATLAB won't allow to protect data (you must command matlab to deleate the file first) or more likely, the directory which you are trying to generate the file into is not one that you have permission to create the file in. This is a common problem if the directory is the same location as the MATLAB install rather than one of your own directories. The soloution is to change where MATLAB is writing too.
Let me know if that helps,
Christopher

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by