how can i do music on megadrive?
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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.
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:
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)
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)
Last edited by Stef on Mon Feb 12, 2007 10:29 am, edited 1 time in total.
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
When would it happen ? I hope I can understand itStef wrote:I'll post the source just when i'll be back at home

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.
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:
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.
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.
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
I usually don't comment my code, but as long as I understand it... I spend quite some time commenting my WAVPLAY 

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: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
How many samples you play at the time ?
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:
Of course you canKanedaFr 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...

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 :-/
-
- Very interested
- Posts: 2452
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Your code is really understandable, your coding style is exactly like mineStef 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![]()

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