Audiooutput on only one channel (DAC1)

wmsu2003
Posts: 1
Joined: Tue Jun 22, 2021 2:51 pm

Audiooutput on only one channel (DAC1)

Postby wmsu2003 » Tue Jun 22, 2021 3:00 pm

Hello,
I want to output my audio only on one DAC. So I can use the other for somethink else.
I found this:

On the ESP32, pin25 and pin26 are used (DAC1 and DAC2):
https://github.com/earlephilhower/ESP82 ... 2S.cpp#L78
The code is this one:

if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM) {
i2s_set_pin((i2s_port_t)portNo, NULL);
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
}
But if you set the i2s with this:

i2s_set_dac_mode(I2S_DAC_CHANNEL_LEFT_EN);

Only DAC2 is used and you can use the DAC1 for something else.



I changed the AudioOutputI2S.cpp in the way you mentioned.
But I get audio signal on PIN25 and PIN26.
Can someone see an error in my program?

Code: Select all

#include <SPI.h>
    #include <Wire.h>

    long myTimer1 = 0;
    long myTimeout1 = 2000;
    #include <Arduino.h>
    #include "AudioFileSourceSD.h"
    #include "AudioOutputI2S.h"
    #include "AudioGeneratorWAV.h"
    File dir;
    AudioFileSourceSD *source = NULL;
    AudioOutputI2S *out;
    AudioGeneratorWAV *wav;

    void setup() {
    Serial.begin(115200);
    audioLogger = &Serial;
    source = new AudioFileSourceSD();
    out = new AudioOutputI2S(0, 1);
    out -> SetGain(2.0); //max 4.0
    wav = new AudioGeneratorWAV();
    SD.begin();
    delay(500); //Abwarten 0,5s
    }

    void loop() {
    delay(100);
    wavabspielen1 ("/1756.wav");
    }
    void wavabspielen1 (char Dateiname[]) {
    File file = SD.open(Dateiname);
    source->close();
    source->open(file.name());
    wav->begin(source, out);
    while ((wav) && (wav->isRunning())) {
    if (!wav->loop()) wav->stop();
    }
    }

Who is online

Users browsing this forum: No registered users and 66 guests