Skip to content

Commit

Permalink
Fixed a bug in ajm.midi2coll. Pulses per quartner note is now determi…
Browse files Browse the repository at this point in the history
…ned from the midi file, rather than assuming 480.
  • Loading branch information
adamjmurray committed Jun 7, 2011
1 parent f70228d commit 2a002a6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ajm/ruby/ajm_midi2coll.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'midilib/sequence'

VALID_BEAT_UNITS = [1,2,4,8,16]
TICKS_PER_QUARTER_NOTE = 480

inlet_assist 'read/timesig/quantize'
outlet_assist 'note data in coll format', 'track index', 'number of tracks'
Expand Down Expand Up @@ -73,9 +72,8 @@ def read(midi_file)
class Midi2Coll

def initialize(midi_file, beats_per_bar=4, beat_unit=4, quantize_in_ticks=nil, cc_filter=false)
@midi_file = midi_file # TODO validate (meh, currently this is handled by the ajm.cosy abstraction)
@midi_file = midi_file # TODO validate
@track_tick_maps = []
@ticks_per_beat = (4.0/beat_unit * TICKS_PER_QUARTER_NOTE).to_i
@beats_per_bar = beats_per_bar.to_i
@quantize = quantize_in_ticks
@cc_filter = cc_filter
Expand All @@ -85,7 +83,8 @@ def initialize(midi_file, beats_per_bar=4, beat_unit=4, quantize_in_ticks=nil, c
File.open(@midi_file, 'rb') do |file|
@sequence.read(file)
end

@ticks_per_beat = @sequence.ppqn.to_i

@sequence.tracks.each_with_index do |track,index|
@track_tick_maps[index] = @tick_map = {}
@pitch_map = {}
Expand Down

0 comments on commit 2a002a6

Please sign in to comment.