Permalink
Browse files

retab, looking at the files outside an editor was a nightmare

  • Loading branch information...
bleything committed Apr 3, 2009
1 parent 0c344fa commit 16c9e7791e4a53a81109f2b5d3bac59351873c90
@@ -27,9 +27,9 @@
C5, Cs5, D5, Eb5, E5, F5, Fs5, G5, Gs5, A5, Bb5, B5 ]
scale.each do |note|
- midi.play note
+ midi.play note
end
scale.reverse.each do |note|
- midi.play note
+ midi.play note
end
View
@@ -28,15 +28,15 @@
@tempo = 120.0
if input = ARGV[0]
- begin
- @tempo = Float( input )
- rescue ArgumentError => e
- $stderr.puts "'#{input}' is not a valid tempo.\n"
- $stderr.puts "Please specify the tempo in beats per minute " +
- "(bpm). Fractional values are allowed!"
+ begin
+ @tempo = Float( input )
+ rescue ArgumentError => e
+ $stderr.puts "'#{input}' is not a valid tempo.\n"
+ $stderr.puts "Please specify the tempo in beats per minute " +
+ "(bpm). Fractional values are allowed!"
- exit 1
- end
+ exit 1
+ end
end
require 'rubygems'
@@ -66,10 +66,10 @@
@timer = MIDIator::Timer.new( @interval / 10 )
def register_next_bang( time )
- @timer.at( time ) do |yielded_time|
- register_next_bang yielded_time + @interval
- @midi.play MiddleC
- end
+ @timer.at( time ) do |yielded_time|
+ register_next_bang yielded_time + @interval
+ @midi.play MiddleC
+ end
end
puts "Starting metronome running at #{@tempo} bpm."
View
@@ -26,9 +26,9 @@
C5, Cs5, D5, Eb5, E5, F5, Fs5, G5, Gs5, A5, Bb5, B5 ]
scale.each do |note|
- midi.play note
+ midi.play note
end
scale.reverse.each do |note|
- midi.play note
+ midi.play note
end
View
@@ -14,22 +14,22 @@
#
module MIDIator
- VERSION = "0.3.0"
+ VERSION = "0.3.0"
end
#####################################################################
-### E X T E R N A L D E P E N D E N C I E S
+### E X T E R N A L D E P E N D E N C I E S
#####################################################################
require 'rubygems'
require 'platform'
#####################################################################
-### C O R E L I B R A R Y E X T E N S I O N S
+### C O R E L I B R A R Y E X T E N S I O N S
#####################################################################
require 'string_extensions'
#####################################################################
-### M I D I A T O R C O R E
+### M I D I A T O R C O R E
#####################################################################
require 'midiator/driver'
require 'midiator/driver_registry'
View
@@ -22,127 +22,127 @@
class MIDIator::Driver
- ##########################################################################
- ### M I D I C O M M A N D C O N S T A N T S
- ##########################################################################
+ ##########################################################################
+ ### M I D I C O M M A N D C O N S T A N T S
+ ##########################################################################
- # Note on
- ON = 0x90
+ # Note on
+ ON = 0x90
- # Note off
- OFF = 0x80
+ # Note off
+ OFF = 0x80
- # Polyphonic aftertouch
- PA = 0xa0
+ # Polyphonic aftertouch
+ PA = 0xa0
- # Control change
- CC = 0xb0
+ # Control change
+ CC = 0xb0
- # Program change
- PC = 0xc0
+ # Program change
+ PC = 0xc0
- # Channel aftertouch
- CA = 0xd0
+ # Channel aftertouch
+ CA = 0xd0
- # Pitch bend
- PB = 0xe0
+ # Pitch bend
+ PB = 0xe0
- ##########################################################################
- ### M A G I C H O O K S
- ##########################################################################
+ ##########################################################################
+ ### M A G I C H O O K S
+ ##########################################################################
- ### Auto-registers subclasses of MIDIator::Driver with the driver registry.
- def self::inherited( driver_class )
- driver_name = driver_class.to_s.underscore
- MIDIator::DriverRegistry.instance.register( driver_name, driver_class )
- end
+ ### Auto-registers subclasses of MIDIator::Driver with the driver registry.
+ def self::inherited( driver_class )
+ driver_name = driver_class.to_s.underscore
+ MIDIator::DriverRegistry.instance.register( driver_name, driver_class )
+ end
- ##########################################################################
- ### I N T E R F A C E A P I
- ##########################################################################
- # These methods are the same across all drivers and are the interface that
- # MIDIator::Interface interacts with.
- ##########################################################################
+ ##########################################################################
+ ### I N T E R F A C E A P I
+ ##########################################################################
+ # These methods are the same across all drivers and are the interface that
+ # MIDIator::Interface interacts with.
+ ##########################################################################
- ### Do any pre-open setup necessary. Often will not be overridden.
- def initialize
- open
- end
+ ### Do any pre-open setup necessary. Often will not be overridden.
+ def initialize
+ open
+ end
- ### Shortcut to send a note_on message.
- def note_on( note, channel, velocity )
- message( ON | channel, note, velocity )
- end
+ ### Shortcut to send a note_on message.
+ def note_on( note, channel, velocity )
+ message( ON | channel, note, velocity )
+ end
- ### Shortcut to send a note_off message.
- def note_off( note, channel, velocity = 0 )
- message( OFF | channel, note, velocity )
- end
+ ### Shortcut to send a note_off message.
+ def note_off( note, channel, velocity = 0 )
+ message( OFF | channel, note, velocity )
+ end
- ### Shortcut to send a polyphonic aftertouch message for an individual note.
- def aftertouch( note, channel, pressure )
- message( PA | channel, note, pressure )
- end
+ ### Shortcut to send a polyphonic aftertouch message for an individual note.
+ def aftertouch( note, channel, pressure )
+ message( PA | channel, note, pressure )
+ end
- ### Shortcut to send a control change.
- def control_change( number, channel, value )
- message( CC | channel, number, value )
- end
+ ### Shortcut to send a control change.
+ def control_change( number, channel, value )
+ message( CC | channel, number, value )
+ end
- ### Shortcut to send a program_change message.
- def program_change( channel, program )
- message( PC | channel, program )
- end
+ ### Shortcut to send a program_change message.
+ def program_change( channel, program )
+ message( PC | channel, program )
+ end
- ### Shortcut to send a channel aftertouch message.
- def channel_aftertouch( channel, pressure )
- message( CA | channel, pressure )
- end
+ ### Shortcut to send a channel aftertouch message.
+ def channel_aftertouch( channel, pressure )
+ message( CA | channel, pressure )
+ end
- ### Shortcut to send a pitch bend message.
- def pitch_bend( channel, value )
- message( PB | channel, value )
- end
- alias bend pitch_bend
+ ### Shortcut to send a pitch bend message.
+ def pitch_bend( channel, value )
+ message( PB | channel, value )
+ end
+ alias bend pitch_bend
- ##########################################################################
- ### D R I V E R A P I
- ##########################################################################
- # subclasses must implement these methods.
- ##########################################################################
- protected
- ##########################################################################
+ ##########################################################################
+ ### D R I V E R A P I
+ ##########################################################################
+ # subclasses must implement these methods.
+ ##########################################################################
+ protected
+ ##########################################################################
- ### Open the channel to the MIDI service.
- def open
- raise NotImplementedError, "You must implement #open in your driver."
- end
+ ### Open the channel to the MIDI service.
+ def open
+ raise NotImplementedError, "You must implement #open in your driver."
+ end
- ### Close the channel to the MIDI service.
- def close
- raise NotImplementedError, "You must implement #close in your driver."
- end
+ ### Close the channel to the MIDI service.
+ def close
+ raise NotImplementedError, "You must implement #close in your driver."
+ end
- ### Send MIDI message to the MIDI service.
- def message( *args )
- raise NotImplementedError, "You must implement #message in your driver."
- end
+ ### Send MIDI message to the MIDI service.
+ def message( *args )
+ raise NotImplementedError, "You must implement #message in your driver."
+ end
- ### The only non-required method. Override this to give the user instructions
- ### if necessary.
- def instruct_user!
- end
+ ### The only non-required method. Override this to give the user instructions
+ ### if necessary.
+ def instruct_user!
+ end
end
@@ -17,37 +17,37 @@
require 'midiator'
class MIDIator::DriverRegistry
- include Singleton
+ include Singleton
- ### Stores the given +klass+ in the <tt>@drivers</tt> hash, keyed by +name+.
- ### Typically called via MIDIator::Driver's +inherited+ hook.
- def register_driver( name, klass )
- @drivers ||= {}
+ ### Stores the given +klass+ in the <tt>@drivers</tt> hash, keyed by +name+.
+ ### Typically called via MIDIator::Driver's +inherited+ hook.
+ def register_driver( name, klass )
+ @drivers ||= {}
- raise ArgumentError, "Attempted to register something that is not a MIDIator::Driver" unless
- klass < MIDIator::Driver
+ raise ArgumentError, "Attempted to register something that is not a MIDIator::Driver" unless
+ klass < MIDIator::Driver
- @drivers.each do |existing_name, existing_klass|
- raise ArgumentError, "Already registered #{existing_klass.to_s} as '#{existing_name}'." if
- existing_klass == klass
- end
+ @drivers.each do |existing_name, existing_klass|
+ raise ArgumentError, "Already registered #{existing_klass.to_s} as '#{existing_name}'." if
+ existing_klass == klass
+ end
- @drivers[ name ] = klass
- end
- alias register register_driver
- alias << register_driver
+ @drivers[ name ] = klass
+ end
+ alias register register_driver
+ alias << register_driver
- ### Returns the number of drivers currently registered.
- def size
- return @drivers.size
- end
+ ### Returns the number of drivers currently registered.
+ def size
+ return @drivers.size
+ end
- ### Included to make the registry quack like a hash. Delegates to the
- ### <tt>@drivers</tt> hash.
- def []( name )
- return @drivers[ name ]
- end
+ ### Included to make the registry quack like a hash. Delegates to the
+ ### <tt>@drivers</tt> hash.
+ def []( name )
+ return @drivers[ name ]
+ end
end
Oops, something went wrong.

0 comments on commit 16c9e77

Please sign in to comment.