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!