GithubHelp home page GithubHelp logo

Comments (3)

davidluzgouveia avatar davidluzgouveia commented on August 30, 2024 1

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.

cauto84 avatar cauto84 commented on August 30, 2024

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.

Phibonacci avatar Phibonacci commented on August 30, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.