Skip to content

chriskiefer/iil-python-tools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

153 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repository Structure

  • iipyper: python package for easy MIDI, OSC, event loops
  • notochord: python package for the Notochord MIDI performance model
    • notochord: package source code
    • scripts: helper scripts for training, data preprocessing etc
  • examples:
    • iipyper: basic usage for iipyper
    • notochord: interactive MIDI apps with notochord and SuperCollider
      • tidalcycles: notochord interface to TidalCycles
    • bela: Bela examples in C++, Pure Data and so on
    • faust: Faust examples
    • tidalcycles TidalCycles examples
    • puredata: Pure Data examples

Setup

clone the repository:

git clone https://github.com/Intelligent-Instruments-Lab/iil-python-tools.git
cd iil-python-tools

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.

you can check that this worked with which python -- it should have 'miniconda' in the path

now set up a python environment:

conda env create -f environment.yml
conda activate iil-python-tools
pip install -e notochord
pip install -e iipyper

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.

notochord

download a model checkpoint (e.g. notochord_lakh_20G.ckpt) from the releases page: https://github.com/Intelligent-Instruments-Lab/iil-python-tools/releases

Run python server

In a terminal, make sure the iil-python-tools conda environment is active (conda activate iil-python-tools) and run:

python examples/notochord/server.py --checkpoint ~/Downloads/notochord_lakh_20G.ckpt

this will run notochord and listen continously for OSC messages.

examples/notochord/generate.scd and examples/notochord/harmonize.scd are example scripts for interacting with the notochord server from SuperCollider.

Tidal interface

see examples/notochord/tidalcycles:

add Notochord.hs to your tidal boot file. Probably replace the tidal <- startTidal line with something like:

:script ~/iil-python-tools/examples/notochord/tidalcycles/Notochord.hs

let sdOscMap = (superdirtTarget, [superdirtShape])
let oscMap = [sdOscMap,ncOscMap]

tidal <- startStream defaultConfig {cFrameTimespan = 1/240} oscMap

In a terminal, start the python server as described above.

In Supercollider, step through examples/notochord/tidalcycles/tidal-notochord.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.

Install fluidsynth (optional)

fluidsynth (https://github.com/FluidSynth/fluidsynth) is a General MIDI synthesizer which you can install from the package manager. On mac:

brew install fluidsynth

fluidsynth needs a soundfont to run, like this one: https://drive.google.com/file/d/1-cwBWZIYYTxFwzcWFaoGA7Kjx5SEjVAa/view

run fluidsynth in a terminal (see the fluidsynth block in examples/notochord/tidalcycles/tidal-notochord.scd for an example command).

Train your own Notochord model (GPU recommended)

preprocess the data:

python notochord/scripts/lakh_prep.py --data_path /path/to/midi/files --dest_path /path/to/data/storage

launch a training job:

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

progress can be monitored via tensorboard.

Develop

add new dependencies to environment.yml, then run:

conda env update -f environment.yml

About

Simple Python app to host a Pytorch model and send/receive OSC messages

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%