Skip to content

Commit

Permalink
big bugfix in BPM
Browse files Browse the repository at this point in the history
Also super important: I now use deepcopy. Without it there was a really big mistake and data of the loaded midi file were changed.
  • Loading branch information
Datseris committed Feb 19, 2018
1 parent 9f997f8 commit 02a2bee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/midifile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,20 @@ function BPM(t::MIDI.MIDIFile)
if typeof(tlist[i]) == MIDI.MetaEvent
y = tlist[i]
if y.metatype == 0x51
tttttt = y.data
tttttt = deepcopy(y.data)
break
end
end
end
# Ensure that tttttt is with correct form (first entry should be 0x00)
if tttttt[1] != 0x00
unshift!(tttttt, 0x00)
else
# Handle correctly "incorrect" cases where 0x00 has entered more than once
tttttt = tttttt[findin(tttttt, 0x00)[end]:end]
end

# Get the microsecond number from tttttt
unshift!(tttttt , 0x00)
u = ntoh(reinterpret(UInt32, tttttt)[1])
μs = Int64(u)
# BPM:
Expand Down

0 comments on commit 02a2bee

Please sign in to comment.