I want to increase/decrease volume of audio file using the slider,is it necessary to run audio data from slider?

조회 수: 7 (최근 30일)
global filename;
[y,Fs] = audioread(filename);
slider_val = get(hObject, 'Value');
if slider_val == 0
x = y/5; % Decrease volume
player = audioplayer(x, Fs);
play(player,[1 (get(player, 'SampleRate')*3)]);
elseif slider_val == 1
x = y*5; % Increase volume
player = audioplayer(x, Fs);
play(player,[1 (get(player, 'SampleRate')*3)]);

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 12일
You should use the Audio Systems Toolbox. At each point you would fetch a batch of samples and multiply them by the current slider value, and queue them to be played as audio.
Creating a separate audio player for each batch of sounds is too much overhead, and there is no feasible way to update the sound samples of an audioplayer once it is built.
  댓글 수: 6
Madhav Sapkota
Madhav Sapkota 2018년 12월 14일
편집: Madhav Sapkota 2018년 12월 14일
[x,Fs]= audioread('G:\Year3\MediaTechnology\Assignment\Sune Khabar.mp3');
slider_val = get(hObject, 'Value'); % for getting the slider value
disp(get(hObject,'Value')); % displaying the slider value
k = slider_val; % Setting slidervalue in k
% player = audioplayer(x,Fs*k);
[loudness,loudnessRange] = integratedLoudness(x,Fs);
volume = [loudness*k,loudnessRange];
player = audioplayer(volume);
play(player); %play
guidata(hObject,handles);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by