Skip to content
Snippets Groups Projects
Commit 06776991 authored by Marina Kreme's avatar Marina Kreme
Browse files

unnecessary file deletion

parent 588eb162
No related branches found
No related tags found
No related merge requests found
function x_loc = load_localized_signal(ind_localized, resampling_fs, sig_len, deb)
if nargin ==0
deb=0;
end
data = load('signal_lists.mat');
n = size(data.localized_sources_files, 1);
if ind_localized > n
error('%s: The ind_localized value you entered is outside the value range. Please try another value.', upper(mfilename));
end
localized_file = [data.localized_sources_files(ind_localized).folder, ...
filesep, ...
data.localized_sources_files(ind_localized).name];
x_loc= wave_read(localized_file, resampling_fs, sig_len, deb);
end
function x_wd = load_wideband_signal(ind_wideband,resampling_fs, sig_len, deb)
if nargin == 3
deb=0;
end
data = load('signal_lists.mat');
n = size(data.wide_band_sources_files, 1);
if ind_wideband > n
error('%s: The ind_wideband value you entered is outside the value range. Please try another value.', upper(mfilename));
end
wideband_file = [data.wide_band_sources_files(ind_wideband).folder, ...
filesep, ...
data.wide_band_sources_files(ind_wideband).name];
x_wd= wave_read(wideband_file, resampling_fs, sig_len, deb);
end
\ No newline at end of file
function make_wav_pairs()
%% MAKE_WAV_PAIRS: make_wav_pairs()
% function that generates two structures.
% One containing the wideband sounds and the other one with the well localized sounds
%
% Author : A. Marina KREME
% e-mail : ama-marina.kreme@lis-lab.fr/ama-marina.kreme@univ-amu.fr
% Created: 2020-28-01
%%
wide_dir = './data/data_8000Hz_16384samples/wide_band_sources/';
loc_dir = './data/data_8000Hz_16384samples/localized_sources/';
wide_band_sources_files= dir([wide_dir, '*.wav']); % set the path to the .wav file
localized_sources_files = dir([loc_dir, '*.wav']);
save('signal_lists.mat','wide_band_sources_files', 'localized_sources_files');
end
function wav_write(filename, y, fs)
%% WAV_WRITE
% Function that writes an audio data file $y$ from a sampling frequency $fs$to a
% file called a $filename$.The filename entry also specifies the format
% of the output file.
%
% Author : A. Marina KREME
% e-mail : ama-marina.kreme@lis-lab.fr/ama-marina.kreme@univ-amu.fr
% Created: 2020-28-01
%%
x= y/max(abs(y));
audiowrite(filename,x,fs);
end
\ No newline at end of file
function x= wave_read(filename, resampling_fs, sig_len, deb)
%% WAVE_READ -- x= wave_read(filename, resampling_fs, sig_len, deb)
% This function takes an input audio signal and resamples it at the desired frequency
%
% Inputs:
% filename : filename in .wav format
% resampling_fs : resampling frequency
% sig_len: (int). signal length
% deb : Start of the selection in seconds or minutes (int)
%
% Output:
% x : resampled signal
%
% Author : A. Marina KREME
% e-mail : ama-marina.kreme@lis-lab.fr/ama-marina.kreme@univ-amu.fr
% Created: 2020-28-01
%%
if nargin==3
deb =0;
end
if exist(filename, 'file') ~= 2
error('The file was not found. Please Check the path or the file name : %s.', filename);
end
[x,fs] = audioread(filename);
x = x(:,1);
if fs~=resampling_fs
x = resample(x,resampling_fs,fs);
end
s_end = deb*resampling_fs+sig_len;
% if s_end > sig_len
% error('Take a start value lower than the value you entered: index exceeds matrix dimension : %.f', s_end);
% end
if length(x)<sig_len
% msg = ['the length of input signal is smaller than the requested signal length',...
% '. It would be better to take a signal that has a length greater than or equal to sig_len'];
% warning(msg)
y =x;
x=zeros(sig_len,1);
x(1:length(y))=y;
end
x = x(deb*resampling_fs+1:s_end);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment