-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwavButter.m
23 lines (20 loc) · 872 Bytes
/
wavButter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% Running Butterworth band pass filter on a wav file
% Use the same settings as for filtering the FFRs (in eeglab_ABR.m)
% https://stackoverflow.com/questions/17340198/what-is-the-command-for-butterworth-bandpass-filter
filename = 'CH01.wav';
% load the wav file to transform
wavStimulus = wavread(filename);
fs = 16384; % sampling frequency (Hz)
% run the butterworth filter on normalised values
% 2nd order; 70 low cut-off and 2000 high cut-off are used for filtering
% in eeglab_ABR.m
[b,a] = butter(2, [70 2000]/(fs/2), 'bandpass');
% apply the filter to the loaded wav file
wavStimulusFilt = filter(b,a,wavStimulus);
% append the name of the new file
prefix = 'filtered';
outputFilename = strcat(prefix, filename);
wavwrite(wavStimulusFilt, fs, outputFilename);
% BT's function - transforms wav to avg
% BT has to be added to the path
wav2avg(outputFilename, fs);