Skip to content

Language Sketch

Rodri Pizarro edited this page Aug 4, 2020 · 5 revisions

ChordScript sketch

Sounds definition

  • Sample (wav)

sound a = sample(W_BASS);
sound b = sample("myGuitarSample.wav");
  • Pre-defined function

sound c = S_SQUARED;
  • Function defined by user

sound c = myFunction;

Sound modifications

  • Envelope

a.decay(ratio).sustain(ratio);
  • Filters

b.lowpassfiler(order,fc);
  • Effects

b.reverb(R_HALL);
  • Apply your own effects!

b.effect((argv)myEffect);

Notes nomenclature

1 whole = T_W
2 half = T_H
3 = 1+2 dotted whole
4 quarter = T_Q
..
6 = 2+4 dotted half
..
8 eighth = T_E
..
12 = 4+8 dotted quarter
..
16 sixteenth = T_S
32 thirty second = T_TS
64 sixty fourth = T_SF

.3 triplet

Playing music

  • A sound could play a loop

a.loop(
    ([N_S],4),
    ([N_C],4),
    ([N_S],4),
    ([N_C],4)
);
  • Or a sequence of notes only once

a.play(
    ([N_A3,N_C3,N_E3,N_G3],6),
    ([N_S],2),
    ([N_D3],4)
);
  • Stopping music

a.stop(); # This functionality has sense in live coding

Grouping of sounds

Grouping is useful for setting parameters for several sounds at once

group myGroup = [a,b,snare,kick];

myGroup.bpm(110);
myGroup.reverb(R_HALL);

Single sections could be grouped in a part to use it later

part verse = [
    ([N_A3,N_C3,N_E2],T_Q),
    ([N_G3,N_D3,N_B3],T_Q),
    ([N_C3,N_E3,N_G3],T_Q),
    ([N_C3,N_E3,N_G3],T_E+T_TS), #This is the way to make a ligature of notes
    ([N_S],T_S+T_TS) # The same way for silences
];

part chorus = [
  ([N_FS3,N_B3,N_DS2],4).envelope([0.0,0.0],[0.2,1.0],[0.5,0.8],[0.7,0.4],[1.0,0.4]),
  ([N_G3,N_D3,N_B3],4).envelope(function), #Same as applying an LFO
  ([N_C3,N_E3,N_G3],4).attack(0.3).release(1.0),
  ([N_C3,N_E3,N_G3],4)
];

Then, parts could be combined and/or played

part mySong = [verse * 2, chorus, verse];
a.play(song);

Data types

  • sample
  • string
  • sound
  • real
  • number
  • argument ()
  • group
  • function
  • boolean
  • buffer

Statements

  • if (else)
  • for
  • break
  • return

Operators

  • Arithmetical + - * /
  • Assignation =
  • Boolean == < <= > >= != | &

Constants prefixes

  • N_ for notes
  • T_ for times or notes duration
  • S_ for sounds and synthesized functions
  • W_ for wav files or samples
  • R_ for reverb functions