How to play beep before each trial
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have 80 audio files and I want to play beep before each audio starts as a cue.
Should I add "Beeper(400, [0.3], [0.5]);" in the loop, or outside of the loop?
for i=1:length(audio_files)
aud_file=strcat('C:\toolbox\aud_file\',audio_files(i).name);
% load sound file (make sure that it is in the same folder as this script)
[soundData freq]=audioread(aud_file);
% opens sound buffer at a different frequency
pahandle = PsychPortAudio('Open', [], [], 2, []);
% loads data into buffer
PsychPortAudio('FillBuffer', pahandle, soundData');
% how many repititions of the sound
repetitions=1;
%starts sound immediatley
PsychPortAudio('Start', pahandle, repetitions,0);
% stop
PsychPortAudio('Stop', pahandle, 1,0);
%wait
WaitSecs(3);
%close
PsychPortAudio('Close', pahandle);
end
5 Commenti
Walter Roberson
il 11 Set 2019
% opens sound buffer at a different frequency
pabhandle = PsychPortAudio('Open', [], [], 2, []);
% generate a beep
beepWaveform = MakeBeep(1000,.250,44100);
% make stereo
beepWaveform = repmat(beepWaveform, 2, 1);
% fill buffer
PsychPortAudio('FillBuffer', pabhandle, beepWaveform);
% how many repititions of the sound
repetitions=1;
%randomaize
a=randperm(3);
for i=1:length(audio_files)
aud_file=strcat('C:\toolbox\aud_file\',audio_files(a(i)).name);
% load sound file (make sure that it is in the same folder as this script)
[soundData freq]=audioread(aud_file);
% opens sound buffer at a different frequency
pahandle = PsychPortAudio('Open', [], [], 2, []);
% loads data into buffer
PsychPortAudio('FillBuffer', pahandle, soundData');
%starts beep sound immediatley
PsychPortAudio('Start', pabhandle, repetitions,0);
% stop beep
WaitSecs(1);
PsychPortAudio('Stop', pabhandle, 1,0);
% how many repititions of the sound
repetitions=1;
%starts sound immediatley
PsychPortAudio('Start', pahandle, repetitions,0);
% stop
PsychPortAudio('Stop', pahandle, 1,0);
%wait
WaitSecs(1);
%close
PsychPortAudio('Close', pahandle);
end
%close beep
PsychPortAudio('Close', pabhandle);
Risposte (0)
Vedere anche
Categorie
Scopri di più su Audio and Video Data in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!