Jump to content
IGNORED

How to convert WAV2CV sound data into Coleco BIOS sound format


newcoleco

Recommended Posts

Before reading, make sure you know how to write hexadecimal values in

C, and what they represent in decimal values.

 

THIS MESSAGE IS ABOUT CONVERTING (BY HAND) FROM MARCEL'S SOUND FORMAT

TO COLECO SOUND FORMAT FOR AUTOMATICALLY GENERATED SOUND TABLES (WITH

WAV2CV TOOL).

 

1. THE BASE CODE:

 

Before converting the sound, you have to decide on which tone channel

he will be played. Marcel's sound routines doesn't care which tone

channel, they choose for you, and because of that you don't have the

control of your sounds, and sometimes it creates overlaping sounds.

 

The base code is this :

 

Tone CH#1 = 0x40

Tone CH#2 = 0x80

Tone CH#3 = 0xC0

 

For the example, I will use the base code for Tone CH#1. (0x40)

 

2. THE UNNECESSARY STUFF.

 

The first line of the sound data is unnecessary, just delete it.

 

byte wav2cv_sound0[] = {0, 0x63, 0xf, 1,

0x83,0xE5,0x90,2, 0x83,0xE7,0x90,2, 0x83,0xEC,0x96,2, 0x83,0xF6,0x9A,2,

0x83,0xF5,0x9C,2, 0x83,0xF5,0x9E,2, 0x9f,4, 0x83,0xA3,0x9E,2,

0x83,0xD1,0x9C,2,

...

0,0,0};

 

Became this :

 

byte wav2cv_sound0[] = {

0x83,0xE5,0x90,2, 0x83,0xE7,0x90,2, 0x83,0xEC,0x96,2, 0x83,0xF6,0x9A,2,

0x83,0xF5,0x9C,2, 0x83,0xF5,0x9E,2, 0x9f,4, 0x83,0xA3,0x9E,2,

0x83,0xD1,0x9C,2,

...

0,0,0};

 

3. SIMPLE NOTES

 

Each code starting with 0x8?, 0xa? or 0xc? is a note. You deal with

them by first replacing it with your base code but keep in mind the

less significant nibble.

 

0x83, => 0x40, (keep in mind : 3)

 

Pass the second code.

 

0xE5, => 0xE5, (keep the same)

 

Delete de most significant nibble for the third code. Put as less

significant nibble the number you keep in mind previously.

 

0x90, => 0x03, ( 0 from 90 and 3 from 83 )

 

Pass the fourth code and you have converted the first note.

 

In our example, the conversion continue :

 

0x83,0xE7,0x90,2, => 0x40,0xE7,0x03,2,

0x83,0xEC,0x96,2, => 0x40,0xEC,0x63,2,

0x83,0xF6,0x9A,2, => 0x40,0xF6,0xA3,2,

0x83,0xF5,0x9C,2, => 0x40,0xF5,0xC3,2,

0x83,0xF5,0x9E,2, => 0x40,0xF5,0xE3,2,

 

And then we have this result :

 

byte wav2cv_sound0[] = {

0x40,0xE5,0x03,2, 0x40,0xE7,0x03,2, 0x40,0xEC,0x63,2, 0x40,0xF6,0xA3,2,

0x40,0xF5,0xC3,2, 0x40,0xF5,0xE3,2, 0x9f,4, 0x83,0xA3,0x9E,2,

0x83,0xD1,0x9C,2,

...

0,0,0};

 

4. REST CODE

 

0x9f,4, is a silence (0x9f = mute) during 4 cycles.

 

Add 0x20 to your base to get the base code for silence.

 

Silence for Tone CH#1 = 0x60

Silence for Tone CH#2 = 0xA0

Silence for Tone CH#3 = 0xE0

 

Now, you need your knowledge about hexadecimal values to deal with the

number of cycles. You need to add the number of cycles into the

silence code, but you can't add more than 30 cycles into the silence

code, so if you need more than 30 cycles of silence you can use more

than one rest code.

 

0x9f,4, => 0x64,

 

5. THE FINAL 0,0,0 BECOME...

 

In our example here, we are now at the end of the sound data.

 

byte wav2cv_sound0[] = {

0x40,0xE5,0x03,2, 0x40,0xE7,0x03,2, 0x40,0xEC,0x63,2, 0x40,0xF6,0xA3,2,

0x40,0xF5,0xC3,2, 0x40,0xF5,0xE3,2, 0x64, 0x40,0xA3,0xE3,2,

0x40,0xD1,0xC3,2,

...

0,0,0};

 

The 0,0,0 code became simple a single END CODE which is 0x10 more than

the BASE CODE for the tone CHANNEL.

 

END CODE for Tone CH#1 = 0x50

END CODE for Tone CH#2 = 0x90

END CODE for Tone CH#3 = 0xD0

 

So the conversion to Coleco sound format gives this :

 

byte wav2cv_sound0[] = {

0x40,0xE5,0x03,2, 0x40,0xE7,0x03,2, 0x40,0xEC,0x63,2, 0x40,0xF6,0xA3,2,

0x40,0xF5,0xC3,2, 0x40,0xF5,0xE3,2, 0x64, 0x40,0xA3,0xE3,2,

0x40,0xD1,0xC3,2,

...

0x50};

 

6. REPEAT CODE

 

Instead of putting the END CODE, you can put a REPEAT CODE which is

the same but with 8 at the less significant nibble instead of 0.

 

REPEAT CODE for Tone CH#1 = 0x58

REPEAT CODE for Tone CH#2 = 0x98

REPEAT CODE for Tone CH#3 = 0xD8

 

7. DECLARE SOUND IN SND_TABLE

 

When converted you need to declare all your sound tables into

snd_table. Each entry in this table is associated with an AREA which

also represent the priority of your sound. Higher is the AREA number,

higher is the priority. LIB4K already set 7 AREAs, you just need to

use them as you want.

 

Warning : To setup the sound areas in RAM, Coleco uses the first entry

of snd_table as a reference for the first AREA. So, whatever the order

you declare your sound tables into snd_table, the first entry should

be associated with AREA 1, like this :

 

const sound_t snd_table[] = {

{wav2cv_sound0,SOUNDAREA1},

...

};

 

8. PLAY AND STOP SOUND.

 

To start a sound, simply use play_sound. To stop a sound, simply use

stop_sound. To force replaying a sound already playing, stop then

start the sound.

 

play_sound(1); /* Play sound wav2cv_sound0 */

stop_sound(1); /* Stop sound wav2cv_sound0 (if already playing of

course) */

 

I hope you will find this information message about conversion useful

for your projects.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...