Comments (3)
Hello @Phibonacci, I appreciate your feedback!
Looking back, I realize this was a significant oversight on my part. I probably didn't encounter songs with such high tempos before, which led me to overlook this aspect.
Initially, when I wrote this, it wasn't intended to be universally applicable; rather, it was tailored to a specific project I was working on at that time, which had its own set of constraints, such as rounding BPM tempos to whole numbers being acceptable.
In hindsight, opting to use bytes on the model to conserve memory seems unnecessary, especially considering the small size of these files.
I'll make some time to review and update the code to fix these issues!
from midi-parser.
How to get the BPM of the track? I'm a bit confused, each note is returning a different value for the tempo or BeatsMinute
from midi-parser.
You should have a look at the MIDI protocol first to understand how it works.
Only the meta event packets of type MetaEventType.Tempo
are setting the tempo. In this library it is directly converted into BPM from PPQ (Pulses per quarter note) following this formula: 60000 / (BPM * PPQ)
But there is a bug where a BPM > 256 will result in an overflow.
If you want to get the original MIDI tempo expressed in PPQ instead you should have a look at my modification.
Whatever you decide you should at least change the types of data1 and data2 from bytes to int as I did to avoid an overflow for high tempos.
from midi-parser.
Related Issues (5)
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 midi-parser.