|
1 | | -# Structure |
| 1 | +# Repository Structure |
2 | 2 |
|
3 | 3 | - iipyper: python package for easy MIDI, OSC, event loops |
4 | | -- notochord: python package for defining+training pytorch RNN models |
5 | | - - notebooks: jupyter notebooks |
| 4 | +- notochord: python package for the Notochord MIDI performance model |
| 5 | + - notochord: package source code |
6 | 6 | - scripts: helper scripts for training, data preprocessing etc |
7 | 7 | - examples: |
8 | 8 | - iipyper: basic usage for iipyper |
9 | 9 | - notochord: interactive MIDI apps with notochord and SuperCollider |
| 10 | + - tidalcycles: notochord interface to TidalCycles |
10 | 11 | - bela: [Bela](https://bela.io) examples in C++, Pure Data and so on |
11 | 12 | - faust: [Faust](https://faustdoc.grame.fr/) examples |
12 | 13 | - tidalcycles [TidalCycles](https://tidalcycles.org) examples |
|
15 | 16 |
|
16 | 17 | # Setup |
17 | 18 |
|
| 19 | +clone the repository: |
| 20 | +``` |
| 21 | +git clone https://github.com/Intelligent-Instruments-Lab/iil-python-tools.git |
| 22 | +cd iil-python-tools |
| 23 | +``` |
| 24 | + |
| 25 | +we manage python dependencies with `conda`. If you don't have an anaconda/miniconda python install already, download an installer from https://docs.conda.io/en/latest/miniconda.html or use `brew install --cask miniconda` on mac. |
| 26 | + |
| 27 | +you can check that this worked with `which python` -- it should have 'miniconda' in the path |
| 28 | + |
| 29 | +now set up a python environment: |
18 | 30 | ``` |
19 | 31 | conda env create -f environment.yml |
20 | 32 | conda activate iil-python-tools |
21 | 33 | pip install -e notochord |
22 | 34 | pip install -e iipyper |
23 | 35 | ``` |
| 36 | +this will install all dependencies in a conda environment called `iil-python-tools`, and do an editable install of notochord and iipyper so you can hack on them. |
24 | 37 |
|
25 | 38 | # notochord |
26 | | -## Train a model |
| 39 | +download a model checkpoint (e.g. `notochord_lakh_20G.ckpt`) from the releases page: https://github.com/Intelligent-Instruments-Lab/iil-python-tools/releases |
| 40 | + |
| 41 | +## Run python server |
| 42 | +In a terminal, make sure the `iil-python-tools` conda environment is active (`conda activate iil-python-tools`) and run: |
27 | 43 | ``` |
28 | | -python notochord/scripts/lakh_prep.py --data_path /path/to/midi/files --dest_path /path/to/data/storage |
29 | | -python notochord/train.py --data_dir /path/to/data/storage --log_dir /path/for/tensorboard logs --model_dir /path/for/checkpoints train |
| 44 | +python -m notochord server --checkpoint ~/Downloads/notochord_lakh_20G.ckpt |
| 45 | +``` |
| 46 | +this will run notochord and listen continously for OSC messages. |
| 47 | + |
| 48 | +`examples/notochord/generate-demo.scd` and `examples/notochord/harmonize-demo.scd` are example scripts for interacting with the notochord server from SuperCollider. |
| 49 | + |
| 50 | +## Tidal interface |
| 51 | + |
| 52 | +see `examples/notochord/tidalcycles`: |
| 53 | + |
| 54 | +add `Notochord.hs` to your tidal boot file. Probably replace the `tidal <- startTidal` line with something like: |
30 | 55 | ``` |
| 56 | +:script ~/iil-python-tools/examples/notochord/tidalcycles/Notochord.hs |
31 | 57 |
|
32 | | -## Run OSC app |
| 58 | +let sdOscMap = (superdirtTarget, [superdirtShape]) |
| 59 | +let oscMap = [sdOscMap,ncOscMap] |
33 | 60 |
|
| 61 | +tidal <- startStream defaultConfig {cFrameTimespan = 1/240} oscMap |
| 62 | +``` |
| 63 | + |
| 64 | +In a terminal, start the python server as described above. |
| 65 | + |
| 66 | +In Supercollider, step through `examples/notochord/tidalcycles/tidal-notochord-demo.scd` which will receive from Tidal, talk to the python server, and send MIDI on to a synthesizer. There are two options, either send to fluidsynth to synthesize General MIDI, or specify your own mapping of instruments to channels and send on to your own DAW or synth. |
| 67 | + |
| 68 | +### Install fluidsynth (optional) |
| 69 | +fluidsynth (https://github.com/FluidSynth/fluidsynth) is a General MIDI synthesizer which you can install from the package manager. On mac: |
| 70 | +``` |
| 71 | +brew install fluidsynth |
| 72 | +``` |
| 73 | +fluidsynth needs a soundfont to run, like this one: https://drive.google.com/file/d/1-cwBWZIYYTxFwzcWFaoGA7Kjx5SEjVAa/view |
| 74 | + |
| 75 | +run fluidsynth in a terminal (see the fluidsynth block in `examples/notochord/tidalcycles/tidal-notochord.scd` for an example command). |
| 76 | + |
| 77 | +## Train your own Notochord model (GPU recommended) |
| 78 | + |
| 79 | +preprocess the data: |
| 80 | +``` |
| 81 | +python notochord/scripts/lakh_prep.py --data_path /path/to/midi/files --dest_path /path/to/data/storage |
| 82 | +``` |
| 83 | +launch a training job: |
34 | 84 | ``` |
35 | | -python examples/notochord/server.py --checkpoint /path/to/my/model.ckpt |
| 85 | +python notochord/train.py --data_dir /path/to/data/storage --log_dir /path/for/tensorboard/logs --model_dir /path/for/checkpoints --results_dir /path/for/other/logs train |
36 | 86 | ``` |
37 | | -step through `examples/notochord/generate.scd` in SuperCollider IDE |
| 87 | +progress can be monitored via tensorboard. |
38 | 88 |
|
39 | 89 | # Develop |
40 | 90 |
|
|
0 commit comments