Skip to content

Commit

Permalink
Fix broken tempo control for SMFWriter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Voorhis committed Nov 2, 2008
1 parent 080fbfa commit 3602ccb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/chopin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def score
final.transpose(12)
end

SMFWriter.new(:tempo => 80).
SMFWriter.new(:tempo => 40).
track(score, :name => 'Op. 20, No. 2').
save('chopin-op28-no20')

5 changes: 2 additions & 3 deletions lib/music/smf_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class SMFWriter
def initialize(options = {})
@time = MidiTime.new(options.fetch(:resolution, 480))
@seq = Sequence.new(1, @time.resolution)
@tempo = SetTempo.new(1, bpm_to_qn_per_usec(
options.fetch(:tempo, 2_000_000)))
@tempo = SetTempo.new(1, bpm_to_qn_per_usec(options[:tempo]))
end

def track(arrangement_or_timeline, options = {})
Expand Down Expand Up @@ -49,7 +48,7 @@ def gen_seq_name
end

def bpm_to_qn_per_usec(bpm)
((bpm/60.0) * 1_000_000).to_i
(60_000_000.0 / bpm).to_i
end
end
end

0 comments on commit 3602ccb

Please sign in to comment.