[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: terminate routine
From: |
Herr Oswald |
Subject: |
Re: terminate routine |
Date: |
Mon, 25 Feb 2019 10:34:19 +0100 |
@ Przemek, Uwe:
Thank you very much for your hints. I forwarded them to my programming
friend, he sounds as if he could deal with them. We'll see...
I'll send a final success message when we're done!
Cheers,
Wolf
Am Freitag, den 22.02.2019, 19:34 +0100 schrieb Uwe Damm:
> if you need a non-blocking kbhit, just pass a parameter to it
> (kbhit(1))
>
> example:
>
> cnt=0;
> while(1)
> k=kbhit(1);
> if k=='q'
> break;
> end
> disp(int2str(cnt));
> fflush(stdout);
> cnt=cnt+1;
> end
>
> Uwe
>
> Am 22.02.19 um 17:01 schrieb Przemek Klosowski:
> > On 2/22/19 6:23 AM, Herr Oswald wrote:
> > > Hello,
> > >
> > > a dear friend of mine (who is familiar with matlab) wrote a few
> > > lines
> > > to analyse tempo variations in musical recordings.
> > >
> > > One problem he could not get around is how to terminate the
> > > routine. At
> > > present this is solved with a timeout of 10s.
> > >
> > > When started, the routine writes time stamps into an array
> > > whenever a
> > > key is pressed. What we now need is a handle to terminate the
> > > process
> > > by a special key with the contents of the array preserved - ctrl-
> > > C or
> > > ctrl-D seem not to work.
> >
> > I think that you are capturing the tempo by hitting a key while
> > listening to the music, and want to terminate the process when the
> > music stops---am I right? If so, could you just look at the last
> > character and quit when you see something like a 'q'?
> >
> > while ((a=kbhit()) != 'q') ; coll(end+1) = time; end
> >
> > >
> > > This is the code:
> > >
> > > <raw>f=figure;
> > > pause(0.05);
> > > set(f,'Position',[1 1 2 2]);
> > > time=0;
> > > coll=[];
> > > tic;
> > > while time<10
> > > waitforbuttonpress;
> > > time=toc;
> > > tic;
> > > coll=[coll time];
> > > end
> > > coll
> > > col=60./coll;
> > > close(f);
> > > plot(col(1:end-1))</raw>
> > >
> > > We would be very grateful for a brief hint.
> > >
> > > Cheers,
> > > Wolf
> > >
> > >
> > >
> >
> >
> >
> >
>
>