Jump to content
IGNORED

Sound format for Start_sound?


youki

Recommended Posts

Hello,

 

This is my first post on that forums.

 

I started to develop a new game for Colecovision. It is the first game i write on this console.

 

for now , I use the HighTech C and the Starter kit done by newcoleco.

 

Until now i used sound example i found around the web. But i want try to compose my own music. And if needed develop a Windows tool to make it.

 

I have studied the sound chip documentation. I had understood the basis.

 

But i didn't find documentation of the specific format of data to give to Start_sound function. (it seems it is different from the format used by the Coleco's BIOS routines)

 

static byte shoot_sound[]=

{

1,0xf8,0xe4, 1,0xf2, 1,0xe4, 1,0x63,0x02,0x01,0xe5,

1,0xe4, 1,0xe5, 1,0xe4, 1,0xe5, 1,0xe4, 1,0xe5, 1,0xe4, 5,

0,0,0

};

 

The only information i found is that the sound should finish by 0,0,0 ... not enough to create my own sound track! :)

 

 

BTW, i have also use newcoleco's tool Wav2cv ,that's a great tool for short Sound effect , but for the kind of music i want do it is not appropriate.

 

Another thing. Is there a tool to convert MIDI music to Coleco sound ? (i found the opposite Coleco to Midi)

 

thanks a lot for your help.

 

Youki

Link to comment
Share on other sites

  • 2 weeks later...
Another thing. Is there a tool to convert MIDI music to Coleco sound ? (i found the opposite Coleco to Midi)

 

Well, using midi2abc and abc2cvm works for simple midi files, however it will generate output for use with my libraries (which work with sdcc not HITECH-C). Some of the music in Schlange CV hase been done that way.

 

Philipp

Link to comment
Share on other sites

Another thing. Is there a tool to convert MIDI music to Coleco sound ? (i found the opposite Coleco to Midi)

 

Well, using midi2abc and abc2cvm works for simple midi files, however it will generate output for use with my libraries (which work with sdcc not HITECH-C). Some of the music in Schlange CV hase been done that way.

 

Philipp

 

Thanks for your anwser. I will look for these tools.

 

Could you give me detail on the format used by your libraries? I think i could convert it to a format i can use.

Link to comment
Share on other sites

Another thing. Is there a tool to convert MIDI music to Coleco sound ? (i found the opposite Coleco to Midi)

 

Well, using midi2abc and abc2cvm works for simple midi files, however it will generate output for use with my libraries (which work with sdcc not HITECH-C). Some of the music in Schlange CV hase been done that way.

 

Philipp

 

Thanks for your anwser. I will look for these tools.

 

Could you give me detail on the format used by your libraries? I think i could convert it to a format i can use.

 

It's a rather primitive format, which I intend to replace by a better one one day, but that probably won't happen this year.

 

Music is just arrays array of 16 bit values, each value is one note. You need an array for every sound channel you use.

 

The special value 0xffff marks the end of the music.

Let bit 0 be the least significant bit in the 16 bit value, bit 15 the most significant one.

Let [n,m] be the m-n+1 - bit integer consisting of bits n, n + 1, ... , m.

 

[0, 1] is the loudness, where the default value of 2 stands for mezzo forte, 3 for forte, 1 for mezzo piano, 0 for piano.

[2, 3] is the note length, where 1 is 25% (staccato), 2 is 50% (unsused), 3 is 75% (default), 0 is 100% (legate or ties).

[4, 7] is the note length, where 1 is a 1/16 note, 2 is a 1/8 note, etc, with 0 being a 1/1 note.

[8, 11] is the halftone (C is 0, C# is 1, D is 2, etc); the special value 0xf stands for a pause.

[12, 15] is the octave.

 

I suppose you probably could just use the music playing functions from libcvu and replace the calls to cv_set_frequency() and cv_set_attenuation() with whatever Daniel's library uses to set frequency and attenuation of tone generators. They're written in standard C so they will probably compile with HITECH-C with just some minor changes.

 

Philipp

Link to comment
Share on other sites

Thanks a lot for all these helpful information.

 

I'm going to toy with all ABC tools i have found and have a look to your a library too.

 

A last question , would you know if there is somewhere a repository where i can find some set of already made ABC music? (video game music , i have already found others)

Edited by youki
Link to comment
Share on other sites

A last question , would you know if there is somewhere a repository where i can find some set of already made ABC music? (video game music , i have already found others)

 

No. I haven't looked for something like that though, since I mostly use classic music for my games.

 

Philipp

Link to comment
Share on other sites

Hello Youki,

 

If you refer to the actual Hi-Tech C kit, not one from 2005 and before, then you should know that the sound format is different.

 

Marcel de Kogel did the first version of the Coleco library with his sprites and sounds format and routines. To get more closer to ColecoVision developments the actual kit based on Coleco BIOS routines do not use the Marcel's sound format you are talking about that ends with 0,0,0.

 

Anyway, I can explain both sound formats right now... at least the basic knowledge about them.

 

ABOUT MARCEL'S COLECO SOUND FORMAT

The very first code is 0 or 1, which 0 is a melodic sound (tone channels), and 1 is a noisy sound (noise channel).

-----

0 = "Jump to"

The next 2 bytes is the address of where the sound data continue.

The null address which is represented as two bytes equal to zero "0,0", is the code for "END OF SOUND DATA".

------

1 to 63 (01 - 3F) = "Duration"

This leave the actual sound "as is" during this number (from 1 to 63) of cycles.

To do a more longer duration of nothing new, you simply have to add more delay codes.

------

64 to 79 (40 - 4F) = "Frequency sweep"

The next 2 bytes is for speed (delay) and variation (decrementation).

If speed is 1, then every cycle will result into a change of frequency.

If frequency decrementation is between 1 (01) to 127 (7f), it results into a sound sliding to lower frenquencies

If frequency decrementation is between -1 (FF) to -128 (80), it results into a sound sliding to higher frenquencies

If speed or variation(decrementation) equal zero, then there is no effect.

------

96 to 111 (60-6F) = "Volume sweep"

The next 2 bytes is for speed (delay) and decrementaiton.

If speed is 1, then every cycle will result into a change of frequency. Speed can't be 0.

If volume decrementation is between 1 (01) to 15 (0F), it results into a volume sliding down

If volume decrementation is between -1 (FF) to -15 (F1), it results into a volume sliding up

If speed or variation(decrementation) equal zero, then there is no effect.

Any other volume decrementation is valid but not logic.

------

128 to 143 (80-8F) = TONE CHANNEL FREQUENCY

The next 1 byte is to complete the frequency code.

For this kind of data, you should consider to code into hexadecimal to be more visual for you.

For example, the code 81 AB results into the sound code 1AB which is a medium C note.

For example, the code 83 56 results into the sound code 356 which is a one octave lower C note than 1AB.

A full table of these sound codes are in the documentations already.

-----

144 to 159 (90-9F) = TONE CHANNEL VOLUME

This code alone is the attenuation, the volume. zero attenuation is volume at max, max attenuation is mute.

-----

224 to 226 (E0-E2) = NOISE CHANNEL FREQ

Periodic noise sound, like a buzz. E0 is lower in frequency than E1, and same thing between E1 and E2.

227 (E3)

Periodic sound based on frequency of tone channel 3, which is almost impossible to get work properly within Marcel's sound format.

228 to 230 (E4-E6)

White noise sound, like a no tv signal. E4 is lower in frequency than E5, and same thing between E5 and E6.

Explosion of bug objects are usually with E4, and explosion of small objects or a gun shooting sound is more E5 or E6.

231 (E7)

White noise sound based on freqeuncy of tone channel 3, which is almost impossible to get work preoperly within Marcel's sound format.

-----

240 to 255 (F0-FF) = NOISE CHANNEL VOLUME

This code alone is the attenuation, the volume. zero attenuation is volume at max, max attenuation is mute.

Link to comment
Share on other sites

ABOUT COLECO BIOS SOUND FORMAT

For more details, go see : ColecoVision Coding Guide

The following information is the sound data format to be used in the songs encoded in real coleco games.

 

ATTENUATION = REVERSE OF VOLUME (HIGH ATTENUATION EQUAL LOW VOLUME), 15 (F) = MUTE

PERIOD = REVERSE OF FREQUENCY (HIGH PERIOD EQUAL LOW FREQUENCY)

CHANNEL = 00 is NOISE, 01 is TONE#1, 02 is TONE#2, 03 is TONE#3

NOISE "FREQUENCY" is encoded as a 3 bits value, see NOISE RENDERING from technical sound chip specification.

 

Please remark that because the noise channel is different than a tone channel, it needs a different data structure.

 

 

REST (no sound)

 

1 byte : channel + 1 + length (duration up to 31, up to 30 only if channel is 3 (11) )

 

For example, no sound for channel tone 2 during 5 cycles is encoded as 1 byte : 10100101 = 165 (A5)

 

Expert note : In some occasions, it's better to use a single a muted freq sweep code than multiple rest codes.

 

 

SIMPLE NOTE (TONE ONLY)

 

1st byte : Channel # + 000000

2nd byte : low-part period code (8 bits)

3rd byte : Attenuation (4 bits) + 00 + high-part period code (2 bits)

4th byte : Duration (length 1 to 255, 0 = 256)

 

For example, a loud medium C note during 40 cycles at tone channel 1 is encoded as :

01000000 = 64 (40)

10101011 = 171 (AB)

00000001 = 1 (01)

00101000 = 40 (28)

 

 

SIMPLE NOISE

 

1st byte : 00 (noise) + 000010

2nd byte : null

3rd byte : Attenuation (4 bits) + 0 + FB + NF1 + NF2

4th byte : Duration (length 1 to 255, 0 = 256)

 

For a short (6 cycles) loud white noise somehow like a gun shoot, it's encoded like this :

00000010 = 2 (02)

00000000 = 0 (00)

00000101 = 5 (05)

00000110 = 6 (06)

 

For the rest of the explanation of this format I really suggest you to refer to the ColecoVision Coding Guide.

Link to comment
Share on other sites

NOTES CONVERSION (FREQ => DATA)

 

	A : 110.00hz = 3F8, 220.00hz = 1FC, 440.00hz = 0FE, 880.00hz = 07F, 1760.0hz = 03F

A#/Bb : 116.54hz = 3BF, 233.08hz = 1DF, 466.16hz = 0EF, 932.33hz = 077, 1864.6hz = 03B

B : 123.47hz = 389, 246.94hz = 1C4, 493.88hz = 0E2, 987.77hz = 071, 1975.5hz = 038

C : 130.81hz = 356, 261.63hz = 1AB, 523.25hz = 0D5, 1046.5hz = 06A, 2093.0hz = 035

C#/Db : 138.59hz = 327, 277.18hz = 193, 554.36hz = 0C9, 1108.7hz = 064, 2217.5hz = 032

D : 146.83hz = 2F9, 293.66hz = 17C, 587.33hz = 0BE, 1174.7hz = 05F, 2349.3hz = 02F

D#/Eb : 155.56hz = 2CE, 311.13hz = 167, 622.25hz = 0B3, 1244.5hz = 059, 2489.0hz = 02C

E : 164.81hz = 2A6, 329.63hz = 153, 659.25hz = 0A9, 1318.5hz = 054, 2637.0hz = 02A

F : 174.61hz = 280, 349.23hz = 140, 698.46hz = 0A0, 1396.9hz = 050, 2793.8hz = 028

F#/Gb : 185.00hz = 25C, 370.00hz = 12E, 739.99hz = 097, 1480.0hz = 04B, 2960.0hz = 025

G : 196.00hz = 23A, 391.99hz = 11D, 783.99hz = 08E, 1568.0hz = 047, 3136.0hz = 023

G#/Ab : 207.65hz = 21A, 415.30hz = 10D, 830.61hz = 086, 1661.2hz = 043, 3322.4hz = 021

Link to comment
Share on other sites

If you know how works the real ColecoVision sound initialization and encoding, you can them detect and extract sound data from actual commercial roms, which is something I did for my web application OS7 SOUND BANK. (Side note : the name OS7 can be translated as OS version 7, which is the version of the ColecoVision BIOS we all use; and in previous versions, they did put the tables for their routines at the begginning of the RAM so when they decided to place them at the end instead, they forgot to migrate the sound tables which is why the memory section started at 7020-... is for the sounds when all the other tables like those for the joystick are at the end (after 7300).

 

I still have this tool to extract sound data from commercial Coleco games, however you can't use it on every commercial games and you have to know how the sound is encoded and how noise and tone channel 3 sometimes works together to make these group of sound data as blocks to be played all togheter. Parker Brothers did not use Coleco BIOS for sounds so it's impossible to get sound data from their games with my tool. Also, some sound data did use the special code that refer to a code in ROM to be the sound renderer for thi sparticular sound like the random beep-beep-beep of Commander Space Fury talking at the end of the game. So, even if I give you the software to extract sound data, you may not be able to use it, or know how to use it.

 

And when I was working with Marcel's sound format, I did a midi to Coleco converter that did help me a few times for some demo and games. For those who did play DACMAN or JEEPERS CREEPERS ending, you did hear the music converted from a midi file I did find convertable with my tool and simply use it, I didn't know the origine of the music of this midi file before. Anyway, after that, I did program my own music by hand, encoding each note one by one, it takes time but I have better optimization that way.

Edited by newcoleco
Link to comment
Share on other sites

Billions of thanks Daniel!!!

 

That's exactly the kind of information i was looking for.

 

And when I was working with Marcel's sound format, I did a midi to Coleco converter that did help me a few times for some demo and games. For those who did play DACMAN or JEEPERS CREEPERS ending, you did hear the music converted from a midi file I did find convertable with my tool and simply use it, I didn't know the origine of the music of this midi file before. Anyway, after that, I did program my own music by hand, encoding each note one by one, it takes time but I have better optimization that way.

 

Would it be possible you provide me the tool you used to convert Midi to Marcel's sound format?

 

At then end, i think i will code also my own routine , but in a first time i want try to see what i can obtain by converting existing mid.

 

did you made a tool to program your own music "by hand"? a Kind of Coleco Sound tracker ?

Link to comment
Share on other sites

Well, I may find back the midi converter I did in the past, back from year 2000. It's a DOS only application, do you think you can use it?

 

Are you sure you are using Marcel's sound library? As far as I remember, you downloaded my kit only this year, which is most probable to be Coleco BIOS sound format.

 

And coding sound by hand is exactly what it means, taking a pencil and figure out every single code for every single note, checking one by one in the table of NOTES and how to encode them properly. no software at all.

Edited by newcoleco
Link to comment
Share on other sites

Well, I may find back the midi converter I did in the past, back from year 2000. It's a DOS only application, do you think you can use it?

 

Are you sure you are using Marcel's sound library? As far as I remember, you downloaded my kit only this year, which is most probable to be Coleco BIOS sound format.

 

And coding sound by hand is exactly what it means, taking a pencil and figure out every single code for every single note, checking one by one in the table of NOTES and how to encode them properly. no software at all.

 

Yes, i can use a DOS application , no problem. And if you provide source code i could even port it to windows with a nice GUI ,if you need it.

 

Honestly i'm not sure what library i'm using , concerning sound i based my code on example i found at diverse location. I know i used your tool that converted wav to coleco for the music (to test, but the result is not good for the kind of music i use) , and for shoot and other effecst i use sound that finish by 0,0,0.

 

As function, i use Start_sound and update_sound in the NMI.

 

I think it is Marcel's function?

 

For now, i'm more concentrated on doing graphics, level and gameplay. So i didn't dig really in sound , but for my project the sound track is very important so i will have.

Link to comment
Share on other sites

  • 2 weeks later...

I didn't find yet my application to deal with midi files. Even if I find back the application, there is a possiblity that I will not find back the source code.

 

And about the sound format...

 

start_sound is for Marcel's sound format, play_sound is for Coleco sound format... it's the way I did program my kit. heck my other message about conversion from marcel to coleco sound format, it may be useful for you if you want to use the new kit I'm developing with SDCC and LIB4K.

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...