pschatzmann / ESP32-A2DP

A Simple ESP32 Bluetooth A2DP Library (to implement a Music Receiver or Sender) that supports Arduino, PlatformIO and Espressif IDF
Apache License 2.0
1.73k stars 278 forks source link

samples errors: 'I2SClass' does not name a type #628

Closed josef2600 closed 5 hours ago

josef2600 commented 5 hours ago

Problem Description

in some of the samples you used I2SClass i2s; . all of them get 'I2SClass' does not name a type error. but with I2SStreamthey work. and the rest of the codes are deprecated. check them if you had time.

Device Description

esp32

Sketch

#include "ESP_I2S.h"
#include "BluetoothA2DPSink.h"

const uint8_t I2S_SCK = 5;       /* Audio data bit clock */
const uint8_t I2S_WS = 25;       /* Audio data left and right clock */
const uint8_t I2S_SDOUT = 26;    /* ESP32 audio data output (to speakers) */
I2SClass i2s;

BluetoothA2DPSink a2dp_sink(i2s);

void setup() {
    i2s.setPins(I2S_SCK, I2S_WS, I2S_SDOUT);
    if (!i2s.begin(I2S_MODE_STD, 44100, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO, I2S_STD_SLOT_BOTH)) {
      Serial.println("Failed to initialize I2S!");
      while (1); // do nothing
    }

    a2dp_sink.start("MyMusic");
}
void loop() {}

Other Steps to Reproduce

No response

Provide your Version of the EP32 Arduino Core (or the IDF Version)

Arduino Core 3.0.7

I have checked existing issues, discussions and online documentation

pschatzmann commented 5 hours ago

I2SClass i2s is part of the Arduino I2S API. If you are using a core < 3.0 you need to adapt the example it to the old Arduio I2S API since this has changed as well! Have a look at the ESP32 I2S examples provided by Arduino!

This is described in the README

josef2600 commented 5 hours ago

I2SClass i2s is part of the Arduino I2S API. If you are using a core < 3.0 you need to adapt the example it to the old Arduio I2S API since this has changed as well! Have a look at the ESP32 I2S examples provided by Arduino!

This is described in the README

did you read the post? no! Arduino Core 3.0.7 and it is exactly your sample. i said if you have the time check them. if not, what is the point of reporting?

pschatzmann commented 4 hours ago

I compiled the sketch in Arduino 3.1rc3 and 3.0.7 and for me it is working w/o issues.

Did you try to compile one of the I2S examples provided by Arduino. I guess something is wrong with your core installation!

josef2600 commented 4 hours ago

in Arduino example :

void setup() {
  // Create an instance of the I2SClass
  I2SClass i2s;

...

I2SClass i2s; is inside the setup, not outside. and it has#include <ESP_I2S.h>

pschatzmann commented 4 hours ago

Simple_tone.ino compiles w/o issue. What did you try ? ES8388_loop_back.ino compiles for me also w/o errors...

Did you enventually change the compiler-warning settings in the preferences from default to something else ?

josef2600 commented 4 hours ago

no. the problem was from#include "ESP_I2S.h" . when inserting it, all works. in the documents, non of them have it. funny thing! you always say read them, but this time they were the problem! example :bt_music_receiver_arduino_i2s makes error : I2S.h: No such file or directory

thanks for your replies.

pschatzmann commented 1 hour ago

I don't understand: your example (from bt_music_receiver_arduino_i2s_3.ino) that you pasted above has this include!

If you read the comment in bt_music_receiver_arduino_i2s.ino, it clearly states that it is for ESP32 I2S < 3.0.0