Separating an matrix into multiple matrices to generate audio.
显示 更早的评论
I have an matrix which is 1*n and another which is n*1. The 1 contains a row of 0 and 1 and the other contains values. I want to everytime a 0 is in the first row n*1 add the 1*n value in a new matrix I called temp. When a 1 shows up in the first row my temp should be written to an audio file since it is an audio signal I am working with. I will attach my code with more of an explanation. I atteched an example of the data I am working with.
for i = 1:length(speech1) %Speech1 is the n*1 matrix which contains the audio data
while( quiet_row == 0 ) % quiet_row contains the 0 and 1 elements
counter = counter+1
temp(counter,1) = speech1(i,1) %when a 0 is found in quiet_row the corresponding value is speech 1 should be saved to the temp matrix.
if(quiet_row == 1) %whenever quiet_row finds a 1 after a bunch of 0's the temp array should be written to an audio file.
audiowrite("sound.flac",temp,Fs)
clear temp
end
end
end
2 个评论
KALYAN ACHARJYA
2020-9-15
Can you modify the question with sample example of two matrices,which may help to understand the question easiliy?
Meghan van Deventer
2020-9-15
回答(1 个)
load sspeech1.mat ;
load quiet_row.mat ;
temp = speech1(quiet_row) ; % this will get all values of speech1 for which quiet_row is 1
audiowrite("sound.flac",temp,Fs)
类别
在 帮助中心 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!