Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » Common calls

Common calls

or()

object.or(arg) - executes if the previous operation on the object failed.

If arg is function, it will execute in the current object's context, otherwise, it will be printed via the console.log.

and()

object.and(arg) - executes when the object is ready.

If arg is function, it will execute in the current object's context, otherwise, it will be printed via the console.log.

Example

engine = JZZ().or('Cannot start MIDI engine!').and('MIDI engine is ready!');

wait()

object.wait(delay) - returns a "delayed" instance of the object.

delay is the timeout in microseconds.

Example

Both code snippets below do the same timing:

port.wait(100).send(0x90,60,127)
    .wait(100).send(0x90,64,127)
    .wait(100).send(0x90,67,127);
 
port.wait(100).send(0x90,60,127);
port.wait(200).send(0x90,64,127);
port.wait(300).send(0x90,67,127);

err()

object.err() - returns the object's error log.

Example

JZZ().openMidiOut('MyMidiOut')
     .or(function(){ alert('Cannot open MyMidiOut!\n' + this.err()); })
     ...

See also