43 lines
1.3 KiB
Matlab
43 lines
1.3 KiB
Matlab
pkg load signal
|
|
|
|
file_path = 'signaluk.wav';
|
|
|
|
[x, Fs] = audioread(file_path);
|
|
|
|
t = (0:length(x)-1) / Fs;
|
|
|
|
|
|
% Assuming you have already loaded the audio signal 'y' and the sampling rate 'Fs'
|
|
|
|
% Calculate the total duration of the signal in seconds
|
|
total_duration = length(y) / Fs;
|
|
|
|
% Define the time points for splitting the signal
|
|
start_time_part1 = 1.0; % Start time for the first part (in seconds)
|
|
end_time_part1 = start_time_part1 + 1.0; % End time for the first part (in seconds)
|
|
|
|
% Find the indices corresponding to the desired time range for part 1
|
|
start_index_part1 = floor(start_time_part1 * Fs) + 1;
|
|
end_index_part1 = floor(end_time_part1 * Fs);
|
|
|
|
% Split the signal into part 1
|
|
part1_signal = y(start_index_part1:end_index_part1);
|
|
|
|
% Calculate the time points for part 2
|
|
start_time_part2 = end_time_part1; % Start time for the second part (in seconds)
|
|
end_time_part2 = total_duration; % End time for the second part (in seconds)
|
|
|
|
% Find the indices corresponding to the desired time range for part 2
|
|
start_index_part2 = floor(start_time_part2 * Fs) + 1;
|
|
end_index_part2 = floor(end_time_part2 * Fs);
|
|
|
|
% Split the signal into part 2
|
|
part2_signal = y(start_index_part2:end_index_part2);
|
|
|
|
|
|
% Save the two parts as separate WAV files
|
|
filename = 'part1.wav';
|
|
audiowrite(char(filename), part1_signal, Fs);
|
|
filename = 'part2.wav';
|
|
audiowrite(char(filename), part2_signal, Fs);
|