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

1 view (last 30 days)
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 Comments
Reeki
Reeki on 26 Jan 2014
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

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Jan 2014
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.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!