25
25
# Settings
26
26
27
27
LEVEL = 0.25 # Use `SAMPLES[notenum]["level"]` to override
28
- FILTER_MAX = 20000.0
28
+ FILTER_MAX = min ( 20000.0 , hardware . SAMPLE_RATE / 2.0 )
29
29
FILTER_MIN = 50.0
30
+ WIDTH = 1.0 # 0.0->1.0
30
31
31
32
VELOCITY_HARD = 100 # Velocity is 0->127
32
33
VELOCITY_SOFT = 0 # Adjust to act as gate
44
45
VELOCITY_HARD : "snare_hard" ,
45
46
VELOCITY_SOFT : "snare_soft"
46
47
},
47
- "level" : 0.3
48
+ "level" : 0.3 ,
49
+ "panning" : - 0.3 * WIDTH
48
50
},
49
51
41 : {
50
52
"samples" : {
51
53
VELOCITY_HARD : "tom_lo_hard" ,
52
54
VELOCITY_SOFT : "tom_lo_soft"
53
- }
55
+ },
56
+ "panning" : 1.0 * WIDTH
54
57
},
55
58
42 : {
56
59
"samples" : {
57
60
VELOCITY_SOFT : "hihat_closed"
58
- }
61
+ },
62
+ "panning" : - 1.0 * WIDTH
59
63
},
60
64
43 : {
61
65
"samples" : {
62
66
VELOCITY_HARD : "tom_mid_hard" ,
63
67
VELOCITY_SOFT : "tom_mid_soft"
64
- }
68
+ },
69
+ "panning" : 0.4 * WIDTH
65
70
},
66
71
44 : {
67
72
"samples" : {
68
73
VELOCITY_SOFT : "hihat_pedal"
69
- }
74
+ },
75
+ "panning" : - 1.0 * WIDTH
70
76
},
71
77
45 : {
72
78
"samples" : {
73
79
VELOCITY_HARD : "tom_hi_hard" ,
74
80
VELOCITY_SOFT : "tom_hi_soft"
75
- }
81
+ },
82
+ "panning" : - 0.4 * WIDTH
76
83
},
77
84
46 : {
78
85
"samples" : {
79
86
VELOCITY_SOFT : "hihat_open"
80
- }
87
+ },
88
+ "panning" : - 1.0 * WIDTH
81
89
},
82
90
49 : {
83
91
"samples" : {
84
92
VELOCITY_HARD : "crash_hard" ,
85
93
VELOCITY_SOFT : "crash_soft"
86
- }
94
+ },
95
+ "panning" : - 0.6 * WIDTH
87
96
},
88
97
51 : {
89
98
"samples" : {
90
99
VELOCITY_HARD : "ride_hard" ,
91
100
VELOCITY_SOFT : "ride_soft"
92
- }
101
+ },
102
+ "panning" : 0.6 * WIDTH
93
103
}
94
104
}
95
105
125
135
effect_reverb .play (effect_filter )
126
136
effect_filter .play (mixer )
127
137
128
- for i , wav in enumerate (samples .values ()):
129
- mixer .voice [i ].play (wav )
130
- mixer .voice [i ].level = 0.0
131
-
132
138
def get_sample (notenum :int , velocity :int = 127 ) -> tuple [str , float ]| None :
133
139
if notenum in SAMPLES :
134
140
sample = SAMPLES [notenum ].copy ()
@@ -151,6 +157,7 @@ def play_sample(sample:dict) -> None:
151
157
i = get_sample_index (sample ["name" ])
152
158
wav = samples [sample ["name" ]]
153
159
mixer .voice [i ].level = sample .get ("level" , LEVEL )
160
+ mixer .voice [i ].panning = sample .get ("panning" , 0.0 )
154
161
mixer .voice [i ].loop = sample .get ("loop" , False )
155
162
mixer .voice [i ].play (wav )
156
163
@@ -244,7 +251,7 @@ async def controls_handler():
244
251
ui .setA (hardware .knobA .value >> 8 )
245
252
ui .setB (hardware .knobB .value >> 8 )
246
253
247
- await asyncio .sleep (0.005 )
254
+ await asyncio .sleep (0.01 )
248
255
249
256
async def main ():
250
257
await asyncio .gather (
0 commit comments