Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - SMS Music

Reply to topic
Author Message
Eric
  • Guest
Reply with quote
SMS Music
Post Posted: Thu Jul 22, 1999 6:00 pm
Inspired by yesterday's postings on how to implement music in SMS games, I have started to write up a sample program to play "Mary had a Little Lamb" an SMS emulators.

As part of this project, I have been researching musical note frequencies and have started writing up a table of the 10-bit PSG-port frequency values necessary to generate each note. These values are based on the formula provided in Richard Talbot-Watkins' "SEGA MASTER SYSTEM TECHNICAL INFORMATION" document (10th June 1998)" document. He indicates the frequency of notes generated by the PSG is determined by this forumula: 125000/hhhhhhllllll where "hhhhhhllll" is the 10-bit value written to the PSG port. Once it is completed, I will be donating the table of values to this web-site for anyone interested to include in their SMS programs.

Regarding the program itself, I have written code that reads music data from a table and plays each note for the duration specified. However, I was unable to synchronize this with the VBlank interrupt. Consequently. the duration is based on arbitrary timing delays (spin-loops) as opposed to the real-time VBlank interrupt. I suspect the problem is that the VBlank interrupts are not being generated properly. I am currently looking into the problem.

Once the program is fully working (using VBlanks to synchronize) I will donate the entire source to anyone interested.

Eric
 
Nyef
  • Guest
Reply with quote
Post Posted: Thu Jul 22, 1999 7:44 pm
Quote
> Inspired by yesterday's postings on how to implement music in SMS games, I have started to write up a sample program to play "Mary had a Little Lamb" an SMS emulators.

"Oh boy, I've always wanted one of those!". Well, maybe not, but it is a cool project. :-)

Quote
> As part of this project, I have been researching musical note frequencies and have started writing up a table of the 10-bit PSG-port frequency values necessary to generate each note. These values are based on the formula provided in Richard Talbot-Watkins' "SEGA MASTER SYSTEM TECHNICAL INFORMATION" document (10th June 1998)" document. He indicates the frequency of notes generated by the PSG is determined by this forumula: 125000/hhhhhhllllll where "hhhhhhllll" is the 10-bit value written to the PSG port. Once it is completed, I will be donating the table of values to this web-site for anyone interested to include in their SMS programs.

This 125KHz value has been bugging me for some time now. It just doesn't feel right (given that the only XTAL on the SMS board is for the NTSC color subcarrier (which I don't remember offhand, but I do know is specified to 6-7 decimal places). Can anyone provide a "better" value? Preferably close to this 125KHz value, but also one that divides XTAL1 evenly?

Quote
> Regarding the program itself, I have written code that reads music data from a table and plays each note for the duration specified. However, I was unable to synchronize this with the VBlank interrupt. Consequently. the duration is based on arbitrary timing delays (spin-loops) as opposed to the real-time VBlank interrupt. I suspect the problem is that the VBlank interrupts are not being generated properly. I am currently looking into the problem.

Obvious questions: Did you enable them? Did you put your interrupt handler in the right place (0x66 IIRC)? :-)

Quote
> Once the program is fully working (using VBlanks to synchronize) I will donate the entire source to anyone interested.

That's nice to hear. Now if some more emulator authors did that, we'd be all set. :-)

Quote
> Eric

--Nyef
 
Chris
  • Guest
Reply with quote
Post Posted: Thu Jul 22, 1999 7:57 pm
Marry Had A Little Lamb? You gotta be kidding me here. Why that song? If you're going to mess
around with SMS sound, you may as well go all the way. If you want, I could send you a copy of
the music from Super Castlevania 4 in midi format. It's the music that's played when you enter
your name or the password. The song was easy to convert because there are only 3 melodic
tracks and 3 echo tracks. Take away the echo tracks and it sounds just as good. The original
tracks were in reed organ, flute, and some kind of horn. All I did was change the patches
to square wave and erased the 3 echo tracks and presto, you're left with 3 channel SMS
sound! I could mail you a copy of a bunch of songs made by me (original) or video
game music converted to SMS.

I wish I could do the music for great basketball! The in-game music has great transition
and a nice melody.

Chris :o)
 
Nyef
  • Guest
Reply with quote
Post Posted: Thu Jul 22, 1999 8:21 pm
Quote
> Marry Had A Little Lamb? You gotta be kidding me here. Why that song? If you're going to mess
> around with SMS sound, you may as well go all the way. If you want, I could send you a copy of
> the music from Super Castlevania 4 in midi format. It's the music that's played when you enter
> your name or the password. The song was easy to convert because there are only 3 melodic
> tracks and 3 echo tracks. Take away the echo tracks and it sounds just as good. The original
> tracks were in reed organ, flute, and some kind of horn. All I did was change the patches
> to square wave and erased the 3 echo tracks and presto, you're left with 3 channel SMS
> sound! I could mail you a copy of a bunch of songs made by me (original) or video
> game music converted to SMS.

Chris, have you actually managed to write an SMS sound routine that works? If so, did you start by trying to get all four sound channels running at once, or did you just try to get one channel running first, and work from there?

I think a single-voice song is perfect to start with. It would certainly be easier to get running properly, and as most programmers know, running code is one of the best motivators.

And there are far worse songs than "Mary had a little lamb". Most christmass carols come to mind... :-)

That said, if I did an SMS sound project, it'd probably be a 4-voice version of "Greensleeves". :-)

Quote
> I wish I could do the music for great basketball! The in-game music has great transition
> and a nice melody.

One wonders if someone should propose an SSF format similar to the NSF format. Possibly with FM support as well as PSG support.

Quote
> Chris :o)

--Nyef
 
Eric
  • Guest
Reply with quote
Post Posted: Thu Jul 22, 1999 11:05 pm
Quote
> Obvious questions: Did you enable them? Did you put your interrupt handler in the right place (0x66 IIRC)? :-)

Well, I set the VSync (or whatever it's called) bit (Bit 5) in VDP Register 1. I did not touch any other VDP regs. I'm sure I've made some stupid mistake which is causing the interrupts not to work, but it was late last night and I didn't look into to too much. I'll examine it closer tonight. I'm sure the problem is nothing serious.

As far as the handler address, I put it at 0x0038. It is my understanding that 0x0066 is for non-maskable interrupts (NMI's). As far as I know, the pause button is the only thing that generates NMIs. I believe VBlank is a normal interrupt, therefore it's handler should be at 0x0038. Please correct me if I'm wrong.

Regarding "Mary Had a Little Lamb":

I chose it for 4 reasons:

1.) I know how to play it
2.) All notes are in one octave
3.) All notes are roughly the same duration.
4.) It's short.

Once its working it's a (relatively) simple task to re-write the data table in order to play another song.

Eric
 
Eric
  • Guest
Reply with quote
SSF
Post Posted: Thu Jul 22, 1999 11:30 pm
Quote
> One wonders if someone should propose an SSF format similar to the NSF format. Possibly with FM support as well as PSG support.

I propose we (the faithful readers of this message-board) develop a SSF format.

I would be happy to contribute anything I can, although I know very little about NSF or MIDI or computer music in general. However, I do have a musical background and, as mentioned in my previous post, I've been playing around with the SMS's music capabilites.

My first contribution is that whatever the format, we should have the ability to use the SSF file not just for playing/capturing SMS/GG music but as the standard music resource for use in our own SMS programs. Basically, a SSF file should have the ability to be "linked" directly into our SMS program source code with very little modification. While we're developing the SSF format we can also be developing a function library to easily use the SSF file information.

If any one is interested, please respond, and we can start getting this thing organized. Perhaps if there's enough interest, we can persuade Zoop to help out and implement support for SSF in future versions of Meka.

Eric
 
Chris
  • Guest
Reply with quote
MIDI Help
Post Posted: Fri Jul 23, 1999 12:09 am
If you need any help with midi programming or anything just ask me. I can't wait to finish typing up
my video game midi music page so you and everyone else can hear my converted songs. I think
their really good.

Chris :o)
 
Nyef
  • Guest
Reply with quote
Re: SSF
Post Posted: Fri Jul 23, 1999 2:48 am
Quote
> > One wonders if someone should propose an SSF format similar to the NSF format. Possibly with FM support as well as PSG support.

> I propose we (the faithful readers of this message-board) develop a SSF format.

Oh goody. I've always wanted one of those. :-)

Quote
> I would be happy to contribute anything I can, although I know very little about NSF or MIDI or computer music in general. However, I do have a musical background and, as mentioned in my previous post, I've been playing around with the SMS's music capabilites.

The NSF format is actually code ripped from NES roms with a special header. An NSF player is a stripped down NES emulator that only handles sound and VBlank interrupts.

Quote
> My first contribution is that whatever the format, we should have the ability to use the SSF file not just for playing/capturing SMS/GG music but as the standard music resource for use in our own SMS programs. Basically, a SSF file should have the ability to be "linked" directly into our SMS program source code with very little modification. While we're developing the SSF format we can also be developing a function library to easily use the SSF file information.

I was actually thinking of having a "Tracker" that would have a playing routine in both SSF and source code form, and a reasonably universal data format. That way an SSF file might not be includable in our programs, but if we wrote our own music, we could include that.

I suppose you could include music from other games in your own. Especially if we design an easy to use format. :-)

I was also thinking that it might be a good idea to write a library of "functional modules" or similar for, say, displaying intro screens or a scrolling overhead map or a menu system of somesuch. If we get enough modules, we could knock off a number of games in fairly short order. :-)

Quote
> If any one is interested, please respond, and we can start getting this thing organized. Perhaps if there's enough interest, we can persuade Zoop to help out and implement support for SSF in future versions of Meka.

With one of those neat visualization things? Please? :-)

Quote
> Eric

--Nyef
 
Nyef
  • Guest
Reply with quote
Post Posted: Fri Jul 23, 1999 2:55 am
Quote
> > Obvious questions: Did you enable them? Did you put your interrupt handler in the right place (0x66 IIRC)? :-)

> Well, I set the VSync (or whatever it's called) bit (Bit 5) in VDP Register 1. I did not touch any other VDP regs. I'm sure I've made some stupid mistake which is causing the interrupts not to work, but it was late last night and I didn't look into to too much. I'll examine it closer tonight. I'm sure the problem is nothing serious.

It may require that graphics be enabled, but I doubt it.

Quote
> As far as the handler address, I put it at 0x0038. It is my understanding that 0x0066 is for non-maskable interrupts (NMI's). As far as I know, the pause button is the only thing that generates NMIs. I believe VBlank is a normal interrupt, therefore it's handler should be at 0x0038. Please correct me if I'm wrong.

My mistake, it is indeed an "RST 38h" instruction for IRQs (did you remember to set the interrupt mode? Did you remember to enable interrupts on the CPU side?).

Quote
> Regarding "Mary Had a Little Lamb":

To get Chris to shut up, I assume? :-)

Quote
> I chose it for 4 reasons:

> 1.) I know how to play it

Always a plus.

Quote
> 2.) All notes are in one octave
> 3.) All notes are roughly the same duration.

These don't hurt, either.

Quote
> 4.) It's short.

I can't complain about that, either. :-)

Quote
> Once its working it's a (relatively) simple task to re-write the data table in order to play another song.

Which is what I've been saying. Too bad some people don't seem to understand this. :-)

Quote
> Eric

--Nyef
 
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Post Posted: Fri Jul 23, 1999 5:09 pm

Quote
> Regarding "Mary Had a Little Lamb":

Damnit! Why not "Fade to Black" by Metallica, or "Eulogy" by Tool?
I'm joking, alright?

Quote
> I chose it for 4 reasons:

> 1.) I know how to play it
> 2.) All notes are in one octave
> 3.) All notes are roughly the same duration.
> 4.) It's short.

> Once its working it's a (relatively) simple task to re-write the data table in order to play another song.

Yeah, man! And then somebody could write a frontend for it or something to convert some notes on a stave into the appropriate data-table thingy whatsit. Yeah. Cool. I'm always on the lookout for new ways to write my music, and this sounds rather cool!

Quote
> Eric
  View user's profile Send private message
  • Joined: 12 Jul 1999
  • Posts: 891
Reply with quote
Oh, my God! That sounded so blond!!!!!! *nt*
Post Posted: Fri Jul 23, 1999 5:17 pm
No Text!
  View user's profile Send private message
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
Re: SSF
Post Posted: Fri Jul 23, 1999 7:34 pm
Quote
> we can persuade Zoop to help out and implement support for SSF in future versions of Meka.

No need to persuade me, I'll do it.
I just don't think I will have the time to work on the format development, though.
Anyone know about NSF ?
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!