Pushbotton which can not be controled with a 'Pause' command.

조회 수: 1 (최근 30일)
Reeki
Reeki 2014년 1월 26일
댓글: Reeki 2014년 1월 26일
Hi!
I hope someone can help me with this. I've made a GUI and what it does is: when the user press button 1 it ask's the user to choose a wav file. If they press button 2, there is a denoiser which removes some ambient noise included in the files. And then if they press button 3, it starts to play the wav file in segments of 5 seconds.
In my code, I included a 'Pause' command in the point of segmenting the wav in 5 seconds window, which works when im running the code without the gui figure. Supose this button 3 is called 'Next sample' and what i want is the user press that button and hear the first 5 seconds. Then when he press again, the next 5 seconds are played and we can repeat this process until the wav file ends.
Now, my problem is: The user can play a sample of 5 seconds and then press the button of denoising again, and maybe he wants to continue hearing the next 5 seconds of the wav, that's why that 'pause' command is not working for what i want to do. What i need is to play 5 seconds and stay in that point but without that pause comand. Then whenever the user wants to play the next 5 seconds, he/she press the 'next sample' button again and hears the next 5 second.
Any ideas? I hope i explained the situation in a way you guys can understand me.
Thanks!
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 1월 26일
I do not understand why you have included the pause() ?
Reeki
Reeki 2014년 1월 26일
Because in my code i have a for, in that 'for' i take the 5 seconds window, show spectrogram and plot those 5 signals, if I dont wirte that pause, i dont have any time to see the spectrogram of those 5 seconds.
Then when the user finishes to see the specgram he press any button and see next 5 seconds.
Something like:
for i=1:length(indfin),
next=output_signal(indini(i):indfin(i));
subplot(211)
t=[0:(length(next)-1)]*(1/fs);
plot(t,next)
xlabel('tiempo(seg)')
subplot(212)
[ysa,f,t,p] = spectrogram(next,2*1024,2*1000,512,fs);
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Tiempo');
ylabel('Frecuencia (Hz)');
soundsc(next,fs);
pause
end

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

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 26일
In the place you initialize indfin, set
handles.curseg = 1;
and at the end of that routine,
guidata(hObject, handles);
Then in the callback that you currently have the "for" loop, change to
i = handles.curseg; %new
if i <= length(indfin) %changed
next=output_signal(indini(i):indfin(i));
subplot(211)
t=[0:(length(next)-1)]*(1/fs);
plot(t,next)
xlabel('tiempo(seg)')
subplot(212)
[ysa,f,t,p] = spectrogram(next,2*1024,2*1000,512,fs);
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Tiempo');
ylabel('Frecuencia (Hz)');
drawnow(); %new
soundsc(next,fs);
handles.curseg = i + 1; %new
end
and at the end of that routine,
guidata(hObject, handles); %new
This code does nothing when the end is reached; you will probably want to change that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by