Class: Burn::Fuel::Rom::Music
- Defined in:
- lib/burn/fuel/rom/music.rb
Instance Method Summary collapse
- #channel(instrument, &block) ⇒ Object
-
#initialize(resource_name, context) ⇒ Music
constructor
A new instance of Music.
- #tempo(speed) ⇒ Object
Methods inherited from DslBase
Methods included from Debug
Constructor Details
#initialize(resource_name, context) ⇒ Music
Returns a new instance of Music.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/burn/fuel/rom/music.rb', line 5 def initialize(resource_name, context) super(resource_name, context) @default_tempo = :allegro if resource_name.nil? then raise Exception.new "Resource name for Music class must be provided." else @resource_name = resource_name end @context.instance_exec resource_name, &lambda{|resource_name| @resources["#{resource_name}"] = Array.new } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Burn::Fuel::DslBase
Instance Method Details
#channel(instrument, &block) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/burn/fuel/rom/music.rb', line 22 def channel(instrument, &block) @context.instance_exec(@resource_name,@default_tempo) do |resource_name, default_tempo| stream = ChannelStream.new(@resources["#{resource_name}"].count, instrument, default_tempo) stream.load(&block) @resources["#{resource_name}"] << stream.generate #@resources["#{resource_name}"] << " .byte $43,$1d,$80,$1f,$80,$21,$82,$1d,$80,$1d,$80,$1f,$92" end end |
#tempo(speed) ⇒ Object
31 32 33 |
# File 'lib/burn/fuel/rom/music.rb', line 31 def tempo(speed) @default_tempo = speed end |