R2D2 Pitch Detection project

I’ve just uploaded an attempt at extracting pitch from human voice to GitHub. It’s a Processing sketch that uses the following classes:

PitchProject.pde – main sketch file.
AudioSource.pde – gets audio from wav files or microphone.
ToneGenerator.pde – creates an output tone with a triangle wave.
PitchDetectorAutocorrelation.pde – an audio listener that uses Autocorrelation to extract pitch from captured sound.
PitchDetectorHPS – an audio listener that uses Harmonic Product Spectrum to extract pitch from captured sound (not working yet).

Right now it’s prepared to open wav files with a file chooser and apply Autocorrelation to extract pitch. When executing the sketch, you should see some bars on screen that represent the pitch, and an output tone that corresponds to the one found in the audio. Try it!
However, while it works quite nicely, I am not sure if I’m doing things right (this is my first Processing project!). Are minim buffers being used properly? Is the Audio Listener correctly implemented? Shouldn’t all this be a little bit smoother? (audio experiments small hiccups from time to time…) Opinions, advices and suggestions are welcomed!

3 thoughts on “R2D2 Pitch Detection project

  1. Hi, I’ve tested your program (on Ubuntu) with a microphone and I found 3 things:
    * I had to change the size(…) from OPENGL to P3D cause I saw a corrupted graphic
    * the Pitch Detector works quite well but it needs to be faster in order to be “usable”
    * I think it’s needed a parameter to set a threshold on the audio input to cut off some noise when you acquire audio from a microphone… something like:
    if (audio_level<threshold) do_nothing(); //just skip to the next cycle
    else {
    //pitch things 🙂
    }

    Thank you for your work!

    Bye,
    Nicola

    1. Thank you Nicola!

      * Misteriously, in MacOS, Processing’s OPENGL doesn’t work either and P3D must be used too. I don’t know why!
      * Is it SO slow? I’ve been optimizing the code a little bit, I have to update the project in GitHub with the new code. But it’s not too slow on my computers. Do you feel it laggy?
      * Sure, it needs to decide if it’s just listening to ambient noise. Otherwise you get funny noises when the amplitude is below a certain level. It could be computed automatically from the lowest amplitude values.

      Nevertheless, I may probably abandon Processing in favor of Unity3D. I may still use Processing to capture microphone input, but I’m planning to send it via UDP to Unity3D, and process sound in C#. I hope that will be a little bit faster, but moreover, I’ll be able to draw fancy things on screen easily. All this is part of a bigger project that requires visual output, and I fear that Processing is not fast enough to handle it.

  2. Hi there! I simply want to give an enormous thumbs up for the good info you’ve right here on this post. I might be coming back to your blog for more soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About

This is PlayMedusa's game devlog: sketches, artwork, news, tutorials... Know more about us and our work in our MAIN SITE!

We create games mostly because we enjoy doing so. We hope you also enjoy playing them! Check them out at itchio Some can be played on the browser!

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información.plugin cookies

ACEPTAR
Aviso de cookies