I don't understand your last point, doesn't look like the same idea than Pascal was speaking about ?TmEE co.(TM) wrote:8 and 16KHz, sounds interesting, but changing banks is still a real sample rate killer...
My idea: play 1 sample alone, no mixing, play 2nd sample and mix it with one from another channel. Then you can have 2 channels, which one plays at half speed.
how can i do music on megadrive?
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
2channels, 1 at half speed, if 1st channel is 16KHz, other will be @ 8KHz.Stef wrote:I don't understand your last point, doesn't look like the same idea than Pascal was speaking about ?
You play 2 samples form 1 channel, and when you play 2nd sample, you mix it with one sample from the 2nd channel. It will be little hassle to get such thing working though...
Your driver implementation is so fast because it does practically everything on registers, I can't reach 56KHz because 1 regset is for sample playback and other is reserved for music part and I must do some things in memory (counting down lenght to know when to end/restart).
IF I play only one channel, I could use all the regs and achieve very high sampling rate though

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

http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Hehe, yep my single channel player put all data in registerTmEE co.(TM) wrote:2channels, 1 at half speed, if 1st channel is 16KHz, other will be @ 8KHz.Stef wrote:I don't understand your last point, doesn't look like the same idea than Pascal was speaking about ?
You play 2 samples form 1 channel, and when you play 2nd sample, you mix it with one sample from the 2nd channel. It will be little hassle to get such thing working though...
Your driver implementation is so fast because it does practically everything on registers, I can't reach 56KHz because 1 regset is for sample playback and other is reserved for music part and I must do some things in memory (counting down lenght to know when to end/restart).
IF I play only one channel, I could use all the regs and achieve very high sampling rate though.

The 2ch player also heavily use register (EXX instruction very usefull here) but the structure of the code doesn't permit me to speed up a lot when the player is doing only 1 channel. Anyway i've to use a fixe rate or my sample would play too fast when only 1 channel is actually playing (or slower when 2 channels are played, depend your point of view :p)
56 Khz is anyway not usefull at all, it was just a sort of proof of concept...
ok...DAC is good but I now have a problem with all other...
let me explain
so, as you, perhaps, can see, I'm able to play the 3 things (with DAC not at 40KHz!)
my problem, when Vint occurs while I'm playing with DAC, bank switch occurs and DAC is then reading my FM data ...
it's a wonderful world between vint bankswitches and loop bankswitches....
the only possibilities I saw : di / dac stuff / ei
which is impossible
some idea ?
let me explain
Code: Select all
Vint :
-> bankswitch
-> psg data
-> bankswitch
-> FM data
Loop:
-> bankswitch
-> DAC data
my problem, when Vint occurs while I'm playing with DAC, bank switch occurs and DAC is then reading my FM data ...
it's a wonderful world between vint bankswitches and loop bankswitches....
the only possibilities I saw : di / dac stuff / ei
which is impossible

some idea ?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Actually i also tried to do some weird tasks in the V-int handler.KanedaFr wrote:ok...DAC is good but I now have a problem with all other...
let me explain
so, as you, perhaps, can see, I'm able to play the 3 things (with DAC not at 40KHz!)Code: Select all
Vint : -> bankswitch -> psg data -> bankswitch -> FM data Loop: -> bankswitch -> DAC data
my problem, when Vint occurs while I'm playing with DAC, bank switch occurs and DAC is then reading my FM data ...
it's a wonderful world between vint bankswitches and loop bankswitches....
the only possibilities I saw : di / dac stuff / ei
which is impossible
some idea ?
But you just can't do anything which "corrupt" the main processing.
The only thing you can do in V-Int code is to set flag as "playPSG" to 1.
Then in your main loop you check for that flag at sometime and you do the PSG process

Actually except setting some sort of flag in the V-int routine, you can't do anything.
The same is true on 68000 side, if your main loop is doing some VDP stuff, you V-int code can't do any VDP stuff...
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
My Music (not there yet) & Sound Engine does this (simplified):
Vint:
EXX
BankSwitch
DoFM
MaybeDoPSG
BankSwitch -> for DAC
EXX
RETI
Maincode
DI
InitFMsynth
EI
Start:
BankSwitch
LoadSample1
BankSwitch
MixSamples
PlaySample
Goto Start
I wonder, how much the FM code affects sample rate...?
Vint:
EXX
BankSwitch
DoFM
MaybeDoPSG
BankSwitch -> for DAC
EXX
RETI
Maincode
DI
InitFMsynth
EI
Start:
BankSwitch
LoadSample1
BankSwitch
MixSamples
PlaySample
Goto Start
I wonder, how much the FM code affects sample rate...?
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

http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Code: Select all
Vint :
-> Read previous bankswitch
-> bankswitch
-> psg data
-> bankswitch
-> FM data
-> Set back bankswitch
Loop:
-> bankswitch
-> DAC data
-
- Very interested
- Posts: 159
- Joined: Sat Feb 24, 2007 11:35 pm
- Location: San Antonio, TX
A trick I learned from ColecoVision might help:KanedaFr wrote:ok...DAC is good but I now have a problem with all the only possibilities I saw : di / dac stuff / ei
which is impossible
When doing something that will conflict with the interrupt, set a "busy" flag. In the interrupt, if the "busy" flag is set, don't do the sound code right away, but set another "interrupt deferred" flag. In the main Z80 loop, check for this flag, then you can call the sound code for the FM/PSG stuff.
Or don't have the interrupt do anything but set a "time to update FM/PSG" flag, and always handle it in the main Z80 loop, since the timing doesn't need to be as accurate as the PCM.
In addition to sound, this trick was used to work around a big problem with the TMS9918A video. You had to read the VDP status register to acknowledge the vblank interrupt, but if the vblank interrupt (hooked up to NMI, so you couldn't just DI/EI, also level-sensitive, so you HAD to acknowledge the interrupt!) happened in the middle of a VDP address write, reading the status register would cause the VDP to reset the control port mode, stuff would get written to the wrong address, and you would get glitchy video.
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Least we don't have to ack any ints here
But checking if something happens on the FM side in DAC loop really kills the sampling rate, we check for commands, it takes sampling rate down, then we have to check for some other stuff...
8bitwizard, maybe you want to try to make your own z80 driver too, you have lots of experience with z80, maybe you're able to make the fastest driver


8bitwizard, maybe you want to try to make your own z80 driver too, you have lots of experience with z80, maybe you're able to make the fastest driver

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

http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Hehe, sounds like the same i said in my previous post8bitwizard wrote:A trick I learned from ColecoVision might help:KanedaFr wrote:ok...DAC is good but I now have a problem with all the only possibilities I saw : di / dac stuff / ei
which is impossible
When doing something that will conflict with the interrupt, set a "busy" flag. In the interrupt, if the "busy" flag is set, don't do the sound code right away, but set another "interrupt deferred" flag. In the main Z80 loop, check for this flag, then you can call the sound code for the FM/PSG stuff.
Or don't have the interrupt do anything but set a "time to update FM/PSG" flag, and always handle it in the main Z80 loop, since the timing doesn't need to be as accurate as the PCM.
In addition to sound, this trick was used to work around a big problem with the TMS9918A video. You had to read the VDP status register to acknowledge the vblank interrupt, but if the vblank interrupt (hooked up to NMI, so you couldn't just DI/EI, also level-sensitive, so you HAD to acknowledge the interrupt!) happened in the middle of a VDP address write, reading the status register would cause the VDP to reset the control port mode, stuff would get written to the wrong address, and you would get glitchy video.


-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
I think, I'm giving up on my 2ch code, I'm unable to achieve reasonable rampling rate
Least I got pretty good 1ch code 


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

http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
ah ah!!
8bits gave more hints, I didn't see it like this when I first read Stef post
I got the point but as TmEE said, it will drop the DAC freq
If I add FM switch + FM play + (PSG switch + PSG play)*3 on loop..I'll have 1Khz DAC
or perhaps here is the real reason to optimize more my DAC driver (I really thought 9Khz was enought for what I want)
thanks anyway, I knew asking here will give me hints
EDIT: perhaps the freq will not drop that much since the PSG/FM will not be done at each loop...
I already used that 'trick' of doing some stuff every X loop and won some hz...
8bits gave more hints, I didn't see it like this when I first read Stef post

I got the point but as TmEE said, it will drop the DAC freq

If I add FM switch + FM play + (PSG switch + PSG play)*3 on loop..I'll have 1Khz DAC

or perhaps here is the real reason to optimize more my DAC driver (I really thought 9Khz was enought for what I want)
thanks anyway, I knew asking here will give me hints

EDIT: perhaps the freq will not drop that much since the PSG/FM will not be done at each loop...
I already used that 'trick' of doing some stuff every X loop and won some hz...
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Doing PSG / FM stuff at V-int period won't really kill the DAC rate, the rate will stay the same except at the PSG/FM update time, that create a sort of "hole" in the sample. It's why almost voices sound somewhat crappy in Genesis game :-/ Faster is your update PSM/FM code, better the sample is.KanedaFr wrote:ah ah!!
8bits gave more hints, I didn't see it like this when I first read Stef post
I got the point but as TmEE said, it will drop the DAC freq
If I add FM switch + FM play + (PSG switch + PSG play)*3 on loop..I'll have 1Khz DAC
or perhaps here is the real reason to optimize more my DAC driver (I really thought 9Khz was enought for what I want)
thanks anyway, I knew asking here will give me hints
EDIT: perhaps the freq will not drop that much since the PSG/FM will not be done at each loop...
I already used that 'trick' of doing some stuff every X loop and won some hz...
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
I wrote a stereo sample player these 2 last days. It's worked perfectly with Kega but not with Gens :p
On real hardware, it was first just doing silent... After i figured some weird stuff about the YM2612 chip, i was able to get it up on real hardware, unfortunatly the used trick doesn't work because of the YM2612 hardware latency :-/
Too bad, having stereo sample on Genesis would have been a neat trick (as it doesn't support it natively)... anyway i've already some others ideas in head ^^
On real hardware, it was first just doing silent... After i figured some weird stuff about the YM2612 chip, i was able to get it up on real hardware, unfortunatly the used trick doesn't work because of the YM2612 hardware latency :-/
Too bad, having stereo sample on Genesis would have been a neat trick (as it doesn't support it natively)... anyway i've already some others ideas in head ^^
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Hehe, I did such thing too !!! But it was in 68K code though. I played 16 samples from one channel and 16 from another. I didn't have my SRAM cart then so I don't know what it would do on real HW, and I probably can't check it, 'cos I think I fried it (was in bus conflict all night, RAMs were pretty hot).Stef wrote:I wrote a stereo sample player these 2 last days. It's worked perfectly with Kega but not with Gens :p
On real hardware, it was first just doing silent... After i figured some weird stuff about the YM2612 chip, i was able to get it up on real hardware, unfortunatly the used trick doesn't work because of the YM2612 hardware latency :-/
Too bad, having stereo sample on Genesis would have been a neat trick (as it doesn't support it natively)... anyway i've already some others ideas in head ^^
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

http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen