How to cut audio file into segments?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an audio file (.wav) which I need to cut into segments. Segments (start and stop values) are stored in cell array C. I managed to get values only from one cell to cut the sound file, but I don't know how to get one by one values from cell array C and parallel cut the sound signal. Intervals in the text file look like this:
0.300000 0.410000 ,0.41000 0.430000 ,0.95000 0.990000 ,1.21500 1.260000 ,...
In cell array C every interval is in it's own cell -
'0.300000 0.410000', '0.41000 0.430000' , ...
I have this code:
[data,Fs] = audioread('sound.wav');
list = fopen('intervals.txt','r');
for k=1:length(list)
content = fgets(list)
C= strsplit(content,',')% splits str at the delimiters specified by delimiter
nums = C{1,k} % gets only data from the first cell
x = str2num(nums) %convert from char to numeric value
for n=1:length(x)
start=x(1)
stop=x(2)
N = length(data);
totaldur = N/Fs; % total duration
t = linspace(0,totaldur,N); % create a time vector
%logical indexing
seg1 = data(t>start & t<stop)
sound(seg1) %play the segment
end
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!