Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 14:33 04 Dec 2022 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 : CMM2 PLAY command

Author Message
cletus3x

Newbie

Joined: 31/07/2020
Location: United States
Posts: 17
Posted: 07:33pm 07 Aug 2020
Copy link to clipboard 
Print this post

Hi Shed crew,

I am a N00b but had a few questions about the PLAY command and the FM output.

So I really love how the CMM2 can output FLAC, MP3, MOD and WAV files right out of the box.  As soon as I unboxed mine from Circuit Gizmo's I threw some MOD's on a time-warped right back to the early 90's.

I have read the user manual and the programming manual and there did not seem to be a lot of detail on playing of these files and I was hoping the forum here could help me out with the following:

- Some of the MOD files I try and play seem to lockup the CMM2, it does appear to be larger files.  Is there a way to enable debug output and see what is going on?

- The programming manual notes: "The PLAY command can also be instructed to play all files in a directory back-to-back and only signal an interrupt when the last file has completed playing. " - I could not find and example how does one do this?

- How is the built-in player handling DAC output?  I noticed the DAC in the processor is 2 x 12 bit, is this running a dac for each channel? What is the output?  What is the highest quality the CMM2 can play?

- Are we able to connect a I2S dac up to the unit like a Raspberry pi?  I see the processor does have I2S in the data sheet.    

I wanted to look at trying to build a more full featured player for files as I thought it would be very cool.

Thanks,

-George
CMM2 Demos:
Kit Cat Clock
BCD Clock Video
 
TweakerRay

Senior Member

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

Hi ! I also find the documentation for sound very lacking... I thought it would be much easier to programm sound on this machine or that it has a few channels which you can use... right now I have found out that you can't play mp3 files while the speak synth command is running...
so the soundoptions to work with this machine are very limited... which I find very strange since I already saw a youtubevideo with a player which played chiptune...
I don't know if that was made differently but I would love to know
how you can a) use channels and how to do something like that:

https://www.youtube.com/watch?v=wQ3vrV61PuY

That is emulating a NES Soundchip...
http://tweakerray.bandcamp.com
 
cletus3x

Newbie

Joined: 31/07/2020
Location: United States
Posts: 17
Posted: 08:16pm 07 Aug 2020
Copy link to clipboard 
Print this post

TweakerRay,

Thanks for the link!  I'm glad I'm not the only one who thought sound documentation was lacking.  

Mauro is a wizard!  I did see some of his demo's before.  Awesome we can get his code off GitHub.

-George
CMM2 Demos:
Kit Cat Clock
BCD Clock Video
 
matherp
Guru

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

  Quote  - The programming manual notes: "The PLAY command can also be instructed to play all files in a directory back-to-back and only signal an interrupt when the last file has completed playing. " - I could not find and example how does one do this?


Manual page 76

  Quote  If fname$ is a directory then the firmware will list all the files of the relevant type in that directory and start playing them one-by-one.  To play files in the current directory use an empty string (ie, "").  Each file listed will play in turn and the optional interrupt will fire when all files have been played. The filenames are stored with full path so you can use CHDIR while tracks are playing without causing problems.
All files in the directory are listed if the command is executed at the command prompt but the listing is suppressed in a program


  Quote  How is the built-in player handling DAC output?  I noticed the DAC in the processor is 2 x 12 bit, is this running a dac for each channel? What is the output?  What is the highest quality the CMM2 can play?

One 12-bit DAC per channel each giving an output of 0-3.3V centred at 1.65V (c 1V RMS)

From the manual

  Quote  For WAV files MMBasic will automatically compensate for the frequency, number of bits and number of channels of the WAV file.  
For FLAC files the supported frequencies are:
44100Hz 16-bit(CD quality) and 24-bit
48000Hz 16-bit and 24-bit
88200Hz 16-bit and 24-bit
96000Hz 24-bit
Maximums for FLAC and WAV file playback are 96KHz 24-bit. Both will auto-configure to the file provided.  As an indication, 96KHz 24-bit FLAC uses just over 50% of the CPU's resources.


  Quote  Are we able to connect a I2S dac up to the unit like a Raspberry pi?

No: not supported by the firmware

  Quote  Some of the MOD files I try and play seem to lockup the CMM2, it does appear to be larger files.  Is there a way to enable debug output and see what is going on?


The firmware uses an open-source mod file codec which seems pretty robust but may not cater for all variants. It has been tested using a 284Kbyte mod file which works fine. You will have to test mod files for compatibility before use in a program
 
capsikin
Guru

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

  TweakerRay said  Hi ! I also find the documentation for sound very lacking... I thought it would be much easier to programm sound on this machine or that it has a few channels which you can use... right now I have found out that you can't play mp3 files while the speak synth command is running...
so the soundoptions to work with this machine are very limited... which I find very strange since I already saw a youtubevideo with a player which played chiptune...
I don't know if that was made differently but I would love to know
how you can a) use channels and how to do something like that:

https://www.youtube.com/watch?v=wQ3vrV61PuY

That is emulating a NES Soundchip...


The manual calls it "soundno" instead of channel but it's the same thing (except it uses "channel" for left vs right channel)

(message update: it's only in the PLAY SOUND command, not PLAY TTS, PLAY MP3, or any others)

Example:


print "start hum"
play sound 1,B,q,100

pause 500

print "zap sound, smooth"
print "playing as sound number 2 while sound number 1 continues"
for k=1 to 2
 ' multiples of 50 cycles per second
 for n=800 to 100 step -50
   play sound 2,B,q,n
   ' 20ms is a 50th of a second
   pause 20
 next n
next

play sound 2,B,O,300
pause 500
play sound 1,B,O,300

end

Edited 2020-08-09 11:05 by capsikin
 
berighteous
Senior Member

Joined: 18/07/2020
Location: United States
Posts: 110
Posted: 05:47pm 10 Aug 2020
Copy link to clipboard 
Print this post

I have short 6 second wav files that I need to loop during the menus of my game.  How do I do that?  can someone show me a code snippet to load a wav and keep it looping until I choose to quit it?  Here's the wav:
OZ4.zip
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6619
Posted: 05:52pm 10 Aug 2020
Copy link to clipboard 
Print this post

Two ways:

Play it with an interrupt routine specified and play it again in the interrupt. Use PLAY STOP when you have had enough

Use the code I posted in another thread to load it into an array and use the DAC command to play it in the background - you will have to search for the thread.
 
cletus3x

Newbie

Joined: 31/07/2020
Location: United States
Posts: 17
Posted: 02:47pm 12 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  - The programming manual notes: "The PLAY command can also be instructed to play all files in a directory back-to-back and only signal an interrupt when the last file has completed playing. " - I could not find and example how does one do this?


Manual page 76



matherp, I apologize I missed this on page 76  

Duh, have to use empty string ""

Any idea on how the DAC is handling 16 bit sources at only 12 bits?

Anyway to debug output?

Thanks,
Edited 2020-08-13 00:48 by cletus3x
CMM2 Demos:
Kit Cat Clock
BCD Clock Video
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2022