Skip to content

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

@LusterWong

Description

@LusterWong

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions