| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
; Audio out Audio in No messages MIDI in |
| 5 |
-odac -iadc -d -M0 ;;;RT audio I/O with MIDI in |
| 6 |
</CsOptions> |
| 7 |
<CsInstruments> |
| 8 |
|
| 9 |
sr = 44100 |
| 10 |
ksmps = 10 |
| 11 |
nchnls = 2 |
| 12 |
|
| 13 |
; Set MIDI channel 1 to play instr 1. |
| 14 |
massign 1, 1 |
| 15 |
|
| 16 |
instr 1 |
| 17 |
|
| 18 |
; Returns MIDI note number - an integer in range (0-127) |
| 19 |
iNum notnum |
| 20 |
|
| 21 |
; Convert MIDI note number to Hz |
| 22 |
iHz = (440.0*exp(log(2.0)*((iNum)-69.0)/12.0)) |
| 23 |
|
| 24 |
; Generate audio by indexing a table; fixed amplitude. |
| 25 |
aosc oscil 10000, iHz, 1 |
| 26 |
|
| 27 |
; Since there is no enveloping, there will be clicks. |
| 28 |
outs aosc, aosc |
| 29 |
|
| 30 |
endin |
| 31 |
|
| 32 |
</CsInstruments> |
| 33 |
<CsScore> |
| 34 |
|
| 35 |
; Generate a Sine-wave to be indexed at audio rate |
| 36 |
; by the oscil opcode. |
| 37 |
f1 0 16384 10 1 |
| 38 |
|
| 39 |
; Keep the score "open" for 1 hour so that MIDI |
| 40 |
; notes can allocate new note events, arbitrarily. |
| 41 |
f0 3600 |
| 42 |
|
| 43 |
e |
| 44 |
</CsScore> |
| 45 |
</CsoundSynthesizer> |