我正在尝试在psychtoolbox上创建一个实验,其中一部分涉及在参与者无法响应时发出警报。
我尝试使用提供的嘟嘟声但听起来根本不像是警报。有没有办法实现这一点,而无需下载外部声音?
我不知道声音或声波,所以请帮助!
答案 0 :(得分:1)
以下代码将加载.wav文件,并通过Psychtoolbox音频系统播放。这使您可以获得声音开始的时间戳,并允许比使用声音()或哔声更好的控制。您也可以使用MATLAB本身生成一个音调(很容易生成特定频率的正弦波)并使用它而不是.wav数据。
%% this block only needs to be performed once, at the start of the experiment
% initialize the Psychtoolbox audio system in low latency mode
InitializePsychSound(1);
% load in a waveform for the warning
[waveform,Fs] = audioread('alarm.wav');
numChannels = size(waveform, 2);
% open the first audio device in low-latency, stereo mode
% if you have more than one device attached, you will need to specify the
% appropriate deviceid
pahandle = PsychPortAudio('Open', 2, [], 1, Fs, numChannels);
%% during the experiment, when you want to play the alarm
PsychPortAudio('FillBuffer', pahandle, waveform' );
startTime = PsychPortAudio('Start', pahandle, 1);
%% at the conclusion of the experiment
PsychPortAudio('Close');
如果您想要自己生成声音,请查看Psychtoolbox功能' MakeBeep',然后将其替换为波形,例如1000 Hz音调,持续250毫秒,采样率为44.1k:
% generate a beep
beepWaveform = MakeBeep(1000,.250,44100);
% make stereo
beepWaveform = repmat(beepWaveform, 2, 1);
% fill buffer, play
PsychPortAudio('FillBuffer', pahandle, beepWaveform );
startTime = PsychPortAudio('Start', pahandle, 1);
答案 1 :(得分:0)
对我来说,beep
可以通过在循环中多次播放来做你想做的事情:
% Adjust the no. of loop iterations depending on how long you want to play the alarm
for k=1:100
beep; pause(1);
end
除此之外,你可以使用这样的内置声音:
load('gong'); % This sound seems suitable to me for alarm. Try others from the list
for k=1:100
sound(y,Fs); pause(1);
end
以下是您可能想要尝试的内置声音列表:
chirp
gong
handel
laughter
splat
train