drumlatency#
optionoav-p5?oav_drumlatency=auto | 0 to 500 (milliseconds)
How long it takes a drum hit to be heard after oav-p5 hands it to the audio clock, so pictures land with the sound: auto or milliseconds.
The drum machine hands each hit to the audio clock slightly ahead of time, and tells the sketch (drumHit(), kickDetected(), env('kick')) when you will hear it, which is the scheduled moment plus the output latency. auto uses the latency the browser reports. If the browser's figure is smaller than what your output really takes, the picture runs ahead of the sound, and giving the number yourself fixes that. The project's README names a Bluetooth speaker as the case and suggests trying 200.
- Type
String | Number- Values
auto | 0 to 500 (milliseconds)- default
auto
A number is held between 0 and 500. Anything that is not a number means auto. OAVp5.options.drumlatency reads back in seconds (0.2 for 200).
Notes
- Only the default drum machine (
drums=lookahead) uses it: the frame-driven one has nothing scheduled ahead. - Set it before oav-p5 loads.
window.OAV_P5 = { drumlatency: … };above the loader line wins, then?oav_drumlatency=…on the page address, then?drumlatency=…on the script's own URL. Values inwindow.OAV_P5are turned into text, so write'off', notfalse. On OpenProcessing the page address takes?sketch_oav_drumlatency=…(the project's README says OpenProcessing forwards it to the sketch).
Examples
window.OAV_P5 = { drumlatency: 200 };
function setup() {
createCanvas(400, 300);
startDrums('bd*4, [~ sd]*2, hh*8', 108);
}
function draw() {
background(20);
fill(255);
text('drumlatency: ' + OAVp5.options.drumlatency + ' s', 20, 30);
circle(width / 2, height / 2, 50 + env('kick', 0.01, 0.3) * 200); // told 0.2 s after the hit is scheduled
}To be confirmed
No Bluetooth speaker was tried: the suggested 200 comes from the project's README, not from a measurement made for this page.
Related
drumsHow the drum machine is clocked:lookahead(hits scheduled ahead on the audio clock) orframe(moved by animation frames, 0.5's way).startDrums()Starts a drum machine: a 16-step grid on the page that plays a preset, your own grid or one line of rhythm, and counts the bars for your sketch.drumHit()An event you define: it is called for every hit of the drum machine, with the drum that sounded and how hard.env()A 0..1 pulse that jumps up after each event (a kick, a beat, a key, a press) and then fades out: TouchDesigner's Trigger CHOP.