Writing an audio file

조회 수: 3 (최근 30일)
Grant Wallis
Grant Wallis 2021년 3월 16일
댓글: Christopher McCausland 2021년 3월 16일
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"

답변 (1개)

Christopher McCausland
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
Grant Wallis
Grant Wallis 2021년 3월 16일
I received the error
"Error using audiowrite>validateFilename
Cannot create file YourName_PA6_Problem2.wav. Permission denied"
Christopher McCausland
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 CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by