RheingoldGraph is a graph representation of musical information. So far, the build has been focused on getting the core functionality and features correct rather than scale and optimization.
These instructions walkthrough how to setup RheingoldGraph in a Mac OSX environment.
There are 3 key parts of the setup:
- Midi (for playback)
- Gremlin Server and TinkerGraph (for a graph computing framework)
- Python and dependencies
Using Homebrew, setting up RtMidi is as simple as:
brew install rtmidi
Our python dependencies will be installed during the creation of our virtual environment below.
To use Midi with our prototype, you'll need to setup a MIDI port.
Use Mac OSX Audio MIDI Setup to open up an IAC Driver MIDI Port. Let's call it PythonMido.
You'll need to link a Midi instrument to be able to play the output. An easy test setup if you're on a Mac is to simply start up GarageBand.
Gremlin Server is part of the Apache TinkerPop graph computing framework. As a initial backend, we're using TinkerGraph. TinkerGraph provides a simple in-memory, non-transactional graph engine for RheingoldGraph. It's easy to configure and startup, and provides all the core functionality we need right now for feature building ad unit testing.
RheingoldGraph is being developed to run on TinkerPop>=3.3.0. Most testing has focused on TinkerPop 3.3.1, which can be download here.
Automated setup script coming soon!
- Unzip the file
- Add an alias
alias gremserv='~/my/tinkerpop/server/bin/gremlin-server.sh'
- Copy the Rheingold conf/ directory contents to the Gremlin Server conf/ directory
Coming soon!
- Python 3.6
- conda package and environment manager
- All Python dependencies found in the environment.yml file
A simple and lightweight way to get up and running with Python 3.6 and conda is to download Miniconda
Follow the instructions at the link above, or download and install from the command line
curl -O https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
sudo bash Miniconda3-latest-MacOSX-x86_64.sh
curl -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
sudo bash Miniconda3-latest-Linux-x86_64.sh
Create a virtual environment for this project with all dependencies, then activate it
conda-env create --name rheingoldgraph -f environment.yml
source activate rheingoldgraph
If you want to use RheingoldGraph with TensorFlow and Magenta models, then use the environment_magenta.yml file
conda env create --name rheingold_magenta -f environment_magenta.yml
source activate rheingold_magenta
There will be a Jupyter notebook coming soon with a more detailed walktrhough.
# Connect to an existing Gremlin Server via Websocket
server_uri = 'ws://localhost:8182/gremlin'
session = Session(server_uri)
# Add an XML file to the graph
session.add_lines_from_xml(filename='scores/BachCelloSuiteDminPrelude.xml',
piece_name='bach_cello')
# View the line we just added
session.graph_summary()
# Total Vertices: 644
# Total Edges: 1292
# Number of Lines: 1
# ----------------
# bach_cello: 643
# Play our line over an open MIDI port
midi_port = 'IAC Driver MidoPython'
session.play_line(line_name='bach_cello', qpm=80, midi_port=midi_port)
# Remove our line from the graph
session.drop_line(line_name='bach_cello')
We can also interface RheingoldGraph directly with TensorFlow models, such as those developed by Google's Magenta project.
# Use our line as a primer for generating new melodies
# from a trained TensorFlow (Magenta) model
bundle_file = '~/magenta_data/mag/basic_rnn.mag'
session.generate_melody_from_trained_model(trained_model_name='melody_rnn_generator',
bundle_file=bundle_file,
primer_line_name='bach_cello',
primer_len=11,
num_outputs=1,
qpm=80,
num_steps=150)
# INFO:tensorflow:Wrote 1 line to the graph.
# INFO:tensorflow:Wrote line bach_cello_magenta_20180204_2030
# Play our newly added melody
session.play_line('bach_cello_magenta_20180204_2030')