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

Index instrument note ons and offs by channel rather than by channel program #84

Merged
merged 2 commits into from
Sep 1, 2016

Conversation

douglaseck
Copy link
Contributor

I'm not 100% convinced this works. But it seems to work. Please give it a look.

@douglaseck
Copy link
Contributor Author

fixes #84
Running the test code in the issue now yields:
[Instrument(program=0, is_drum=False, name=""), Instrument(program=0, is_drum=False, name="")]
[Note(start=0.022727, end=0.045455, pitch=43, velocity=20)]

I'm still not 100% sure this is a legit fix, but it makes sense to me.

@craffel
Copy link
Owner

craffel commented Sep 1, 2016

This seems like the right thing to me. current_instrument is used to keep track of the most recent program change seen on each channel in a given track. This is useful for determining which Instrument to associate with each completed note. last_note_on, on the other hand, should be used for determining notes which appeared on a given track/channel/pitch prior to seeing a note-off. So, we still need both, but it makes sense (after 0ca39fd) to use event.channel as the key rather than current_instrument[event.channel]. I think this change was basically missing from 0ca39fd.

Of course, we need tests #32 for stuff like this.

@craffel craffel merged commit 60b1503 into craffel:master Sep 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants