L

LambdaSpeak Speech Synthesizer, Sample Player, RTC, MP3, Serial Interface, MIDI

Started by LambdaMikel, 08:56, 01 May 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GUNHED

Quote from: XeNoMoRPH on 07:00, 03 June 19
is there any RSX command to play mp3 files ?  :)
They will come! And they will be easy.  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

LambdaMikel

Alright, |pcmup is working now! And indeed much faster than the BASIC version  :)
|pcmplay also works fine, but we would need RSX commands to enable the PCM EEPROM playing mode. These are not there yet, right?

zhulien

Hi Mikel,


Playing with the mp3 and speech, and at the same time, i think either i am doing something wrong (likely) in the way I am reading statuses. 


I have artifical delays in lines 40 and 110 (using after) to force a delay, is there a status that can be read to know when the current command is finished processing?
line 30 configures a track to play.  The silencing at the start is not reliable (I have randomly tried different combinations of mode changes to experiment), since... if a game was playing an mp3 and it is reset, the mp3 will continue to play, however, switching to serial mode, then silencing the mp3 seems to be logical (if run again or a silence command is created). 
There is a lot of speech relating to changing modes, is there a command to silence mode changes?
In the below example, 'ideally', the behaviour would be... speak a single sentence (Now, let us listen to some music) then play the mp3 immediately after (without an artifical delay) - as the music is playing if you break (or end), running again should silence it before speaking again...  when the music is playing, manually gosubbing to the various subroutines, you can of course change modes and cause speech to come out - which proves in principle, that speech and mp3 playback is possible at the same time.


Below is an example:



10 MODE 2
20 WINDOW #2,1,80,20,25
30 t%=4'current track
40 PRINT"silence..";:GOSUB 230:GOSUB 140:GOSUB 160:GOSUB 180:GOSUB 210:AFTER 150 GOSUB 60
50 GOTO 50
60 GOSUB 270:GOSUB 230:PRINT"done"
70 PRINT"reset..";:GOSUB 140:PRINT"done"
80 PRINT"enter epson mode..";:GOSUB 160:PRINT"done"
90 PRINT"enter echo mode..";:GOSUB 180:PRINT"done"
100 a$="Now, let us listen to some music.":PRINT a$:GOSUB 200
110 GOSUB 210:GOSUB 270:AFTER 150 GOSUB 130'artificial delay
120 RETURN
130 GOSUB 300:RETURN
140 'reset to default ssa1 mode
150 OUT &FBEE,&FF:GOSUB 450:RETURN
160 'enter epson mode
170 OUT &FBEE,&EF:GOSUB 450:RETURN
180 'echo mode
190 OUT &FBEE,&EF:GOSUB 450:OUT &FBEE,&EB:GOSUB 450:RETURN
200 FOR i%=1 TO LEN(a$):c$=MID$(a$,i%,1):OUT &FBEE,ASC(c$):NEXT:OUT &FBEE,13:GOSUB 450:RETURN
210 'enter serial mode
220 OUT &FBEE,&F1:GOSUB 450:RETURN
230 'exit serial mode
240 OUT &FBEE,&FF:OUT &FBEE,&14:GOSUB 450:RETURN
250 'send serial command
260 OUT &FBEE,&7E:OUT &FBEE,&FF:OUT &FBEE,&FF:OUT &FBEE,&6:OUT &FBEE,a%:OUT &FBEE,&0:OUT &FBEE,b%:OUT &FBEE,c%:OUT &FBEE,&EF:OUT &FBEE,255:OUT &FBEE,2:RETURN
270 'reset mp3 player
280 a%=&C:b%=0:c%=0:GOSUB 250:RETURN
290 'play track
300 a%=&F:b%=1:c%=t%:GOSUB 250:RETURN
310 'increase volume
320 a%=4:b%=0:c%=0:GOSUB 250:RETURN
330 'decrease volume
340 a%=5:b%=0:c%=0:GOSUB 250:RETURN
350 'silence
360 a%=6:b%=0:c%=0:GOSUB 250:RETURN
370 'half volume
380 a%=6:b%=0:c%=15:GOSUB 250:RETURN
390 'max volume
400 a%=6:b%=0:c%=30:GOSUB 250:RETURN
410 'pause
420 a%=&E:b%=0:c%=0:GOSUB 250:RETURN
430 'continue
440 a%=&D:b%=0:c%=0:GOSUB 250:RETURN
450 'wait
460 a%=INP(&FBEE):IF a%=0 THEN GOTO 460 ELSE PRINT #2,a%
470 RETURN

LambdaMikel

hi @zhulien


it should not be necessary to write delay loops.
All modes have some kind of "ready" indicator that you can wait for on port &fbee.


For example, here is a piece of Z80 that resets LS 3 and then waits until it is ready to receive commands (as the reset takes about half a second or so):




org #8000
.start
LD BC,#FBEE
LD A,#FF
OUT (C),A
.loop1
IN A,(C)
CP 128
JP NZ,loop1
RET


There is also a version of this program on the LS300.dsk


https://github.com/lambdamikel/LambdaSpeak3/blob/master/cpc/lambda/LS300.dsk


Wrt to the MP3 serial module, I will have to check... I have not tried reading back the UART responses from it that are being generated as responses to the "play MP3 file" commands and similar. I believe it does generate return messages, but I haven't written code for that. In principle, if it does, it should just be possible after each command to read the return message; maybe have a look at the "serial.bas" program on the LS300.dsk above to see how to read back the received serial data (you can query / poll for the number of bytes in the receive buffer after the serial command has been sent - if the MP3 module acknolwedges a command by sending back a return string, then you can just repeatedly check if an answer is available in the buffer, and if so, retrieve it).


I can also try this and post the result here. 


And yes, it is also possible "to silent" the acknowledgement messages such that mode switching should be "silent"; try out &fbee,&e8 ("confirmations off"). Table of command bytes is here:

https://github.com/lambdamikel/LambdaSpeak3

(search for "&e8" in this page)


I think speech and MP3 should be possible at the same time, but I think you would need to start the MP3 first, and then do the speech. Otherwise I am afraid that you will only be able to start the MP3 AFTER the speech has finished; I have to try this for myself. Will post the results here.

LambdaMikel

PS Let me run your program and see if I can tweak it a bit...

LambdaMikel

OK, I have looked at this, and with the current LS 3 firmware, there is no solution which is entirely satisfying. It wasn't really designed with that in mind. This code is the best I could come up with for the current firmware - annoyingly, it always anounces "LambdaSpeak initialized, SSA-1 mode" after each "exit serial mode" command.

We need to change the "exit serial mode" command such that it can exit "silently", then this should work (I mean, it works, but it speaks this unwanted stuff as well).

Also, I did not manage to get any confirmation for MP3 commands from the module, maybe it doesn't send any. In that case, one needs to wait a little bit before sending the next MP3 command... see the for loop.

So, it is constant switching back and forth between Epson mode and Serial Mode / Exit Serial mode, and the latter one needs to be changed such that it can be done silently, without acknowledgements. In principle, it is possible though.
10 MODE 2
20 WINDOW #2,1,80,20,25
30 GOSUB 130 
40 FOR t%=1 TO 8
50 a$="Now, let us listen to some music. How about track "+CHR$(48+t%)+".":PRINT a$:GOSUB 170
60 GOSUB 460
70 GOSUB 180
80 GOSUB 260
90 GOSUB 150
100 a$=INKEY$:IF a$="" THEN 100
110 NEXT
120 halt
130 'reset to default ssa1 mode
140 OUT &FBEE,&FF:GOSUB 430:OUT &FBEE,&E8:GOSUB 430:OUT &FBEE,&EF:GOSUB 450:OUT &FBEE,&EB:GOSUB 450:RETURN
150 'exit serial
160 OUT &FBEE,&FF:OUT &FBEE,&14:GOSUB 420:OUT &FBEE,&E8:GOSUB 420:OUT &FBEE,&EF:GOSUB 450:OUT &FBEE,&EB:GOSUB 450:RETURN     
170 FOR i%=1 TO LEN(a$):c$=MID$(a$,i%,1):OUT &FBEE,ASC(c$):NEXT:OUT &FBEE,13:RETURN
180 'enter serial mode
190 OUT &FBEE,&F1:GOSUB 450:RETURN
200 'send serial command
210 OUT &FBEE,&7E:OUT &FBEE,&FF:OUT &FBEE,&FF:OUT &FBEE,&6:OUT &FBEE,a%:OUT &FBEE,&0:OUT &FBEE,b%:OUT &FBEE,c%:OUT &FBEE,&EF:OUT &FBEE,255:OUT &FBEE,2
220 FOR i=1 TO 100:NEXT
230 RETURN
240 'reset mp3 player
250 a%=&C:b%=0:c%=0:GOSUB 200:RETURN
260 'play track
270 a%=&F:b%=1:c%=t%:GOSUB 200:RETURN
280 'increase volume
290 a%=4:b%=0:c%=0:GOSUB 200:RETURN
300 'decrease volume
310 a%=5:b%=0:c%=0:GOSUB 200:RETURN
320 'silence
330 a%=6:b%=0:c%=0:GOSUB 200:RETURN
340 'half volume
350 a%=6:b%=0:c%=15:GOSUB 200:RETURN
360 'max volume
370 a%=6:b%=0:c%=30:GOSUB 200:RETURN
380 'pause
390 a%=&E:b%=0:c%=0:GOSUB 200:RETURN
400 'continue
410 a%=&D:b%=0:c%=0:GOSUB 200:RETURN
420 'wait
430 a%=INP(&FBEE):IF a%<>128 THEN GOTO 430
440 RETURN
450 'wait2
460 a%=INP(&FBEE):IF a%<>32 THEN GOTO 460
470 RETURN

Btw, the 2 different wait / wait2 subprocedures are necessary, because of SSA-1 compatibility, a "READY" has to be announced as 128 (the SSA-1 does it so!), but to distinguish the modes, I am using 128 to signal "READY" in the "native" modes (Epson, ...). If I used 32 for Epson, then this might trap and trick existing SSA-1 software into thinking that it is dealing with an SSA-1 (even though LS 3 is in Native / DECtalk / Epson mode), and that won't work obviously.

GUNHED

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

Quote from: LambdaMikel on 01:01, 09 June 19
Alright, |pcmup is working now! And indeed much faster than the BASIC version  :)
|pcmplay also works fine, but we would need RSX commands to enable the PCM EEPROM playing mode. These are not there yet, right?


Do you mean this one: |pcmmode, number_of_channels
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

LambdaMikel

Quote from: GUNHED on 11:39, 11 June 19

Do you mean this one: |pcmmode, number_of_channels
Right! Oh, it exists? Maybe it doesn't show up in the |lshelp?

GUNHED

Quote from: LambdaMikel on 15:29, 11 June 19
Right! Oh, it exists? Maybe it doesn't show up in the |lshelp?
Of course it does, take a look at the picture I posted quite a while ago. Probably, the commands are getting too much. But we're not done yet.  ;)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

LambdaMikel

Quote from: GUNHED on 15:41, 11 June 19
Of course it does, take a look at the picture I posted quite a while ago. Probably, the commands are getting too much. But we're not done yet.  ;)
Gosh, it is 100 degrees F here... I guess I didn't see it because of heat  :D


LambdaMikel

Quote from: GUNHED on 11:16, 11 June 19
Just saw the first LambdaSpeak III Review:


https://auamstrad.es/2019/05/review-del-nuevo-lambdaspeak-3/
Ah, written by our friend @XeNoMoRPH   :D Thanks!!
Google translate does an amazing job translating this into English btw.

zhulien

Quote from: LambdaMikel on 02:14, 12 June 19
@zhulien  are you capable of flashing the firmware by now?


i will order an eprom programmer soon.

LambdaMikel

Quote from: zhulien on 04:58, 12 June 19

i will order an eprom programmer soon.
Make sure I does AVR / ATmega ...
OK, let me know, and you can get an updated firmware.

GUNHED

Today I decided what to use for MP3 RSX commands, that should be:


MP3PLAY,song(1-99)
MP3XPLAY,folder(1-99), song(1-99)
MP3PLAYC,song(1-99)
MP3PLAYF,folder(1-99)

MP3VOL,volume(0-30)

MP3STOP
MP3HOLD
MP3CONT

MP3RES



http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

LambdaMikel

Excellent! I would suggest to also have some serial mode commands, e.g.,
|serial, |exitserial,
|serialsend,a$
|serialreceive,@a$
|setbaud
|setwidth,...
etc.  ;)


I know, it's a lot...

GUNHED

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

Quote from: LambdaMikel on 06:27, 28 May 19
@GUNHED  another thing I forgot to ask - now that you got your LS3, does it actually fit in the Amsdap? Remember I changed the PCB design according to your suggestion  :)


Well, let's see. Here some pictures I could make today...


Finally slot 3 seems to suitable the best. But I think to go for slot 4, even if I have to flatten the connector a bit. The fully enhanced LS3 need some space in the back and also the SD card needs to be inserted there. So slot 4 may be the best option. Take a look for yourself.


In brief: It works!  ;D

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

And some more... (few missing, forum does see a security problem  :-X )
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

zhulien

Quote from: GUNHED on 19:29, 12 June 19
Today I decided what to use for MP3 RSX commands, that should be:


MP3PLAY,song(1-99)
MP3XPLAY,folder(1-99), song(1-99)
MP3PLAYC,song(1-99)
MP3PLAYF,folder(1-99)

MP3VOL,volume(0-30)

MP3STOP
MP3HOLD
MP3CONT

MP3RES


Playing with BASIC and using outs, I think best to use Lambdaspeak in default mode most of the time but switch to mp3 very briefly then back to control it, so there isn't any complicated stuff happening.


If it isn't too difficult, put the following... note: i am yet to try 999 to see if we can in fact play 999 tracks. but... my suggestion

MP3PLAY,song(1-99),optionalfadeinfromvolume,optionalfadeintovolume,optionalfadeoutfromvolume,optionalfadeintovolume,optionalsonglength

the songlength provided so you can work out when to start fading out, since the CPC isn't really playing mp3.  However, I would think there needs to be a little smarts to know if speech is playing already at the time an interrupt comes in (if speech is the main mode).  Wait for speech buffer to be filled (can speak asyncrhonously too)

GUNHED

Fade in and fade out would require interrupt usage, that's possible. But only fading out would make sense IMHO since most songs are fading in by themselves.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

LambdaMikel

Quote from: GUNHED on 10:24, 13 June 19
In brief: It works!  ;D
Good to know! Since I could never test it with Amsdap (don't own one). Thanks for sharing  :) What does not work is probably Amdrum mode with Amsdap, right? Because Amsdap is claiming the FFxx address space if I remember correctly.


GUNHED

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

zhulien

Quote from: GUNHED on 15:01, 14 June 19
Fade in and fade out would require interrupt usage, that's possible. But only fading out would make sense IMHO since most songs are fading in by themselves.


I agree on that.  You can even edit the mp3 if you want the fade out to be at the end, but there are situations where you might in a game like to fade out early rather than just cut off the music.  So fade out as an option would be awesome as it would help BASIC game developers.


On the Wii, it is possible to substitute the in-game music with your own mp3's for some games.  I wonder if developers on CPC if they do start using mp3s might like to consider standardising on the allocations.   Eg: 01 title music, 02 gameover music, 03 highscore music, (04..20 reserved for specific musics), 21 start life ditty, 22 die dity, (23..29 reserved for specific dities), 51..x level music - that way you could be lazy to change your musics if you don't want to and at least have some sense in the structure.  Any thoughts?


I hope if game developers do support mp3, they do have AY CPC music as an option too.


With developing my front end for 8bitology, i have put everything in an 8bit folder, inside that an INI file to configure stuff. If everyone was to follow a standard for configuration, that would be cool too, eg: a m4 folder hardware/lambda.ini, where people configured how they want their hardware to work or be used, then games could default to those settings.  of course they don't need to use folders, users could have an ini file in each game folder perhaps.  In the case of 8bit API, i need to store the credentials that are returned from the server, you could call it a form of a cookie as browsers would use, but there are other things that benefit from it.

Powered by SMFPacks Menu Editor Mod