Code Monkey home page Code Monkey logo

semweb-midi-tape's Introduction

The Semantic Web MIDI Tape

The swmiditp is a read/write RESTful interface for publishing MIDI as Linked Data

What is this?

The Semantic Web MIDI Tape is a set of tools and associated RESTful API to stream MIDI as RDF triples, serialize them, attach additional metadata to them, upload/download them to a SPARQL endpoint, and play them back. The set of tools is available in this repo and the RESTful API is generated from these SPARQL queries using grlc.

Requirements and install

You'll need an input MIDI instrument (or virtual device) and a POSIX system with Python 2.7. To install requirements, clone this repository and do

$ pip install -r requirements.txt

Usage example

The first thing you can do with swmiditp is to generate a live stream of RDF triples as you play along your MIDI instrument. Make sure your device is plugged in an recognized by your system. Then, move to src/ and do

python swmiditp-stream.py

There is an interactive menu to guide you through the tool. The first thing is to select the input MIDI device you want to use from a list (if your's isn't there, make sure your system recognizes it). Simply type the device number and hit enter. After this, you'll see some basic metadata in RDF on screen, and if you start playing your MIDI device, you should see a stream RDF triples representing exactly your performance. You can hit Ctrl-C at any time to stop. This will trigger a few questions about the metadata you want to attach to your performance (such as your FOAF profile, links to the composer, etc.).

All interactions are redirected to stderr, which means that you can always redirect the output of swmiditp-stream.py to a file and you'll get a syntactically valid RDF NTriples file:

python swmiditp-stream.py > myperformance.nt

When you hit Ctrl-C to stop playing, the system will provide you a URI link to your MIDI RDF performance that uniquely identifies it; let's assume that link is http://purl.org/midi-ld/pattern/example and that you've saved your triples in a file called myperformance.nt. Then you can do

./swmiditp-upload.sh http://virtuoso-midi.amp.ops.labs.vu.nl/none myperformance.nt

The first parameter is the URI of the named graph you want to load the triples into (it can be arbitrary but could come in handy if you want to store different performances in different graphs). This will upload your performance in RDF to the MIDI Linked Data cloud endpoint. You can change that endpoint by cloning this repo and specifying your own endpoint in the insert_pattern query (make sure to edit the API call names in src/ accordingly).

After a few seconds (depending on how long you played) your performance will be available online in shiny de-referenceable RDF! Just direct your browser to http://purl.org/midi-ld/pattern/example and haven fun surfing the triples with brwsr.

You can retrieve the RDF of your MIDI performance back anytime with

./swmiditp-download.sh http://purl.org/midi-ld/pattern/example > myperformance.ttl

Through the rdf2midi algorithm of midi2rdf you can convert this back into MIDI, and play it with your favourite synthesizer:

python rdf2midi.py myperformance.ttl myperformance.mid timidity myperformance.mid

semweb-midi-tape's People

Contributors

albertmeronyo avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.