-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
download the bitKlavier dataset to do a polyphonic faust piano example (
#62)
- Loading branch information
Showing
10 changed files
with
176 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ def has_ext_modules(foo): | |
'Documentation': 'https://ccrma.stanford.edu/~braun/dawdreamer', | ||
'Source': 'https://github.com/DBraun/DawDreamer', | ||
}, | ||
version='0.5.7.9', | ||
version='0.5.7.10', | ||
author='David Braun', | ||
author_email='[email protected]', | ||
description='An audio-processing Python library supporting core DAW features', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
librosa>=0.8.1 | ||
numpy>=1.21.2 | ||
pytest>=6.2.4 | ||
scipy>=1.7.0 | ||
scipy>=1.7.0 | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bitKlavierGrand_PianoBar |
Binary file added
BIN
+97.7 KB
...sets/MIDI-Unprocessed_SMF_02_R1_2004_01-05_ORIG_MID--AUDIO_02_R1_2004_05_Track05_wav.midi
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
declare name "MyInstrument"; | ||
|
||
declare options "[nvoices:8]"; // FaustProcessor has a property which will override this. | ||
import("stdfaust.lib"); | ||
|
||
// variation of hs_phasor that doesn't loop. It's like a one-shot trigger. | ||
my_phasor(inc,c) = inc*on_memory : + ~ (_*(1-start_pulse)) | ||
with { | ||
is_on = c>0; | ||
|
||
start_pulse = is_on & (1-is_on'); | ||
on_memory = is_on : max ~ (_*(1-start_pulse)); | ||
}; | ||
|
||
gain = hslider("gain",0.1,0,1,0.01); // note velocity | ||
gate = button("gate"); // note on/off | ||
key = hslider("freq", 60, 1, 127, 1) : ba.hz2midikey : _ , -21 : +; | ||
// note that A0 is midi note 21, so we subtract 21 to get to 0 (the first file is named 0.wav) | ||
release = hslider("release",0.1,0.,2.,0.001); // note release in seconds | ||
envVol = en.adsr(0., 0., 1., release, gate); | ||
safeKey = key : min(87) : max(0); | ||
totalGain = gain * envVol * .5; | ||
|
||
process = safeKey,my_phasor(1., gate):soundfile("mySound",2):!,!,_,_ : _*totalGain, _*totalGain; | ||
// polyphonic DSP code must declare a stereo effect | ||
effect = _, _; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# author: David Braun ([email protected]) | ||
|
||
import soundfile as sf | ||
import pyrubberband as pyrb | ||
import os.path | ||
|
||
""" | ||
This file takes the bitKlavier Grand Piano dataset and turns it into 88 wav files, named 0.wav through 87.wav. | ||
You can customize a few parameters directly below: | ||
""" | ||
|
||
velocity = 'v8' | ||
src_dir = 'E:/data/bitKlavierGrand_PianoBar_44k16b' | ||
duration_seconds = 10. | ||
output_dir = os.path.abspath('bitKlavierGrand_PianoBar_converted') | ||
|
||
# No need to modify below here: | ||
|
||
os.makedirs(output_dir, exist_ok=True) | ||
|
||
pairs = [ | ||
('A0', 0), # A | ||
('A0', 1), # A# | ||
('C1', -1), # B | ||
('C1', 0), # C | ||
('C1', 1), # C# | ||
('D#1', -1), # D | ||
('D#1', 0), # D# | ||
('D#1', 1), # E | ||
('F#1', -1), # F | ||
('F#1', 0), # F# | ||
('F#1', 1), # G | ||
('A1', -1), # G# | ||
] | ||
|
||
num_completed = 0 | ||
is_done = False | ||
octave = 0 | ||
|
||
while not is_done: | ||
|
||
for i, (input_note, shift) in enumerate(pairs): | ||
|
||
note = input_note[:-1] + str(octave if i < 2 else octave + 1) | ||
|
||
filepath = os.path.join(os.path.normpath(src_dir), f"{note}{velocity}.wav") | ||
print(filepath) | ||
y, sr = sf.read(filepath, always_2d=True) | ||
|
||
y = y[:int(sr*(duration_seconds+1.)), :] # limit the time | ||
|
||
y_stretch = pyrb.pitch_shift(y, sr, shift) | ||
|
||
y_stretch = y_stretch[:int(sr*duration_seconds), :] # limit the time | ||
|
||
output_filepath = os.path.join(output_dir, f"{num_completed}{velocity}.wav") | ||
sf.write(output_filepath, y_stretch, sr) | ||
|
||
num_completed += 1 | ||
is_done = num_completed >= 88 | ||
if is_done: | ||
break | ||
|
||
octave += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters