I saw some super posts in the archives about sound ripppers and stuff related to sound so I thought I would take a run making a sound list player.
All of this can be done in FB Forth or TF as well. However there are some words that will need adjustment.
The missing words would be MS, which is just a quick delay loop.
: MS 8 0 DO LOOP ; ( something like this, 8 is "about" the correct number for 1 MS)
And PAUSE which is a noop.
: PAUSE ; will fix that quickly.
And ?NUMBER in CAMEL Forth is non-standard, but Lee created an equivalent in FB Forth for another one of my posts a while back.
(Will find that and post here)
However what a little player like this might be good for is trying out some data to listen to it for ALC programmers.
You can feed it sounds lists from the keyboard and play them to see how you like the sound.
Couple of things to be aware of:
1. This player turns all 4 sound channels off when it gets to the end of a list with the word SILENT.
If you use the TI player you will need to add the string of bytes to turn off your sounds.
2. The BYTES word does not use commas, so sound lists tried here will have to have the commas removed.
3. UN-comment SND! for other Forth systems or use the equivalent word to write a byte to the sound chip address.
4. LSHIFT is the ANS Forth word, but TF uses << for the same thing I believe. Not sure about FB Forth .
How it works:
PLAY$ takes the address of a string of bytes with a count byte at the start and a time duration byte at the end.
It converts the duration byte to milliseconds assuming a 1/60 of a second ISR time.
It then computes the start and end address of the sound bytes and loops through them sending each one to SND! (the chip address)
When the loop is completed it waits for the duration of milliseconds.
PLAY Is the high level word to use for playing a sound list. It simply looks to see if there is a non-zero byte count in a sound string.
While that is true is calls PLAY$.
Then using the count byte it computes the address of the next string in the list and plays the next string until it hits a final ZERO.
CREATE XXXX is Forth's way of making a new word in the Dictionary of words and will return the start of the data address of that new word.
BYTES is a compiler directive that was created to parse the input stream, convert the data to a number and compile it into the next byte of memory.
It could have been done with the C, primitive but it makes the lists harder to read ( example AA C, 7 C, DE C, ETC... )
I believe the code here will run with the CAMEL99 version in GITHUB /BIN folder. (did not try it yet)
I stole some sounds from PARSEC for FIRE and EXPLODE and I must confess it was a religious experience to hear those sounds come out my Forth system.
If you get it working type:
3 SHOTS at the console. That does 3 FIRE sounds and then runs the EXPLODE list. Memories...
Edited by TheBF, Mon Sep 4, 2017 6:43 PM.