Small music theory library with MIDI capabilities written in Rust

Overview

mumuse

build license doc.rs crates.io rustc

Small music theory library with MIDI capabilities written in Rust (wip).


Examples

Creating notes and transpositions

// Declare Note from &str
let _a = Note::try_from("C0").unwrap();

// Declare from struct
let n = Note::new(Letter::C, 2);
println!("Note : {}", n);

// Transpose up by one Fifth
let fifth = n + Interval::Fifth;
println!("Fifth up : {}", fifth);

// Transpose down by one Octave
let octave = n - Interval::Octave;
println!("Octave down : {}", octave);

Chords, transpositions and inversions

// From an str Vec directly
let chord_from_str = Chord::from(vec!["C4", "E4", "G4"]);
println!("From str vector : {}", chord_from_str);

// Inversions
let first_inv = chord_from_str.invert(1);
let second_inv = chord_from_str.invert(2);
println!("First inversion : {}", first_inv);
println!("First inversion : {}", second_inv);

// Transpositions
let chord_one_fifth = chord_from_str.clone() + Interval::Fifth; // Chord is not Copy
let chord_one_octave_down = chord_from_str.clone() - Interval::Octave;
println!("Fifth up : {}", chord_one_fifth);
println!("Octave down : {}", chord_one_octave_down);

Build scales and chords from scales

// Declare a root note
let root = Note::try_from("C0").unwrap();

// Declare vector of intervals
let intervals = vec![Interval::MajorSecond, Interval::Fifth];

// Declare scale from root and intervals and print it
let scale = Scale::new(root, intervals);
println!("{}", scale);

// Declare existing scales
let major_scale = Scale::major(root);
println!("{}", major_scale);

// Construct Chord from Scale degree
let one_chord = Scale::major(root).one(3); // 3 notes chord
let five_chord = Scale::major(root).five(4); // 4 notes chord
println!("I chord of C Major Scale : {}", one_chord);
println!("V7 chord of C Major Scale : {}", five_chord);

Play with chords and secondary dominants

// Secondary dominants function
fn get_five(scale: &Scale, degree: usize) -> Chord {
    Scale::major(scale.notes()[degree-1]).five(4)

// Declare a root note
let root = Note::try_from("C3").unwrap();
let major_scale = Scale::major(root);

// Fill with chords
let chords = (1..6).map(|degree| major_scale.by_degree(degree, 3).invert(2));
let secondary_dominants = (1..6).map(|degree| get_five(&major_scale, degree+1));

// Play them through midi
// midi::show_output_ports(); // show output ports
let mut conn_out = midi::get_output_connection("Virtual Midi Bus 1".to_string());
for (chord, second) in chords.zip(secondary_dominants) {
    chord.send_midi(&mut conn_out, 500, 64);
    second.send_midi(&mut conn_out, 500, 64);

Modes too

// Declare a root note
let root = Note::try_from("C0").unwrap();

// Declare major scale
let major_scale = Scale::major(root);
println!("{}", major_scale);

// Construct modes
let ionian = major_scale.mode(1); // Does not change anything on Major scale
let dorian = major_scale.mode(2);
let phrygian = major_scale.mode(3);

// Print scales
println!("{ionian}");
println!("{dorian}");
println!("{phrygian}");

Receive MIDI messages from Device

midi::show_input_ports();
midi::receive("Arturia KeyStep 32".to_string());


You might also like...
Encrypt and decrypt files by playing melodies on your MIDI keyboard.

midicrypt Encrypt and decrypt files by playing melodies on your MIDI keyboard. Written in Rust. ❯ ./midicrypt -h midicrypt 0.1.0 NINNiT Encrypts and D

🎹 Simple MIDI note repeater plugin (VST3/CLAP).

⏱️ Clockwork A simple MIDI note repeater plugin, written in Rust. 🎬 Showcase: (turn on audio) clockwork-showcase.mp4 📖 Manual: The user manual can b

Drumsthesia is a simple software that helps you to learn how to play the drums (or midi controllers).
Drumsthesia is a simple software that helps you to learn how to play the drums (or midi controllers).

Drumsthesia A shameless copy of Neothesia adapted for e-Drums. Youtube Video Binaries for MacOS, Linux (untested) and Windows (untested). Download Scr

Polyrhythmically-inclinded Midi Drum generator
Polyrhythmically-inclinded Midi Drum generator

Polyrhythmix Polyrhythmix (Poly) is a command-line assistant designed to generate MIDI files from the description of drum parts. It provides a conveni

Build custom songs for Pokémon Mystery Dungeon: Explorers of Sky from Soundfonts and MIDI files

skysongbuilder A tool to build custom songs for Pokémon Mystery Dungeon: Explorers of Sky from Soundfonts and MIDI files Features: Optimizations down

Minimalist multi-track audio recorder which may be controlled via OSC or MIDI.
Minimalist multi-track audio recorder which may be controlled via OSC or MIDI.

smrec Minimalist multi-track audio recorder which may be controlled via OSC or MIDI. I did this because I needed a simple multi-track audio recorder w

musify is a simple discord bot to play music within a voice channel, written in the rust programming language.

musify-rs musify is a simple discord bot to play music within a voice channel, written in the rust programming language. Features A simple song queue

 Terminal Music Player written in Rust
Terminal Music Player written in Rust

Terminal Music Player written in Rust Listen to music freely as both in freedom and free of charge! Freedom: As time goes by, online service providers

A terminal music player written in the Rust language.
A terminal music player written in the Rust language.

A terminal music player written in the Rust language. (Windows) Requirements Configuration file path: C:\Users\xxx\.config\music_player\config.yml # P

Releases(v0.7.0)
  • v0.7.0(Feb 6, 2022)

  • v0.6.0(Feb 3, 2022)

    Adds time and duration management with Time and Duration modules.

    • Time is defined as (bar, divisions, position)
    • Duration is defined as (divisions, length)

    This is a not a tradionnal way of expressing music timing, but I wanted my definition to be as general as possible for advanced use of polyrhythm and polymeter compositions.

    Adds Stream to construct sequences of timed notes.

    • Stream can play notes in real time with constant async tick rateprecision
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jan 16, 2022)

  • v0.4.0-alpha(Jan 15, 2022)

    mumuse isn't a complete pile of garbage right now and can be used for a few things (already using it for music composition experimentation).

    Browse some of the examples in order to overview some of its capabilities. You can also check the documentation and download the crate on crates.io.

    I plan to implement more features, but with a building blocks philosophy: advanced uses won't be necessarily implemented but hopefully easily derivable.

    Source code(tar.gz)
    Source code(zip)
Owner
Alexis LOUIS
Signal Processing Engineer
Alexis LOUIS
Very simple, efficient, task oriented, low cognitive, Midi player and jukebox for midi instruments

Midi and Virtual Book jukebox Player A cross-platform MIDI and virtual book jukebox player. It only includes the necessary functionalities to play MID

Barrel Organ Discovery 4 Jun 29, 2023
Tools for working with MIDI files - written by All the Music LLC for musicians.

Tools for Generating and Working with MIDI Files NOTICE: This repo is under construction and is not ready for use. Once it is ready, and the other rep

null 9 Nov 17, 2022
Rust-crate with functions and helpers for working with music / audio, inspired by computer music languages.

music-math This crate contains common functions and helpers for working with music / audio in Rust. Most of these are inspired by similar functions fo

Mads Kjeldgaard 3 Apr 10, 2024
Polaris is a music streaming application, designed to let you enjoy your music collection from any computer or mobile device.

Polaris is a music streaming application, designed to let you enjoy your music collection from any computer or mobile device. Polaris works by streami

Antoine Gersant 1k Jan 9, 2023
A small program that converts midi files to RPE (Re: Phigros Edit) Charts

Midi to RPE(Re: Phigros Edit) chart converter $ mid2json --help Usage: mid2json [OPTIONS] <MIDI_PATH> Arguments: <MIDI_PATH> Name of the input fil

液氦 4 Jun 8, 2023
Small, compact music player written with Rust.

trill Small, compact music player based on rodio. Usage Run the program with --help to see the available options. To just play a sound file: trill -p

Will 3 Nov 25, 2022
Cross-platform realtime MIDI processing in Rust.

midir Cross-platform, realtime MIDI processing in Rust. Features midir is inspired by RtMidi and supports the same features*, including virtual ports

Patrick Reisert 392 Dec 27, 2022
Midnote is a terminal application that reads a MIDI file and displays you its notes bar-by-bar, while playing it.

MIDNOTE Midnote is a terminal application that reads a MIDI file and displays you its notes bar-by-bar, while playing it. Goals As a blind musician my

null 4 Oct 30, 2022
MIDI-controlled stereo-preserving granular-synthesizer LV2 plugin

Stereog "Stereog" rhymes with "hairy dog." Stereog is a MIDI-controlled stereo-preserving granular synthesizer LV2 plugin. It is experimental software

Ed Cashin 6 Jun 3, 2022
Map the Teenage Engineering OP-1 MIDI output to keyboard commands

OP1NPUT Maps the Teenage Engineering OP-1's MIDI output to keyboard keypresses so it may be used as a game controller. This exists because many of the

Glen Murphy 4 Nov 7, 2022