«fast fm windchimes 4 fealty» by s2s2s2s2s

on 18 Jun'22 03:24 in i loike windchimes

oldpatch

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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
(
        var fm,tuner,dist,t=0.08,sine,fx,reverb,weights;
                                                             
        fm={ |freq=440, cmRatio=1, index=1, mul=1|              
                var m=freq/cmRatio,d; d=index*m;                      
                SinOsc.ar(freq+SinOsc.ar(m,0,d),0,mul)
        };              
        tuner={ |key,octave,transpose,detune|        
                (key+(12*octave)+transpose).max(0).midicps+detune                     
        };                                    
                                        
        reverb={ |in,trFB,trFilt|
                var amp,local;                 
                amp = Amplitude.kr(Mix.ar(in));
                in = in * (amp > 0.04); 
                in = in * 0.5;
                local = LocalIn.ar(2) * trFB;        
                local = OnePole.ar(local, trFilt);                    
                local = Rotate2.ar(local[0], local[1], 0.237);
                local = AllpassN.ar(local, 0.05, { Rand(0.01,0.05) }!2);
                local = DelayN.ar(local, 0.3, { Rand(0.15,0.33) }!2);
                local = AllpassN.ar(local, 0.05, { Rand(0.03,0.15) }!2);
                local = LeakDC.ar(local);                                              
                local = local + in;       
                                                     
                4.do({ var t;                          
                        t={ Rand(0.005,0.02) }!2;      
                        local = AllpassN.ar(local, t, t, 1);
                });                                       
                                                          
                LocalOut.ar(local);
                local                                             
        };                                                 
                                                                
        SynthDef(\fm, { |key=4,oct=5,cmrDur=1,ndxDur=1,i_dur=1,amp=1,pan=0|
                Out.ar(0,Pan2.ar(fm.(tuner.(key,oct,0,0),XLine.kr(0.102,0.405,cmrDur),   
                        XLine.kr(2.021,0.098,ndxDur),Line.ar(amp,0,i_dur,doneAction:2)),pan))                                                                                                 
        }).send(s);                                               
                                                        
        SynthDef(\reverb,{ |trFB=0.5,trFilt=0.5,wetDry=0.5|                      
                XOut.ar(0,wetDry,RLPF.ar(HPF.ar(reverb.(In.ar(0),trFB,trFilt),10000),15000))                                                                                                  
        }).send(s);                        
                                                        
        SynthDef(\fx,{ |dt1,dec1,dt2,dec2,dt3,dec3,trFB,trFilt,rcSpeed,                                                                                                                       
                rcLo,rcHi,rcPhase,rcWidth,fftBuf1,fftBuf2,wetDry|         
                                          
                var in=In.ar(0,2),local,amp,chain,rverb;
                                       
                local=in;                        
                local=CombN.ar(local,4,Lag.kr(dt2,dt2),dec2);
                local=CombN.ar(local,4,dt3,dec3);        
                local=CombN.ar(local,4,dt1,dec1);
                rverb=reverb.(local,trFB,trFilt);
            
                chain = FFT([fftBuf1,fftBuf2],local);
                chain = PV_RectComb(chain,SinOsc.ar(rcSpeed).range(rcLo,rcHi),rcPhase,
                        Lag.kr(rcWidth,t*64));
                local = IFFT(chain);

                XOut.ar(0,wetDry,local+rverb/8)
        }).send(s);


        dist={ |lo,hi,dist|
                (lo+(dist.windex/dist.size*(hi-lo))).clip(lo,hi).asInt
        };

        play(r({
                var buf1,buf2;
                buf1=Buffer.alloc(s,1024);
                buf2=Buffer.alloc(s,1024);
                s.sync;
                fx=Synth(\fx, [
                        \dt1,t*16,
                        \dec1,t*4,
                        \dt2,t/8,
                        \dec2,t,
                        \dt3,t*8,
                        \dec3,t*4,
                        \trFB,0.5,
                        \trFilt,0.1,
                        \rcSpeed,1/t/128,
                        \rcLo,0,
                        \rcHi,1,
                        \rcPhase,0.999,
                        \rcWidth,0.01,
                        \fftBuf1,buf1.bufnum,
                        \fftBuf2,buf2.bufnum,
                        \wetDry,1
                ]);
                Synth.after(fx,\reverb,
                        [\trFB,1,\trFilt,0.5,\wetDry,0.8]);
        }));

        weights=[
                [ 0, 0.021, 0.034, 0, 0.944, 0 ],
                [ 0, 0, 0.236, 0, 0.115, 0.649 ],
                [ 0.288, 0.696, 0.015, 0.001, 0.001, 0 ],
                [ 0, 0, 0.647, 0, 0, 0.353 ]
        ];

        Task({
                var keyw,div,octHi,octLo;
                var env=Env([0.0392,1,-0.0196],[0.5,0.5],\sine);
                var dst={ |i| env[1/32*i] }!32,switch=32,times=3,up=1;
                dst=dst.normalizeSum;
             inf.do({
                        if(up<0,{
                                up=1;
                                octHi=4;
                                octLo=1;
                        },{
                                up=1.neg;
                                octHi=8;
                                octLo=6;
                        });
                        switch=[64,32,16,8,4].choose;
                        (switch*times).do({ |i|
                                var key,oct,cmr,ndx,dur,amp;
                                if(i%switch==0,{
                                        if(coin(0.8),
                                                { keyw=weights.choose },
                                                { keyw=normalizeSum({ 1.0.rand }!5) });

                                        div=2.8.rand;
                                        octHi=octHi+up;
                                        octLo=octLo+up;
                                        if(up.isPositive,
                                                {t=t*1.3},
                                                {t=t/1.3})
                                });
                                key=[ 0,2,5,0,7,10].wchoose(keyw);
                                oct=dist.(octLo,octHi,dst);
                                cmr=[ 0.002, 0.001 ].choose/div;
                                ndx=[ 0.102, 0.051 ].choose*div*
                                        [0.06,0.5,0.8,1.2].wchoose([0.5,0.25,0.2,0.025]);
                                dur=[0.3,0.4,0.2,1.6].wchoose([ 0.25, 0.25, 0.25, 0.125])*(9/(i+1));
                                amp=[ 0.04, 0.313, 0.111 ].choose;
                                s.makeBundle(s.latency,{
                                        Synth(\fm,[\key,key,\oct,oct,\cmrDur,cmr,
                                                \ndxDur,ndx,\i_dur,dur,\amp,amp*26,\pan,0.2.rand2
                                        ]);
                                        if(i%switch==0,{
                                                fx.set(\dt1,t*[8,1,2,4].wchoose([0.1,0.1,0.4,0.4]),
                                                        \rcWidth,0.2.rand)
                                        })
                                });
                                wait(t)
                        })
                })
        }).play
)
raw 7729 chars (focus & ctrl+a+c to copy)
reception
comments
tom.dugovic user 18 Jul'22 01:51

Cool sound.

One nitpick - It does throw a deprecation warning on 3.11+, as .asInt has been deprecated in favor of .asInteger.