Writing an audio file
3 次查看(过去 30 天)
显示 更早的评论
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"
0 个评论
回答(1 个)
Christopher McCausland
2021-3-16
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 个评论
Christopher McCausland
2021-3-16
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!