-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDuetTest.hs
99 lines (75 loc) · 3.14 KB
/
DuetTest.hs
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
import Audio
import Synths
import Sound.SC3
import Sound.SC3.ID hiding (ID)
import Sound.SC3.Lang.Pattern.ID
import Sound.OpenSoundControl.Type
import Sound.OpenSoundControl as O
initf =
let files = [--"/home/scott/noise/duet.wav"
-- , "/home/scott/noise/stabat.wav"
-- , "/home/scott/noise/wisdomclipp1.wav"
"/home/scott/noise/wisdomclipp2.wav"
-- , "/home/scott/noise/wisdomclipp3.wav"
-- , "/home/scott/u/362/perfect.wav"
]
-- fn0 = "/home/scott/noise/duet.wav"
-- fn1 = "/home/scott/noise/stabat.wav"
in withSC3 (\fd -> mapM (\(i,fn) ->
async fd (b_allocRead i fn 0 0))
$ zip [0..] files
)
f n = n * sampleRate
--mono $ ph 500 0.2 (mouseY KR 0 3 Linear 0.1) + ph 500 0.2 0
--mono $ phasor AR 0 (400 / sampleRate) 0 1 0
--mono $ saw AR 400
--mono $( lfSaw AR 400 0 * 0 + phasor AR 0 400 0 1 (mouseY KR 0 3 Linear 0.1) ) * 0.2
pat1 b len =
pinstr_s (return "loop") $
pbind $ [ ("b",toP [b])
, ("amp",toP . take len $ itrconcat (* 1.05) [3,0.5,0.2,0.1])
, ("dur", toP . take len $ [1])
, ("sustain", toP [1])
, ("bus", toP . take len $ [0,1,0,1,1,0,1,0])
, ("rate", toP [0.01,0.05,0.1,0.2]) -- ,0.8,1.0])
]
pat2 b len =
pinstr_s (return "loop") $
pbind $ [ ("b",toP [b])
, ("amp",toP . take len $ itrconcat (* 1.02) [0.7,0.5,0.4,0.3])
, ("dur", toP . take len $ [0.5])
, ("sustain", toP [1])
, ("bus", toP . take len $ [0,1,0,1,1,0,1,0])
, ("rate", toP . take len $ itrconcat (* 1.5) [1..4]) -- ,0.8,1.0])
]
main = do
resetSC3OSC
installSynthOSC loopSynth
let snum = 22
-- addSynthOSC "play" snum
let b = 0
sc = bufRateScale KR b
fr = bufFrames KR b
dur = bufDur KR b
s1 = fr/dur
pos rate = (lfSaw AR (rate * 0.5/dur) 0 * fr) -- + f (mouseY KR (-5) 5 Linear 0.2)
my a b = mouseY KR a b Linear 0.1
mx a b = mouseX KR a b Linear 0.1
slowspeed = 0.05
frames = [1,1.001..1.01]
speedup = [line KR slowspeed 1 (bufDur KR b / (0.1 * slowspeed)) DoNothing] -- [1,1.001..1.01]
{- sound 1-}
-- audition (pat1 0 192)
{- sound 2-}
-- audition (pat2 48)
{- sound a -}
mono $ loopPlay b (mce speedup) (mce [0,0.05..1.0])
print 22
-- print . (!! 4) $ renderEvents pat
-- writeNRT "/home/scott/noise/quiet1.osc" (Bundle (O.UTCr 0) [g_new [(1, AddToTail, 0)]] : Bundle (O.UTCr 0) [d_recv loopSynth] : renderEvents pat)
-- audition $ out 0 $ mix $ bufRdC 1 AR b (pos $ -1) Loop
-- basic playbuf:
-- audition (out 0 $ mix $ (playBuf 2 AR b (-sc * 0.5) 1 (fr - s1 * 0.1 * (0/0.22 + mce [1..22])) NoLoop DoNothing))
-- audition (out 0 $ mix $ (bufRdC 1 AR b (pos + f 1 * (mce [0..2])) Loop))
-- audition (out 0 $ mix $ (s (s 3.1 0.5 + 1.5) 0.1 + 0.9) * (playBuf 1 AR b (-sc * (s 0.1 0.8 + 0.3)) 1 (fr - s1 * (0 + mce [1..11])) NoLoop DoNothing))
itrconcat f xs = concat $ iterate (map f) xs