Edzelf / Esp-radio

Internet radio based on Esp8266 and VS1053.
MIT License
624 stars 200 forks source link

Request: Optional 1024K SRAM Instead of Ring Buffer #75

Open NonaSuomy opened 7 years ago

NonaSuomy commented 7 years ago

23LC1024 23LCV1024 PDF 23LC1024 PDF 23LCV1024

Arduino Library spiRAM

I've tested samples of these parts from Microchip with Ka-Radio and they work.

23LC1024 has Vhold <== using this one. 23LCV1024 has VBAT

Note: If your chip has a /Vhold in place of /VBAT, the pin 7 must be wired to VCC (pin8) instead of pin 7 to GND for the V series.. *Note2: Pin3 is not used in SPI mode and should not be left floating on the 23LC1024 (23LCV1024 pin3 is N/C).

1:CS = GPIO16 2:MISO = GPIO12 3:NC = VCC 3.3v 4:GND 5:MOSI = GPIO13 6:SCK = GPIO14 7:VCC 3.3v 8:VCC 3.3v

andybrk commented 7 years ago

For what? I think the internal ram is much more faster than a ram on the SPI interface. We have to transfer one byte for max bitrate (320kb) in 25us about.

Edzelf commented 7 years ago

Additional RAM will not have any effect on the performance of Esp-radio. The firmware will still use the limited TCP buffers.

NonaSuomy commented 7 years ago

What are the TCP buffers limited to, I was thinking you could use the sram for network stream buffering then the internal ram for managing high priority stuff.

Edzelf commented 7 years ago

The buffers are allocated by the Espressive firmware. There's no way to add extra buffers. So when the mp3-stream fills up all available buffers, communication with the webinterface and/or mqtt will be blocked. Some stations send more data than the VS1053 can handle. This causes the TCP input-buffers to saturate. I'm working on the ESP32 version now. Maybe this one has a better schema for using the TCP input buffers.

NonaSuomy commented 7 years ago

Thanks for the explanation, well I hope you still work on the esp8266 version as it has the lowest entry and power consumption point currently and seems to work well so far, also glad you did it with Arduino it's one of the reasons I switched from ka-radio, do you happen to know why when trying to play a small sample of say 1 second or few seconds around that it starts off choppy in the audio? When I tell it to stream the Text To Speech files it sometimes chops the first few words up a bit. Anyway you can think to prevent it?

h1aji commented 3 years ago

Hi @Edzelf I found this project ESP8266Audio where SRAM is being used. Can you tell what is done differently there? Is there any chance to use that approach for Esp-radio? Thanks

Edzelf commented 3 years ago

I don't know what the problem is with your radio, but I think extra memory will not help to fix it. In fact, the ringbuffer can be extended, as it is not using all of the available memory.

h1aji commented 3 years ago

The issue is interruptions when the radio works. Only low bitrates works fine, like 64. I checked the antenna and it seems fine. I have seen also on Karadio project optional SRAM which improves this situation

Edzelf commented 3 years ago

I do not think the lack of memory is the problem. Please give me the station that is causing the problem, so I can try to reproduce the error.

h1aji commented 3 years ago

for example this one: http://orion.shoutca.st:8554/stream

D: Connect to orion.shoutca.st on port 8554, extension /stream D: Connected to server D: Switch to HEADER D: Accept-Ranges:none D: Access-Control-Allow-Origin:* D: Cache-Control:no-cache,no-store,must-revalidate,max-age=0 D: Connection:close D: icy-name:DI Radio Digital Impulse - Alex Stendor The Space Trace D: icy-genre:Electronic D: icy-br:320 D: icy-sr:44100 D: icy-url:http://www.di-radio.com D: icy-pub:1 D: content-type:audio/mpeg D: udio/mpeg seen. D: icy-metaint:8192 D: X-Clacks-Overhead:GNU Terry Pratchett D: Switch to DATA, bitrate is 320, metaint is 8192 D: First chunk: D: FF FB E2 44 F9 82 07 A4 D: 71 54 4B 8F 4F 80 D2 CD D: 1B 4F 6B 0C 2D 22 51 DD D: 4C 8E 61 93 CC 2B BD 6A D: Metadata block 64 bytes D: Streamtitle found, 63 bytes D: StreamTitle='Alex Stendor - The Space Trace Mix vol 16 [20N5]';

Edzelf commented 3 years ago

I was able to reproduce the problem. I guess 320 kbps is to much for the processor. The ESP32 version of the radio will play this station without problems.

h1aji commented 3 years ago

Would it be possible to add support for 23LC1024 SPI RAM? like described in this project ESP8266Audio

Using external SPI RAM to increase buffer A class allows you to use a 23lc1024 SPI RAM from Microchip as input buffer. This chip connects to ESP8266 HSPI port and provides a large buffer to help avoid hiccus in playback of web streams.

I have got this SRAM chip and keen to test. Say if it could be added as USESRAM option.

I created fork and modified your code slightly to work with LCD 2004 and IR receiver diagram

Edzelf commented 3 years ago

As I said, the memory is probably not the problem. And I dont think SPI memory will be faster than internal RAM.

h1aji commented 3 years ago

What is the maximum value for RINGBFSIZ ?

And I dont think SPI memory will be faster than internal RAM.

I thought that VS1053 is taking care of decoding and ESP8266 is just responsible for WiFi and mp3 data flow. Is there any way to monitor CPU usage? I have seen (on russian forum) people reported improvements with hiccups on Ka-radio

Edzelf commented 3 years ago

The TEST button in the webinterface will tell you the amount of free memory. Increase the ring buffer size accordingly.