Jump to content
IGNORED

We could really use a playmusic command for c language - hint hint


digress
 Share

Recommended Posts

such as this style for intybasic. Using sound tables is so limited.

 

 

PLAY MusicCode:

 

MusicCode:
DATA 9 : REM tempo

MUSIC F2 , C3 , G4#X, M1

MUSIC - , s , - , -

MUSIC F3 , s , G4#, M2
MUSIC C3 , s , s , -
MUSIC F2 , s , G4 , M3
MUSIC
- , s , s , -
MUSIC F3 , s , F4 , M2

  • Like 1
Link to comment
Share on other sites

I should share my progress on making a music engine for the Colecovision.

 

MusicMakerWIP.zip

 

It's basically using sound effects as a sound font. I used newcoleco's cvnotes application to get the music note code (F3,F6,C2, and etc).

const byte song2[] = {
3,4,5,6,3,4,5,6,255,10,11,12,13,14,15,255,
3,4,5,6,3,4,5,6,255,10,11,12,13,14,15,255,
4,5,6,7,4,5,6,7,255,11,12,13,14,15,16,255,
4,5,6,7,4,5,6,7,255,11,12,13,14,15,16,255,
5,6,7,8,5,6,7,8,255,12,13,14,15,16,17,255,
5,6,7,8,5,6,7,8,255,12,13,14,15,16,17,255,
6,7,8,9,6,7,8,9,255,13,14,15,16,17,18,255,
6,7,8,9,6,7,8,9,255,13,14,15,16,17,18,255,
18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,
};

void Music_Play(void){
if (position==32){play_sound(19);
play_sound(2);}
if (position==64){play_sound(20);}
if (position==96){play_sound(21);}
if(position==128){play_sound(22);play_sound(23);}

a=song2[position];
if (a==255){goto sustain;}
play_sound(a+b);
sustain:
position++;
if (position==144){position=0;
if (b==37){b=0;goto audher;}
//if (b==51){b=37;}
if (b==21){b=37;}
if (b==0){b=21;}
audher:}}

The number tables is the music. There's a wildcard, 255 to sustain the note.
playsound(a+b)
a is extracted from a=song2[position]; +b is added to get soundeffect number. Like 3+21 will playsound(24);

game=1;
while (game==1){
if(tempo==0){Music_Play();tempo=8;}
tempo--;
delay(1);
}

In the game or nmi{} loop. One thing I'm not to sure if the drum beat will keep sync during NMI{} or you'll might have to stop the music player before going into disable_nmi(). This is still a work in progress. It did work in RockCutter though. Although I may not find more space for Rockcutter to add the music player and it notes back in unless I figured out how to convert this game to a Megacart game.

 

One draw back, there's a limit to about 60-62 sounds in a table. The programmer manual saying something play_sound(63) is a special number or something. It won't play or cut off the sound above 60.

Edited by Kiwi
  • Like 1
Link to comment
Share on other sites

Yep That's exactly what I did in Mr Turtle. Same problem though being limited to 62 predefined notes was not quite enough for the 3 separate voices and their full range of note values.

 

 

I should share my progress on making a music engine for the Colecovision.

 

attachicon.gifMusicMakerWIP.zip

 

It's basically using sound effects as a sound font. I used newcoleco's cvnotes application to get the music note code (F3,F6,C2, and etc).

const byte song2[] = {
3,4,5,6,3,4,5,6,255,10,11,12,13,14,15,255,
3,4,5,6,3,4,5,6,255,10,11,12,13,14,15,255,
4,5,6,7,4,5,6,7,255,11,12,13,14,15,16,255,
4,5,6,7,4,5,6,7,255,11,12,13,14,15,16,255,
5,6,7,8,5,6,7,8,255,12,13,14,15,16,17,255,
5,6,7,8,5,6,7,8,255,12,13,14,15,16,17,255,
6,7,8,9,6,7,8,9,255,13,14,15,16,17,18,255,
6,7,8,9,6,7,8,9,255,13,14,15,16,17,18,255,
18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,
};

void Music_Play(void){
if (position==32){play_sound(19);
play_sound(2);}
if (position==64){play_sound(20);}
if (position==96){play_sound(21);}
if(position==128){play_sound(22);play_sound(23);}

a=song2[position];
if (a==255){goto sustain;}
play_sound(a+b);
sustain:
position++;
if (position==144){position=0;
if (b==37){b=0;goto audher;}
//if (b==51){b=37;}
if (b==21){b=37;}
if (b==0){b=21;}
audher:}}

The number tables is the music. There's a wildcard, 255 to sustain the note.
playsound(a+b)
a is extracted from a=song2[position]; +b is added to get soundeffect number. Like 3+21 will playsound(24);

game=1;
while (game==1){
if(tempo==0){Music_Play();tempo=8;}
tempo--;
delay(1);
}

In the game or nmi{} loop. One thing I'm not to sure if the drum beat will keep sync during NMI{} or you'll might have to stop the music player before going into disable_nmi(). This is still a work in progress. It did work in RockCutter though. Although I may not find more space for Rockcutter to add the music player and it notes back in unless I figured out how to convert this game to a Megacart game.

 

One draw back, there's a limit to about 60-62 sounds in a table. The programmer manual saying something play_sound(63) is a special number or something. It won't play or cut off the sound above 60.

  • Like 1
Link to comment
Share on other sites

The amount of data to make the table currently is enourmous and limited to 62 sounds.

 

If we could with 1 data line play music,

voice1 c4

voice2 c5

voice3 e4 and even optionally the noise channel combined with the 3rd channel d1 d2 or something

 

every line would have the same note length once you call it it doesn't rely on a data table being in bank as it's only called when you want it to look up the next 3 notes.

 

I'm lookling at the c++ libraries code but assembler is still mostly beyond me.

 

There is also a large library of tandy 1000/ibm pcjr basic music done in 3 voices already which would become easy to reuse.

Link to comment
Share on other sites

If you have Ghostblaster source code, then you could see how newcoleco does his music in his umusic.s. I believe the sound data is a track with an end or a repeat, when the counter get to a specific number, then it play the next track. Music tend have a lot of loops. That's another method of compression, keeping the music quality high and using coleco's sound engine.

 

http://www.theadamresource.com/programs/

Link to comment
Share on other sites

I had done quickly a little music composition tool . It is still really basic but allowed a friend that is just musician and not developper to compose musics for me.

 

The idea is to create music pattern, then you assemble pattern to build a Melodie.

 

Then the tool generate directly ASM code compatible with Daniel Bienvenu Kit and Colecovision music Bios format.

 

You just have to copy and paste the ASM code in a Music.s file (that you can copie with CCI2 from Daniel Kit)

 

Finally you can play the music in C , like that :

#include <coleco.h>
#include <getput1.h>

/* from music.s */
extern const void Melodie[];

/* from sound.s */
extern const void snd_table[];

void main(void)
{

set_snd_table(snd_table);

enable_nmi();

play_music(Melodie);

while(1);


}

void nmi(void)
{
update_music();
}

If you want try the tool , you can download it from here .

 

It runs under windows uniquely. and sorry it is only in French. For now i does not manage noise channel and effect , it will come later if i can find some time.

 

Link to comment
Share on other sites

I'm also using tursi's vgm routines but I was looking into alternative methods as well to see what might work best for me.

 

some good ideas here from everyone. I'll look over them.

 

The problem I kept running into was inefficient reuse of long form sound code:

 

so instead of something simple like c4,c4,d4,e4,f4,f4 which would only be potential 6 bytes

 

you have 6 bytes per note or 6 times the amount of data

 

my solution was a lookup table the same was kiwi did. Which worked great but there isn't sounds available.

 

 

so ex from daniels birthday demo

>>

/* HAPPY BIRTHDAY SONG : TONE CHANNEL 1 */
static const byte music_hb1[] = {
0x42,0x1d,0x01,0x10,0x18,0x42, // tone freq 392,5Hz - vol 15 (max) swept down - lengt 16
0x42,0x1d,0x01,0x10,0x18,0x42, // tone freq 392,5Hz - vol 15 (max) swept down - lengt 16
0x42,0xfe,0x00,0x20,0x18,0x42, // tone freq 440,4Hz - vol 15 (max) swept down - lengt 32
0x42,0x1d,0x01,0x20,0x18,0x42, // tone freq 392,5Hz - vol 15 (max) swept down - lengt 32
0x42,0xd5,0x00,0x20,0x18,0x42, // tone freq 525,2Hz - vol 15 (max) swept down - lengt 32
0x42,0xe2,0x00,0x20,0x18,0x42, // tone freq 495,0Hz - vol 15 (max) swept down - lengt 32

Are you aware of the facilities in libcvu and of abc2cvm? See

http://colecovision.eu/ColecoVision/development/tutorial2.shtml

Another example from a libcvu demo is attached.

 

Philipp

 

 

If you have Ghostblaster source code, then you could see how newcoleco does his music in his umusic.s. I believe the sound data is a track with an end or a repeat, when the counter get to a specific number, then it play the next track. Music tend have a lot of loops. That's another method of compression, keeping the music quality high and using coleco's sound engine.

 

http://www.theadamresource.com/programs/

 

I had done quickly a little music composition tool . It is still really basic but allowed a friend that is just musician and not developper to compose musics for me.

 

The idea is to create music pattern, then you assemble pattern to build a Melodie.

 

Then the tool generate directly ASM code compatible with Daniel Bienvenu Kit and Colecovision music Bios format.

 

You just have to copy and paste the ASM code in a Music.s file (that you can copie with CCI2 from Daniel Kit)

 

Finally you can play the music in C , like that :

#include <coleco.h>
#include <getput1.h>

/* from music.s */
extern const void Melodie[];

/* from sound.s */
extern const void snd_table[];

void main(void)
{

set_snd_table(snd_table);

enable_nmi();

play_music(Melodie);

while(1);


}

void nmi(void)
{
update_music();
}

If you want try the tool , you can download it from here .

 

It runs under windows uniquely. and sorry it is only in French. For now i does not manage noise channel and effect , it will come later if i can find some time.

 

Link to comment
Share on other sites

That is so cool. I just tried it out very nice music tool. Now make it import vgm or midi next.

 

I had done quickly a little music composition tool . It is still really basic but allowed a friend that is just musician and not developper to compose musics for me.

 

The idea is to create music pattern, then you assemble pattern to build a Melodie.

 

Then the tool generate directly ASM code compatible with Daniel Bienvenu Kit and Colecovision music Bios format.

 

You just have to copy and paste the ASM code in a Music.s file (that you can copie with CCI2 from Daniel Kit)

 

Finally you can play the music in C , like that :

#include <coleco.h>
#include <getput1.h>

/* from music.s */
extern const void Melodie[];

/* from sound.s */
extern const void snd_table[];

void main(void)
{

set_snd_table(snd_table);

enable_nmi();

play_music(Melodie);

while(1);


}

void nmi(void)
{
update_music();
}

If you want try the tool , you can download it from here .

 

It runs under windows uniquely. and sorry it is only in French. For now i does not manage noise channel and effect , it will come later if i can find some time.

 

Link to comment
Share on other sites

That is so cool. I just tried it out very nice music tool. Now make it import vgm or midi next.

 

thanks.

 

I don't plan such of import feature. At least it is not my priority. however It already export to VGM , but not import.

 

I want add the noise channel , and a kind of "instrument" library and few effects.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

my humble idea was more about using trackers like VortexTracker (runs fine on Wine (a native GNU/Linux is to be released as soon Lazarus can compile its sources), and the default file format is a txt), and generate a file like vgm (a more, or far more, optimized version - my idea for now is to replace “redundancy” from "0x61 nn nn" and "0x7n" into 0x62 or 0x63 - a sequence of bytes would be read and played until getting 0x62 or 0x63 and wait for video-blank ) to be embedded in the source somehow (included as binary instead of code) - and considering multiplatform development purposes as well (like being able to output to AY-3-8910 or other chips)

Edited by nitrofurano
Link to comment
Share on other sites

thanks.

 

I don't plan such of import feature. At least it is not my priority. however It already export to VGM , but not import.

 

I want add the noise channel , and a kind of "instrument" library and few effects.

 

i think that importing vgm isn’t that difficult - weeks ago i started coding a vgm-to-vortextracker converter, and it worked mostly fine - http://vgmrips.net/forum/viewtopic.php?f=15&t=2335&p=7305#p7305(some few converts got wrong tempo/synchronization that i’m still struggling why that happens)

 

converting from SN76489 or AY-3-8910 seems easier (3 channels, 10 or 12 bits of frequency, 4 bits volume), and i’m struggling on the NES/GameBoy chips (they seems similar to SN and AY somehow) - now i'm trying to improve a converter from K051649 (konami-scc) to a “kind” of ascii version of .mod/.xm (i’m focusing MilkyTracker for now), and i’m interested on Yamaha YM chips as well

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

  • Recently Browsing   0 members

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