|
51 | 51 | ["hihat_closedtop", ["Hihat", "OHLeft", "OHRight"], [42, 46], "hihat", "80", 0.2, 20], \
|
52 | 52 | ["hihat_open", ["Hihat", "OHLeft", "OHRight"], [26], "hihat", "0", 0.7, 23], \
|
53 | 53 | ["hihat_open1", ["Hihat", "OHLeft", "OHRight"], [26], "hihat", "55", 0.7, 23], \
|
54 |
| - ["hihat_open2", ["Hihat", "OHLeft", "OHRight"], [26], "hihat", "20", 0.7, 23], \ |
| 54 | + ["hihat_open2", ["Hihat", "OHLeft", "OHRight"], [26], "hihat", "27", 0.7, 23], \ |
55 | 55 | ["hihat_opentop", ["Hihat", "OHLeft", "OHRight"], [46], "hihat", "0", 0.7, 24], \
|
56 | 56 | ["hihat_open1top", ["Hihat", "OHLeft", "OHRight"], [46], "hihat", "55", 0.7, 21], \
|
57 |
| - ["hihat_open2top", ["Hihat", "OHLeft", "OHRight"], [46], "hihat", "20", 0.7, 23], \ |
| 57 | + ["hihat_open2top", ["Hihat", "OHLeft", "OHRight"], [46], "hihat", "27", 0.7, 23], \ |
58 | 58 | ["hihat_foot", ["Hihat", "OHLeft", "OHRight"], [44], "hihat", "", 0.1, 23], \
|
59 | 59 | ["tom1", ["Tom1", "OHLeft", "OHRight"], [48, 50], "", "", 0.2, 15], \
|
60 | 60 | ["tom2", ["Tom2", "OHLeft", "OHRight"], [45, 47], "", "", 0.2, 15], \
|
61 | 61 | ["tom3", ["Tom3", "OHLeft", "OHRight"], [43, 58], "", "", 0.4, 15], \
|
62 |
| - ["crash", ["OHLeft", "OHRight"], [55], "", "", 0.5, 15], \ |
63 |
| - ["crash_top", ["OHLeft", "OHRight"], [49], "", "", 0.4, 15], \ |
| 62 | + ["crash", ["OHLeft", "OHRight"], [55, 52], "", "", 0.5, 15], \ |
| 63 | + ["crash_top", ["OHLeft", "OHRight"], [49, 57], "", "", 0.4, 15], \ |
64 | 64 | ["ride", ["OHRight", "OHLeft"], [51], "", "", 1.0, 15], \
|
65 | 65 | ["ride_bell", ["OHRight", "OHLeft"], [53], "", "", 1.0, 16], \
|
66 | 66 | ["ride_side", ["OHRight", "OHLeft"], [59], "", "", 1.0, 15]]
|
|
82 | 82 | disable_positional_sensing_support = True
|
83 | 83 | only_master_channels_per_instrument = True
|
84 | 84 | for instrument in instruments: # remove some instruments for lowest possible memory requirement
|
85 |
| - if "tom2" in instrument or "ride_side" in instrument or "crash_top" in instrument or "hihat_opentop" in instrument: |
| 85 | + if ("tom2" in instrument or "ride_side" in instrument or "crash_top" in instrument or "hihat_opentop" in instrument or |
| 86 | + "hihat_open1top" in instrument or "hihat_open2top" in instrument or "hihat_closedtop" in instrument): |
86 | 87 | instruments.remove(instrument)
|
87 | 88 | for instrument in instruments: # assign now missing MIDI notes to remaining instruments
|
88 | 89 | if "ride" in instrument:
|
|
91 | 92 | instrument[2].append(49)
|
92 | 93 | if "hihat_open" in instrument:
|
93 | 94 | instrument[2].append(46)
|
| 95 | + if "hihat_closed" in instrument: |
| 96 | + instrument[2].append(42) |
| 97 | + instrument[2].append(46) |
| 98 | + if "hihat_open1" in instrument: |
| 99 | + instrument[2].append(46) |
| 100 | + if "hihat_open2" in instrument: |
| 101 | + instrument[2].append(46) |
94 | 102 |
|
95 | 103 |
|
96 | 104 | for instrument in instruments:
|
|
202 | 210 | sample_powers[p][i] = strike_max / 32768 / 32768 # assuming 16 bit
|
203 | 211 |
|
204 | 212 | # extract sample data of current strike
|
205 |
| - sample_strikes[p][i] = np.zeros((strike_end[i][0] - strike_start[i][0] + 1, num_channels), np.int16) |
| 213 | + if raspi_optimized_drumkit: |
| 214 | + x_cur_strike_master = x[strike_start[i][0]:strike_end[i][0] + 1] |
| 215 | + strike_max = np.max(x_cur_strike_master) |
| 216 | + last_index = np.max(np.argwhere(x_cur_strike_master > strike_max / np.power(10, 40 / 10))) # 40 dB below max |
| 217 | + mod_strike_end = strike_start[i][0] + last_index; |
| 218 | + else: |
| 219 | + mod_strike_end = strike_end[i][0] |
| 220 | + |
| 221 | + sample_strikes[p][i] = np.zeros((mod_strike_end - strike_start[i][0] + 1, num_channels), np.int16) |
206 | 222 | for c in range(0, num_channels):
|
207 |
| - strike_cut_pos[strike_start[i][0]:strike_end[i][0] + 1].fill(True) # for debugging |
208 |
| - sample_strikes[p][i][:, c] = sample[c][strike_start[i][0]:strike_end[i][0] + 1] |
| 223 | + strike_cut_pos[strike_start[i][0]:mod_strike_end + 1].fill(True) # for debugging |
| 224 | + sample_strikes[p][i][:, c] = sample[c][strike_start[i][0]:mod_strike_end + 1] |
| 225 | + |
209 | 226 |
|
210 | 227 | # audio fade-in at the beginning
|
211 | 228 | sample_strikes[p][i][:add_samples_at_start, c] = np.int16(sample_strikes[p][i][:add_samples_at_start, c].astype(float) * np.arange(1, add_samples_at_start + 1, 1) / add_samples_at_start)
|
|
215 | 232 | fade_start = int(sample_len * (1 - fade_out_percent / 100))
|
216 | 233 | fade_len = sample_len - fade_start
|
217 | 234 | sample_strikes[p][i][fade_start:, c] = np.int16(sample_strikes[p][i][fade_start:, c].astype(float) * np.arange(fade_len + 1, 1, -1) / fade_len)
|
| 235 | + # TEST -> new logarithmic fade-out (instead of linear) |
| 236 | + #fade_gain = np.power(10, (np.arange(fade_len + 1, 1, -1) / fade_len - np.ones(fade_len)) * 10 / 10) # 10 dB fade-out |
| 237 | + #sample_strikes[p][i][fade_start:, c] = np.int16(sample_strikes[p][i][fade_start:, c].astype(float) * fade_gain) |
218 | 238 |
|
219 | 239 | #print(sample_powers[p][i])
|
220 | 240 | #plt.plot(sample_strikes[p][i][:, master_channel])
|
|
0 commit comments