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

PlayBeep() will be noisy if you modify the DMA buffer parameters. #66

Open
LusterWong opened this issue Mar 31, 2022 · 0 comments
Open

Comments

@LusterWong
Copy link

LusterWong commented Mar 31, 2022

Using the PlayRawPCM example test, modify the DMA buffering in AtomSPK.cpp.

bool ATOMSPK::begin(int __rate)
{
    esp_err_t err = ESP_OK;

    i2s_driver_uninstall(SPAKER_I2S_NUMBER);
    i2s_config_t i2s_config = {
        .mode = (i2s_mode_t)(I2S_MODE_MASTER),
        .sample_rate = __rate,
        .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB
        .channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
        .communication_format = I2S_COMM_FORMAT_I2S,
        .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
        .dma_buf_count = 8,     //<------modify
        .dma_buf_len = 1024,    //<------modify
    };
    ...
    ...

Then execute _AtomSPK.PlayBeep(), sound plays, but there is a lot of noise when the sound ends.

void setup(){
    M5.begin(false,false,false);
    _AtomSPK.begin();
    _AtomSPK.playBeep(2500, 2000, 10000);
}

void loop(){
    if(M5.Btn.isPressed()){
    }
    M5.update();
}

Is there something wrong with my operation?

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