Project

peas

0.0
No commit activity in last 3 years
No release in over 3 years
Peas defines constants from music theory and allows one to perform math with them. Currently supports pitches (as MIDI values), pitch classes, and intervals using semitones, wholetones, chromatic, latin or diatonic abbreviations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.7.0, ~> 0.7
 Project Readme

Peas¶ ↑

Peas defines constants from music theory and allows one to perform math with them. Currently supports pitches (as MIDI values), pitch classes, and intervals using semitones, wholetones, chromatic, latin or diatonic abbreviations.

Coming soon: circles (as in ‘circle of fifths’), scales, chords and chord progressions.

Please ask questions or scold me about this here.

Features¶ ↑

  • Defines common music theory constants:

    • PitchClass: C, Ds, Eb, etc

    • Pitch (as a MIDI value): C4, Ds5, Gb8, etc

    • Intervals:

      • Semitone: S0, S1, S2 … S127

      • Wholetone: W0, W1, W2 … W63

      • Chromatic: d2, A1, d3, A2 … A7

      • Latin: S, T and TT (semi, whole and tritones)

      • Diatonic: P1, m2, M2, m3, M3, P4, A4, d5, P5, m6, M6, m7, M7 and P8

  • Constants output as their name (done using named_value_class)

  • Adds helpers to Fixnum: 2.octaves, 3.semitones, 4.major_seconds, etc.

Installation¶ ↑

gem install peas

Requirements¶ ↑

Requires ruby 1.9. Tested with:

  • ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]

  • jruby 1.6.4 (ruby-1.9.2-p136) (2011-08-23 17ea768) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]

Usage¶ ↑

require 'peas'

include Peas::Pitches
include Peas::Interval::NamedValues

def play_midi_note(pitch)
  # maybe use arirusso/micromidi here
end

[Ab3,G3,Ab3,C2].each do |root_pitch|
  [P1,m3,P5,P5,d5].each do |interval|
    play_midi_note(root_pitch + interval)
    play_midi_note(root_pitch + interval + 2.octaves)
    play_midi_note(root_pitch - 2.tritones)
  end
end

Issues¶ ↑

  • The “super from singleton method that is defined to multiple classes is not supported; this will be fixed in 1.9.3 or later” error from named_value_class shows it’s ugly head sometimes.

  • Still not sure how to best deal with the name collisions of A1-A7 as Intervals and as Pitches.

  • Weak documentation

Author¶ ↑

License¶ ↑

Apache 2.0, See the file LICENSE

Copyright © 2011 Michael Garriss