the csound orchestra semi-colon begins a commentsemi-colon begins a comment csound ignorescsound...
Post on 18-Dec-2015
223 views
TRANSCRIPT
The Csound OrchestraThe Csound OrchestraThe Csound OrchestraThe Csound Orchestra
• semi-colon begins a comment semi-colon begins a comment • Csound ignoresCsound ignores
• everything on the line after the semi-colon everything on the line after the semi-colon • blank lines blank lines
• instr 1 — gives instrument number instr 1 — gives instrument number • first line of instrument designfirst line of instrument design
Assembly Language-Style SyntaxAssembly Language-Style SyntaxAssembly Language-Style SyntaxAssembly Language-Style Syntax
• each line of instrument — one operation each line of instrument — one operation • result variable — left column result variable — left column
• except with operations such as except with operations such as outout which do not which do not have a resulthave a result
• the operation (an "opcode") — second column the operation (an "opcode") — second column • tells Csound which unit generator to usetells Csound which unit generator to use
• one or more arguments — third column one or more arguments — third column
resultresult opcodeopcode argument1, argument2, ... argument1, argument2, ...
outout signalsignal
Initial VariablesInitial VariablesInitial VariablesInitial Variables• begin with the letter "i" begin with the letter "i" • ifreqifreq and and iwtnumiwtnum are initial variables are initial variables • set their values at the beginning of each note set their values at the beginning of each note
— they are single numbers — they are single numbers • remain constant for the note duration — BUT remain constant for the note duration — BUT
• additional statements can revise them additional statements can revise them • example: multiplying iamp by .5 cuts the example: multiplying iamp by .5 cuts the
amplitude in halfamplitude in half
iampiamp == p4p4
iampiamp == iamp * .5 iamp * .5
Initial VariablesInitial VariablesInitial VariablesInitial Variables• iampiamp — constant representing the maximum — constant representing the maximum
amplitude of note (value from parameter amplitude of note (value from parameter field 4 in the score) field 4 in the score)
• ifreqifreq — the frequency of the note (p5) — the frequency of the note (p5) • iattackiattack — the attack time in seconds (p6) — the attack time in seconds (p6) • idecayidecay — the decay time (p7) — the decay time (p7) • isustainisustain — sustain time — duration — sustain time — duration
between attack and decay between attack and decay • isustainisustain definition must come after definition must come after iattackiattack
and and idecayidecay
Amplitude EnvelopesAmplitude EnvelopesAmplitude EnvelopesAmplitude Envelopes
• can fade the waveform incan fade the waveform in• time-varying scalers that allow waveforms time-varying scalers that allow waveforms
to fade in or out and vary in overall to fade in or out and vary in overall amplitudeamplitude
amplitude envelope
ampenvampenv linseglinseg 0,idur,iamp0,idur,iamp
Amplitude EnvelopesAmplitude EnvelopesAmplitude EnvelopesAmplitude Envelopes
• Output signal in first .1 seconds:Output signal in first .1 seconds:
Amplitude EnvelopesAmplitude EnvelopesAmplitude EnvelopesAmplitude Envelopes
• [i:80][i:80] Output signal over full note duration: Output signal over full note duration:
Amplitude EnvelopesAmplitude EnvelopesAmplitude EnvelopesAmplitude Envelopes
• [i:81] [i:81] add decay to the envelope to control add decay to the envelope to control how the note fades out how the note fades out
ampenvampenv linseglinseg 0,iattack,iamp,idecay,00,iattack,iamp,idecay,0
0
iamp
iattack idecay
Audio Rate VariablesAudio Rate VariablesAudio Rate VariablesAudio Rate Variables
• [i:82] [i:82] ampenvampenv — amplitude envelope — amplitude envelope controlling how the note fades in and out controlling how the note fades in and out • linseglinseg arguments — line segment breakpoints arguments — line segment breakpoints • shaped by attack and decay time values in shaped by attack and decay time values in
Csound scoreCsound score
ampenvampenv linseglinseg 0,iattack,iamp,isustain,iamp,idecay,00,iattack,iamp,isustain,iamp,idecay,0
0
iamp
iattack isustain idecay
The Csound OrchestraThe Csound OrchestraThe Csound OrchestraThe Csound Orchestra
; amplitude envelope and signal:; amplitude envelope and signal:ampenvampenv linseglinseg 0,iattack,1,isustain,1,idecay,0,1,00,iattack,1,isustain,1,idecay,0,1,0asigasig oscilioscili iamp, ifreq, iwave iamp, ifreq, iwave ; generate signal; generate signal
outout asig * ampenvasig * ampenv ; output signal; output signalendinendin ; end of instrument; end of instrument
• oscilioscili statement generates the output signal statement generates the output signal ((asigasig) ) • first argument — amplitude (first argument — amplitude (iampiamp) ) • second argument — frequency (second argument — frequency (ifreqifreq) ) • third argument — wavetable number (1) third argument — wavetable number (1)
• outout writes asig to the soundfile writes asig to the soundfile • endinendin turns off the instrument design turns off the instrument design
oscilioscilioscilioscili• a basic Csound unit generator which performs a basic Csound unit generator which performs
wavetable lookupwavetable lookup• arguments: arguments:
• xampxamp — the note's maximum amplitude — the note's maximum amplitude • xfreqxfreq — frequency — frequency • iwtnumiwtnum — wavetable number — wavetable number • example: example:
asigasig oscilioscili ampenv, ifreq, iwtnum ampenv, ifreq, iwtnum
• first letter of each result or argument name first letter of each result or argument name • specifies whether the variable remains constant or specifies whether the variable remains constant or
varies over timevaries over time
Audio Rate VariablesAudio Rate VariablesAudio Rate VariablesAudio Rate Variables• change every sampling period change every sampling period • always begin with the letter "a" always begin with the letter "a" • made of many numbers — used for time-made of many numbers — used for time-
varying variables such as signals and varying variables such as signals and envelopes envelopes • the result the result ampenvampenv in the example is an audio rate in the example is an audio rate
variable:variable:
ampenv linseg 0, iattack, iamp, isustain, iamp, idecay, 0ampenv linseg 0, iattack, iamp, isustain, iamp, idecay, 0
0
iamp
iattack isustain idecay
Control Rate VariablesControl Rate VariablesControl Rate VariablesControl Rate Variables• change once every control period change once every control period • always begin with "k" always begin with "k"
• change more slowly than audio rate variables change more slowly than audio rate variables • control rate usually about 1/10 of audio ratecontrol rate usually about 1/10 of audio rate
• not as precise as audio rate variables, but can not as precise as audio rate variables, but can efficiently represent slowly varying functions such efficiently represent slowly varying functions such as some amplitude envelopesas some amplitude envelopes
• Not as common in recent years with improved CPU Not as common in recent years with improved CPU speeds. Now many Csound user only use audio speeds. Now many Csound user only use audio rate variables for time-varying variables. rate variables for time-varying variables.
kfreq =kfreq = ifreq + kvibifreq + kvib
The Csound OrchestraThe Csound OrchestraThe Csound OrchestraThe Csound Orchestra;sinewave.orc;sinewave.orc ; name of orchestra; name of orchestrasr=22050sr=22050 ; sampling rate; sampling ratekr=2205kr=2205 ; control rate; control rateksmps=10ksmps=10 ; samples/control per.; samples/control per.nchnls=1nchnls=1 ; 1 channel playback; 1 channel playback;-----------------------------------------------------;-----------------------------------------------------instr 1instr 1 ; beginning of instr.; beginning of instr.iduridur == p3p3 ; duration; duration iampiamp == p4p4 ; maximum amplitude; maximum amplitude ifreqifreq == p5p5 ; frequency in Hertz; frequency in Hertziattackiattack == p6p6 ; attack time dur.; attack time dur.idecayidecay == p7p7 ; decay time dur.; decay time dur.isustainisustain == idur - iattack - idecay idur - iattack - idecay ; remaining dur.; remaining dur.iwaveiwave == 11 ; use wavetable 1; use wavetable 1
continued on following slide ...
The Csound OrchestraThe Csound OrchestraThe Csound OrchestraThe Csound Orchestra
; amplitude envelope and signal:; amplitude envelope and signal:
ampenvampenv linseglinseg 0, iattack, 1, isustain, 1, idecay, 00, iattack, 1, isustain, 1, idecay, 0
asigasig oscilioscili iamp, ifreq, iwave iamp, ifreq, iwave ; generate signal; generate signal
outout asig * ampenvasig * ampenv ; output signal; output signal
endinendin ; end of instrument; end of instrument