Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/FileMix4.csd
blob: ee76b268b29f115c2aff9dcad34a41e0ac8b91b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
; FileMix4 (2010) for realtime Csound5 - by Arthur B. Hunkins
;  requires MIDI device with 4-16(17) knobs/sliders; 4 files only
;  1-4 controls/parameters per file (amp, band-pass peak freq, peak gain, speed/freq)
;  1 parameter requires 4(5) knobs/sliders; 2 parameters, 8(9); 3 parameters, 12(13);
;   4 parameters, 16(17). The additional controller is optional Master volume.
;  Files must be stereo; can have different sample rates, may be a variety of
;   uncompressed types including WAV and AIFF; also Ogg/Vorbis (with Sugar 0.86/
;   Blueberry or later) but not MP3.
;  They must be named soundin.1 to soundin.4, and in the same folder as this file.

<CsoundSynthesizer>
<CsOptions>

-odac -+rtaudio=alsa -+rtmidi=alsa -M hw:1,0 -m0d --expression-opt -b128 -B2048 -+raw_controller_mode=1

</CsOptions>
<CsInstruments>

sr      = 44100
; change sample rate to 48000 if 44100 gives no audio. (Necessary for Intel Classmate PC.)
ksmps   = 100
nchnls  = 2

gichan  chnexport "chan", 1
gictrl1 chnexport "ctrl1", 1
gictrl2 chnexport "ctrl2", 1
gimast  chnexport "mast", 1
giparm  chnexport "parms", 1

        massign 0, 0
        seed    0
ga1     init    0
ga2     init    0
        
gitemp  ftgen 2, 0, 512, -5, 200, 512, sr / 13.2

        instr 1, 2, 3, 4

        if p1 > 1 igoto skip
gimast  =       ((gichan == 0) && (giparm == 4)? -1: gimast)
skip:
kamp	ctrl7   (gichan == 0? p1: gichan), (gichan == 0? 7: gictrl1 + (p1 - 1)), 0, 1
kamp2   table   kamp * 512, 1
kamp2   port    kamp2, .01
ilen    filelen p1
ipeak   filepeak p1
imult   =       8190 / ipeak
kamp2   =       kamp2 * imult
irand   unirand ilen * .75
; physically set these controllers to .5 after start
kbase   ctrl7   (gichan == 0? p1 + 12: gichan), (gichan == 0? 7: gictrl2 + (p1 + 3)), .9, 1.1
kbase   port    kbase, .01
kbase   =       (giparm == 4? kbase: 1)
a1, a2  diskin2 p1, kbase, irand, 1
        if giparm > 1 goto skip2
ga1     =       ga1 + (a1 * kamp2)   
ga2     =       ga2 + (a2 * kamp2)
        goto end  
skip2:
; physically set these controllers to .5 after start
kfreq   ctrl7   (gichan == 0? p1 + 4: gichan), (gichan == 0? 7: gictrl1 + (p1 + 3)), 0, 512
kfreq   table   kfreq, 2
kfreq   port    kfreq, .01
kres    ctrl7   (gichan == 0? p1 + 8: gichan), (gichan == 0? 7: gictrl2 + (p1 - 1)), .25, .7
kres    port    kres, .01
kres    =       (giparm > 2? kres: .25)
a3,a4,a5 svfilter a1, kfreq, kres
a6,a7,a8 svfilter a2, kfreq, kres
ga1     =       ga1 + (a5 * kamp2)   
ga2     =       ga2 + (a8 * kamp2)  
end:
        endin
   
        instr 5

        if (gichan > 0) && (gimast > -1) goto skip
        if (giparm < 4) && (gichan == 0) && (gimast > -1) goto skip
kamp2   =       1
        goto skip2 
skip:
kamp	ctrl7   (gichan == 0? gimast: gichan), (gichan == 0? 7: gimast), 0, 1
kamp2   table   kamp * 512, 1
kamp2   port    kamp2, .01

skip2:
        outs    ga1 * kamp2, ga2 * kamp2
ga1     =       0
ga2     =       0
end:
        endin

</CsInstruments>

<CsScore>

f 1 0 512 16 0 512 .8 1
i 1 0 3600
i 2 0 3600
i 3 0 3600
i 4 0 3600
i 5 0 3600

e

</CsScore>
</CsoundSynthesizer>