how can i do music on megadrive?

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

Moderator: BigEvilCorporation

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

Post by Stef » Tue Mar 06, 2007 8:06 am

TmEE co.(TM) wrote:Fully featured means you can Stop/Pause, give commands - things like that.
It runs very fast but still, If I try to make 2ch player, I can't get over 10KHz !!! All the slowdowns lie in changing banks. I'll upload it tomorrow
For 2 ch play, you should use a complete different logic, do not use your 1 ch player code. I fixed some timing bugs with my 2 ch player and now it's doing 13.5 Khz on emulator and something as 13.2 Khz on real hardware (Z80 is waiting for 68K bus).

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 Mar 06, 2007 9:25 am

What kind of different logic ? My method works perfectly, but is slow, because changing bank kills the sample rate. My 1ch code is a big optimization exercize: My first 1ch could go 16KHz and latest 4 times faster !!!
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 » Tue Mar 06, 2007 12:51 pm

By changing logic i mean : not doing just a sort of 2x 1 ch player.
For 2ch play, you have to read 2 samples (more if you want) at once each time... anyway you probably already know that ;)

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 Mar 06, 2007 1:12 pm

I've been doing so much z80 programming last days, that I have started to stare at my ASM help "z80 Destination <- Source, 68K Source -> Destination" - I'm constantly switching operands in my 68K code !!! Just like when I started 68K programming :wink:
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 » Tue Mar 06, 2007 2:04 pm

TmEE co.(TM) wrote:I've been doing so much z80 programming last days, that I have started to stare at my ASM help "z80 Destination <- Source, 68K Source -> Destination" - I'm constantly switching operands in my 68K code !!! Just like when I started 68K programming :wink:
hehe, i got many troubles with 68k programming because of that. I did a lot of x86 assembly (no AT&T) in past...
z80 assembly seems logic for me =)

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 Mar 06, 2007 2:11 pm

Stef wrote:hehe, i got many troubles with 68k programming because of that. I did a lot of x86 assembly (no AT&T) in past...
z80 assembly seems logic for me =)
I started with x86 (to speed up my QB stuff), then I moved to MD dev and really started to like 68K and now z80 too. I still like 68K more because I'm spoiled by its flexibility :wink:
Anyone want me to finish my MIDI tracker so I can make a MD tracker ?
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

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) » Wed Mar 07, 2007 7:41 am

OOPS, I forgot the source :( But I can upload it today evening :)
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

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) » Wed Mar 07, 2007 4:27 pm

Source of my 64KHz playback system (32KB) http://www.hot.ee/tmeeco/DWNLOADS/64KHZ.RAR
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 » Wed Mar 07, 2007 11:12 pm

Thanks, very interesting, that gimme some ideas :)

Edit : now my fastest DAC play loop takes something between 34 and 38 cycles. That mean a rate of ~100 Khz. I believe we reached the limit of Z80, i'm not sure we can do a faster sample player ;) The code can still handle command but no more variable playback rate. Anyway it was just a test :)

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 Mar 08, 2007 6:35 am

Can I see yours ? It sounds very awesome :D (and fast :wink: )
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 » Thu Mar 08, 2007 5:18 pm

TmEE co.(TM) wrote:Can I see yours ? It sounds very awesome :D (and fast :wink: )
In fact i just did a test with that. I give you the main loop part which is the important part :

loop
LD A, (DE) ; (7-8 ) get sample
LD (HL), A ; (7-8 ) put sample to dac

INC E ; (4) increment source address
JR Z, carry_E ; (7-8 )

DJNZ loop ; (13) decrement wav len
...

7+7+4+7+13 = 38 cycles = 94210 Hz
8+8+4+8+13 = 41 cycles = 87317 Hz

oups, i was wrong, my loop does between 38 and 41 cycles so it's not exactly 100 Khz :oops:

Edit: I inverted HL and DE in the loop, fixed now :p (anyway i guess you noticed it)
Last edited by Stef on Fri Mar 09, 2007 9:21 am, edited 3 times in total.

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) » Fri Mar 09, 2007 6:46 am

I'll try it out !!! PS I don't count cycles, I just watch the last result :wink:

I just gave a thought on it, it is extremely grealt idea to use DJNZ, but sample rate variations hurt ears, I'm going to figure out a workaround
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 » Fri Mar 09, 2007 9:32 am

TmEE co.(TM) wrote:I'll try it out !!! PS I don't count cycles, I just watch the last result :wink:

I just gave a thought on it, it is extremely grealt idea to use DJNZ, but sample rate variations hurt ears, I'm going to figure out a workaround
sample variation arrive only each 256/2 loop, which isn't that hurting imo :)

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) » Fri Mar 09, 2007 10:26 am

Thats not hurting at all, mine does things after every 256 samples too
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

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 Mar 12, 2007 1:33 pm

I was thinking about 1 thing: What would happen if VBL happens while you're changing bank :?:
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

Post Reply