Author Topic: LambdaSpeak CPC Speech Synthesizer, Sample Player, RTC, MP3, Serial Interface  (Read 25587 times)

0 Members and 1 Guest are viewing this topic.

Offline zhulien

  • 464 Plus
  • *****
  • Posts: 391
  • Country: au
    • 8bitology
  • Liked: 177
  • Likes Given: 103
Rather than fadein or fadeout as part of the playing of the mp3 itself, perhaps just a fade rsx, |fade,startvol,endvol,fadespeed,increment/decrement, eg: fade 30,0,10,-2, would go from 30 to 0 volume at the time it is called in steps of -2 10/50ths of a second apart?  That would only be used if you wanted to fade in or out programatically.  A full song fadein or fadeout, let the developer edit the mp3 files to suit.

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Back from my weekend trip. I can start working on the firmware upgrade tonight.

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
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?
Yes and Yes!!! Very cool idea! The way we use MP3's is to tell the device: Play #xxx from folder #yyy. So yes, you can exchange / hack in your own music.
And yes, it would be great to have some definition which number shall be used for something.
Great idea!!!  :) :) :)

http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
I have uploaded a new firmware (still experimental, but should do):

https://github.com/lambdamikel/LambdaSpeak3/blob/master/firmware/atmega644/lambdaspeak-firmware-alternative.hex

Changes:
  • does not say "LambdaSpeak initialized. SSA-1 mode" as boot message.
  • "exit serial mode" returns to previous mode; no more reset.
  • silent mode changes possible.
  • serial mode uses READY and BUSY notifications now when ready to receive new serial command.
  • some speed improvements to PCM EEPROM upload mode
  • more coming soon.
  • version number not yet updated (still 15).
Also:
check out program "JULIAN.BAS" to use with this new firmware for seemless speaking and MP3 playing
https://github.com/lambdamikel/LambdaSpeak3/blob/master/cpc/lambda/LS300.dsk

Also:
check out programs "DRUMLD2.BAS" and "DRUMMER2.BAS" for TFM-based PCM sample loading and drumming:
https://github.com/lambdamikel/LambdaSpeak3/blob/master/cpc/lambda/midefseq2.dsk

Offline XeNoMoRPH

  • 464 Plus
  • *****
  • Posts: 390
  • Country: es
  • " ... in space no one , can hear you scream ... "
  • Liked: 736
  • Likes Given: 672
Is there a manual to update the firmware?  :o

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
Is there a manual to update the firmware?  :o


Well, from memory...


- Pull carefully out the ATMega CPU
- Position the CPU in your Burner
- Load the file to be updated, how this works is different from burner-software to burner-software
- Set the fuses if they are different. Check carefully. I will try to put pictures on this post.
- Burn new firmware
- Verify new firmware

http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
For the old firmware I just released the new update of the LS3 ROM, see my homepage. Most of the desired MP3 commands are added and working. If not try a 2nd time. I'm working hard with LambdaMikel to enhance performance.  :)
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Great job adding all these MP3 commands, @GUNHED  :)

Unfortunately, with the current "alternative" firmware that I had posted, it hangs for me. The old BASIC programs for MP3.BAS and RTC.BAS from the LS300.DSK work fine though, also with the new alternative firmware. So I guess the RSX commands are having a timinig / synchronization issue because I changed the ready / busy confirmation in the new Serial Mode in the alternative firmware?

For example, I have my MP3 files in a folder "01/001xxx.mp3" etc. So if I just do |mp3playf,"01", or |mp3playf,1, the RSX hangs and does not return, and I don't hear any music.
Do I need to send another command first? Haven't tried with the old firmware yet. I guess we 2 need to sort out the firmware issue first, and we are already working on this (offline). Maybe some synchronization issue. I guess this is my fault of changing the firmware, but in a sense, you really also want these changes (see Julian discussion), so let's work on this together to sort that out  :)   
So if possible, let's make this work with old and new "alternative" firmware, because I think we would want the "alternative" firmware to become the next version of the LS 3 firmware (minus outstanding bugs and plus some improvments of course). 

Also, are you initializing the MP3 module? If I remember correctly, it needs some initialization command (see MP3.BAS) for it to work.
« Last Edit: 08:10, 20 June 19 by LambdaMikel »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
So I guess the RSX commands are having a timinig / synchronization issue because I changed the ready / busy confirmation in the new Serial Mode in the alternative firmware?

To issue and MP3 command one needs to send a number of bytes to port &fbee. What I do is:
- Confirmations OFF
- Serial Mode on
- send MP3 command code
- Serial Mode OFF
That's it.

How do I synchronize? Well, after sending a byte to port &FBEE, I do wait until LS3 provides value &20 on port &FBEE to tell me it's ready.  Maybe it does set the port to &20 to early?
« Last Edit: 17:23, 20 June 19 by GUNHED »
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
... another update to the alternative / experimantal firmware has been posted in the GitHub.
Making sure now that BUSY / READY signal is set correctly in UART / Serial Mode, HOWEVER:
- |mp3play and friends still does not return from serial mode
- |mp3play sometimes STILL needs a second invocation for MP3 music playing to start.
Please notice that I do not know when the MP3 module is ready for the next command. So even if LS3 Serial Mode sends "READY" indicator, that does NOT mean that the MP3 module is ready. I don't know that, since I am not getting any handshaking signal / confirmation for the commands that are being sent. The TX line of the MP3 module is connected, but it seems it never sends anything. So, the only thing that helps is making sure that commands are not being sent to quickly... that should fix it.

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
New firmware works well!

- Use !MP3RES before any other MP3 command
- To wait 1/50 of a second allows to exit serial mode, but in a programs life that's an eternity... sooo
- Commands !SERIAL and !SEROFF added
- "How to update firmware" manual added (I'm the DAU regarding this anyway)

The LS3 is playing (again) all Captain Future Songs since hours here. Happy weekend!  :)
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Execellent work @GUNHED ! All MP3 commands work now with the latest firmware and no longer block.

I have hence made the "alternative" firmware the "official" one, and deleted the "alternative" one. Please upgrade your firmware to the latest official one:

https://github.com/lambdamikel/LambdaSpeak3/blob/master/firmware/atmega644/lambdaspeak3-firmware.hex

Changes there:
  • in serial mode, the READY (= 32) and BUSY signal is used consistently now.
  • in serial mode, all serial commands that return a value are using the following protocol now: to send <byte> to the CPC, the serial command follows the following protocol:
  • out &fbee,<byte>
  • wait according to fast or slow getters
  • out &fbee 0
  • wait according to fast or slow getters
  • finally, out &fbee,32 for READY to receive commands again
Please check out SERIAL.BAS on the updated LS300.DSK for how to communicate and read serial data. For example, to read a byte from the input receive buffer:

Code: [Select]
10 rem wait for ready:
20 wait &fbee,32
30 rem send get byte at cursor position in serial receive buffer command
40 out &fbee,255
50 out &fbee,9
60 rem read byte - notice that in BASIC that will only suceed if "slow getters" are enabled; in MC, it doesn't matter
70 byte=inp(&fbee)
80 if inp(&fbee)=0 then 80
90 if inp(&fbee)<>32 then 90
100 print "Received: ", byte
@GUNHED I have checked again and the MP3 module does not return any confirmations, so waiting a little bit in between commands is the only way of making sure that commands are not skipped. Your MP3 commands are working great with the latest firmware that has these changes, no changes required. The biggest change in this firmware is:
  • PCM EEPROM Upload is now much faster: I am now writing the received bytes on a "per page" basis, i.e., 512 Bytes at once. This makes is 512 times faster. I can now upload 64 KBs in 2 to 3 seconds to the EEPROM module. No changes to |pcmup require, @GUNHED
So, @zhulien it is time to upgrade the firmware now. See the program "JULIAN.BAS" for simultaneous speech and MP3 playing.
« Last Edit: 07:20, 24 June 19 by LambdaMikel »

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Here are ideas for the next version:
  • |pcmupfile - EEPROM PCM upload directly from WAV file
  • |sersend,@string - send string over serial interface
  • |serrecv,@rec - receive string from serial interface
  • |serbauds,baudrate
  • |decsing,songfile
All serial settings other than baud rate are not important IMHO (and don't require a dedicated RSX command - they can be used directly using out &fbee,<command>).

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464

Here are ideas for the next version:
  • |pcmupfile - EEPROM PCM upload directly from WAV file
  • |BLOW,@string - send string over serial interface
  • |SUCK,@rec - receive string from serial interface
  • |serbauds,baudrate
  • |decsing,songfile

Good ideas! And one question, for the |decsing command: Are there rules which blocks of bytes / characters I need to send to the LS3? Since I do read a file sequential - byte by byte - sometimes it needs to stop to read more bytes from disc to the RAM buffer. When do I "wait". Sorry, I'm not sure if I can explain what I mean. :-X
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Good question... well the input buffer is being flushed automatically to the Epson chip at character 254 if no CR had been received. 

After that, one needs to send the "preamble / header" again, which sets the right mode for singing which each "line" you are going to send in that way.

Please have a look at the DECSING.BAS program on the LS300.DSK. The tricky part is how to compute and extract the "preamble / header" again. I could imaging a DECsing song format which first declares the overall settings (line 1), then declares the header / preamble (second line), and then each subsequent line is implicitly  being prefixed with the header / preamble. That way you don't need to compute it from the standard DECTalk song format.

There are lot of songs on the "Flame of Hope" website:
http://theflameofhope.co/dectalk%20speak%20window/

However, most of these only work for DECtalk V2, and LambdaSpeak uses DECTalk v5. So most (if not all of them) don't work out the box, without editing. But I have 2 songs converted on the LS300.DSK that do work with DECtalk v5.

See also
https://forums.parallax.com/discussion/141536/zip-file-of-emic-2-songs
Ideally, the song is broken up at position which have pauses, "_<....>".
 
« Last Edit: 18:05, 24 June 19 by LambdaMikel »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
Ok, so this has to be more complex and a command like !speakfile would not work for DEC songs.


It's sad that v5 doen't "eat" the older v2 songs.  :-\
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Right, that one is not so easy...


Wrt ideas:
Maybe at some point we could explore other use cases for the EEPROM, now that we can upload 128 KBs within 3 or 4 seconds. It could be used as a simple drive. Not sure how difficult it would be to patch AMSDOS or similar for it though. And 128 KBs are not that much. Wish they made larger 25LC.... EEPROMs (well, maybe they do, but I couldn't get any in that DIP package).

 
« Last Edit: 21:07, 24 June 19 by LambdaMikel »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
Other usages are 'in principle' good ideas. IMHO they should stay connected with LS though. Because we have X-MEM, SF2, SF3, RAM and ROM expansions without an end.


I could imagine some (stupid) things like:
- Data for sentences (transfer a number to the LS instead of a full sentence)
- aehm... apps to be temporarily load into LS3
- aaaaeeeeehmmmmmmm ... going to sleep over it  ;D
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
In any case, I will add a function that allows the CPC to read the EEPROM contents per page. It can then be used to store up to 128 KBs of arbitrary data, and can be used for anything we like, not only PCM data. Maybe we can store alarms for the RTC or what have you. Or a couple BASIC Welcome programs. In that regard, I would find a RSX function |eeprom2ram,<startpage>,<number of pages>,<cpc start address> useful.


It won't turn into a ROM / RAM expansion though, because the board doesn't support the extra control lines.


How about a |hibernate and |resume for the CPC?  :)  That could be a good use case.
« Last Edit: 20:43, 25 June 19 by LambdaMikel »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
Ok, usually one can use 127,5 KB (because page 0 can't be accessed). How to get 128 KB?

Maybe upload 2 pages starting at page 255?
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Ok, usually one can use 127,5 KB (because page 0 can't be accessed). How to get 128 KB?

Maybe upload 2 pages starting at page 255?


THat's a good idea... so page 255 will be 1024 bytes (= 4 EEPROM pages) and all other pages 512 bytes (= 2 EEPROM pages).


Hmm, thinking about why this was necessary in the first place... actually, that problem did only arise because I needed a way to trigger PCM sample playing without halting the firmware (it needs to continue sample playing WHILE accepting new arguments for the next PCMPLAY command, and I couldn't use an interrupt based solution because I need max performance for PCM sample playing). Hence, I figured I will use the "0" as a separator byte (or "clock" byte) for the arguments of the |pcmplay command. Hence, I could not allow the 0 as an argument since it was used as a separator / clock byte. That was the only reason.


However, for the EEPROM as data storage application, this 0-based synchronisation for sending arguments to |pcmplay is not required. We can just use 0 as the start page. Only |PCMPLAY is not allowed to use 0. But |eeprom2ram can use page 0 as an argument / address, why not. Here, it is ok if the firmware waits until the page number argument has been supplied.


So let me change this tonight.   
 
« Last Edit: 01:48, 26 June 19 by LambdaMikel »

Offline zhulien

  • 464 Plus
  • *****
  • Posts: 391
  • Country: au
    • 8bitology
  • Liked: 177
  • Likes Given: 103
btw, i got an eprom programmer - hopefully a working one.

Offline LambdaMikel

  • 6128 Plus
  • ******
  • Posts: 1.402
  • Country: us
    • Homepage
  • Liked: 769
  • Likes Given: 528
Great! Maybe still wait a couple of days with firmware update... TFM and I are still working on some things. We'll give you a green light soon.

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.195
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 658
  • Likes Given: 1464
Yes, we do. Days and nights... new commands: !SAYTEMP, !EEUP, !EEGET... more to come...
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.01.14)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Ver.: 2019.07.02)

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 10.852
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 3807
  • Likes Given: 391
The instruction manual for your EPROM is going to end up being bigger than the CPC Manual :D

Bryce.