interval is a tiny library that provides simple musical note pitch and interval arithmetic. It is intended to do one thing: given a pitch add (or subtract) an interval and give the resulting pitch.

Observe:

p = Interval::Pitch.from_string("c")
i = Interval::Interval.from_string("M3")
p2 = p+ i
p2.to_short_name# => "e"
i.to_s# => "Major Third"
i2 = Interval::Interval.from_string("p5")
i2.to_s# => "Perfect Fifth"(p2 - i2).to_s# => "a"

Interval Quiz

interval was written primarily for learning intervals. interval-quiz is a gem that depends on interval that provides a command-line quiz. Here’s the output of an interval-quiz session:

$ interval-quiz
Here are the intervals:
unison p1 a1
second m2 M2 d2 a2
third m3 M3 d3 a3
fourth p4 d4 a4
fifth d5 p5 d5 a5
sixth m6 M6 d6 a6
seventh m7 M7 d7 a7
octave p8 d8
enter the intervals you want (or a blank line to quit):
M3
p5
["M3", "p5"]
1. above
2. below
3. both
do you want to be quizzed on intervals above, below, or both? 3
what is a major third below f# ? d
correct!
what is a major third above g# 1/1 (100%)? b#
correct!
what is a major third below b 2/2 (100%)? g
correct!
what is a perfect fifth below eb 3/3 (100%)? a
wrong. the answer is ab
what is a perfect fifth below c# 3/4 (75%)? d
wrong. the answer is f#

## Interval – a ruby library for musical interval arithmetic

## Interval

`interval`

is a tiny library that provides simple musical note pitch and interval arithmetic. It is intended to do one thing: given a pitch add (or subtract) an interval and give the resulting pitch.Observe:

## Interval Quiz

`interval`

was written primarily for learning intervals.`interval-quiz`

is a gem that depends on`interval`

that provides a command-line quiz. Here’s the output of an`interval-quiz`

session:## Installing

## Source

http://github.com/jashmenn/interval

http://github.com/jashmenn/interval-quiz

Share: