spotify / basic-pitch-ts

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection.
https://basicpitch.io
Apache License 2.0
212 stars 15 forks source link

Pitch range units? #17

Open nick-thompson opened 11 months ago

nick-thompson commented 11 months ago

In what units are the values given in the pitchBend array on a note event?

In my experiments, I'm seeing values like 0, -1, 1, 2, 4, and 5. I see from the other basic pitch repo an issue that seems to suggest these values are semitones, but numbers like 4 and 5 make that seem odd. Further, I'm not seeing any non-integer values, meaning that if we're in semitones, the resolution of this library doesn't consider cents, which also seems odd.

Hoping for some clarification, thank you!

rabitt commented 10 months ago

Hey @nick-thompson !

We're following the General MIDI protocol for pitch bend values. The values will be between -8192 and 8191, representing a semitone range of +/- 2 semitones (i.e. you can divide the pitch bend value by 8192 to get the equivalent shift in semitones).

paulrosen commented 6 months ago

I'm not understanding this. If a semitone is 4096, then a quarter tone is 2048, right? I'm seeing numbers like "3" when it is approximately a quarter tone. For instance, this particular note in my recording bent from about a quarter tone to almost in tune and the bend array contained 3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1. And I've seen some wildly out of tune recordings and I generally don't see a number larger than 3.