私はMATLAB関数を使用してサウンドを開始しています。この機能は次のとおりです。MATLAB:サウンドの再生を停止する
function playTone (duration, toneFreq)
% Generate a tone
global player; % as a global variable, sound will continue to play after the function has ended.
samplesPerSecond = 44100; % the bit rate of the tone
y = sin(linspace(0, duration * toneFreq * 2 * pi, round(duration * samplesPerSecond))); % the equation of the sound wave
player = audioplayer(y, samplesPerSecond); % create an audio object from the sound wave at the specified bit rate
play(player); % play the audio, blocking control until the sound completes
私は、要求に応じて音を止めることができます。私が使用することはできません。
clear playsnd;
私はaudioplayer()関数(ない音()関数)を使って音を扇動しているため。
私はまた、使用することはできません:(「???未定義の関数や変数 『プレーヤー』」)
stop(player);
私は親関数からの音を停止しようとしていますので、
私が持っていましたサブ関数から音色を生成する必要があるので、上記のように関数を設定することができます。サウンドウィンドウを登録できないというエラーメッセージが表示されることがあるので、sound()関数を使用できません。 'player'変数はグローバルとして設定され、関数が完了した後もサウンドが引き続き再生されるようにします。