music
(band inst1 ... inst8): composition?

  inst: number?, a valid MIDI instrument program number (1--128)

Creates a new composition that plays comp with the given instruments, where the ith instrument is assigned to the ith MIDI channel. Individual channels can be selected for playback using the instrument mod.

(bend amount): composition?

  amount: number?, -1 <= amount <= 1

Creates a new composition where the pitch is bent by a factor of amount × 2 semitones. If amount = 0, then the pitch is played normally.

(denominator dur): integer?

  dur: duration?

Returns the denominator of dur.

(dur num den): duration?

  num: integer?
  den: integer?

Creates a new duration object representing the ratio num/den.

(dur? v): boolean?

  v: any

Returns #t if and only v is a valid duration object.

(dynamics velocity comp): composition?

  velocity: integer?, 0 <= level <= 127
  comp: composition?

Creates a new composition that plays comp at the given MIDI velocity value. Note that a velocity of 127 corresponds to full volume for that note.

empty: composition?

The empty composition.

en: dur?

An eighth note duration (1/8).

hn: dur?

A half note duration (2/4).

(instrument prog): composition?

  prog: integer?, a valid MIDI program number (0--127)

Creates a new composition that plays composition comp played with MIDI sound or program prog. See the Generam MIDI Wikipedia for a complete list of MIDI program numbers to sound mappings.

(mod kind comp): composition?

  kind: mod?
  comp: composition?

Creates a new composition that plays comp with the given modification mod.

(note midi-note dur): composition?

  midi-note: integer?, 0 <= midi-note <= 127
  dur: dur?

Creates a new composition consisting of a single note from the given MIDI note value and duration.

(note-freq freq dur): composition?

  midi-note: integer?, 0 <= frequency <= 4000
  dur: dur?

Creates a new composition consisting of a single note of the given frequency and duration.

(numerator dur): integer?

  dur: duration?

Returns the numerator of dur.

(octave? v): boolean?

  v: any

Returns #t if and only v is a valid octave, an integer in the range (0, 10).

(onnote fn): composition?

  fn: function?, a function of zero arguments that returns void.

fn is called when the modded composition begins to play.

(par comp1 comp2 ...): composition?

  comp: composition?

Creates a new composition that plays comp1, comp2, …, in parallel.

percussion: mod?

A modification that switches playback to percussion mode (MIDI channel 9). In percussion mode, each note corresponds to one percussion instrument.

(pickup c1 c2): composition?

  c1: composition?
  c2: composition?

Creates a new composition that plays c2 preceded by c1. c1's duration is not factored into the duration of the overall composition.

(pitch? v): boolean?

  v: any

Returns #t if and only v is a valid pitch, a string denoting a pitch class, e.g., "Ab".

(play-composition comp): void

  comp: composition?

Plays the given composition. Note that this function must be triggered from some user action on the screen, e.g., a button click. Otherwise, the browser will silently block audio playback.

qn: dur?

A quarter note duration (1/4).

(repeat n comp): composition?

  n: integer?, n >= 0
  comp: composition?

Creates a new composition formed by repeating comp n times sequentially.

(rest dur): composition?

  dur: dur?

Creates a new composition consisting of a single rest from the given duration.

(seq comp1 comp2 ...): composition?

  comp: composition?

Creates a new composition that plays comp1, comp2, …, in sequence.

sn: dur?

A sixteenth note duration (1/16).

(tempo beat bpm comp): composition?

  beat: dur?, the pulse of the tempo
  bpm: number?, beats per minute
  comp: composition?

Creates a new composition that plays comp at the given beat and bpm.

tn: dur?

A thirty-secondth note duration (1/32).

(trigger proc): composition?

  proc: procedure?, a procedure that takes no arguments

Creates a new composition that calls the function proc when played.

wn: dur?

A whole note duration (4/4).