Commit e6100f38 authored by Joanna Luberadzka's avatar Joanna Luberadzka

adjusting levels!

parent 9564d0d1
function [sig, noise]=compute_snr_signals(SNR,signal,noise,L_sig)
% INPUT:
% SNR - desired SNR
% signal - target signal
% noise - noise signal
% L_sig - desired level of the target signal
% what is the rms level of the original signal
L_old=20*log10(rms(signal)/(2*10^-5));
% change the level to desired level
v_signal_new=signal*10^((L_sig-L_old)/20);
% compute gain for the noise
P_sig=sum(mean(v_signal_new.^2));
P_noise=sum(mean(noise.^2));
G=P_sig/(10^(SNR/10));
G=sqrt(G/P_noise);
noise=noise*G;
sig=v_signal_new;
% L_sig=20*log10(rms(sig)/(2*10^-5));
% L_noise=20*log10(rms(noise)/(2*10^-5));
end
\ No newline at end of file
......@@ -2,6 +2,9 @@
%
% This matlab skript is called by afc_main when starting
% the experiment 'experimentDOA_cfg'.
%
% afc('main','experimentDOA','joa','10deg','ollo_male','white');
%
% experimentDOA_cfg constructs a structure 'def' containing the complete
% configuration for the experiment.
% To design an own experiment, e.g., 'myexperiment'
......
......@@ -62,7 +62,7 @@ end
% define the calibration level (assume 90 dB SPL for 0 dB FS)
work.currentCalLevel = 90;
setup.level=40;
setup.level=50;
% define signals in structure setup
% setup.modsine = sin([0:def.intervallen-1]'*2*pi*work.exppar1/def.samplerate);
......@@ -78,7 +78,7 @@ addpath(genpath(def.hrirdir))
% create a cell array which has the same lenght as
% the number of referece angles that we want to test
setup.HRIRs=cell(length(def.exppar1),1)
setup.HRIRs=cell(length(def.exppar1),1) % [0 45 90];
for k=1:length(setup.HRIRs)
%load the hrir for the reference angle
setup.HRIRs{k}.hrir_ref=loadHRIR('Anechoic', 80, 0, def.exppar1(k),'in-ear')
......
......@@ -50,8 +50,13 @@ fullWavFileName = fullfile([setup.filedir, baseWavFileName]);
% resample the signal
[P,Q] = rat(def.samplerate/fssig);
sig=resample(sig,P,Q);
sig_level=work.expvaract;
sig=sig.*10^((sig_level - work.currentCalLevel)/20);
% sig=sig.*10^((sig_level - work.currentCalLevel)/20);
L_rms=(20*log10(rms(sig(:,1)+sig(:,2))/(2*10^-5)));
L_des=work.expvaract;
sig=sig*10^((L_des-L_rms)/20);
L_rms_check1=(20*log10(rms(sConf.sig11(:,1)+sConf.sig11(:,2))/(2*10^-5)));
% choose hrir:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment