CelliesProjects / ESP32_VS1053_Stream

A streaming library for Arduino esp32 with a vs1053 mp3/aac/ogg/flac decoder. Plays http, https (insecure mode) and chunked streams and parses the metadata. Also plays ogg and mp3 from sdcard.
MIT License
40 stars 10 forks source link

How to use other DAC chip type NS4168? #6

Closed franciscogimeno2000 closed 2 years ago

franciscogimeno2000 commented 2 years ago

Hello, thanks for your example codes. I am using a m5satck ATOM Speaker Kit with a NS4168 chip decoder, could you tell me how to implement the library of this chip so that it works with your example?

https://shop.m5stack.com/products/atom-speaker-kit-ns4168?_pos=1&_sid=968a46ad3&_ss=r

Thanks.

CelliesProjects commented 2 years ago

That would be unpossible as the ns4168 is a dac and not a codec. (So it expects/plays samples and not a coded stream)

See for example https://www.analogictips.com/what-is-a-codec/

You might try https://github.com/schreibfaul1/ESP32-audioI2S/ to decode the streams. I used that lib with a couple of different dacs and it should be fairly easy to get it running.

The stream has to be decoded before you send it to the dac which would be done by ESP32audioI2S which sends the decoded data (the samples) to the ns4168.

https://github.com/schreibfaul1/ESP32-audioI2S/wiki

franciscogimeno2000 commented 2 years ago

OK thank you very much.

CelliesProjects commented 2 years ago

Just try the example from https://github.com/schreibfaul1/ESP32-audioI2S/wiki#a-simple-project-to-receive-a-webstream, change the pin numbers to the numbers used by the ns4168 and it could very well be that it works.

franciscogimeno2000 commented 2 years ago

ok thanks, i'll try it.

franciscogimeno2000 commented 2 years ago

It seems to me that it is better to use a codec chip than a DAC. Faster, better quality and less problems. With a codec you get the transcoding of the flow done and you avoid noise, latencies and, as I say, problems. Ultimately more professional.

CelliesProjects commented 2 years ago

I can only agree with that. I started out with software decoding and after a lot of hassling ended up -very satisfied- with a hardware decoder.

franciscogimeno2000 commented 2 years ago

I have been using your library and with the codec chip vs1053 the sound is perfect. One question, is your library capable of automatically reconnecting if the server goes down? Or do I have to read the playback status and launch it again

franciscogimeno2000 commented 2 years ago

Another thing, if while it is playing I deactivate the server, the ESP32 gives a panic message and restarts. I don't know if it happened to you.

this is my network server: stream.connecttohost("http://192.168.0.145:8080");

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. Core 1 register dump: PC : 0x400d3e74 PS : 0x00060430 A0 : 0x800d3f3c A1 : 0x3ffb1e40
A2 : 0x00000000 A3 : 0x3ffb1e8f A4 : 0x00000001 A5 : 0x00000001
A6 : 0x0000059c A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x3ffcbc00 A12 : 0x00000050 A13 : 0x00000001
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x400d3e74:0x3ffb1e40 0x400d3f39:0x3ffb1e60 0x401623d2:0x3ffb1e80 0x400d66a9:0x3ffb1eb0 0x400d66d5:0x3ffb1ed0 0x40162371:0x3ffb1ef0 0x400d136a:0x3ffb1f10 0x400d1f7e:0x3ffb1f50 0x400d0966:0x3ffb1f90 0x400d7764:0x3ffb1fb0 0x4008990e:0x3ffb1fd0

Rebooting...

CelliesProjects commented 2 years ago

Interesting. I assumed -and the code does- that radio streams never stop. And as you probably know assumption is the mother of all fuckups so there you go.

What setup do you use to start/stop a stream? I want to test this scenario in my network.

franciscogimeno2000 commented 2 years ago

Use any vlc type player and generate a streaming of an mp3 and when it is playing do not hit the vlc stop, close it directly.

franciscogimeno2000 commented 2 years ago

I have also tried to remove the wifi while playing, and in that scenario no error occurs. With which I believe that the problem is in the reproduction, not in the management of the wifi or the client.

CelliesProjects commented 2 years ago

Thanks, got the streaming part running. Next thing is debugging. Stay tuned...

franciscogimeno2000 commented 2 years ago

ok

franciscogimeno2000 commented 2 years ago

One question... do you know how to synchronize several esp32 so that when connected they play the audio at the same time?

I have read that the WMA protocol sends the real time of the current position of the player in the encoding. But I don't know how to read this.

CelliesProjects commented 2 years ago

I am getting "application/octet-stream" mime-type headers from the local vlc streamer on all filetypes. You are using macOS of windows?

franciscogimeno2000 commented 2 years ago

win