Comments (3)
- In this line: midi.NoteOnEvent(tick=720, channel=0, data=[62, 126]), what do the list elements in the data field represent?
They are pitch and velocity. (cf. NoteEvent
source code)
Pitch uses the standard MIDI note numbers:
Velocity is a measure from 0-127 of how hard the note was struck. If your MIDI track was generated from software or recorded from an instrument without velocity control, these values might all be the same.
2. Why are there duplicate events? this event seems identical to this event
3. Why aren't the events sorted by tick?
(There's some previous discussion here.) By default tick values are relative, so they measure how many ticks have passed since the event before it. When you have things happening at the exact same time (like playing notes in a chord, or one note ending precisely as the next one begins) it will be listed as a series of events with tick=0
.
Your events aren't duplicates, it's just two instances of a particular pitch occurring at the same time as something else.
As an alternative to the relative mode, you can convert a Pattern (or Track) to absolute tick values using Pattern.make_ticks_abs()
. Since you're gonna be using a formula to compare outside data with MIDI ticks, that will probably be a lot easier.
4. [...] Where should I look for the Tempo?
Tempo isn't set directly on the Pattern/Track, it's set through the SetTempoEvent
. In your example they are all set in their own track at the top, which is fairly common IIRC.
SetTempoEvent
data looks pretty goofy in the dumpout because it uses 3 bytes to store one value. So the first event has data=[12, 11, 226]
, which sets the tempo to (12 << 16) + (11 << 8) + 226 = 789474
microseconds per quarter note. Then the song stays at that speed for quite some time, until 49200 ticks later when it starts to slow down (presumably for the big finish). Every quarter note (240 ticks) from there on out it slows, until reaching a final speed of (24 << 16) + (23 << 8) + 195 = 1578947
μspqn, which is about half the original speed.
You don't have to deal with the weird unit of measurement, by the way. The library includes a converter to/from beats per minute. Just use TempoChangeEvent.bpm
.
from python-midi.
I should add that the meaning of the data
field is always going to depend on what kind of event it is. Them being pitch
and velocity
is exclusive to Note events.
It's really just a simple way to handle how MIDI files are loaded and saved, while still allowing properties of events to be modified easily.
from python-midi.
you can convert a Pattern (or Track) to absolute tick values using Pattern.make_ticks_abs(). Since you're gonna be using a formula to compare outside data with MIDI ticks, that will probably be a lot easier.
Great tip! Yes I'll definitely need this.
Everything makes a lot more sense now. Thanks for taking the time to write this up!
from python-midi.
Related Issues (20)
- Marker
- Meta
- Handling Marker Events
- Appending an event with a tick less than the last one in absolute mode results in invalid tick
- package installation issue HOT 7
- MIDI Events
- make_ticks_rel is broken
- Python2 Errors HOT 1
- The 'midi==0.2.3' distribution was not found and is required by the application
- SetTempoEvent to 120 bpm doesn't seem to align with my metronome or in my music software
- Does python-midi still work?
- The loss of generator is always negative. HOT 1
- Can't install the package in anaconda HOT 4
- Is this repo still being maintained? HOT 1
- I made it available for Windows and Python 3 HOT 11
- pip3 package doesn't work HOT 2
- Installation issue HOT 7
- Do you have a python version HOT 1
- where can i find the ref doc
- Ubuntu Studio 23.10 - Mary.mid example fails HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-midi.