Class NotesCollection
In: app/models/notes_collection.rb
Parent: Object

NotesCollection represents a collection of notes. Using this collection, you can determine chord and scale/mode matches in specific or all keys. This class is currently under heavily development and will eventually be home to heavy logic involved in associating an arbitrary collection of notes with chords, given that some scales tone may be "omitable", etc.

Creating a NotesCollection object

Creating the collection of notes should be done by indexing the Notes class directly with a comma-separated string of notes.

Current Limitations

Will only do exact 100% match of notes given and notes in chords. No fuzzyness such as the ability to omit the root and other non-important tones. Does not yet find supersets or subsets.

Examples

Finding All Associated Chords

  NotesCollection['C, E, G, A'].chords.symbols
  # => "Amin7, Cmaj6"

Finding Associated Chords in Given Key

  NotesCollection['C, E, G, A'].in_key_of('A').chords.symbols
  # => "Amin7"

Methods

chords   new   to_xml  

Included Modules

Enumerable KeyContext

External Aliases

new -> []

Attributes

invalid_keys  [RW] 
keys  [RW] 

Public Class methods

[Source]

    # File app/models/notes_collection.rb, line 39
39:         def initialize(value = [])
40:                 @value_as_given = value
41:                 @keys = []
42:                 @invalid_keys = []
43:                 
44:                 value = value.split(/,| /).map(&:strip) if value.instance_of?(String)
45:                 value.each do |key_name|
46:                         key_object = Key[key_name]
47:                         
48:                         if key_object.nil?
49:                                 @invalid_keys << key_name
50:                         else
51:                                 @keys << key_object
52:                         end
53:                 end
54:         end

Public Instance methods

Chords associated with this collection of notes

[Source]

    # File app/models/notes_collection.rb, line 63
63:         def chords
64:                 if key
65:                         chords_in_key(key)
66:                 else
67:                         Key.primaries.map do |in_key|
68:                                 chords_in_key(in_key)
69:                         end.flatten
70:                 end.extend(ChordCollection)
71:         end

XML Representation

[Source]

    # File app/models/notes_collection.rb, line 74
74:         def to_xml
75:                 '<NotesCollection name="' + @value_as_given.to_s + '"></NotesCollection>'
76:         end

[Validate]