vishnubob / python-midi

Python MIDI library
MIT License
1.49k stars 370 forks source link

Get relative tick respecting the tempo? #164

Open Enovale opened 5 years ago

Enovale commented 5 years ago

Maybe this has been asked before, but when I use the ticks of NoteOnEvents and NoteOffEvents, when reesembled, the notes are much longer than the original midi and there is more space in between. I'd rather not convert to absolute ticks if possible, i just want relative ticks that work with tempo

semininja commented 5 years ago

Sounds like your resolution (ticks per beat) is changing when you don't intend it to. Are you creating a new sequence, moving notes from one sequence to another, or just modifying one sequence in place?

Enovale commented 5 years ago

I'm putting the notes into a completely tempo-less environment, outside of MIDI

I'm using the ticks like they're milliseconds, basically (which i'm now realizing is not correct)

semininja commented 5 years ago

You might want to inspect the README a bit more closely; there's some good info there.

Enovale commented 5 years ago

I understand how tempo and ticks work, I was just being absent minded and forgot while coding. Even so, I still don't know how to do what im trying to do

semininja commented 5 years ago

What is it that you're trying to do? I might be able to offer some more specific assistance.

Enovale commented 5 years ago

Basically, i'm using the ticks on the NoteOffEvents and NoteOnEvents to make a list of strings accordingly, that im using as Arduino C code. Formatted like this:

beep(NoteOnData1, TheNextEventInMidiTick); delay(NoteOnTick); beep(NextNoteOnData1); etc etc Like this: https://gist.github.com/nicksort/4736535

I hope that makes sense. the places where ticks are used should be in miliseconds, not the random nature of ticks per beat, which is the problem

EDIT: Weird format issues

Enovale commented 5 years ago

Any ideas @semininja ?

Enovale commented 5 years ago

I think basically, I just need a way to convert ticks to miliseconds.

semininja commented 5 years ago

Divide your tempo value (given in microseconds per beat) by your resolution (ticks per beat) to get microseconds per tick.

Enovale commented 5 years ago

alright. I think I figured it out and fixed my problem...

Well now i'm curious if theres a way to convert all chords (or multiple NoteOnEvents without a NoteOff in between) to single NoteOns with NoteOffs, but maybe thats a question for a new issue