Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:56 19 Apr 2024 Privacy Policy
Jump to

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 : Sound on the Color Maximite 2

     Page 1 of 2    
Author Message
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 07:13pm 03 Aug 2020
Copy link to clipboard 
Print this post

Today I have tried to check out a little the Speek synthesizer...
I wrote a little test programm...

Anyone have some more infos also how to work with sound on that machine ?
Are there any programms I can take a look on ?

Yesterday I tried to programm a simple keyboard which could play sound but
I got frustrated because I don't know how I can check if a key is still pressed.

So the idea was to press a key the computer plays the note.
As long as you hold the key the sound stays on...

with the commands on the maximite basic I can't figure out how to do that.  

So I checked the speek synthesizer today and unfortunatly if you try to let it speek different strings and it is not finished with one string it will give out an error...

Here is my little test programm:  


If anyone has info about how you can work with sound on that machine I would love to know how I can implement that... I find the small section about sound has not many infos...


speektest.zip
http://tweakerray.bandcamp.com
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 07:34pm 03 Aug 2020
Copy link to clipboard 
Print this post

  Quote  I got frustrated because I don't know how I can check if a key is still pressed.


KEYDOWN function

  Quote  So I checked the speek synthesizer today and unfortunatly if you try to let it speek different strings and it is not finished with one string it will give out an error...


Use the completion interrupt to set a flag

a=0
play tts "hello world",,,,,myint
do
loop while a=0
play tts "By world"
end

sub myint
a=1
end sub
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 12:33am 04 Aug 2020
Copy link to clipboard 
Print this post

I wrote a small program to display what keys are pressed using keydown (by code number) - it's not exactly what you need to do but you might like to take a look:

http://www.thebackshed.com/forum/ViewTopic.php?TID=12451&PID=151445#151445

I'm guessing you've seen the manual as you know what some of the commands are, otherwise you can have a look in the manual for the commands you are interested in.

I have a short demo making sounds using "PLAY SOUNDS" you can read or test here:

http://www.thebackshed.com/forum/ViewTopic.php?TID=12402&PID=150948#150948

Mauro has a very impressive demo, I think it also uses "PLAY SOUNDS" but with interrupts for the timing instead of "PAUSE", but the code is quite complex.

I hadn't seen any example programs with speech before the ones in this thread (I haven't searched though), and haven't tried PLAY TTS yet.
 
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 03:04pm 05 Aug 2020
Copy link to clipboard 
Print this post

@ Mattherb : Thanks ! I will try that with that interupt flag !
Cool...

I just wonder if I will get an error with that too... because if the channel is in use and it loops back to the command play tts and gets it while it still plays the string it would give me an error... But I will try this... :-)

Thanks !

@ capsikin Thanks a lot I will take a look at that... the sound programms look cool.

I am very interested in how you could maybe use the CMM2 as a synth  ? That would be cool... I already saw some other topics here who would be also interested in that.
http://tweakerray.bandcamp.com
 
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 07:38pm 07 Aug 2020
Copy link to clipboard 
Print this post

So today I worked on my little writer (and now text to speak) programm...
I still am unable to control if the voice channel is still in use or not.
I tried a interupt but I only get it once and if the command is working again
it does not jump to that subroutine ...

The problem is when a sentence is spoken the program needs to wait to speak the next line...
if it doesn't then the programm gets an error while the speak channel is still in use.

Here is the programm...

Everything works good as long as you dont speed up the text with "+"

The writer has 12 lines right now of text which are declared in a field
a$(x2)

If you press 1 or 2 or 3 you can change the color of the text
if you press 0 you get some additional infos of the string (that just was for me to check)

if you use + or - you can speed up the textwrtiting... and then the problem starts.
if the line isn't finished and tries to speak the next line it gets an error that the
channel is still in use... so I have to tell the programm that it needs to wait if the line isn't finished yet... or stop that line and start the new again...

anyone has an idea ?

Here is the programm:
Writer2sound.zip



I find it extremly difficult to do something with sound

I also tried to play a mp3 in the background but that also does not work while the computer is speaking...
http://tweakerray.bandcamp.com
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5882
Posted: 11:02pm 07 Aug 2020
Copy link to clipboard 
Print this post

This is part of your program showing how to wait until the TTS has finished before starting the next sentence.

 MODE 1,8
 DIM letter$(100),a$(100),laenge(100)

 speedv=50
 pitchv=100
 mouthv=120
 throatv=100

CLS:
 ' COLOR RGB(r,g,b)
 
 
 SPEED=55 :' value for pause
 addtempo=0
 abst=13
 
 ' Declaration of fields are as follow:
 ' letter$(x2) will be each letter of the string
 ' a&(x2) will be the full text row
 ' laenge (x2) is the length of the string
 ' x2 will be how many strings you have - in this example its 12
 ' abs space between rows of writing
 
 a$(01)="Hallo! I implemented the speek synthesizer."
 a$(02)="Now your Colormaximite can speek."
 a$(03)="Sad that you have to pause, so you dont get any errors."
 a$(04)="If you speed up the text you wll get errors."
 a$(05)="Programm written by TweakerRay."
 a$(06)=" "
 a$(07)="Check out http://tweakerray.bandcamp.com"
 a$(08)=" "
 a$(09)="Toggle additional info with 0          "
 a$(10)="Speed up or slowdown Text with + and - "
 a$(11)="Press E for END. Press 1 for green 2 for orange 3 for blue"
 a$(12)="--------------------------------------------------------------------------------"
 
 
 voiceflag=1: ' voiceflag set to 1 to indicate that voice is not running
 x2 = 0
 DO
   DO : LOOP UNTIL voiceflag = 1 ' wait until voice is finished
   PAUSE 500 ' delay between sentences
   x2=x2+1
   IF a$(x2)<>"" AND a$(x2)<> " " THEN ' not a very safe test but works with the given strings
     voiceflag = 0 ' indicate that the voice is busy
     PLAY TTS a$(x2),speedv,pitchv,mouthv,throatv,myinterupt
   ENDIF
   
   PRINT x2
 LOOP UNTIL x2 = 12
END
 
SUB myinterupt
 voiceflag=1
END SUB


I also changed all the REM to ' which is the preferred way of starting comments.

Jim
Edited 2020-08-08 09:05 by TassyJim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 07:13am 08 Aug 2020
Copy link to clipboard 
Print this post

You can also do it this way:

play tts "hello world",,,,,myint
do
loop while mm.info(sound)<>"OFF"
play tts "By world"
do
loop while mm.info(sound)<>"OFF"
end


A little manual reading and less criticism perhaps required

  Quote  also tried to play a mp3 in the background but that also does not work while the computer is speaking.


The sound system can do one thing at a time with the single exception of playing a WAV file at the same time as a MOD file is playing
 
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 06:20pm 13 Aug 2020
Copy link to clipboard 
Print this post

@TassyJim: Thank you - I will check that out. I can't write a ' because the colormaximite does not accept the key of my keyboard... I didn't know only a few usb keyboards are supported and it seemed I could use any keyboard... thats why I have to type rem... not that I would love to use ' shortcuts like that...


@ matherp:

I have read the manual... and about sound there are not really much infos. Especially when you are beginning to check out this machine. I have printed out the manual even. So I find this a little bit high from the horse speaking like that.

That the sound system can do one thing at a time sounded different to me when I saw all the amazing demos (Exactly I bought this because I thought wow... so cool what you can do with that in basic: https://www.youtube.com/watch?v=IA7REQxohV4 )

And also it seemed that the machine is capable about a lot cool sound stuff (even while this is an emulation...https://www.youtube.com/watch?v=wQ3vrV61PuY  I thought it would be much better in sound)

BTW: There is one small text in the Introduction to programming with the CMM2 on Page 77 and THATS it...
In the bigger manual (which i also have printed out is not really clear, what wav format (samplerate, bitrate)

On that description is seemed to me that it can play background music and soundeffects at the same time. For me it does not make sense if you can't play music in the background and can't also do sfx if you want to programm a game...

I am a soundguy and I exspected a little bit more from that CMM2 (maybe I was fooled by the videos or exspected too much... But I come from a c-64 and thought this one would be superior in their abilitys...and thought this machine has so much power that this would be a joke for it to do...

The criticism was not against you just showing that i was frustrated. My frustration was because I did invest already some time into this and thought it was easier... and when you programm and test out and don't know why things don't work you ask in a forum and hope for some help. (as I got... but a little bit more encouragement for beginners instead of "RTM" (Read the manual) would have been nice... I am asking in a forum because I didn't found the answers in that manual... also I have to translate everything because I am german. So it's even more difficult to understand this all

I hope you can now understand my situation a little bit better...

Nothing for ungood.

I will try out your examples ... but as I said as a beginner in this its not that easy as it might seem to you Guru Foxes...

Cheers TweakerRay
http://tweakerray.bandcamp.com
 
Womble

Senior Member

Joined: 09/07/2020
Location: United Kingdom
Posts: 267
Posted: 08:44pm 13 Aug 2020
Copy link to clipboard 
Print this post

  TweakerRay said  I can't write a ' because the colormaximite does not accept the key of my keyboard... I didn't know only a few usb keyboards are supported and it seemed I could use any keyboard... thats why I have to type rem... not that I would love to use ' shortcuts like that...

I note from your User Location that you are in Germany ?
I assume that you are using a german QWERTZ layout usb keyboard ?
What firmware version are you using ?
Recent versions of the firmware support keyboard type DE for german keyboards.  Updating to the latest firmware might help with your sound issues too.  This is a developing project and things are changing all the time.

page 118 of the latest manual (which is bundled in the firmware download .zip) covers firmware updates in detail.  See also UPDATE FIRMWARE on page 89.

OPTION USBKEYBOARD nn on page 52 refers to changing the keyboard type.

Latest firmware (beta) supports UK US FR DE ES:
  matherp said  V5.05.05b7
Note I'm using the ISO 3166 country codes so Spain is ES
http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip


Hope this helps

Womble
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 03:28pm 14 Aug 2020
Copy link to clipboard 
Print this post

  Quote   The sound system can do one thing at a time with the single exception of playing a WAV file at the same time as a MOD file is playing


Peter, a few questions and suggestions on this:

1/ Will this limitation always be true? Playing two or more WAV files concurrently is something you often want to do in a game (my sense is the Maximite platform was not originally intended to be a “gaming platform”, but clearly the work you put into the graphics capabilities have turned it into one!)

2/ The manual says that PLAYing an audio file will make it play “in the background” and by this I interpret it to mean “play asynchronously”, but that’s not my experience, at least not in the practical sense of spawning an independent process. Before I saw this TBS thread, I arrived at the “interrupt subroutine setting a finished flag” technique through trial and error, and it works reasonably well - I assume this this is the best / only method to determine if a WAV file has finished playing? Ideally, the PLAY EFFECT command would be truly asynchronous and run in a separate thread independently of whatever else is going on, and not require a MOD file to be playing.

3/ Related to the previous and to your CMM2 graphics programming document (distilled from these Forum posts, I believe...), a document with expanded scope (e.g. something like  “The CMM2 Game Developer Guide”) would be very valuable for us newbies, notwithstanding the fact that figuring stuff out on your own is part of the fun of “Maximiting” :)

It would include all the sprite and blit stuff, plus technical details on the CMM2’s sound engine, and assorted techniques & best practices for writing an optimal “game event loop” (e.g. concurrent music and sound effects, efficient collision detection and screen updating, handling multiple KEYDOWN events, etc.).

I’ve tried to reverse-engineer Mauro’s insanely great PSG and Gauntlet code to understand how he performs his magic, but frankly, his techniques are way above my head at this point. Short of a full-blown document, I believe Mauro indicated he would publish some “generously commented” code in the near future, which would also be an awesome resource.

Judging from the posts here on TBS, I’m definitely not the right guy to lead such a project at this stage in my CMM2 game-writing journey, but if folks think the idea has merit, I would be happy to contribute in any way I can (technical writing, editing, illustrations, testing, etc).

Happy Maximiting, everyone!

Joe P.
Montreal, Canada
Enjoy Every Sandwich / Joe P.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 03:57pm 14 Aug 2020
Copy link to clipboard 
Print this post

  Quote   Will this limitation always be true?


Yes. I'm at the limit of what is reasonable in the audio interrupt routine and trying to read multiple files from disk at high data rates would slow things down too much.

  Quote  at least not in the practical sense of spawning an independent process


The CMM2 does not use a RTOS. It is a single thread with H/W interrupts

  Quote  I assume this this is the best / only method to determine if a WAV file has finished playing?


See my answer earlier in the thread as to how to use MM.INFO

  Quote  Ideally, the PLAY EFFECT command would be truly asynchronous and run in a separate thread independently of whatever else is going on, and not require a MOD file to be playing.


Job for the developer of the Maximite 3

  Quote  a document with expanded scope (e.g. something like  “The CMM2 Game Developer Guide”) would be very valuable for us newbies


Agreed but someone needs to write it. Neither Geoff or I are game developers and Mauro has a full time job. Panky has done a fantastic job pulling together disparate information on graphics and we now have several great developers inventing new techniques so I think it is up to the community to pool  experience and work together to develop something like this
 
TweakerRay

Senior Member

Joined: 01/08/2020
Location: Germany
Posts: 138
Posted: 04:02pm 14 Aug 2020
Copy link to clipboard 
Print this post

  Womble said  
I note from your User Location that you are in Germany ?
I assume that you are using a german QWERTZ layout usb keyboard ?
What firmware version are you using ?
Recent versions of the firmware support keyboard type DE for german keyboards.  Updating to the latest firmware might help with your sound issues too.  This is a developing project and things are changing all the time.

page 118 of the latest manual (which is bundled in the firmware download .zip) covers firmware updates in detail.  See also UPDATE FIRMWARE on page 89.

OPTION USBKEYBOARD nn on page 52 refers to changing the keyboard type.

Latest firmware (beta) supports UK US FR DE ES:
  matherp said  V5.05.05b7
Note I'm using the ISO 3166 country codes so Spain is ES
http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip


Hope this helps

Womble


Hi Womble, Yes I am from germany and Yes I user QWERTZ Layout and I also tried the option DE for the keyboard already I am on Firmware 5.05.04RC5 MM Basic

On the US Layout I get the keys... but its all messed up on the layout...
In my german layout I simply don't get the # or ' instead it gets me < and >
also my § does not work... (I think you don't need it) but anyway...

I am a little bit scared about that updating process with that programm and pulling Jumpers and stuff... I don't want to break it with that since I am not sure what I am doing... Right now it works - I don't want to ruin it with that...

I thought it would be an easy way to update this like setting this with a usb cable to a computer and uploading the firmware... I really don't want to open the machine and mess with the inside... Is there any other EASY WAY ?

Thanks in advance for your help. It's much appreciated and Sorry if some things I post may seem boring or stupid , but I am a beginner on this. I programmed a little basic on C-64 and Amiga but this is all new to me...

Cheers TweakerRay
Edited 2020-08-15 02:14 by TweakerRay
http://tweakerray.bandcamp.com
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 04:09pm 14 Aug 2020
Copy link to clipboard 
Print this post

  jpusztai said  I’ve tried to reverse-engineer Mauro’s insanely great PSG and Gauntlet code to understand how he performs his magic, but frankly, his techniques are way above my head at this point. Short of a full-blown document, I believe Mauro indicated he would publish some “generously commented” code in the near future, which would also be an awesome resource.


Sorry about my so little commented code... I'm trying to make all my source codes better readable, like the commented sections used in Wolf3D and Demo X.

If it helps, I will see again the PSGDemo and PSGLib and try to make it more readable with more consistent comments.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 04:26pm 14 Aug 2020
Copy link to clipboard 
Print this post

  Quote  Is there any other EASY WAY ?


Yes. Use the UPDATE FIRMWARE command. Then you can update via the USB console serial port or via the Keyboard USB (much faster) without opening the box or changing anything. Follow the details in the manual for running STM32CubeProgrammer
Edited 2020-08-15 02:30 by matherp
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 04:44pm 14 Aug 2020
Copy link to clipboard 
Print this post

  MauroXavier said  
  jpusztai said  I’ve tried to reverse-engineer Mauro’s insanely great PSG and Gauntlet code to understand how he performs his magic, but frankly, his techniques are way above my head at this point. Short of a full-blown document, I believe Mauro indicated he would publish some “generously commented” code in the near future, which would also be an awesome resource.


Sorry about my so little commented code... I'm trying to make all my source codes better readable, like the commented sections used in Wolf3D and Demo X.

If it helps, I will see again the PSGDemo and PSGLib and try to make it more readable with more consistent comments.


Mauro, it was not meant as a criticism :)

You have shown everyone “the art of the possible”, which speaking personally, is tremendously motivating. Also speaking personally, I believe I am a decent programmer, but I’ve always had a hard time following other people’s code, and yours is particularly tricky and “dense” - definitely not for beginners!

I’m working on my first game (in my entire life!), so trying to cram as many ideas and techniques as I can into my head at once, both general stuff (e.g. collision detection) as well as CMM2-specific stuff. So far so good - with any luck, I’ll have something “alpha” to show off soon. In the meantime, thanks for the reply and for your awesome work!
Enjoy Every Sandwich / Joe P.
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 04:56pm 14 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Is there any other EASY WAY ?


Yes. Use the UPDATE FIRMWARE command. Then you can update via the USB console serial port or via the Keyboard USB (much faster) without opening the box or changing anything. Follow the details in the manual for running STM32CubeProgrammer


I just did my first FW upgrade this week and it went without a hitch - Appendix G in the User Manual has flawless step-by-step instructions. I had to install Java for the ST programming software to run, but that was about it.

The only problem some folks might have is getting their hands on a USB Type A-Type A cable; these are not very common. My solution to this problem was to order a couple of Type A male-male and female-female adapters, and micro-USB to full-size USB adapters, with which you should be able to adapt cables your have around the house.
Enjoy Every Sandwich / Joe P.
 
Womble

Senior Member

Joined: 09/07/2020
Location: United Kingdom
Posts: 267
Posted: 08:01pm 14 Aug 2020
Copy link to clipboard 
Print this post

  jpusztai said  The only problem some folks might have is getting their hands on a USB Type A-Type A cable; these are not very common.

I bought this one:
eBay item number: 184324984489 USB 3.0 Type A Male to A Male Data Cable

I have also successfully used one of those double headed USB-A cables that came with Startech USB 2.0 2.5" HDD Caddys
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 01:04am 15 Aug 2020
Copy link to clipboard 
Print this post

  jpusztai said  
  MauroXavier said  
  jpusztai said  I’ve tried to reverse-engineer Mauro’s insanely great PSG and Gauntlet code to understand how he performs his magic, but frankly, his techniques are way above my head at this point. Short of a full-blown document, I believe Mauro indicated he would publish some “generously commented” code in the near future, which would also be an awesome resource.


Sorry about my so little commented code... I'm trying to make all my source codes better readable, like the commented sections used in Wolf3D and Demo X.

If it helps, I will see again the PSGDemo and PSGLib and try to make it more readable with more consistent comments.


Mauro, it was not meant as a criticism :)

You have shown everyone “the art of the possible”, which speaking personally, is tremendously motivating. Also speaking personally, I believe I am a decent programmer, but I’ve always had a hard time following other people’s code, and yours is particularly tricky and “dense” - definitely not for beginners!

I’m working on my first game (in my entire life!), so trying to cram as many ideas and techniques as I can into my head at once, both general stuff (e.g. collision detection) as well as CMM2-specific stuff. So far so good - with any luck, I’ll have something “alpha” to show off soon. In the meantime, thanks for the reply and for your awesome work!


I'm looking forward to any new PSGDemo/PSGLib releases but I've already learned from looking at it earlier.

The main things I noticed about the sound part:
It uses PLAY SOUND, multiple "soundno" channels, (see the PLAY SOUND section of the manual)
It uses SETTICK to call a function (edit: I mean a SUB) with set timing, which then updates the sound (using PLAY SOUND)
The interrupt seems to be every 10 or 1 milliseconds.

It reads information for the PLAY SOUND commands from an array.
It reads information for the array from a file.

I don't know about the format of the PSG files though, or how to make PSG files with good sounds. (edit: I mean VGM files, see Wikipedia )

It uses variables so it can vary most of the arguments to PLAY SOUND.
It uses SELECT CASE statements to vary the other arguments: left/right channel, and sound type (square wave, sine wave, etc)

A snippet where it selects between Q (square wave) and W (sawtooth)

CASE "Q":  Play Sound Ch+1,B,Q,SN,15-ChVol(Ch)
CASE "W":  Play Sound Ch+1,B,W,SN,25-ChVol(Ch)*1.5


A snippet where it decides whether to turn off sound in a "soundno" channel:

if ChType$(Ch)<>"" then Play Sound Ch+1,B,O,1,1


A snippet where an interrupt is set:

SetTick 10,IntSND,4

(editing to add: IntSND is a "SUB" that's called every 10 milliseconds in the example)
Edited 2020-08-15 16:15 by capsikin
 
BrianP
Senior Member

Joined: 30/03/2017
Location: Australia
Posts: 292
Posted: 11:39pm 15 Aug 2020
Copy link to clipboard 
Print this post

  Womble said  
  jpusztai said  The only problem some folks might have is getting their hands on a USB Type A-Type A cable; these are not very common.

I bought this one:
eBay item number: 184324984489 USB 3.0 Type A Male to A Male Data Cable

I have also successfully used one of those double headed USB-A cables that came with Startech USB 2.0 2.5" HDD Caddys

I "made" one from 2 A-B cables (obviously not "finished")

B

Edited 2020-08-16 09:40 by BrianP
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1590
Posted: 02:57am 17 Aug 2020
Copy link to clipboard 
Print this post

Jaycar A-A USB cables
1.8m
0.5m

Bill
Keep safe. Live long and prosper.
 
     Page 1 of 2    
Print this page
© JAQ Software 2024