Skip to content

Commit 1db2563

Browse files
committed
add support for audio fade-in at the beginning of each PearlMMX instrument sample
1 parent e6e3c8c commit 1db2563

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/create_drumgizmo_kit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
source_samples_dir_name = "source_samples" # root directory of recorded source samples
7272
fade_out_percent = 10 # % of sample at the end is faded out
7373
thresh_from_max_for_start = 20 # dB
74-
add_samples_at_start = 20 # additional samples considered at strike start
74+
add_samples_at_start = 20 # additional samples considered at strike start (also defines the fade-in time period)
7575
min_time_next_strike_s = 0.5 # minimum time in seconds between two different strikes
7676

7777
# TEST for optimizing the algorithms, only use one instrument
78-
#instruments = [instruments[7]]
78+
#instruments = [instruments[9]]
7979

8080
# settings for optimized drum kit for Raspberry Pi (with limited RAM)
8181
if raspi_optimized_drumkit:
@@ -207,6 +207,9 @@
207207
strike_cut_pos[strike_start[i][0]:strike_end[i][0] + 1].fill(True) # for debugging
208208
sample_strikes[p][i][:, c] = sample[c][strike_start[i][0]:strike_end[i][0] + 1]
209209

210+
# audio fade-in at the beginning
211+
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)
212+
210213
# audio fade-out at the end
211214
sample_len = len(sample_strikes[p][i][:, c])
212215
fade_start = int(sample_len * (1 - fade_out_percent / 100))

0 commit comments

Comments
 (0)