Debian Codegraph @

src/Examples/FLOSS Manual Examples/01 Basics/01B04_Midi_to_frequency.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac -m128
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 ksmps = 32
9 nchnls = 2
10 0dbfs = 1
11 A4 = 457
12
13 instr LetPlay
14
15 iMidiKeys[] fillarray 69, 69, 69, 68, 67, 66, 65, 64
16 iDurations[] fillarray 2, 1, 1, 1, 1, 1, 1, 4
17 iIndex = 0
18 iStart = 0
19 while iIndex < lenarray(iMidiKeys) do
20 schedule "Play", iStart, iDurations[iIndex]*3/2, iMidiKeys[iIndex]
21 iStart += iDurations[iIndex]
22 iIndex += 1
23 od
24
25 endin
26
27 instr Play
28
29 iMidiKey = p4
30 iFreq mtof iMidiKey
31 S_name mton iMidiKey
32 printf_i "Midi Note = %d, Frequency = %f, Note name = %s\n",
33 1, iMidiKey, iFreq, S_name
34 aPluck pluck .2, iFreq, iFreq, 0, 1
35 aOut linen aPluck, 0, p3, p3/2
36 aL, aR pan2 aOut, (iMidiKey-61)/10
37 out aL, aR
38
39 endin
40
41 </CsInstruments>
42 <CsScore>
43 i "LetPlay" 0 1
44 </CsScore>
45 </CsoundSynthesizer>
46 ;example by joachim heintz