how can i do music on megadrive?

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

User avatar
TmEE co.(TM)
Very interested
Posts: 2279
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sun Oct 14, 2007 5:53 pm

I know how that blip sounds... and it is evident in MD, but, yes, very quiet... once I get FM out of my sound driver, and finish instrument editor in my tracker, I can spend some time on the blip mystery...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Eke
Very interested
Posts: 817
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Jan 24, 2008 2:24 pm

I give up with this one, after many tests, it is now clear that this is ONE particular instrument setting on Channel 3 (with special mode enabled) that is bugged.

Steve Snake is the only person knowing exactly where the bug exactly comes from but is definitely not quite in the mood of sharing info with anybody (I try direct asking since he seems to be back on eidolon's inn... with no success) :oops:

I still don't believe that if he could have discovered this some years ago, nobody can do it again now :?

Anyway, if someone want to do some test programs to run on the real thing, here is the setttings always used (beside two parameters, annoted as "variable") on Channel 3 for every soundtrack that rely on that "bug":

CHANNEL 3 settings:

KEYMODE: disabled
CH3 SPECIAL: enabled
TIMER A: enabled
TIMER B: disabled
LFO: enabled (0x00)
ALGO: 4
M1 --- C1 --|
M2 --- C2 --|
FEEDBACK: 4
L CHANNEL enabled
R CHANNEL enabled
AMS: 0
FMS: 0

SLOTS SETTINGS:

SLOT1 (MODULATOR M1):
DT1: 3
MUL: 15
TL: variable
AR: 31
KS: 1
AM disabled
D1R: 15
D2R: 28
T1L: 8
RR: 4
SSG-EG: 0
FNUM, BLOCK: 117,4

SLOT2 (CARRIER C1):
DT1: 7
MUL: 12
TL: 8
AR: 31
KS: 3
AM: enabled
D1R: 0
D2R: 16
T1L: 4
RR: 9
SSG-EG: 0
FNUM, BLOCK: 95,4

SLOT3 (MODULATOR M2):
DT1: 1
MUL: 15
TL: 0
AR: 28
KS: 3
AM enabled
D1R: 0
D2R: 0
T1L: 0
RR: 4
SSG-EG: 0
FNUM, BLOCK: 94,4

SLOT4 (CARRIER C2):
DT: 7
MUL: 0
TL: variable
AR: 31
KS: 3
AM disabled
D1R: 17
D2R: 16
T1L: 4
RR: 9
SSG-EG: 0
FNUM, BLOCK 0,4



I don't know, maybe it has something to do with D1R/D2RTL/T1L set to 0 with AM enabled, I guess someone should test each parameter


For the moment, in the YM2612 MAME core, I implemented some kind of preliminary hack to detect this particular instrument setting:
case 0x40: /* TL */
set_tl(CH,SLOT,v);
if ((c==2) && (ym2612.OPN.ST.mode & 0x40) && !v)
{
/* set Channel 3 OFF (this is a hack, on real hardware,
it seems more like the channel is very attenuated)
*/
ym2612.OPN.pan[ c*2 ] = 0;
ym2612.OPN.pan[ c*2+1 ] = 0;
}
break;
As far as I tested, it has no impact on other soundtracks and obviously, the infamous blipblip sound is gone :)

User avatar
Stef
Very interested
Posts: 2608
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Jan 26, 2008 9:39 pm

Hey,

I did some time ago what you just did these last days.
As you said, it seems to be a real bug from the hardware, very strange indeed. The channel 3 sounds like very attenuated in this case, looks like TL value are not interpreted correctly in some case.
Good work for your researchs though ! it would be awesome to understand what happen exactly and why :)
I'm following this topic with lot of interest =)

Eke
Very interested
Posts: 817
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Sun Jan 27, 2008 12:09 pm

Thanks Stef
I extracted the incriminated instrument with Shiru's last tool and imported it in TFMaker to play with the settings...

http://www.megafileupload.com/en/file/4 ... 2-tfi.html

Indeed, if you lower the TL values for operators #3 and #4 (C1 and C2) to half value (63), it sounds more like on real harware (i.e very attenuated but not completely shut off)


Another mysterious thing about the YM2612 would be to know how the SSG-EG part really work
:?:

User avatar
Stef
Very interested
Posts: 2608
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Jan 27, 2008 10:39 pm

Eke wrote:Thanks Stef
I extracted the incriminated instrument with Shiru's last tool and imported it in TFMaker to play with the settings...

http://www.megafileupload.com/en/file/4 ... 2-tfi.html

Indeed, if you lower the TL values for operators #3 and #4 (C1 and C2) to half value (63), it sounds more like on real harware (i.e very attenuated but not completely shut off)


Another mysterious thing about the YM2612 would be to know how the SSG-EG part really work
:?:
Yep, i tried to implement the SSG-EG envelop in Gens as SSG-EG should work in theory. As far i remember a very few number of game uses this feature and only one rely on it for correct sound ! a formula one type game ot something like that. When i added the SSG-EG the game music was fixed but it added some weird bug in others games. I know my SSG-EG support is buggy, i do it quickly and didn't tested it enough... anyway again a strange stuff about the YM2612, it seems the SSG-EG support isn't complete, but it partially works...

Eke
Very interested
Posts: 817
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Tue Mar 18, 2008 8:34 am

I downloaded my first Wii Virtual Console game yesterday: Comix Zone

Beside the fact it is running at 50Hz with vertical borders :roll: , to my surprise, the FM emulation is pretty good, and the YM2612 bug is apparently emulated: there is no "blip blip" in some of the soundtracks (#5, #10 I think) like in most emulators

I wonder if this means that complete documentation of YM2612 exists somewhere or if the emulator that they are using is a port of Kega (I think Steve Snake already made such deal with Kgen for a Sega retro compilation)

:?:

Mask of Destiny
Very interested
Posts: 555
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Tue Mar 18, 2008 2:52 pm

Eke wrote: I wonder if this means that complete documentation of YM2612 exists somewhere or if the emulator that they are using is a port of Kega (I think Steve Snake already made such deal with Kgen for a Sega retro compilation)

:?:
I seem to recall that Kega is written in pretty much 100% x86 assembly. Since the Wii is using a PowerPC processor a port of Kega doesn't seem to likely.

User avatar
Christuserloeser
Very interested
Posts: 145
Joined: Sun Jan 28, 2007 2:01 am
Location: DCEvolution.net
Contact:

Post by Christuserloeser » Thu Mar 20, 2008 10:06 pm

A friend of mine said that sound emulation in Kid Chameleon would be really buggy...
http://www.DCEvolution.net - Gigabytes of free Dreamcast software for you

Image

User avatar
TmEE co.(TM)
Very interested
Posts: 2279
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon Apr 28, 2008 12:59 am

2 year old topic.... so many memories.... I wrestled with 6KHz 2Ch playback code and now I have (or had) 56KHz 2Ch code, plus music and sound effects !!! I said "I will I will", and I now, I've done it !!! (it took quite some time though). I feel good :)
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Wed Apr 30, 2008 2:45 am

TmEE co.(TM) wrote:2 year old topic.... so many memories.... I wrestled with 6KHz 2Ch playback code and now I have (or had) 56KHz 2Ch code, plus music and sound effects !!! I said "I will I will", and I now, I've done it !!! (it took quite some time though). I feel good :)
TmEE: Hey - do you have enough cycles left over on the z80 to do a fixed point math counter (two 8bit variables)? Or at least an 8bit incrementor? I'm assuming you're using an INC for the read position on the source wave.

User avatar
TmEE co.(TM)
Very interested
Posts: 2279
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Apr 30, 2008 7:56 am

there's no free cycles left... anything I'll add will have tiny effect on sample quality... but so far, it sounds good, so why not.

Why is there a need for such thing ? Additional timing ?
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Fri May 02, 2008 4:02 am

TmEE co.(TM) wrote: Why is there a need for such thing ? Additional timing ?
Oh - just for frequency scaling. One way is to use two bytes. The low byte acts as the float part and the upper byte is the whole part. Just add the whole part/byte to the wave/sample pointer. That way you don't have to store multiple samples of the same instruments at different prescaled notes.

Another fast method is to have the sample prescaled into all the notes for a given octave, then you can easily move up or down in an octave by using power of 2 for the wave incrementor. Not very efficient, but you can easily get a 3 octave range but just storing one octave range of notes. Gives you a balance of speed and space.

Chilly Willy
Very interested
Posts: 2466
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Fri May 02, 2008 7:56 am

tomaitheous wrote:
TmEE co.(TM) wrote: Why is there a need for such thing ? Additional timing ?
Oh - just for frequency scaling. One way is to use two bytes. The low byte acts as the float part and the upper byte is the whole part. Just add the whole part/byte to the wave/sample pointer. That way you don't have to store multiple samples of the same instruments at different prescaled notes.

Another fast method is to have the sample prescaled into all the notes for a given octave, then you can easily move up or down in an octave by using power of 2 for the wave incrementor. Not very efficient, but you can easily get a 3 octave range but just storing one octave range of notes. Gives you a balance of speed and space.
A byte really isn't enough for a decent instrument sample. I used a word when I did some MIDI instruments on the Amiga. Most of my instruments weren't 64K long, but most WERE longer than 256 bytes. You probably could do some really simple instruments in 256 bytes, though.

Anywho, I used a long for the sample step - it was a 16.16 fixed point number. I could simply do a swap, use the word index addressing mode, then swap back. The 68K is nice that way. If you were doing a 32X or SEGA CD game, you could use the main 68K CPU that way. It's also fast enough to add several instruments together in that manner. On a 14 MHz 68020, I could mix 16 stereo instruments and 16 stereo sound effects together with that sort of pitch scaling using only about 5% of the CPU time (on a stock A1200). All instruments and sound effects were a 11025 Hz sample rate. It'd take more CPU time on a 7.6 MHz 68000, but for a 32X/SEGA CD game, you have that CPU time available.

User avatar
TmEE co.(TM)
Very interested
Posts: 2279
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri May 02, 2008 11:29 am

my engine does no resampling whatsoever... and I can't add it becasue of the way samples are played back... everything happens in 256 byte chunks... and if I change it, I'd rather have no sample playback at all since I lose the rate, and I need it for good sounding cymbals... if banks would be changed by a single (or two writes) I would have happily had resampling, but since resampling is pretty dynamic business, I have to change banks really often and that just kills the rate.... lest kick Sega in the nuts !!!
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

AamirM
Very interested
Posts: 469
Joined: Mon Feb 18, 2008 8:23 am
Contact:

Post by AamirM » Fri May 02, 2008 12:20 pm

Hi,
Stef wrote:Yep, i tried to implement the SSG-EG envelop in Gens as SSG-EG should work in theory. As far i remember a very few number of game uses this feature and only one rely on it for correct sound ! a formula one type game ot something like that. When i added the SSG-EG the game music was fixed but it added some weird bug in others games. I know my SSG-EG support is buggy, i do it quickly and didn't tested it enough... anyway again a strange stuff about the YM2612, it seems the SSG-EG support isn't complete, but it partially works...
Shiru's and HardWareMan's TurboFM player uses SSG-EG in some background instruments. Alisia's Dragon also seems to use it. SSG-EG is not supported in my FM core right now. But it will be supported in upcoming version (releasing on linux first). Play the TurboFM player in Regen then in Kega (the Top Gun music) to hear the difference.

BTW, Could somebody please test the blip, blip sound (like in Ariel, Scooby Doo Mystery etc...) in real hardware and in Regen (SuperHQ on) then tell me how far is Regen from reality?

stay safe,

AamirM

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest