MATLAB에서 sound() 함수를 사용하여 톤을 생성하고 있습니다. 다음 함수는 440Hz로에서 4 초 동안 신호음이 들리고 :MATLAB : audioplayer()
duration = 4
toneFreq = 440
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
sound(y, samplesPerSecond); % play the sound wave at the specified bit rate
때때로 (기능 몇 번 사용 후), 나는 "소리 창을 등록 할 수 없습니다"라는 MATLAB에서 오류가 발생합니다. 조금 인터넷을 둘러 보았는데, 이것이 MATLAB (버전 R14 SP3)의 알려진 버그이므로 일반적인 조언은 'audioplayer' function을 대신 사용하는 것으로 보입니다. 따라서 코드를 다음과 같이 업데이트했습니다 :
duration = 4
toneFreq = 440
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); % play the sound wave at the specified bit rate
play(player)
그러나 이것은 소리를 내지 않습니다. 누구든지이 새로운 코드 작업을 만들 수 있습니까?
새 코드가 저에게 효과적입니다. 이전 코드가 얼마 동안 작동하고 멈추었 기 때문에 Java 또는 오디오 드라이버와 관련이있을 수 있습니다. 확실하지 않습니다. MATLAB 또는 컴퓨터를 다시 시작하려고 시도 했습니까? – yuk
이전 코드는 작동하지만 가끔 실패하고 오류 메시지가 생성됩니다. 그런 다음 MATLAB을 다시 시작해야합니다. ( – CaptainProg
문제의 근본 원인을 찾았습니다. 코드가 자체 함수 내에 있습니다. 함수가 끝나면 사운드 재생이 중지됩니다. 마지막 함수는 소리가 실제로 시작되기 전에 소리가 멈추는가? 이것을 극복하는 방법 – CaptainProg