Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Internet radio working on the WebMite with VS1053
Page 3 of 3 | |||||
Author | Message | ||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 358 |
This is exactly what I hear after switching from one station to another. It goes on for a short while (maybe 10-20s) and after that the it is OK. Must be something left in the buffer from previously selected station?? I have tried several things to empty the buffer; Without success. Some stations are clear and bright while others does not work properly or at all. Unfortunately my qualities are very well hidden wrt html. (Copying matherp's code parts and adding some trial and error, ...mostly error). Pluto |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Pluto, Thanks for that. Your suspicion of the buffer fits the bill. I was getting UK FM even though I had deleted it as a channel. I'll try turning the Pico off in between versions. Cheers, Andrew |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Andrew, to test a URL you can try putting it in your browser. That will play it in it's default player and confirm that the address does work http://live-radio01.mediahubaustralia.com/3FMW/mp3/ should be classic FM I will tell you how I get the sites tomorrow. Jim PS I usually go with classic rock... VK7JH MMedit MMBasic Help |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Jim, That seems to work - I'm listening to a man and a women talking (on my PC). No rush tomorrow as I'm tied up all morning. Cheers, Andrew |
||||
Pluto Guru Joined: 09/06/2017 Location: FinlandPosts: 358 |
VS1053 has also an onboard 2048-byte FIFO (buffer). Can this have something to do with the squeek problem?? Pluto |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Jim, Pluto et al, Thanks for your help. I now have ABC radio1 and radio2 working on the VS1053; crystal clear with no adverse sound effects. I'll post the relevant code later on. (It would be good if you could point me to the source of the URLs in due course.) Cheers, Andrew |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hello all, How to change channels on VS1053? I'm not sure if I am the only one with the following issue (Pluto may have seen it?). When I have set a channel playing on the VS1053 I can't just 'PLAY STOP' before setting up a new channel. If you do the old channel keeps playing over the top of the new channel. I assume the buffer still has old content. Is there any way to clear Buff%() in readiness for new data? ('CLEAR' and 'ERASE' don't work for me). Any suggestions? Cheers, Andrew |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
To clear a buffer LONGSTRING CLEAR array%() To clear the internal buffer of the VS1053 you have to set bit 3 of the mode register. I won't have time to put my system together today so it is all only supposition. Jim VK7JH MMedit MMBasic Help |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Andrew, Try play stop WEB CLOSE TCP CLIENT I also added r% = 0 : w% = 0 to reset the counters but not sure if thats required. when you end one stream before starting the next. Works for me. (My visitors are late so a little time to play) Jim Edited 2024-02-20 14:39 by TassyJim VK7JH MMedit MMBasic Help |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Jim, Enjoy your dinner. Unfortunately still not changing channels. When a 'button' is touched it calls this subroutine: Sub Radio_Off print "Radio is off" play Stop WEB CLOSE TCP CLIENT LONGSTRING CLEAR buff%() r% = 0 : w% = 0 End Sub 'Radio_Off I'll keep looking at my code just in case there is a gotchya. Cheers, Andrew |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Jim et al, Found it! (I think). Well at least it appears to be working! I'd been relying on the above subroutine "SUB Radio_Off" to be adequate. I've now repeated the following in "SUB Radio_On" before setting up a$ and q$, ie: a$ = "": q$ = "" on error Skip play Stop on error Skip WEB CLOSE TCP CLIENT on error Skip LONGSTRING CLEAR buff%() r% = 0 : w% = 0 Maybe overkill but it appears to work. I'll investigate more on a cooler evening - no a/c here. Thanks for your help, Andrew |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Nup, A false dawn. At least it is not superimposing two channels but it is still sticking with the first channel. Andrew |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Try this and see what happens: OPTION ESCAPE OPTION EXPLICIT OPTION DEFAULT NONE DIM url_list$(10,2) DIM INTEGER n DIM k$ DIM buff%(4095),w%,r% ' fill the favorites list 'cls PRINT CHR$(27);"[H";CHR$(27);"[2J" PRINT "0","Stop play" FOR n = 1 TO 9 READ url_list$(n,1),url_list$(n,2) IF url_list$(n,1) = "END" THEN url_list$(n,1) = "" : url_list$(n,2) = "" EXIT FOR ENDIF PRINT n,url_list$(n,1) NEXT n DO k$ = INKEY$ SELECT CASE k$ CASE "x","X" ' quit program endplay EXIT DO CASE "0" ' end play endplay CASE "1" TO "9" endplay PAUSE 500 n= VAL(k$) listen url_list$(n,2) CASE ELSE ' END SELECT PAUSE 10 LOOP END SUB listen url$ LOCAL q$, a$, strm$, k% IF UCASE$(LEFT$(url$,7)) = "HTTP://" THEN url$ = MID$(url$,8) r% = 0 : w% = 0 k% = INSTR(url$,"/") a$ = LEFT$(url$,k%-1) strm$ = MID$(url$,k%) PRINT a$ PRINT strm$ q$="GET " INC q$, strm$ INC q$," HTTP/1.1\r\n" INC q$,"Host: " INC q$,a$ INC q$,"\r\nConnection: close\r\n\r\n" PLAY STREAM buff%(), r%, w% WEB OPEN TCP STREAM a$,80 WEB TCP CLIENT STREAM q$, buff%(), r%, w% END SUB SUB endplay IF MM.INFO$(SOUND)<>"OFF" THEN PRINT MM.INFO$(SOUND) PRINT MM.INFO$(TCPIP STATUS) PLAY STOP ON ERROR SKIP WEB CLOSE TCP CLIENT ENDIF END SUB ' Display name , url myList: DATA "ABC Jazz","live-radio02.mediahubaustralia.com/JAZW/mp3/" DATA "ABC Melbourne","live-radio04.mediahubaustralia.com/3LRW/mp3/" DATA "NEWS","live-radio02.mediahubaustralia.com/PBW/mp3/" DATA "Classic FM","live-radio01.mediahubaustralia.com/3FMW/mp3/" DATA "END","" Jim VK7JH MMedit MMBasic Help |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
I think we have a corruption problem. Every 3 seconds, a string variable old_play_state$ gets corrupted. If I change the order in the DIM statement line, no corruption (or none noticed yet) The program: OPTION ESCAPE OPTION EXPLICIT OPTION DEFAULT NONE DIM url_list$(10,2) DIM INTEGER n DIM k$, old_play_state$, play_state$ ' Dim k$, play_state$, old_play_state$ ' this variable order causes corruption DIM buff%(4095),w%,r% ' fill the favorites list 'cls PRINT CHR$(27);"[H";CHR$(27);"[2J" PRINT 0,"Stop play" FOR n = 1 TO 9 READ url_list$(n,1),url_list$(n,2) IF url_list$(n,1) = "END" THEN url_list$(n,1) = "" : url_list$(n,2) = "" EXIT FOR ENDIF PRINT n,url_list$(n,1) NEXT n DO k$ = INKEY$ SELECT CASE k$ CASE "x","X" ' quit program endplay EXIT DO CASE "0" ' end play endplay CASE "1" TO "9" ' change stream endplay PAUSE 500 n= VAL(k$) listen url_list$(n,2) CASE ELSE ' END SELECT PAUSE 10 play_state$ = MM.INFO$(SOUND) IF INSTR(" OFF PAUSED TONE WAV FLAC SOUND STREAM ",play_state$) THEN IF old_play_state$<>play_state$ THEN PRINT TIME$,play_state$, old_play_state$ ' corrupted data old_play_state$ = play_state$ PRINT TIME$,play_state$, old_play_state$ ' should be equal ENDIF ENDIF LOOP END SUB listen url$ LOCAL q$, a$, strm$, k% IF UCASE$(LEFT$(url$,7)) = "HTTP://" THEN url$ = MID$(url$,8) r% = 0 : w% = 0 k% = INSTR(url$,"/") a$ = LEFT$(url$,k%-1) strm$ = MID$(url$,k%) PRINT a$ PRINT strm$ q$="GET " INC q$, strm$ INC q$," HTTP/1.1\r\n" INC q$,"Host: " INC q$,a$ INC q$,"\r\nConnection: close\r\n\r\n" PLAY STREAM buff%(), r%, w% WEB OPEN TCP STREAM a$,80 WEB TCP CLIENT STREAM q$, buff%(), r%, w% END SUB SUB endplay IF MM.INFO$(SOUND)<>"OFF" THEN PRINT MM.INFO$(SOUND) PRINT MM.INFO$(TCPIP STATUS) PLAY STOP PAUSE 100 PRINT MM.INFO$(SOUND) ON ERROR SKIP WEB CLOSE TCP CLIENT ENDIF END SUB ' Display name , url myList: DATA "ABC Jazz","live-radio02.mediahubaustralia.com/JAZW/mp3/" DATA "ABC Melbourne","live-radio04.mediahubaustralia.com/3LRW/mp3/" DATA "NEWS","live-radio02.mediahubaustralia.com/PBW/mp3/" DATA "Classic FM","live-radio01.mediahubaustralia.com/3FMW/mp3/" DATA "END","" Could this help explain some of the distortion when switching streams? I have not noticed the distortion yet. Jim Edited 2024-02-21 12:09 by TassyJim VK7JH MMedit MMBasic Help |
||||
Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 847 |
Hi Jim, Just back from a meeting. Your program two posts above at 07:20 works a treat. No audible distortions and a smooth transition between channels. I noticed that I did not have these options on: "OPTION CPUSPEED 250000" "OPTION TELNET CONSOLE ON" but it works without them. Also, I had "OPTION ESCAPE" as the second statement in my code. Does that run foul of the manual?: Your code is far more sophisticated than mine and I am working through it to understand and learn. Many thanks, Andrew |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6098 |
Good to hear that it's working. Ignore my additional options. That is my standard for WEBmites. The listen sub is all Peter's work except that I prefer to keep url and stream in the one string. Just personal preference. I have added a couple of PAUSE statements which 'might' be helping. I use mm.info$(sound) to test if we are streaming rather than using on error skip. I don't know if there is similar available for 'Web Tcp Client Stream' I have had the occasional dropout but I get them on the 'real' tuner so I will have to live with that. testing for 'Web Tcp Client Stream' would help detect any dropouts. The time it spends buffer at the start is noticeably less than to 'real' tuner so that's a plus. Jim VK7JH MMedit MMBasic Help |
||||
Page 3 of 3 |
Print this page |