• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    Ruby
  • Created over 16 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Jazz Model - A data model for Jazz theory and other cool stuff.

Jazz Model¶ ↑

Jazz Model is full ActiveRecord model of concepts in Jazz theory, establishing relationships between chords and scales, and much more. Aside from representing jazz theory relationships in the database, jazz model can do key conversions and other operations on these jazz “objects”. By default it uses an in-memory sqlite3 database, but it could be persisted elsewhere.

Defunct¶ ↑

NOTE: This project is no longer under active development. All work is now devoted to Jazzity, the public interface inspired by this project: www.jazzity.com. Sign up there if you’re interested in the potential for mathematical analysis of Jazz theory.

Architecture Overview¶ ↑

The core of Jazz Toolbox is a full Ruby object model representing concepts of Jazz theory, distilled to their most basic concepts and architected in a very abstract manner. The system is data-centric and all “rules” (for example, the tones in a C7 chord) in theory are self-contained in the database.

All chord/scale/mode/etc. definitions are stored as a mathematical system (sequences of numbers) which are then used to perform calculations. For example, putting some chord in a different key is a matter of adding a semitone delta and doing modulo 12.

While there are currently many chord calculators in existence, to my knowledge this project is the first one that attempts to fully represent the entirety of Jazz theory as a mathematical/computational system exposed through an elegant object model.

Note: the current database consists entirely of my own personal knowledge of Jazz theory. I haven’t yet scoured through the Jazz theory literature to formalize and expand the current database of chords, scales, and chord-scales. There’s still a lot of work to do and I have lots of ideas for how to expand this.

Core Features¶ ↑

  • Scale & Mode Enumeration

  • Handles Variety of Notations

  • ChordTone Enumeration

  • Traversing ScaleChord Relationships with Strength Metric

  • Full Understanding of Theoretic Tones (vs. only Pitches)

Installation¶ ↑

Simply include the gem in your Gemfile:

gem "jazz_model"

From here you can begin using the classes under JazzModel directly, but it won’t be much use until you load the definitions:

JazzModel::Base.load_definitions

Examples using Default Definitions¶ ↑

Everything is under the JazzModel namespace, so first do this if you want to use these classes directly:

include JazzModel

Getting a Chord object:¶ ↑

Chord['maj7']
Chord['Bbmaj7']  # <- With Key Context
Chord['Abmaj7#11']
...

Getting a Scale object:¶ ↑

Scale['Major']
Scale['Melodic Minor']
Scale['Diminished']
...

Getting a particular mode of a scale:¶ ↑

Scale['Major'].modes['Dorian']  # By Mode Name
Scale['Major'].modes[2]  # By Mode Index

# Or directly index the scale object (same as above):
Scale['Major']['Dorian']
Scale['Major'][2]

Enumerate notes of a Chord:¶ ↑

Chord['maj'].notes   # Defaults to C without specified key context
# => ['C', 'E', 'G']

Chord['Ebmaj7'].notes
# => ['Eb', 'G', 'Bb', 'D']

# Or specify key context with chained methods like this...
Chord['maj7'].in_key_of('Eb').notes

Chord['Bmaj7#11'].notes
# => ['B', 'D#', 'F#', 'A#', 'E#']
# Note E# - Correct theoretic value for this chord, not F

Chord['Falt'].notes 
Chord['F7b9#9'].notes
# => ['F', 'A', 'Eb', 'Gb', 'G#', 'C#']

Chord['Gbmaj7'].notes
# => ['Gb', 'Bb', 'Db', 'F']

# But...

Chord['F#maj7'].notes
# => ['F#', 'A#', 'C#', 'E#']

Enumerate notes of a Scale:¶ ↑

Scale['Major'].notes  # Defaults to C without specified key context
# => ['C', 'D', 'E', 'F', 'G', 'A', 'B']

Scale['Eb Major'].notes
# => ['Eb', 'F', 'G', 'Ab', 'Bb', 'C', 'D']

# Or specify key context with chained methods like this:
Scale['Major'].in_key_of('Eb').notes

Scale['Whole Tone'].notes
# => ['C', 'D', 'E', 'F#', 'G#', 'Bb']

Scale['Bebop'].notes
# => ['C', 'D', 'E', 'F', 'G', 'A', 'Bb', 'B']

Enumerate notes from a Scale Mode:¶ ↑

Scale['Major'].in_key_of('Eb').modes['Dorian'].notes
# => ['F', 'G', 'Ab', 'Bb', 'C', 'D', 'Eb']

Scale['Melodic Minor']['Lydian Dominant'].notes
# => ['F', 'G', 'A', 'B', 'C', 'D', 'Eb']

Enumerate scale modes associated with a chord:¶ ↑

Chord['min7'].modes.names  # .names == .map(&:name)
# => ['Dorian']
Chord['min7'].modes[0].scale.name
# => "Major"

Chord['Amin7'].modes.names
# => ['A Dorian']

Enumerate chords associated with a scale mode:¶ ↑

Scale['Major']['Dorian'].chords.symbols
# => ['min7', 'min6']

Scale['Major'][4].chords.symbols
# => ['maj7#11']

Ruby Example Problem:¶ ↑

Find all chords associated with the Major (Ionian) scale and print 
each on a new line with the chord tones.

Scale['Major'].chords.map {|c| c.name + ': ' + c.notes.join(', ')} * "\n"
# => Major 7: C, E, G, B
     Major 6: C, E, G, A
     Dominant 6/9: C, E, G, Bb, D, A

These examples should show that with the power of Ruby and the elegant nature of this API, extracting Jazz data from the system is a breeze (even fun!).

Definitions Available¶ ↑

The default definition is just named “default” and is loaded when you run JazzModel::Base.load_definitions without argument, though you can give a custom argument to this to load a different definition:

JazzModel::Base.load_definitions(:my_custom_set)

Currently there are two definitions available:

  • Keys - Creates the basic 12 keys. This definition should always be loaded so long as you are dealing with Western harmony.

  • Default - The default set of data for jazz models, including many scales and chords. Any other definitions will probably want to build upon this instead of start from scratch.

Creating Definitions¶ ↑

The gem has a distinction between classes such as Chord and the actual definitions such as “C Major Chord”. Definitions are simply packaged set of instructions for initializing the objects with data (which get put in the database). Since by default jazz model uses an in-memory sqlite3 database, definitions need to be loaded when your application loads.

To create a definition, simply do this:

JazzModel::Definition.define :my_definition => [:keys] do

end

Within the block you’ll want to create whatever data is necessary to comprise your definitions. For examples of definitions, see lib/jazz_model/definitions in the project. The argument to define acts like rake tasks - use the hash value to define which dependencies your definition has. In the above case defining “my_definition” will first ensure the “keys” definition is already defined.

Anticipated Future Features¶ ↑

  • Chord Progression Analysis

  • MIDI Integration

  • User Comments & Contributions (such as Chord-Scale recommendations)

  • Melodic Components & Licks

  • Voicings Associated with Chords

More Repositories

1

nilify_blanks

Provides a framework for saving incoming blank values as nil in the database in instances where you'd rather use DB NULL than simply a blank string.
Ruby
322
star
2

message_block

A replacement for error_messages_for that is much more powerful/flexible.
Ruby
160
star
3

validates_lengths_from_database

Introspects your database string field maximum lengths and automatically defines length validations.
Ruby
83
star
4

has_draft

Allows for your ActiveRecord models to have "drafts" which are stored in a separate duplicate table that can be edited without affecting the "live" copy.
Ruby
68
star
5

vexflow-json

A wrapper for the VexFlow staff engraving library to render staff notation from simple JSON instead complex API calls.
JavaScript
46
star
6

jazzity

The Jazz Knowledge Engine
Ruby
25
star
7

rspecify

Uses ruby_scribe to convert your Test::Unit (+ shoulda) tests into RSpecs
Ruby
14
star
8

cukigem

Trying to test your gems in the context of a test Rails application is hard. This gem makes it easy.
Ruby
13
star
9

ruby_transform

A series of useful Ruby AST transformations
Ruby
10
star
10

micro_sessions

The repository has been moved to
Ruby
10
star
11

chords-json

A JSON format for representing musical chord changes with related tools.
9
star
12

jquery-vexflow-json

A jquery library to encapsulate staff engraving via VexFlow. Relies on vexflow-json.
JavaScript
9
star
13

irealb_parser

Parses iReal B chord changes notation into the standard chords-json format.
Ruby
8
star
14

goplay

GoPlay! Game Application in Merb, DataMapper, and jQuery
Ruby
8
star
15

ruby_scribe

Generates nicely-formatted ruby source code given a ruby abstract syntax tree (from seattlerb's ruby_parser).
Ruby
8
star
16

has_meta_data

Allows for your ActiveRecord models to have meta data associated with them that don't require a separate model - primarily useful with STI classes to somewhat emulate Class Table Inheritance.
Ruby
6
star
17

rubify

A framework for AST translations from other languages to a Ruby AST. A foundation for true language conversion to Ruby.
Ruby
4
star
18

factory_girl_upgrader

Uses ruby_parser and ruby_scribe to dynamically convert factory_girl factories in the V1 DSL into the V2 DSL.
Ruby
4
star
19

coworking_nomads

Web application for facilitating ad-hoc coworking among independent workers at free venues around town.
Ruby
3
star
20

ben_hughes

Ben Hughes Personal Website
CSS
2
star
21

ups_shipping

A ruby library for interacting with the UPS Shipping API.
Ruby
2
star
22

magic_hangman

Hangman Project for Magic Night
Ruby
1
star
23

blue_passers

Website for BluePassers.com - Online community and leaderboard for JetBlue BluePass Holders
Ruby
1
star
24

ruby_pranks

Ruby is such a dynamic language, it can be dangerous if you're not careful...
1
star
25

where_in_the_world_is_ben

Simple app to show where I am, through Foursquare checkins
Ruby
1
star
26

jet_blue

Some screen scraping tools to automate the JetBlue AYCJ/BluePass booking engine.
Ruby
1
star
27

ruby_finance

Financial/Business calculations as a ruby library.
1
star
28

penguinoh

Photo album of Penguinoh Waddles
HTML
1
star
29

flight_leverage

Simple Middleman blog for Flight Leverage (Travel Hacking).
HTML
1
star
30

jetting_rubyist

Website for JettingRubyist.com - Nomadic Co-working & Pairing
JavaScript
1
star