10 Parameterized Sound Description

Interaction 10-1. Converting to Hertz in the standard chromatic scale.

cm> *scale*
#<tuning "chromatic-scale">
cm> (hertz 'a4)
440.0
cm> (hertz 69)
440.0
cm> (hertz '(a4 c5 e))
(440.0 523.251 659.255)
cm>

Interaction 10-2. Converting to key numbers.

cm> (keynum 'a4)
69
cm> (keynum 440 :hz)
69.0
cm> (keynum '(440 550 660) :hz)
(69.0 72.863 76.019)
cm>

Interaction 10-3. Converting to notes.

cm> (note 69)
a4
cm> (note 440 :hz)
a4
cm> (note '(69 72 76))
(a4 c5 e5)
cm>

Interaction 10-4. Transposing notes and key numbers.

cm> (transpose 69 6)
75
cm> (transpose 'a4 6)
ef5
cm> (transpose 'a4 (interval 'aug 4))
ds5
cm> (transpose '(a4 c5 e) (interval 'aug -2))
(gf4 bff4 df5)
cm>

Interaction 10-5. Note names in the chromatic scale.

cm> (keynum 'c4)
60
cm> (keynum 'dff4)
60
cm> (keynum 'bs3)
60
cm> (note 'c4 :accidental 's)
bs3
cm> (note 261.625 :hz :accidental 'ff)
dff4
cm> (keynum 'c-1)
0
cm> (hertz 'b10)
31608.531
cm>

Interaction 10-6. Key numbers in the chromatic scale.

cm> (keynum 439 :hz)
68.96
cm> (hertz 69)
440.0
cm> (hertz 69.5)
452.892
cm> (note 69.5)
bf4
cm>

Interaction 10-7. Examples of using the rhythm function.

cm> (rhythm 'q)
1.0
cm> (rhythm 1/4 120.0)
.5
cm> (rhythm 'w+q )
5.0
cm> (define *tempo* 120.0)

cm> (rhythm '(q th e.. x) )
(0.5 0.6666666666666666 0.4375 0.03125)
cm>

Interaction 10-8. The amplitude function.

cm> (amplitude 'mp)
.5
cm> (amplitude 'mp 0 127)
63.5
cm> (amplitude .5 0 1 4)
0.0625
cm>

Chapter Source Code

The source code to all of the examples and interactions in this chapter can be found in the file sound.cm located in the same directory as the HTML file for this chapter. The source file can be edited in a text editor or evaluated inside the Common Music application.