Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve getnotes defaults for type-0 midi files #114

Closed
ssfrr opened this issue Feb 18, 2019 · 2 comments
Closed

improve getnotes defaults for type-0 midi files #114

ssfrr opened this issue Feb 18, 2019 · 2 comments

Comments

@ssfrr
Copy link

ssfrr commented Feb 18, 2019

I was testing with the attached MIDI file, and ran into some issues that I think are related to the fact that it's a type-0 file. For instance, BPM(midi) throws an error, and getnotes requires that the track be specified as 1 (normally it sees to assume that the MIDI data starts on track 2, but type-0 files only have 1 track).

C Major.zip

@ssfrr ssfrr changed the title problems with type-0 file? problems with type-0 file Feb 18, 2019
@Datseris Datseris added help wanted bug Bug report, or fixes a bug (if Pull Request) question and removed bug Bug report, or fixes a bug (if Pull Request) help wanted labels Feb 19, 2019
@Datseris
Copy link
Member

I don't understand the BPM part. There doesn't seem to be a BPM information in your track, or the existing code fails to see it. This is not relevant with it being type 0 or not, because running this piece of loop:

for event in t.tracks[1].events
        if typeof(event) == MetaEvent
            if event.metatype == 0x51
                tttttt = deepcopy(event.data)
                break
            end
        end
    end

Doesn't find the meta event that corresponds to the BPM signature. On the other side there is nothing wrong with the getnotes function:

julia> getnotes(f, 1)
25 Notes with tpq=96
 Note C4  | vel = 100 | pos = 0, dur = 48
 Note E4  | vel = 100 | pos = 0, dur = 48
 Note G4  | vel = 100 | pos = 0, dur = 48
 Note D4  | vel = 100 | pos = 48, dur = 48
 Note F4  | vel = 100 | pos = 48, dur = 48
 Note A4  | vel = 100 | pos = 48, dur = 48
 Note E4  | vel = 100 | pos = 96, dur = 48
  ⋮
 Note B4  | vel = 100 | pos = 288, dur = 48
 Note D5  | vel = 100 | pos = 288, dur = 48
 Note F5  | vel = 100 | pos = 288, dur = 48
 Note A5  | vel = 100 | pos = 288, dur = 48
 Note C5  | vel = 100 | pos = 336, dur = 48
 Note E5  | vel = 100 | pos = 336, dur = 48
 Note G5  | vel = 100 | pos = 336, dur = 48

Yes by default it chooses track number 2, as this is the most probable track to have notes for typical midifiles, but noone forces you to go with it.

@Datseris
Copy link
Member

I guess we could improve the getnotes function to default to track 1 if the midi type is 0. So I'll put the tag "easy" here since it is a trivial fix.

@Datseris Datseris changed the title problems with type-0 file improve getnotes defaults for type-0 midi files Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants