Need help with Volume Slider GUI

9 ビュー (過去 30 日間)
Nikos Korobos
Nikos Korobos 2022 年 4 月 3 日
編集済み: Mohamed Turkmani 2022 年 9 月 7 日
Hello everyone, I've been trying to code an audio player for wav files throught the Matlab GUI (App Designer).
Currently stuck on the volume slider function.
When I choose another volume level, the sound file restarts instead of continuing from the point I used the slider to adjust the volume level.
Any ideas?
My code so far:
Sample code I found online:
Thanks in advance!
  1 件のコメント
Nikos Korobos
Nikos Korobos 2022 年 4 月 9 日
I have also created an audio file player on μatlab, with Upload file and Play/Stop buttons.
Interested to code a display timer to show how long is the audio file while being played.
Can I use disp.AudioFileReader to count its length?
Need to count seconds in every loop.
Any suggestions appreciated.

サインインしてコメントする。

採用された回答

jibrahim
jibrahim 2022 年 4 月 4 日
Hi Nikos,
Consider using audioDeviceWriter to play the audio, and dsp.AudioFileReader to read from the audio file. You do not need to restart these objects when you tune the volume gain.
% EXAMPLE: Read in an audio file and play it back using the standard
% audio device writer.
AFR = dsp.AudioFileReader('speech_dft.mp3');
ADW = audioDeviceWriter(AFR.SampleRate);
gain = 1;
while ~isDone(AFR)
audio = AFR();
ADW(gain*audio);
end
release(AFR); % close the input file
release(ADW); % close the audio output device
At a high level, you create AFR and ADW once in your app (at setup time). You feed the audio signal to ADW. Use the latest and greatest gain to scale the audio.
  8 件のコメント
Raja Palanimurugan
Raja Palanimurugan 2022 年 4 月 12 日
Yes, that is correct.
Mohamed Turkmani
Mohamed Turkmani 2022 年 9 月 7 日
編集済み: Mohamed Turkmani 2022 年 9 月 7 日
@Raja Palanimurugan the volume still doesnt work even when i add the drawnow limitrate. can you please explain how to use it more? when i change the value for the first time it works , for the second time it gives this error
Error using audioDeviceWriter/setupImpl
A given audio device may only be opened once.
drawnow limitrate

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by