-
Notifications
You must be signed in to change notification settings - Fork 4
/
hearingAidF.m
44 lines (33 loc) · 974 Bytes
/
hearingAidF.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function y = hearingAidF(input,g,Psat,transitionV,newfile);
[x,fs] = audioread(input);
xc = denoiseEm(x); % denoising filter
xf = applySkiSlope(xc,g,transitionV,fs); % frequency shaping filter
y = powerCompress(xf, Psat,fs); % amplitude shaping filter
x_length = length(x);
t=[0:1/fs:(x_length-1)/fs];
%sound(y,fs);
% plots for the input and output signals
figure;
subplot(2,1,1);
plot(t,x,'b');
axis tight;
xlabel('Time (sec)');
ylabel('Relative Magnitude');
title('Time Profile for Data in Signal 2');
subplot(2,1,2);
plot(t,y,'r');
axis tight;
xlabel('Time (sec)');
ylabel('Relative Magnitude');
title('Time Profile for Data in Adjusted Signal 2');
figure;
subplot(2,1,1);
specgram(x);
title('Spectrogram of Original Signal 2');
subplot(2,1,2);
specgram(y);
title('Spectrogram of Adjusted Signal 2');
%soundsc(input, fs);
sound(y,fs);
%audiowrite(y,fs,nbits,'linear',newfile);
audiowrite('temp_file.wav',y,fs);