필터 지우기
필터 지우기

frequency shift slider in real time

조회 수: 7 (최근 30일)
Mohamed Turkmani
Mohamed Turkmani 2022년 9월 8일
댓글: rumin diao 2022년 9월 9일
i have the following code that reads an audio file, adds a frequency (the bold line) to the file and plots it , my question is the value of the added frequency comes from a slider (changingvalue), after changing the value the plot is plotted , how can i plot as im changing the value kinda like in real time.
changingValue = event.Value;
app.RPMGauge_2.Value = changingValue;
sample = 44100;
[y,Fs] = audioread("Sound and 1000 new.wav");
dt = 1/sample;
StopTime = 20;
Nsamps = length(y);
t = (1/sample)*(1:Nsamps);
A = 0.017;
xfreq = A*sin(2*pi*changingValue*t);
xfreq(t>StopTime) = 0;
xfreq = xfreq';
mix = y + xfreq;
y_fft = abs(fft(mix));
y_fft = y_fft(1:Nsamps/2);
f = Fs*(0:Nsamps/2-1)/Nsamps;
axes(app.axes3);
plot(f, y_fft)
xlim([0 5000])
ylim([0 9000])

답변 (1개)

rumin diao
rumin diao 2022년 9월 8일
if you add a slider in appdesigner:
you can get the current slider number by "app.Slider.Value" . "app.Slider" is the name and "Value" is the property.
you can see: Slider Properties for more information.
  댓글 수: 2
Mohamed Turkmani
Mohamed Turkmani 2022년 9월 8일
you clearly didint read my question, i dont have any problems with slider my problem is when changing its value i want the plot to change in real time
rumin diao
rumin diao 2022년 9월 9일
same, add a plot in the callback function:
% Value changed function: aSlider
function aSliderValueChanged(app, event)
value = app.aSlider.Value;
plot(app.UIAxes,value);%app.UIAxes is where you want to plot, in your code is app.axes3 maybe.
end

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by