MMBasic there are a number of ways that you can use the sound output. You can play synthesized music, generate tones or generate program controlled voltages (PWM).
This command will play synthesized music in the background while the program is running. The music must be in the MOD format and the file containing the music must be located on the internal flash drive (drive A:).
The audio is high quality and MMBasic will generate full stereo on the CGCOLORMAX Maximite.
The MOD format is a music file format originating from the MOD file format on Amiga systems in the late 1980s. It is not a recording of the music (like a MP3 file) – instead it contains instructions for synthesizing the music. On the original Amiga this task was performed by dedicated hardware.
MMBasic will read this file and continuously play the music in the background while the program that launched the music will continue running in the foreground. Be aware that synthesizing music is a CPU intensive activity and uses a lot of memory and this could affect the performance of the program.
A description of the MOD format can be found at: http://en.wikipedia.org/wiki/MOD_(file_format)
A large selection of files that can be played on the Maximite can be found at: http://modarchive.org (look for files with the .MOD extension). Because the file must be located on drive A: to play it would be wise to select reasonably small files.
You can also create your own music using a tracker. For an example see: http://www.modplug.com
This command will create two tones for the CGCOLORMAX Maximite that will be outputted separately on the left and right sound channels. On the monochrome Maximite only one tone is generated. The tone is a synthesized sine wave and can be in the range of 1Hz to 20KHz with a resolution of 1Hz and is very accurate as it is locked to the PIC32’s crystal oscillator. When the frequency is changed there is no interruption in the output so the output can be made to glide smoothly across a range of frequencies.
The playing time can be specified in milliseconds and the tone will play in the background (ie, the program continues running).
The sound command is included only for compatibility with older programs. It generates a single frequency square wave and should be replaced with the tone or PWM command in new programs.
The PWM (Pulse Width Modulation) command allows the Maximite to generate two square waves with programmed controlled duty cycle. By varying the duty cycle you can generate a program controlled voltage outputs for use in controlling external devices that require an analog input (power supplies, motor controllers, etc). he CGCOLORMAX Maximite has two channels while the monochrome CGMMSTICK Maximite has a single channel.
The frequency for both channels is the same and can be from 20Hz to 1MHz. The duty cycle for each channel can be independently set from between 0% and 100% with a 0.1% resolution.
This command uses the sound output for generating the PWM signal so the components on this output may need to be changed to allow this output to work as a PWM output.