basic-pitch-ts icon indicating copy to clipboard operation
basic-pitch-ts copied to clipboard

Example code for integrate with React

Open neviaumi opened this issue 3 years ago • 7 comments

As a caption

I think it would better to have some show case / references implementation about how to use this module .

for example, if would be great if the official one can be open sourced

neviaumi avatar Aug 20 '22 22:08 neviaumi

I agree that an example for how to use it in a browser would be very helpful, especially one that works real-time!

I wonder if handling incoming audio in separate chunks would work fine or if there has to be some overlap?

fheyen avatar Sep 07 '22 14:09 fheyen

Hi @davidNHK and @fheyen. We can't currently open source basicpitch.io as it contains some Spotify-internal React components that are not open sourced yet. The website largely uses a similar structure to what exists in the README's usage section where a BasicPitch object is instantiated, data is prepared and then the data is evaluated. Once you get the midi output (the last bit of the usage example in the README), you can take that output and write it to a midi file or put it into your web-based synth of choice.

@fheyen unfortunately, even in the website, Basic Pitch is designed with a final output step that uses the inference run of over the entire file. We believe it may be possible to sacrifice quality and run that step on chunks at a time, but haven't had time to prioritize testing the approach. Thankfully, depending on machine, Basic Pitch is pretty fast (at least it can process a minute of audio in 1/3 of a minute on most machines). There's been similar issues posted over in the Python Basic Pitch repo so you're not alone in the idea.

If either of you want to contribute better examples or even take a stab at chunk-based processing we'll appreciate it :)

drubinstein avatar Sep 07 '22 15:09 drubinstein

Thanks @drubinstein for the quick reply, in the meantime I was able to get basic-pitch to run in ObservableHQ: https://observablehq.com/@fheyen/hello-spotify-basic-pitch-ts Feel free to link to this notebook in your readme.

fheyen avatar Sep 07 '22 15:09 fheyen

thanks @fheyen really found this useful in applying this typescript implementation!

mike3osei avatar Sep 26 '22 02:09 mike3osei

Hi, has anyone followed up with this cool idea? Short chunks converted in real-time, even if the delay was pretty long would be fun as a voice to MIDI controller. So not using a file but a mic with a WebAudio buffer.

westonsoftware avatar Jan 26 '24 22:01 westonsoftware

I wrote an online demo shows how to get json and midi format data from basic pitch https://codesandbox.io/p/sandbox/modest-benji-k2nfg5?file=%2Fsrc%2Findex.ts

ttys026 avatar Mar 28 '24 07:03 ttys026

I wrote an online demo shows how to get json and midi format data from basic pitch https://codesandbox.io/p/sandbox/modest-benji-k2nfg5?file=%2Fsrc%2Findex.ts

@ttys026 Thanks for this ... your midi-canvas looks nice too.

westonsoftware avatar Mar 28 '24 18:03 westonsoftware