| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac -m128 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
|
| 12 |
instr SimpleTest |
| 13 |
|
| 14 |
iFac = p4 ;multiplier for each audio sample |
| 15 |
|
| 16 |
aSinus poscil 0.1, 500 |
| 17 |
|
| 18 |
kIndx = 0 |
| 19 |
while kIndx < ksmps do |
| 20 |
aSinus[kIndx] = aSinus[kIndx] * iFac + aSinus[kIndx] |
| 21 |
kIndx += 1 |
| 22 |
od |
| 23 |
|
| 24 |
out aSinus, aSinus |
| 25 |
|
| 26 |
endin |
| 27 |
|
| 28 |
instr PrintSampleIf |
| 29 |
|
| 30 |
aRnd rnd31 1, 0, 1 |
| 31 |
|
| 32 |
kBlkCnt init 0 |
| 33 |
kSmpCnt init 0 |
| 34 |
|
| 35 |
kIndx = 0 |
| 36 |
while kIndx < ksmps do |
| 37 |
if aRnd[kIndx] > 0.99 then |
| 38 |
printf "Block = %2d, Sample = %4d, Value = %f\n", |
| 39 |
kSmpCnt, kBlkCnt, kSmpCnt, aRnd[kIndx] |
| 40 |
endif |
| 41 |
kIndx += 1 |
| 42 |
kSmpCnt += 1 |
| 43 |
od |
| 44 |
|
| 45 |
kBlkCnt += 1 |
| 46 |
|
| 47 |
endin |
| 48 |
|
| 49 |
instr PlaySampleIf |
| 50 |
|
| 51 |
aRnd rnd31 1, 0, 1 |
| 52 |
aOut init 0 |
| 53 |
|
| 54 |
kBlkCnt init 0 |
| 55 |
kSmpCnt init 0 |
| 56 |
|
| 57 |
kIndx = 0 |
| 58 |
while kIndx < ksmps do |
| 59 |
if aRnd[kIndx] > 0 && aRnd[kIndx] < 1/10000 then |
| 60 |
aOut[kIndx] = aRnd[kIndx] * 10000 |
| 61 |
else |
| 62 |
aOut[kIndx] = 0 |
| 63 |
endif |
| 64 |
kIndx += 1 |
| 65 |
od |
| 66 |
|
| 67 |
out aOut, aOut |
| 68 |
|
| 69 |
endin |
| 70 |
|
| 71 |
|
| 72 |
</CsInstruments> |
| 73 |
<CsScore> |
| 74 |
i "SimpleTest" 0 1 1 |
| 75 |
i "SimpleTest" 2 1 3 |
| 76 |
i "SimpleTest" 4 1 -1 |
| 77 |
i "PrintSampleIf" 6 .033 |
| 78 |
i "PlaySampleIf" 8 10 |
| 79 |
</CsScore> |
| 80 |
</CsoundSynthesizer> |
| 81 |
;example by joachim heintz |