Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayWAVFromFunction example produces loud garbled noise instead of tone #730

Open
mujido opened this issue Feb 18, 2025 · 1 comment
Open

Comments

@mujido
Copy link

mujido commented Feb 18, 2025

I'm experimenting with a I2S breakout board from SparkFun using the MAX98357A chip from an ESP32-WROOM-32 (original ESP32). I'm using Version 2.0.0 of ESP8266Audio.

I was able to run the PlayAACFromPROGMEM example without any problems. Maybe a slight distortion but I think that's a gain issue. I tried switching to the PlayWAVFromFunction example because I wanted to generated a pure tone for testing. Instead this example plays very loud and painful noises. There is some kind of repetition in the sound so it does seem to be periodic but I'm not sure the exact problem.

I'm trying to debug the code and see the difference between the two examples.

Also, what can you explain what the fmod() line is doing here? I don't understand what it means by trying to linearize the signal.

  file->addAudioGenerators([&](const float time) {
    float v = sin(TWO_PI * hz * time);  // generate sine wave
    v *= fmod(time, 1.f);               // change linear
    v *= 0.5;                           // scale
    return v;
  });
@mujido
Copy link
Author

mujido commented Feb 18, 2025

It seems it might be related to WAV functionality in general. The PlayWAVFromPROGMEM example produces similar output. Other examples I've been able to try (non-WAV) have worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant