Skip to content

Commit 998268f

Browse files
committed
mh fix
1 parent 8c562aa commit 998268f

File tree

4 files changed

+44
-49
lines changed

4 files changed

+44
-49
lines changed

input/equateRmsWav.m

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ function equateRmsWav(subjName)
44
subjName = input('Enter Subjects name: ', 's');
55
end
66

7-
referenceDir = fullfile(pwd,'Static');
8-
subjectDir = fullfile(pwd,['Motion/sub-', subjName]);
7+
referenceDir = fullfile(pwd, 'Static');
8+
subjectDir = fullfile(pwd, ['Motion/sub-', subjName]);
99

1010
% reference folder (Static)
1111
cd(referenceDir);
@@ -15,70 +15,65 @@ function equateRmsWav(subjName)
1515
cd(subjectDir);
1616

1717
targetWavFn = ['sub-', subjName, '_LRL.wav'];
18-
runFunction (referenceWavFn, targetWavFn)
18+
runFunction(referenceWavFn, targetWavFn);
1919

2020
targetWavFn = [subjName, '_RLR.wav'];
21-
runFunction (referenceWavFn, targetWavFn)
21+
runFunction(referenceWavFn, targetWavFn);
2222

2323
% Targets
2424
cd(referenceDir);
2525
referenceWavFn = fullfile(pwd, 'Static_T.wav');
2626

27-
%target_wav_fn = ['M.wav'];
2827
cd(subjectDir);
2928

3029
targetWavFn = [subjName, '_LRL_T.wav'];
31-
runFunction (referenceWavFn,targetWavFn)
30+
runFunction(referenceWavFn, targetWavFn);
3231

3332
targetWavFn = [subjName, '_RLR_T.wav'];
34-
runFunction (referenceWavFn, targetWavFn)
33+
runFunction(referenceWavFn, targetWavFn);
3534

36-
end
35+
end
3736

3837
function runFunction (referenceWavFn, targetWavFn)
3938
% This Script takes a file (targetWavFn) and equates its rms with
4039
% another reference audio file (referenceWavFn) amd gives the equated
4140
% wav file as an output ('final_wave.wav')
4241

43-
%reference_wav_fn = 'R_L.wav';
44-
%target_wav_fn = 'L_R.wav';
45-
4642
% Get the rms of the original sound
47-
[referenceWav, referenceFs]= audioread(referenceWavFn);
43+
[referenceWav, referenceFs] = audioread(referenceWavFn);
4844
referenceRMS = rms(referenceWav);
49-
disp('rms of the reference wav file')
50-
disp(referenceRMS)
45+
disp('rms of the reference wav file');
46+
disp(referenceRMS);
5147

5248
% Get the rms for the edited combined sound (static)
5349
[targetWav, ~] = audioread(targetWavFn);
5450
targetRms = rms(targetWav);
55-
disp('rms of the target wav file')
56-
disp(targetRms)
57-
51+
disp('rms of the target wav file');
52+
disp(targetRms);
5853

5954
% correct for the rms differences in each channel
60-
finalWav = [targetWav(:,1)*(referenceRMS(1)/targetRms(1)) ...
61-
targetWav(:,2)*(referenceRMS(2)/targetRms(2))];
55+
finalWav = [targetWav(:, 1) * (referenceRMS(1) / targetRms(1)) ...
56+
targetWav(:, 2) * (referenceRMS(2) / targetRms(2))];
6257

6358
% check that the rms of the final is similar to the original
6459
finalRms = rms(finalWav);
6560
disp('rms of the final wav file');
6661
disp(finalRms);
6762

68-
audiowrite([targetWavFn(1:end-4), '_rms.wav'], finalWav, eferenceFs);
63+
audiowrite([targetWavFn(1:end - 4), '_rms.wav'], finalWav, eferenceFs);
6964

7065
%% plot the reference wav and final wav files
71-
figure()
72-
subplot(2, 1, 1)
73-
plot(referenceWav(:,1), 'r')
74-
hold on
75-
plot(referenceWav(:,2), 'b')
76-
title('Reference wav file')
77-
78-
subplot(2, 1, 2)
79-
plot(finalWav(:,1), 'r')
80-
hold on
81-
plot(finalWav(:,2), 'b')
82-
title('Final wav file')
66+
figure();
67+
subplot(2, 1, 1);
68+
plot(referenceWav(:, 1), 'r');
69+
hold on;
70+
plot(referenceWav(:, 2), 'b');
71+
title('Reference wav file');
72+
73+
subplot(2, 1, 2);
74+
plot(finalWav(:, 1), 'r');
75+
hold on;
76+
plot(finalWav(:, 2), 'b');
77+
title('Final wav file');
8378

8479
end

setParameters.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
cfg.design.motionType = 'translation';
4242
cfg.design.names = {'static'; 'motion'};
4343
% 0: L--R--L; 180: R--L--R;
44-
cfg.design.motionDirections = [0 0 180 180];
44+
cfg.design.motionDirections = [0 0 180 180];
4545
cfg.design.nbRepetitions = 14;
4646
cfg.design.nbEventsPerBlock = 12;
4747

subfun/doAuditoryMotion.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
isFixationTarget = thisEvent.fixationTarget(1);
2222
targetDuration = cfg.target.duration;
2323

24-
% % % WIP % % %
25-
24+
% % % WIP % % %
25+
2626
% isSoundTarget = thisEvent.soundTarget(1);
27-
28-
% % % WIP % % %
27+
28+
% % % WIP % % %
2929

3030
soundData = cfg.soundData;
3131

@@ -39,11 +39,11 @@
3939
end
4040

4141
% % % WIP % % %
42-
43-
% if isSoundTarget == 1
44-
% fieldName = [fieldName '_T'];
45-
% end
46-
42+
43+
% if isSoundTarget == 1
44+
% fieldName = [fieldName '_T'];
45+
% end
46+
4747
% % % WIP % % %
4848

4949
sound = soundData.(fieldName);

subfun/loadAudioFiles.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
end
1313

1414
%% Load the sounds
15-
15+
1616
% static Stimuli
1717
fileName = fullfile('input', 'Static', 'Static.wav');
1818
[soundData.S, freq1] = audioread(fileName);
1919
soundData.S = soundData.S';
2020

2121
% motion input
22-
fileName = fullfile('input', 'Motion', subjName, [ subjName, '_LRL_rms.wav']);
22+
fileName = fullfile('input', 'Motion', subjName, [subjName, '_LRL_rms.wav']);
2323
[soundData.LRL, freq2] = audioread(fileName);
2424
soundData.LRL = soundData.LRL';
2525

26-
fileName = fullfile('input', 'Motion', subjName, [ subjName, '_RLR_rms.wav']);
26+
fileName = fullfile('input', 'Motion', subjName, [subjName, '_RLR_rms.wav']);
2727
[soundData.RLR, freq3] = audioread(fileName);
2828
soundData.RLR = soundData.RLR';
2929

@@ -35,18 +35,18 @@
3535
soundData.S_T = soundData.S_T';
3636

3737
% motion Stimuli
38-
fileName = fullfile('input', 'Motion', subjName, [ subjName, '_LRL_T_rms.wav']);
38+
fileName = fullfile('input', 'Motion', subjName, [subjName, '_LRL_T_rms.wav']);
3939
[soundData.LRL_T, freq5] = audioread(fileName);
4040
soundData.LRL_T = soundData.LRL_T';
4141

42-
fileName = fullfile('input', 'Motion', subjName, [ subjName, '_RLR_T_rms.wav']);
42+
fileName = fullfile('input', 'Motion', subjName, [subjName, '_RLR_T_rms.wav']);
4343
[soundData.RLR_T, freq6] = audioread(fileName);
4444
soundData.RLR_T = soundData.RLR_T';
4545

46-
if length(unique([ freq1 freq2 freq3 freq4 freq5 freq6 ])) > 1
46+
if length(unique([freq1 freq2 freq3 freq4 freq5 freq6])) > 1
4747
error ('Sounds do not have the same frequency');
4848
else
49-
freq = unique([ freq1 freq2 freq3 freq4 freq5 freq6 ]);
49+
freq = unique([freq1 freq2 freq3 freq4 freq5 freq6]);
5050
end
5151

5252
cfg.soundData = soundData;

0 commit comments

Comments
 (0)