help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: terminate routine


From: Uwe Damm
Subject: Re: terminate routine
Date: Fri, 22 Feb 2019 19:34:10 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

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










reply via email to

[Prev in Thread] Current Thread [Next in Thread]