Hi Julien,

No, this is not the case. KBHits are only key down events. I tried to include several kb => now, but it didn't help.
See also this example here:
http://chuck.cs.princeton.edu/doc/examples/event/kb2.ck
Apparently, the solution is emptying the event queue by calling kb.getchar() until kb.more() returns false:

KBHit kb;

me.sourceDir() + "/bum.wav" => string filename;

adc => WvOut b => blackhole;
filename => b.wavFilename;
kb => now;
while(kb.more()) kb.getchar();
b.closeFile();

SndBuf buf => dac;
filename => buf.read;
kb => now;

The important line is "while(kb.more()) kb.getchar();", apparently. So I guess kb => now; doesn't wait at all if there are still unprocessed keys in the queue.

Best, Manuel

Am 05/12/13 12:18, schrieb Julien Saint-Martin:
Hi Manuel,

Maybe your problem is as follow:
For each key press there is two kb events: key down and key up.

A simple solution maybe to write "kb => now;" twice.

Cheers,
Julien





2013/12/5 Manuel Bärenz <manuel@enigmage.de>
Hello again,

I also wanted to demonstrate a simple sequencer prototype that lets me
record a file and then plays it back to me. I've come this far:

KBHit kb;

me.sourceDir() + "/bum.wav" => string filename;

adc => WvOut b => blackhole;
filename => b.wavFilename;
kb => now;
b.closeFile();

SndBuf buf => dac;
filename => buf.read;
kb => now;

But strangely, the program doesn't wait for the second kb event, but
exits directly after the first key that I hit. Any ideas what I'm doing
wrong?

Best, Manuel
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users