pschatzmann / arduino-audio-tools

Arduino Audio Tools (a powerful Audio library not only for Arduino)
GNU General Public License v3.0
1.51k stars 233 forks source link

[Not Resolved] No sound from spdif examples #1599

Closed netham45 closed 4 months ago

netham45 commented 4 months ago

Problem Description

Hi, I've tried both the sine wave generator and a2dp spdif examples verbatim. My spdif port is flashing when sending but I'm not getting anything detected by any of my receivers. I'm using an optical transmitter taken off of an 1->3 TOSLINK splitter I had wired to 5v and pin 23.

I'm not really sure where to start troubleshooting this one. Any tips would be welcome. Thanks.

Device Description

ESP32-WROOM-32U

Sketch

/**
 * @file basic-a2dp-audiospdif.ino
 * @brief A2DP Sink with output to SPDIFOutput
 * 
 * @author Phil Schatzmann
 * @copyright GPLv3
 */

#define I2S_BUFFER_COUNT 30
#define I2S_BUFFER_SIZE 384

#include "AudioTools.h"
#include "BluetoothA2DPSink.h"

BluetoothA2DPSink a2dp_sink;
SPDIFOutput spdif;

// Write data to SPDIF in callback
void read_data_stream(const uint8_t *data, uint32_t length) {
    spdif.write(data, length);
}

void setup() {
  Serial.begin(115200);
  AudioLogger::instance().begin(Serial, AudioLogger::Warning);

  // register callback
  a2dp_sink.set_stream_reader(read_data_stream, false);

  // Start Bluetooth Audio Receiver
  a2dp_sink.set_auto_reconnect(false);
  a2dp_sink.start("a2dp-spdif");

  // setup output
  auto cfg = spdif.defaultConfig();
  cfg.pin_data = 23;
  cfg.sample_rate = a2dp_sink.sample_rate();
  cfg.channels = 2;
  cfg.bits_per_sample = 16;
  spdif.begin(cfg);

}

void loop() {
  delay(100);
}

Other Steps to Reproduce

No response

What is your development environment

Arduino IDE v2.3.2 ESP32 Core v3.0.1 (Also tried 2.0.17) Latest version of arduino-audio-tools from repo as of writing (Also tried release 0.96)

I have checked existing issues, discussions and online documentation

netham45 commented 4 months ago

Just to note I have the library working on an ESP32-AudioKit with an esp32-a1s, I'm aiming to make a spdif-out version of what I've already made with an esp32-wroom-32u.

pschatzmann commented 4 months ago

I think this is rather a hardware then a software problem: I would not trust the AudioKit pins: try with a regular ESP32 first. I hope you did not forget to also have a proper connection to GND.

netham45 commented 4 months ago

I'm using a normal ESP32-WROOM-32U as indicated in my report. My goal is to port code I have working on the audiokit to it.

netham45 commented 4 months ago

Do you have a recommended ESP board to use? I also tried another ESP32-WROOM-32U yesterday to eliminate a hardware issue but no change.

pschatzmann commented 4 months ago

I guess you will need to analyze the signal with an oscilloscope or a logic analyzer to confirm that you get a valid signal. As I was writing before, I don't think the issue is the software but your toslink connection....