130 likes | 243 Views
Computer Music Lab. Roger B. Dannenberg School of Computer Science Carnegie Mellon University CS4HS 27 July 2010. Let’s Start With Some Sounds. play osc(60) ; sine wave play osc(61) ; half-step higher play osc(61, 3) ; longer - 3 sec play pluck(48, 2) ; plucked string
E N D
Computer Music Lab Roger B. Dannenberg School of Computer Science Carnegie Mellon University CS4HS 27 July 2010
Let’s Start With Some Sounds • play osc(60) ; sine wave • play osc(61) ; half-step higher • play osc(61, 3) ; longer - 3 sec • play pluck(48, 2) ; plucked string • load "pianosyn.lsp" ; load a library • play piano-note(2, 50, 100) ; parameters are: ; duration, pitch, loudness (1-127)
Pitch in Nyquist (and MIDI) 62 61 63 66 59 68 70 60 62 64 65 67 69 71
Music and Programs define function myscale()begin return seqrep(i, 12, pluck(60 + i))end play myscale() ~ 0.5
Digression(?):Computer Music • 890 AD: Banu Musa on organ building • 995-1050: Guido de Arezzo, pitch names, strings, mnemonics, encoding • 1955: Hiller and Isaacson, Illiac Suite • Early 60s: Max Mathews made first musical sounds by computer at Bell Labs • 70’s: A few centers for computer music • 80’s: Digital synthesizers, MIDI, personal computers, compact disc • 90’s: Real time generation of audio on PCs • 00’s: Napster, iTunes, sampling, laptops, …
Back to Nyquist: Your Turn • Start Nyquist • “Sal” button to get to Sal mode • “New File” button to open editing window • print "hello world" in window • “Save File” button: save to /Users/yourname/Desktop as tmp.sal • “Load” button to load/run changes
Important Syntax Hint • In Nyquist/Sal, a + 3 is an expression, but a+3 is a variable name (!!!) • Use spaces around operators. • You do not need spaces before or after parentheses: pluck(60) is ok • Examples: • pluck(60+3) bad • pluck(60 + 3) good
Try these functions define function chord() begin return sim(pluck(60), pluck(64), pluck(67)) end define function melody() begin return seq(pluck(60), pluck(64), pluck(67)) end play chord() play melody()
Be Creative • Hints: • Use random(n) for a random number from 0 to n-1 • Use seqrep(i, n, expr) for n repetitions of expr, with i = 0, 1, …, n-1 • Instead of pluck(n), you can call your own function
Challenges • Make a random melody • Make a chord with a “root” parameter, e.g. chord(67) plays pitches 67, 71, 74 • … and make a random chord sequence • Play a chord and a melody • Hint: sim and seq can be nested
More Fun Stuff • Try “Browse” button • existing sounds • read the code • Nyquist can be used to write plug-ins for the Audacity editor • Nyquist is a full programming language