nsynth-midi-renderer
Sample based concatenative synthesizer for the NSynth dataset. Render any MIDI (.mid) sequence with the notes of NSynth.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.3%) to scientific vocabulary
Keywords
Repository
Sample based concatenative synthesizer for the NSynth dataset. Render any MIDI (.mid) sequence with the notes of NSynth.
Basic Info
Statistics
- Stars: 11
- Watchers: 2
- Forks: 6
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
NSynth-MIDI-Renderer for massive MIDI dataset
This project is slightly modified from original work. It is designed to render large midifile datasets.
How is it different from the original work?
For a given MIDI sequence, it goes through a process of finding and assigning candidates to lock in a single preset from the beginning to the end of the sequence. If it fails to find one because the combination of instrument, pitch, and velocity is unique, it will randomly use a preset for every note.
- New Version: https://github.com/spear011/NSynth-MIDI-Renderer-for-massive-MIDI-dataset
Original Project (last updated 2023/08/26): https://github.com/hmartelb/NSynth-MIDI-Renderer
When tested with a 130,000 MIDI dataset, only 95 MIDI sequences were randomized, with a probability of 0.0007%.
Quick start
Clone this repository to your system.
bash
$ git clone https://github.com/hmartelb/NSynth-MIDI-Renderer.git
To start synthesizing audios, you need to download the NSynth dataset and MIDI dataset you want.
- The NSynth Dataset, A large-scale and high-quality dataset of annotated musical notes. https://magenta.tensorflow.org/datasets/nsynth
How to use it
For the general use case, 3 parameters must be specified: 1) The path to the NSynth Dataset (dir path) 2) csv file that containing midi file id and instrument information 3) The output dir path
Midi Dataframe
The dataframe containing the information in the midi dataset should look like this.
|id|instrumentstr|splitdata|...| |---|---|---|---| |midifile01|keyboard|train|...| |midifile02|guitar|train|...| |midifile03|guitar|val|...|
Import the NoteSynthesizer Class into a Python script
```python from NoteSynthesizer import NoteSynthesizer
Initialize variables here
...
Create the NoteSynthesizer instance
synth = NoteSynthesizer(pathtonsynth, pathtomidicsv, outputdir, sr, velocities, preload)
you can use it with multiprocessing
import billiard as mp from tqdm.auto import tqdm
cntcpu = mp.cpucount() - 2 pool = mp.Pool(cnt_cpu)
outputdict = {'id': [], 'instrument': [], 'preset': [], 'source': []} total = len(selectedfile_list)
with tqdm(total=total) as pbar: for dictobject in tqdm(pool.imapunordered(synth.rendersequence, selectedfilelist)): for k, v in dictobject.items(): output_dict[k].append(v) pbar.update()
```
Examples
The files in the /output folder looks like this.
bash
output_dir/audio/train/midifile01_030_1.wav
output_dir/audio/train/midifile02_002_0.wav
output_dir/audio/val/midifile03_random_random.wav
The output dictionary looks like this
python
output_dict = {'id': ['midifile01', 'midifile02', 'midifile03'],
'instrument': ['keyboard', 'guitar', 'guitar'] ,
'preset': ['030', '002', 'random'],
'source': [1, 0, 'random']}
The result of this dictionary can be used to track which presets and sources were selected for the MIDI file. Information about the presets of audio sources that were subsequently used can be matched with the nsynth dataset.
Citation
If you use this code in your research, please cite both projects as below: ``` @software{MartelNSynth-MIDI-Renderer2019, author = {Martel, Hctor}, month = {8}, title = {{NSynth-MIDI-Renderer: Sample based concatenative synthesizer for the NSynth dataset.}}, url = {https://github.com/hmartelb/NSynth-MIDI-Renderer}, version = {1.0.0}, year = {2019} }
@software{HanNSynth-MIDI-Renderer-for-massive-MIDI-dataset2023, author = {Han, ChangHeon}, month = {8}, title = {{NSynth-MIDI-Renderer-for-massive-MIDI-dataset : NSynth synthesizer for massive midi dataset}}, url = {https://github.com/spear011/NSynth-MIDI-Renderer-for-massive-MIDI-dataset.git}, version = {1.0.0}, year = {2023} } ```
Licence
``` MIT License Copyright (c) 2019 Hctor Martel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```
Owner
- Name: Héctor Martel
- Login: hmartelb
- Kind: user
- Location: Santa Cruz de Tenerife, Spain
- Company: Tsinghua University
- Website: https://www.linkedin.com/in/hmartelb/
- Repositories: 3
- Profile: https://github.com/hmartelb
MSc. Advanced Computing at Tsinghua University | Guest researcher at University of Hamburg | "la Caixa" Fellow
GitHub Events
Total
Last Year
Dependencies
- Pillow ==9.0.1
- SoundFile ==0.10.3.post1
- audioread ==2.1.9
- cffi ==1.14.5
- cycler ==0.10.0
- decorator ==5.0.9
- joblib ==1.0.1
- kiwisolver ==1.3.1
- librosa ==0.7.2
- llvmlite ==0.31.0
- matplotlib ==3.3.4
- mido ==1.2.10
- numba ==0.48.0
- numpy ==1.22.0
- pretty-midi ==0.2.9
- pycparser ==2.20
- pyparsing ==2.4.7
- python-dateutil ==2.8.1
- resampy ==0.2.2
- scikit-learn ==0.24.2
- scipy ==1.5.4
- six ==1.16.0
- threadpoolctl ==2.1.0
