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

加速度センサーを使った楽器を作ろうとしたら dma_controller/audio_dma_drv.cpp:885 のエラーが発生した #3

Closed
TerukiKirihata opened this issue Aug 24, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@TerukiKirihata
Copy link
Contributor

センサーの値を100ミリ秒周期で読み出して音を出す楽器を作ろうとしたらエラーが発生しました。
エラーが発生した後は音が鳴らなくなりました。

loop関数の疑似コード

void loop() {
    int value = sensor.read();
    if (value > 100) {
        inst.sendNoteOn(60, 64, 0);
    }
    inst.update();
    delay(100);
}

シリアルモニタのエラーメッセージ(一部)

Attention: module[1][0] attention id[2]/code[1] (dma_controller/audio_dma_drv.cpp L885)
@TerukiKirihata TerukiKirihata self-assigned this Aug 24, 2022
@TerukiKirihata TerukiKirihata added the bug Something isn't working label Aug 24, 2022
@TerukiKirihata
Copy link
Contributor Author

起票時の疑似コードではdelay関数が使われているため、音声出力モジュールへの音声データ供給が滞り、Attentionが発生しているようです。

SDカードからの音声データ読み出しが間に合わないときには音声出力モジュールに無音データを供給するように修正しました。これによってAttentionが発生する問題はv0.7.0 以降で改善しますが、次の点には注意してください。

delay関数を実行している間はSDカードから音声データが読み込まれないため音が鳴りません。
適切に音を鳴らすためには、delay関数を使わずにセンサ読み取り周期を実現し、その周期とは関係なく inst.update() が実行されるようにしてください。

unsigned long next_millis = 0;
void loop() {
    unsigned long now = millis();
    if (next_millis <= now) {
        int value = sensor.read();
        if (value > 100) {
            inst.sendNoteOn(60, 64, 0);
        }
        next_millis = now + 100;
    }
    inst.update();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant