Page 4 of 20

Posted: Thu Jan 18, 2007 9:35 am
by TmEE co.(TM)
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.

Posted: Thu Jan 18, 2007 9:40 am
by Fonzie
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.

Posted: Thu Jan 18, 2007 2:21 pm
by TmEE co.(TM)
Warm reccomendation: don't attempt any resampling on Z80, it can't process the numbers fast enough

Posted: Sun Jan 21, 2007 10:59 pm
by KanedaFr
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...

Posted: Mon Jan 22, 2007 5:01 am
by LocalH
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.

Posted: Mon Jan 22, 2007 6:23 am
by TmEE co.(TM)
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

Posted: Mon Jan 22, 2007 9:41 am
by KanedaFr
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 ;)

Posted: Mon Jan 22, 2007 10:51 am
by Stef
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 :-/

Posted: Mon Jan 22, 2007 11:57 am
by KanedaFr
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...

Posted: Mon Jan 22, 2007 12:57 pm
by Stef
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...

Posted: Mon Jan 22, 2007 2:12 pm
by TmEE co.(TM)
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.

Posted: Mon Jan 22, 2007 3:10 pm
by Stef
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 ;)

Posted: Tue Jan 23, 2007 1:29 pm
by TmEE co.(TM)
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...

Posted: Tue Jan 23, 2007 2:42 pm
by plee
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.

Posted: Tue Jan 23, 2007 7:39 pm
by Stef
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 ;)