Separating an matrix into multiple matrices to generate audio.
Show older comments
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 Comments
KALYAN ACHARJYA
on 15 Sep 2020
Can you modify the question with sample example of two matrices,which may help to understand the question easiliy?
Meghan van Deventer
on 15 Sep 2020
Answers (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)
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!