twitchax / kord

A music theory binary and library for Rust / JS.
MIT License
209 stars 10 forks source link

Feature: guess from audio file #2

Closed dscottboggs closed 1 year ago

dscottboggs commented 1 year ago

All the pieces are in place but this doesn't yet work. See the test, I created a simple audio file of a piano Am@4 and the notes that are guessed are D♯3, C3, and G3. I'm not too familiar with the math behind this whole process, I'm wondering if I've selected the wrong sample rate, or I'm doing the transcoding wrong somehow?

Any thoughts?

twitchax commented 1 year ago

All the pieces are in place but this doesn't yet work. See the test, I created a simple audio file of a piano Am@4 and the notes that are guessed are D♯3, C3, and G3. I'm not too familiar with the math behind this whole process, I'm wondering if I've selected the wrong sample rate, or I'm doing the transcoding wrong somehow?

Any thoughts?

Good question. I can take a look at the mp3. The sampling rate should not matter.

twitchax commented 1 year ago

Are you sure that the sample rate of your file is 44.1 kHz?

dscottboggs commented 1 year ago

I wasn't trying to assert that the sample rate of the input file is 44.1kHz, I was trying to convert any input to be 44.1kHz, so that we can calculate the length.

Based on your review, I think parsing the time at the CLI and then reconstructing the string before passing it to ffmpeg, which would negate the need to calculate the length from the count of samples received. I too suspected the sample rate being wrong may be what's causing the guesses to be wrong, so lets see if that fixes the problem before giving it too much more thought haha.

edit: file(1) says the mp3 file is 44.1kHz, but like I said, that shouldn't have affected the output from the transcoding.

dscottboggs commented 1 year ago

The consumer of the library can choose to use an actual logger to emit the logs to console / etc.

well, in this case we have both the library and the consumer. I was asking what you would prefer for the latter.

dscottboggs commented 1 year ago

Closing in favor of #3