Project

rb-music

0.0
No commit activity in last 3 years
No release in over 3 years
This gem provides Ruby classes for working with musical notes, scales and intervals.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 4.2.8, ~> 4.2
>= 10.3.1, ~> 10.3
>= 2.14.1, ~> 2.14
>= 0.8.2, ~> 0.8
 Project Readme

rb-music

rb-music is a Ruby gem for working with musical notes, scales and intervals. It is basically a direct port of the wonderful music.js library by Greg Jopa.

Installation

In your Gemfile:

gem 'rb-music', git: 'https://github.com/mwise/rb-music', branch: 'master'

In your Ruby code:

require 'rb-music'

Overview

Note

Note.from_latin(name): Note by latin name and octave

n = Note.from_latin('A4');  # single note
n.frequency  # 440
n.latin  # "A"
n.octave # 4
n.midi_note_number # 69

n = Note.from_latin('C4')  # base note for scale
n.scale('major') #  NoteSet built from the given note and scale

Interval

Interval.from_name(name): Interval by name

Interval.from_semitones(num): Interval by semitones

Interval.from_name('fifth') # define by name
whole_step = Interval.from_semitones(2) # define by # of semitones

c = Note.from_latin('C3')

# use intervals to transpose notes
d = c.add(whole_step)

# use intervals to define chords
cmaj = c.add(['unison','major third','fifth'])