exp — Returns e raised to the x-th power.
exp(x) (no rate restriction)
where the argument within the parentheses may be an expression. Value converters perform arithmetic translation from units of one kind to units of another. The result can then be a term in a further expression.
Here is an example of the exp opcode. It uses the file exp.csd.
Example 233. Example of the exp opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform -odac ;;;realtime audio out ;-iadc ;;;uncomment -iadc if realtime audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o exp.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs =1 gisine ftgen 0, 0, 2^10, 10, 1 ;table for a sine wave instr 1 ;master instrument koct linseg 6, p3, 12 ; octave register straight rising from 6 to 12 kexp linseg 0, p3/3, 5, p3/3, 5, p3/3, 0 ;exponent goes from 0 to 5 and back kdens = exp(kexp) ;density is e to the power of kexp printks "Generated events per second: %d\n", 1, kdens ktrig metro kdens ;trigger single notes in kdens frequency if ktrig == 1 then ;call instr 10 for 1/kdens duration, .5 amplitude and koct register event "i", 10, 0, 1/kdens, .5, koct endif endin instr 10 ;performs one tone ioct rnd31 1, 0 ;random deviation maximum one octave plus/minus aenv transeg p4, p3, -6, 0 ;fast decaying envelope for p4 amplitude asin poscil aenv, cpsoct(p5+ioct), gisine ;sine for p5 octave register plus random deviation outs asin, asin endin </CsInstruments> <CsScore> i 1 0 30 e </CsScore> </CsoundSynthesizer>
Its output should include lines like this:
Generated events per second: 1 rtevent: T 0.000 TT 0.000 M: 0.00000 0.00000 new alloc for instr 10: rtevent: T 0.811 TT 0.811 M: 0.48906 0.48906 new alloc for instr 10: Generated events per second: 2 rtevent: T 1.387 TT 1.387 M: 0.48611 0.48611 rtevent: T 1.833 TT 1.833 M: 0.48421 0.48421 Generated events per second: 3 rtevent: T 2.198 TT 2.198 M: 0.47536 0.47536 rtevent: T 2.506 TT 2.506 M: 0.46530 0.46530 rtevent: T 2.773 TT 2.773 M: 0.44986 0.44986 Generated events per second: 4 rtevent: T 3.009 TT 3.009 M: 0.48096 0.48096 .........