Page 8 of 20

Posted: Tue Feb 06, 2007 6:32 am
by TmEE co.(TM)
I'll keep it in mind. I was thinking of mixing stuff last night and I've come up with this: If the sounds are in the same 32K segment, mixing is not a problem, but if 1 sound is in 1 32K segment and other in another 32K segment it grows into a problem because changing banks is NOT very good idea when mixing is happening. I was thinking of copying some data from one bank to RAM and mix it later with data from one bank. I guess it is slow, but not slower than changing banks.

Posted: Mon Feb 12, 2007 9:56 am
by Stef
I should give you my code, it's able to mix 2 samples from different bank at 11 Khz. I guess it can up to 14/16 Khz with good optimisations.

I also past my week end to write a new Z80 driver to play simple sample. It can play a sample up to 41 Khz.
Features of this driver :
- capable of playing long sample (> 64 KB)
- stop/restart play at anytime
- keep a status "playing" flag bit
- capable of playing at variable sample rate (parameter of my playSampe function)

Posted: Mon Feb 12, 2007 10:01 am
by KanedaFr
wow!!!

ok, so I stop working on mine ;)
it seems you're better at this than me, I'm at 9.3KHz max :lol:

I'm waiting for the driver !! :)

Posted: Mon Feb 12, 2007 10:32 am
by Fonzie
Hey kaneda :D you are joking?
Sure the the KHz are more impressive but don't forget you're doing something more important at same time :D Don't give up :D 8khz is perfect for most games :)

Posted: Mon Feb 12, 2007 10:37 am
by Stef
I'll post the source just when i'll be back at home :)

Posted: Mon Feb 12, 2007 10:59 am
by Pascal
sweeet , 2 samples mixing is what i need for finishing one of my game :)

Posted: Mon Feb 12, 2007 12:55 pm
by Stef
Pascal wrote:sweeet , 2 samples mixing is what i need for finishing one of my game :)
My code need some tweaks and bit of rewrite as it's quite awful for now but at least it work :) The sample needs to be 8 bits signed for faster mixing operation for now.

Posted: Mon Feb 12, 2007 1:35 pm
by Pascal
only result prevail ;)

Posted: Mon Feb 12, 2007 6:20 pm
by TmEE co.(TM)
Stef wrote:I'll post the source just when i'll be back at home :)
When would it happen ? I hope I can understand it :wink:
Actually I haven't even started to write my mixer, I'm too busy with my new MD game, hint: A+B+C+Start+Down in GBMD.

Posted: Mon Feb 12, 2007 7:32 pm
by Stef
Sorry i was really long, here's the link :

Z80 basic driver for sample play (source)

The code is commented here and there, hope you understand it ;)
have fun :)

Edit : i updated the archive to include C functions using the Z80 drivers. The startPlaySample function also does the "rate to wait state" conversion so it's important to have it ;)
playSample2 is used for another driver, ignores it here.

I'll post my source of the 2 channels player later after some minors tweaks and changes.

Posted: Tue Feb 13, 2007 6:24 am
by TmEE co.(TM)
I usually don't comment my code, but as long as I understand it... I spend quite some time commenting my WAVPLAY :wink:

Posted: Tue Feb 13, 2007 8:49 am
by KanedaFr
Ok, I now know why I'm unable to have your rate : I set the bank every time...
I need to do it since I also play PSG and FM
I so had 3 banks, need to set it before each read...

Stef, may I use some of your code since you optimize it a lot ?
perhaps I can optimize mine a little more...

Posted: Tue Feb 13, 2007 1:09 pm
by TmEE co.(TM)
How many samples you play at the time ?

Posted: Tue Feb 13, 2007 2:29 pm
by Stef
KanedaFr wrote:Ok, I now know why I'm unable to have your rate : I set the bank every time...
I need to do it since I also play PSG and FM
I so had 3 banks, need to set it before each read...

Stef, may I use some of your code since you optimize it a lot ?
perhaps I can optimize mine a little more...
Of course you can :)
At first shot i also did set bank each time but that was a real waste when you're playing a single sample since you can do it only when needed (it's a part of optimisation :p). For 2 samples or more, you haven't anymore choice unfortunatly so the play rate is really reduced what even you do :-/

Posted: Wed Feb 14, 2007 8:29 am
by TmEE co.(TM)
Stef wrote:Sorry i was really long, here's the link :

Z80 basic driver for sample play (source)

The code is commented here and there, hope you understand it ;)
have fun :)
Your code is really understandable, your coding style is exactly like mine :)