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