Hello,
How to make LeftSound and RightSound play complex sounds in 2AFC task, that is, insert a pure tone into the noise, I now use the following code, but always report an error in 'LeftSound = NS * LeftSound + NN * WN;
RightSound = NS * RightSound + NN * WN;'
Thank you
Lanrena
SF = 192000; % Use max supported sampling rate
H.SamplingRate = SF;
LeftSound = GenerateSineWave(SF, 500, 0.1)*.9; % Sampling freq (hz), Sine frequency (hz), duration (s)
RightSound = GenerateSineWave(SF, 4000, 0.1)*.9; % Sampling freq (hz), Sine frequency (hz), duration (s)
ErrorSound = GenerateWhiteNoise(SF, 0.1, 1, 2);
WN = ((rand(1, SF * 0.3) * 2) - 1)*.9;
NS = 1;
NN = 1;
silence_samples = round(0.1 * SF);
LeftSound = LeftSound'; RightSound = RightSound';
LeftSound = [zeros(silence_samples, 1); LeftSound; zeros(silence_samples, 1)];
RightSound = [zeros(silence_samples, 1); RightSound; zeros(silence_samples, 1)];
LeftSound = LeftSound'; RightSound = RightSound';
LeftSound = NS * LeftSound + NN * WN;
RightSound = NS * RightSound + NN * WN;