Unformatted text preview:

Chapter 21. Meeting 21, Languages: Synthesis with Code 21.1. Announcements • Music Technology Case Study Final due Today, 24 November • Sonic System Project Report due Thursday, 3 December • Last quiz: Thursday, 3 December 21.2. Quiz Review • ? 21.3. Modern Music-N • 1985: Csound • Command-line program • Currently available for many platforms, with many interfaces • http://www.csounds.com 21.4. Csound: Score, Orchestra, and CSD Files • Orchestra (a .orc file) defines synthesis processing and interconnections (instruments) • Score (a .sco file) defines control information (events and parameters) • A CSD file combines the score and orchestra into a single file delimited by XML-style markup • Outermost: <CsoundSynthesizer> </CsoundSynthesizer> • Orchestra: <CsInstruments> </CsInstruments> • Score: <CsScore> </CsScore> 21.5. Csound: Orchestra Syntax: Instrument Blocks • A quasi programming language, closer in way to an assembly language 484Orchestra procedures can be extended with Python (Ariza 2008) • Consists of statements, functions, and opcodes • Opcodes are unit generators • Comments: start with a semicolon • Instruments in blocks, named with a number: • Start marker: “instr” and a number • End marker: “endin” • Trivial example instrument definition instr 100 ; comments here! endin 21.6. Csound: Orchestra Syntax: Signals • Signals are created and interconnected (patched) within instrument blocks • Signals: cary streams of amplitude values as numbers within the dynamic range (16 bit audio uses integers from -32768 to 32768) • Signal paths (like patch cords) are named variables • Signal variables can be at different rate resolutions depending on the first letter of the variable name • a-rate: Audio, name starts with an “a” (e.g. aNoise) • k-rate: Control signals, name starts with an “k” (e.g. kEnvl) • i-rate: Initialization values, name starts with an “i” (e.g. iFq) • Example aNoise random -12000, 12000 • Opcodes: unit generators • Syntax uses spaces and commas to delineate: Provide variable, opcode, and space-separated parameter arguments destinationSignal opcodeName arg1, arg2, ... 485• Example: “random”; takes two arguments: min and max • Example: “outs”: takes two arguments: two signals • Example instr 100 aNoise random -12000, 12000 outs aNoise, aNoise endin 21.7. Csound: Score Syntax • A list of events and parameters given to instruments in the orchestra • Provide a space-separated list of at least three values on each line: i instrumentNumber startTime duration p4 p5 ... i instrumentNumber startTime duration p4 p5 ... i instrumentNumber startTime duration p4 p5 ... • Additional parameters (called p-fields) can be added after duration and provided to the instrument in the score • Example: Two events for instrument 23 lasting two seconds, starting at 0 and 5 seconds i 23 0.0 2.0 i 23 5.0 2.0 21.8. Csound: Rendering an Audio File • Call the CSD file with the csound command-line application on the CSD file to render audio csound -d -A noise.csd -o out.aif • Provide a “flag” to indicate type of audio output • -A (aiff output) • -W (wave output) • Give sampling rate, control rate, and number of channels in a header sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 • Example: a noise instrument • Example: tutorial-a-01.csd 486<CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 10 nchnls = 2 instr 100 aNoise random -12000, 12000 outs aNoise, aNoise endin </CsInstruments> <CsScore> i 100 0 2 i 100 3 2 i 100 6 2 </CsScore> </CsoundSynthesizer> 21.9. Csound: GEN Routines and Wave Tables • Some opcodes require a wave table identification number as an argument • Wave tables are created with GEN routines in the score file, before events are listed • Example: a GEN routine used to create a 16384 point sine wave as a wave table f 99 0 16384 10 1 • Oscillators require a wave table to provide a shape to oscillate The oscili opcode oscillates (and interpolates) any shape given in the f-table argument aSrc oscili amplitude, frequency, functionTable • Example: two instruments, a noise and a sine instrument • Example: tutorial-a-02.csd <CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 10 nchnls = 2 instr 100 aNoise random -12000, 12000 outs aNoise, aNoise endin instr 101 aSine oscili 12000, 800, 99 outs aSine, aSine endin </CsInstruments> <CsScore> f 99 0 16384 10 1 487i 100 0 2 i 100 3 2 i 100 6 2 i 101 2 6 </CsScore> </CsoundSynthesizer> 21.10. Csound: Scaling and Shifting Signals • Example: using a scaled sine wave as an envelope of noise • Assignment (=) and operators (+, *) permit mixing and scaling signals • Example: tutorial-a-03.csd <CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 10 nchnls = 2 instr 102 aEnvl oscili .5, 6.85, 99 aEnvl = aEnvl + .5 aNoise random -12000, 12000 aNoise = aNoise * aEnvl outs aNoise, aNoise endin </CsInstruments> <CsScore> f 99 0 16384 10 1 i 102 0 2 i 102 3 2 </CsScore> </CsoundSynthesizer> 21.11. Csound: Adding Parameters to Score and Orchestra • pN (p1, p2, p3, p4, ...) variables in orchestra permit additional parameter values to be provided from the score to the instrument • Design of instruments in the orchestra requires choosing what parameters are exposed in the score • Example: tutorial-a-04.csd <CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 10 nchnls = 2 488instr 102 iDur = p3 iTrem = p4 aEnvl oscili .5, iTrem, 99 aEnvl = aEnvl + .5 aNoise random -12000, 12000 aNoise = aNoise * aEnvl outs aNoise, aNoise endin </CsInstruments> <CsScore> f 99 0 16384 10 1 i 102 0 2 6.2 ; fourth parameter is frequency of sine envelope i 102 3 2 23 i 102 6 2 45.6 </CsScore> </CsoundSynthesizer> 21.12. Csound: Adding Filters • Numerous opcodes exist to explore a wide range of common synthesis tools • Low pass filter aDst lowpass2 aSrc, cutoffFrequency, resonance • Can create a control signal to adjust a lowpass filter cutoff frequency, and applying that lowpass filter to noise • Example: tutorial-a-05.csd <CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 10 nchnls = 2 instr 102 iDur = p3 iTrem = p4 iFilterRate = p5 aEnvl oscili .5, iTrem, 99


View Full Document

MIT 21M 380 - Languages- Synthesis with Code

Download Languages- Synthesis with Code
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Languages- Synthesis with Code and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Languages- Synthesis with Code 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?