using knob to adjust audio frequency
조회 수: 17 (최근 30일)
이전 댓글 표시
How can I use a knob to adjust the frequency of audio such as the handel.mat sound
댓글 수: 0
답변 (1개)
Walter Roberson
2025년 12월 1일 3:21
Use uiknob with the 'ValueChangedFcn' option to call a callback function that stores the new frequency.
Beyond that will depend on whether you want continuous frequency change or discrete frequency change.
If you want discrete frequency change, then you can use audioplayer stop() method, then set the SampleRate property, and then play() -- but this will restart the audio from the beginning, and will play the audio only once per invocation of play(). [Note: it just might be possible to resume() after setting the SampleRate property... not sure.]
If you want continuous frequency change, then you would use https://www.mathworks.com/help/audio/ref/audiodevicewriter-system-object.html . I do not know what happens if you change the SampleRate while you are playing.
You might possibly need to set the SampleRate somewhat high, and then resample() the soundwave from the chosen frequency to the chosen SampleRate; some buffer management would be needed to be able to switch frequencies in mid playing.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!