how can i do music on megadrive?

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

Moderator: BigEvilCorporation

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

Post by TmEE co.(TM) » Thu Jan 18, 2007 9:35 am

Fonzie wrote:On megadrive, a 1khz sample would sound horrible, what does my soundcart do to avoid that?
Maybe your card does dynamic resampling like my Yamaha ? This plays very low quality files like very high quality files.
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

Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie » Thu Jan 18, 2007 9:40 am

Yeah... and there is no way to resample with Z80? I mean, playing a 4khz sample on my sound card is pretty okay... 8khz is almost good :)

About the 4bit samples, no clues why i get a "CHHHHHHH" background by removing the 4 lower bits of a 8bit sample?

Thanx for your answer.

Quickman : Some games uses 68K for drumps & other sounds... Maybe not sonic, yeah.

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

Post by TmEE co.(TM) » Thu Jan 18, 2007 2:21 pm

Warm reccomendation: don't attempt any resampling on Z80, it can't process the numbers fast enough
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

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Sun Jan 21, 2007 10:59 pm

Hello,

there is something I really don't understand...
perhaps it's because of my poor sound (hardware or sofware) knowledge but how can you control the sample rate ?
I mean, how can you play a sample at 12khz, 5Khz or any value ?
I though I must adapt the sample to the z80 speed....

When I used P.Lee z80 driver to play sample, I used 8KHz sample...why 8Khz ? which relation with the 3.58Mhz of the Z80 ???

I know it's perhaps a dumb question, but it seems this is something I can't understand...

LocalH
Very interested
Posts: 152
Joined: Tue Dec 19, 2006 5:04 pm

Post by LocalH » Mon Jan 22, 2007 5:01 am

You change the sample rate by changing the delay between DAC writes. The more often you feed the DAC data, the higher the sample rate is.

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

Post by TmEE co.(TM) » Mon Jan 22, 2007 6:23 am

In a plain "bomb DAC with PCM samples" loop, you can achieve ~32KHz but if you add a little checking (to know when to stop) and bank changing when required I couldn't get over ~16KHz
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

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Mon Jan 22, 2007 9:41 am

So it's what I was afraid of...
the more code you have between each write, lower is the sample rate...

Ok, so how do you know the sample rate needed...?
I looked at TmEE source code and so you made 4 loop between each write
How do you know 4 loop is for 12KHz ?
I don't think you count how much cpu cycle is used by each line of your code...so you found it by multi tries ?

I don't see the 'easy' way to get a constant DAC update.
For the FM, I use the INT38h but it's far to be enought for the DAC part ;)

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

Post by Stef » Mon Jan 22, 2007 10:51 am

You put the finger on the worst point of genesis hardware.
There is no smart way of playing a sample. The YM2612 has 2 timers, they can both be connected to IRQ but unfortunatly they aren't in genesis.
That would be *very* helpfull to have one connected to Z80...

Unfortunatly we have to do with that, the best synchronisation process is to use the YM2612 timers and check status flag.
Another bad point is the bank setting register : having to write it bit per bit is really a waste of time :-/
Last edited by Stef on Mon Jan 22, 2007 12:48 pm, edited 1 time in total.

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Mon Jan 22, 2007 11:57 am

Stef wrote:You put the finger on the worst point of genesis hardware.
There is no smart way of playing a sample.
happy to see my question wasn't so dumb ;)
The YM2612 has 2 timers, they can both be conneted to IRQ but unfortunatly they aren't in genesis.
That would be *very* helpfull to have one connected to Z80...
yeah...MVSTracker use this method
Unfortunatly we have to do with that, the best synchronisation process is to use the YM2612 timers and check status flag.
so 2 possibilities :
- play with the timers (hard when you already using it for FM)
- use a minimal code to be sure DAC write will be done as often as needed
Another bad point is the bank setting register : having to write it bit per bit is really a waste of time :-/
yes...I hate this part... :(
even you can avoid this with <64k in a same bank at a specific address of the MD rom...
but since I want to play DAC at a specific address and FM song at another one, I switch bank every dac or fm update...

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

Post by Stef » Mon Jan 22, 2007 12:57 pm

happy to see my question wasn't so dumb ;)
definitly not ;)
so 2 possibilities :
- play with the timers (hard when you already using it for FM)
- use a minimal code to be sure DAC write will be done as often as needed
Yep, the second way is preferable in case of "aside computing" as basic sample decompression but it can't guarant a correct sample rate (if you want 16 Khz, you'll maybe have 15,2 Khz or something like that). Anyway, not very important :)
yes...I hate this part... :(
even you can avoid this with <64k in a same bank at a specific address of the MD rom...
but since I want to play DAC at a specific address and FM song at another one, I switch bank every dac or fm update...
Switching each time is a big waste of time :-/ but we don't have choice here...

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

Post by TmEE co.(TM) » Mon Jan 22, 2007 2:12 pm

KanedaFr wrote:Ok, so how do you know the sample rate needed...?
I looked at TmEE source code and so you made 4 loop between each write
How do you know 4 loop is for 12KHz ?
Actually I don't know it, but my estimations are quite accurate. For example if I play 8KHz sample, optimize the code and it plays little faster I can say, that it plays ~9Khz.
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

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

Post by Stef » Mon Jan 22, 2007 3:10 pm

TmEE co.(TM) wrote:
KanedaFr wrote:Ok, so how do you know the sample rate needed...?
I looked at TmEE source code and so you made 4 loop between each write
How do you know 4 loop is for 12KHz ?
Actually I don't know it, but my estimations are quite accurate. For example if I play 8KHz sample, optimize the code and it plays little faster I can say, that it plays ~9Khz.
Then it's why i said the rate is somewhat not very correct.
That affects the pitch but generally nobody can really heard it ;)

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

Post by TmEE co.(TM) » Tue Jan 23, 2007 1:29 pm

Stef wrote:The YM2612 has 2 timers, they can both be connected to IRQ but unfortunatly they aren't in genesis.
That would be *very* helpfull to have one connected to Z80...
I guess they would have connected IRQ lines of Ym2612 and Z80 but it starts to mess up Vint (one IRQ on Z80) which is little more important. Now I wonder why they didn't use 68K for int handling, it has 4 more ints available...
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

plee
Very interested
Posts: 66
Joined: Wed Nov 29, 2006 11:32 am
Location: Houston, Texas

Post by plee » Tue Jan 23, 2007 2:42 pm

KanedaFr wrote:Hello,

there is something I really don't understand...
perhaps it's because of my poor sound (hardware or sofware) knowledge but how can you control the sample rate ?
I mean, how can you play a sample at 12khz, 5Khz or any value ?
I though I must adapt the sample to the z80 speed....

When I used P.Lee z80 driver to play sample, I used 8KHz sample...why 8Khz ? which relation with the 3.58Mhz of the Z80 ???

I know it's perhaps a dumb question, but it seems this is something I can't understand...
When I sampled the sounds for Berzerk, I found 8Mhz to be the best sounding without taking too much space. But like it has been said, you can speed/slow the playback by adjusting the delay in the driver.

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

Post by Stef » Tue Jan 23, 2007 7:39 pm

TmEE co.(TM) wrote:
Stef wrote:The YM2612 has 2 timers, they can both be connected to IRQ but unfortunatly they aren't in genesis.
That would be *very* helpfull to have one connected to Z80...
I guess they would have connected IRQ lines of Ym2612 and Z80 but it starts to mess up Vint (one IRQ on Z80) which is little more important. Now I wonder why they didn't use 68K for int handling, it has 4 more ints available...
IMO a YM2612 timer interrupt would have been more usefull than VInt for Z80. 68000 receive VInt and can give it to Z80 (setting a Z80 ram byte to 1 when happened or something like that).
Anyway, we have to do with what we have ;)

Post Reply