rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.88k stars 160 forks source link

Pitch Detection example doesn't work #151

Closed hassanshaikley closed 10 months ago

hassanshaikley commented 11 months ago

Describe the bug A clear and concise description of what the bug is.

https://github.com/rserota/wad#pitch-detection

Doesn't work. Using it in a CRA app and it was printing undefined undefined.

Expected behavior A clear and concise description of what you expected to happen.

I would expect the note and pitch to get pritned.

To Reproduce Include the smallest possible code snippet that reproduces this bug.

import { useEffect } from "react";

import Wad from "web-audio-daw";

export default () => {
  useEffect(() => {
    const voice = new Wad({ source: "mic" }); // At this point, your browser will ask for permission to access your microphone.
    const tuner = new Wad.Poly();
    tuner.setVolume(0); // If you're not using headphones, you can eliminate microphone feedback by muting the output from the tuner.
    tuner.add(voice);

    voice.play(); // You must give your browser permission to access your microphone before calling play().

    tuner.updatePitch(); // The tuner is now calculating the pitch and note name of its input 60 times per second. These values are stored in <code>tuner.pitch</code> and <code>tuner.noteName</code>.

    const logPitch = function () {
      console.log(voice);
      console.log(tuner.pitch, tuner.noteName);
      requestAnimationFrame(logPitch);
    };
    logPitch();
  });

  return <div>Microphone</div>;
};

Screenshots If applicable, add screenshots to help explain your problem.

Device (please complete the following information):

Additional context Add any other context about the problem here.

rserota commented 11 months ago

I'm unable to reproduce this issue. Can you tell me what browser/OS you're using? Does pitch detection work for you without using react? Does your microphone work for other web audio applications?