Git Product home page Git Product logo

sonic-midi's Introduction

sonic-midi

This tool allows to programmatically define melodies that can be played in Sonic Pi via an external command-line interface (CLI) while automatically exporting them to MIDI files to be consumed elsewhere (such as in LMMS).

Note: this is not an official Google product.

Installation

gem install sonic-midi

Usage

sonic-midi sonic melody.rb

sonic-midi midi melody.rb

sonic-midi all melody.rb

Defining a melody

The melodies are defined by the means of simple Ruby programs (see the examples directory for
some examples).
At the very least, a melody file needs to contain a function that specifies a single melody.

For example:

def melody
  return [[60], [0.25]]
end

This will result in the 4th octave C note to be played for a quarter duration.

In general, the simple melody is defined as an array containing two or three subarrays:
  - List of MIDI pitches
  - List of durations (as fractions of the measure)
  - Optional: List of volumes (in the 0..5 range, to match SonicPi)

Note that pitch of 0 is reserved for silence

In order to allow playing multiple notes at the same time, the melody function can return a
dictionary of sub-melodies instead of a single melody.

For example:

def melody()
  return { m1: m1(), m2: m2(), m3: m3() }
end

(We're assuming m1(), m2() and m3() are defined as individual melodies)

In addition to the actual melody, the melody file can specify BPM (via def mybmp()) and a synth to
use in SonicPi (via def mysynth()). Note that mysynth() is ignored when generating the Midi file.

Importing Midi to LMMS

Once you've generated a melody and prototyped it in SonicPi, you can use the exported Midi file
in LMMS. For this, simply do Project | Import in LMMS and select the resulting Midi file. Note that
by default, LMMS will create a SoundFont track, but you can override it with any instrument.

Tip: the Midi files can be used to generate a percussion track (the pitches will get ignored).

sonic-midi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.