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 - Yamaha and PSG Sound Logging

Reply to topic
Author Message
Chris
  • Guest
Reply with quote
Yamaha and PSG Sound Logging
Post Posted: Mon Jul 05, 1999 2:20 am
How does sound logging work? A couple of emulators use this feature (Ines, Genecyst, Callus)
but I don't understand how they work. If I can ever get my SG1000 emulator up and running
I would like to add my own Sound Logging feature to a .PSG file, or better yet directly to
a MIDI file *Sorry Paul :o)* How could you organize the sound writes in binary to a file?
Is it sequential or something? Like, write to Channel 1, channel 2, channel 3, noise,
next write channel 1, channel 2, channel 3, and so fourth? Please help.

Chris :o)
 
Limbs a Flyin'
  • Guest
Reply with quote
Post Posted: Mon Jul 05, 1999 6:58 am
from genecyst's readme :

genecyst can log the YM2612/PSG register writes to a .GYM file.
Someone (not me) could possibly write a utility to convert
this data into a .MID or other music file.
The GYM format works like this:
while (!EOF)
switch (readbyte()) // readbyte() reads the next byte from the file
{
case 0: 1/60th of a second has elapsed;
case 1: ymport=0; ymreg=readbyte(); ymdata=readbyte();
case 2: ymport=1; ymreg=readbyte(); ymdata=readbyte();
case 3: write readbyte() to psg port
}


so when ever genecyst logs psg data, it writes the decimal 3 to file, then the actual byte written to the psg. and '0' when ever the next frame occurs, which would separate each chunk of psg write from each other - other wise your play back tool has no timing.


what you would do is each time the emulated sms/sg/sc(/gg) writes to the psg, store that value to a file. you may want to prefix that byte with some other defining byte so say that the next byte is psg data, (or 2413 data, or something else if you wish - just like we see in the gym format above. this is all up to you if you want to do something different) - note that if you want to keep voice playback (do any sg/sc stuff have that? ;) you would probably want to keep track of some timing info, eg the ofset of time when a particular value got sent to the psg/fm/whatever
 
  • Joined: 29 Jun 1999
  • Posts: 254
  • Location: California, USA; Hiroshima, Japan
Reply with quote
Close, but...
Post Posted: Tue Jul 06, 1999 1:57 am
Quote
> so when ever genecyst logs psg data, it writes the decimal 3
> to file, then the actual byte written to the psg. and '0' when > ever the next frame occurs, which would separate each chunk of
> psg write from each other - other wise your play back tool has > no timing.


Actually, the 0 flag in a .gym file is used only when no data is written to any port in any particular 1/60 second, and _not_ as a marker to seperate PSG port writes.

So, three sequential writes to the PSG would look like this:

3 ' PSG flag
255 ' Write this value to PSG port
3 ' PSG flag
128 ' Write this value to PSG port
0 ' 1/60 second passes; no data written to YM2612 or PSG
0 ' 1/60 second passes
0 ' 1/60 second passes
etc., etc....

Does this help at all?

BTW, if you need any questions about MIDI programming, feel free to ask.

Paul Jensen
Author of gym2mid

  View user's profile Send private message Visit poster's website
Chris
  • Guest
Reply with quote
Clarification
Post Posted: Tue Jul 06, 1999 4:27 am
> Actually, the 0 flag in a .gym file is used only when no data is written to any port in any particular 1/60 second, and _not_ as a marker to seperate PSG port writes.

Quote
> So, three sequential writes to the PSG would look like this:

> 3 ' PSG flag
> 255 ' Write this value to PSG port
> 3 ' PSG flag
> 128 ' Write this value to PSG port
> 0 ' 1/60 second passes; no data written to YM2612 or PSG
> 0 ' 1/60 second passes
> 0 ' 1/60 second passes
> etc., etc....

> Does this help at all?

> BTW, if you need any questions about MIDI programming, feel free to ask.

> Paul Jensen
> Author of gym2mid

I'm trying my best to understand but I don't get it. You're saying that while GYM2MID is
reading data, if it comes across a PSG(3) flag that it will read the next byte(s) and write that
value to one of the PSG channels? Then, if it finds a Zero flag that it will increase the
timer ticks by 1/60 of a second?

You mean like, if I ever get my emulator working and I implement sound logging to add
one byte markers before each PSG sound write to the file? Like 1 equals channel 1,
2 equals channel 2, 3 equals channel 3, 0 equals increase midi ticks(waste time/delay)
and so fourth?

Chris :o)
 
  • Joined: 29 Jun 1999
  • Posts: 254
  • Location: California, USA; Hiroshima, Japan
Reply with quote
Re: Clarification
Post Posted: Fri Jul 09, 1999 4:20 am
Quote
> I'm trying my best to understand but I don't get it. You're saying that while GYM2MID is
> reading data, if it comes across a PSG(3) flag that it will read the next byte(s) and write that
> value to one of the PSG channels? Then, if it finds a Zero flag that it will increase the
> timer ticks by 1/60 of a second?

Exactly. Sometimes the PSG will have to write two bytes to the PSG port for one instruction, but the format is still the same:

3, BYTE1, 3, BYTE2, 3, etc.

Quote
> You mean like, if I ever get my emulator working and I implement sound logging to add
> one byte markers before each PSG sound write to the file? Like 1 equals channel 1,
> 2 equals channel 2, 3 equals channel 3, 0 equals increase midi ticks(waste time/delay)
> and so fourth?

Well, you _could_ do that if you wanted to, but I think the simplest way to implement it would be to simply use the '0' flag for a 1/60 sec. delay, and another flag for the PSG data, followed by the byte written to that port. This way, there would be a lot less coding on your part.

You could even use the .gym file format to log your data, by using the '0' flag and the '3' flag. That way, your output files would be compatible with current programs (like, say, ****GYM2MID**** for a humble example).

Again, I hope this helps.

Paul
  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!