diff --git a/examples/chopin.rb b/examples/chopin.rb index 9197803..90c637b 100644 --- a/examples/chopin.rb +++ b/examples/chopin.rb @@ -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') diff --git a/lib/music/smf_writer.rb b/lib/music/smf_writer.rb index 8140307..04930b2 100644 --- a/lib/music/smf_writer.rb +++ b/lib/music/smf_writer.rb @@ -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 = {}) @@ -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