danigb / soundfont-player

Quick soundfont loader and player for browser
MIT License
453 stars 60 forks source link

Notes are always 10-20 cents sharp #100

Open music-game opened 2 years ago

music-game commented 2 years ago

Love the library. My only issue is that whenever I play any instrument sound, it always ends up being about 10-20 cents sharp when I measure the pitch with a pitch analyzer app. The analyzer is perfectly in tune when I play the same note on an electric keyboard.

In order to compensate, I've been having to call the play function with the note number minus 0.15.

Here is the code I am using that is resulting in the slightly sharp sounds. I can just run this from the browser console on a page where I've included the soundfont-player.js file, and I get the too-sharp notes. Am I missing anything? Thanks!

ac = new AudioContext();
sfPiano = await Soundfont.instrument(ac, "acoustic_grand_piano");
sfPiano.play("C4");