Permalink
Browse files

go through major chords

  • Loading branch information...
1 parent fad81bd commit 4c9c4a33c67ecab95d57311dc7823e2c4640ccbd @ryanb committed Nov 27, 2010
Showing with 28 additions and 1 deletion.
  1. +1 −0 MIDIUtility.m
  2. +4 −0 Maestro.xcodeproj/project.pbxproj
  3. +18 −0 chord.rb
  4. +5 −1 game.rb
View
@@ -107,6 +107,7 @@ + (void)setup
MIDIPortRef inPort;
MIDIClientRef client;
+ // Set up graph for midi playback
createAUGraph(&graph, &synthUnit);
AUGraphInitialize(graph);
MusicDeviceMIDIEvent(synthUnit, kMidiMessage_ControlChange << 4, kMidiMessage_BankMSBControl, 0, 0/*sample offset*/);
@@ -57,6 +57,7 @@
DC52869B1183ED3300A4D471 /* main_view.rb in Resources */ = {isa = PBXBuildFile; fileRef = DC52869A1183ED3300A4D471 /* main_view.rb */; };
DC5820E712A18B6100FE9BB4 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC5820E612A18B6100FE9BB4 /* AudioToolbox.framework */; };
DC5820E912A18B6100FE9BB4 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC5820E812A18B6100FE9BB4 /* AudioUnit.framework */; };
+ DC58213412A1993000FE9BB4 /* chord.rb in Resources */ = {isa = PBXBuildFile; fileRef = DC58213312A1993000FE9BB4 /* chord.rb */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -94,6 +95,7 @@
DC52869A1183ED3300A4D471 /* main_view.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = main_view.rb; sourceTree = "<group>"; };
DC5820E612A18B6100FE9BB4 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
DC5820E812A18B6100FE9BB4 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
+ DC58213312A1993000FE9BB4 /* chord.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = chord.rb; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -119,6 +121,7 @@
DC52869A1183ED3300A4D471 /* main_view.rb */,
DC3DEDB31232C37000B1A3D0 /* game.rb */,
DC3DEDDC1232E63B00B1A3D0 /* note.rb */,
+ DC58213312A1993000FE9BB4 /* chord.rb */,
);
name = Classes;
sourceTree = "<group>";
@@ -267,6 +270,7 @@
DC52869B1183ED3300A4D471 /* main_view.rb in Resources */,
DC3DEDB41232C37000B1A3D0 /* game.rb in Resources */,
DC3DEDDD1232E63B00B1A3D0 /* note.rb in Resources */,
+ DC58213412A1993000FE9BB4 /* chord.rb in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -0,0 +1,18 @@
+class Chord
+ attr_reader :root_note
+
+ def initialize(root_note, *intervals)
+ @root_note = root_note
+ @intervals = intervals
+ end
+
+ def notes
+ [@root_note, *interval_notes]
+ end
+
+ def interval_notes
+ @intervals.map do |interval|
+ Note.new(@root_note.value + interval)
+ end
+ end
+end
View
@@ -2,11 +2,15 @@ class Game
attr_reader :target_note
def initialize
+ @notes = []
new_target
end
def new_target
- @target_note = Note.random
+ if @notes.empty?
+ @notes = Chord.new(Note.random, 4, 7).notes
+ end
+ @target_note = @notes.shift
end
def key_down(key)

0 comments on commit 4c9c4a3

Please sign in to comment.