VGM or TFM with PCM?

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

Moderator: BigEvilCorporation

TechnoZealot
Interested
Posts: 30
Joined: Mon May 06, 2013 2:27 am
Location: Vermont, USA

VGM or TFM with PCM?

Post by TechnoZealot » Tue May 07, 2013 4:11 am

Is there anyway I can play TFM or VGM using the YM2612 while still reserving the DAC/PCM channel to play samples in?

I noticed some function with MVS tracker allowing for this, (I think).

But what I'm basically trying to do is play VGM/TFM music, and then make it so that the ship in my game can make noises when firing or thrusting.

Is there a way to do this?

Thanks!

TechnoZealot
Interested
Posts: 30
Joined: Mon May 06, 2013 2:27 am
Location: Vermont, USA

Post by TechnoZealot » Tue May 07, 2013 4:15 am

I'm actually ok for just reserving a channel or two for YM2612 synth commands. I could probably make a laser sound this way for example, but PCM would of course be preferred if possible.

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

Post by Stef » Tue May 07, 2013 10:41 am

Unfortunately the TFM or VGM driver are not designed to handle SFX to be played at same time, the best you can do now is to use the PSG from the 68000 to play your SFX.

eteream
Very interested
Posts: 81
Joined: Tue Dec 22, 2009 2:13 pm

Post by eteream » Tue May 07, 2013 7:44 pm

..
Last edited by eteream on Sat Jul 20, 2013 8:32 pm, edited 1 time in total.

User avatar
TmEE co.(TM)
Very interested
Posts: 2321
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed May 08, 2013 5:14 am

TFM is not made to share resources. You won't know what is it doing exactly and when you go poking FM you may do it while it does something and that will mess up sound for some duration.
You could possibly hack in something to help coordinate the things, or even better get the Z80 handle things for you along with the TFM stuff. PCM is still gonna be a problem as the Z80 is gonna be pretty busy and getting consistency is probably not gonna easily work out.
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

foobat
Very interested
Posts: 92
Joined: Fri Sep 14, 2012 1:06 pm

Post by foobat » Wed May 08, 2013 8:40 am

It is not easy to play PCM at the same time as playing music. It is possible, but not with these simple drivers. My custom hardware VGM player still slows down a little while playing PCM samples and 5-channel music simultaneously, and it's going to take a coprocessor to fix that.

The stuff Genesis developers managed to do with 30 year old hardware blows my freakin' mind sometimes I tell you what

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

Post by Stef » Wed May 08, 2013 10:37 am

eteream wrote:Is this a software or hardware limitation?

Right now I am using directly the 68K to play sound and music, so I was thinking to use the z80 some day to play some APCM, is that posible?
It's just a software limitation. Actually it is possible to do a driver playing PCM (even on severals channel) and music but the format has to be adapted for that (light enough to not eat too much of z80 time).

eteream
Very interested
Posts: 81
Joined: Tue Dec 22, 2009 2:13 pm

Post by eteream » Fri May 10, 2013 10:48 pm

..
Last edited by eteream on Sat Jul 20, 2013 8:32 pm, edited 1 time in total.

Mask of Destiny
Very interested
Posts: 575
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Fri May 10, 2013 11:24 pm

eteream wrote:You seem inclined to see the z80 as the only qualified to do sound, but then you admit z80 can not handle well PCM and another thing at the same time.
The problem with PCM on the Genesis is that you have to time sample delivery yourself. If you want to playback PCM samples at 22KHz, you need to perform a sample write every 163 Z80 cycles or so. You can certainly fit FM playback in between those samples, it's just a bit awkward and the sound driver needs to be written specifically to do that. This is much easier if the music format is relatively simple.
eteream wrote:Well, in my case, playing music takes so little from the 68k that right now thinking to move this feature to the z80 seems unreasonable. So the right thing to do seems to be to let the 68k make FM, and the z80 make PCM.
I think some commercial games took that approach. The biggest problem is that your sample quality tends to suffer. The reason being that the 68K can only access the YM-2612 when it has the Z80 bus. When the 68K has the Z80 bus it means the Z80 is not running and therefore not writing new samples to the DAC. If you're quick with your access to the Z80 bus and the software on the Z80 can compensate for the lost time, you can minimize the disruption, but it's tricky. If the 68K had a way to interact with the YM-2612 without interrupting the Z80, this setup would be a lot more desirable.
eteream wrote:Although I don't know exactly how the DAC works (or how music in general works, to say the truth), it seems that on the worst case scenario you can block the usage of a channel from 68k, and the use it from z80.

Am I wrong?
There's no mechanism for blocking access to or reserving a channel for one CPU or the other. You can manage that in software, but that's it.

TechnoZealot
Interested
Posts: 30
Joined: Mon May 06, 2013 2:27 am
Location: Vermont, USA

Post by TechnoZealot » Sun May 12, 2013 7:10 am

This may seem rather stupid considering the rest of the conversation, but would it theoretically by possible to hijack an unused channel (ch6) while still using either the default VGM or TFM driver, and force that channel to play either PCM or a custom FM sound?

Also for simple things, such as rendering a gunshot sound, how do I access the PSG, and if I am using the VGM driver, (I do not think TFM will do this since it was originally built for YM2203), will it lock up the PSG channels?

I have yet to find a tracker that lets me customize PSG sounds for music as well.

eteream
Very interested
Posts: 81
Joined: Tue Dec 22, 2009 2:13 pm

Post by eteream » Thu May 16, 2013 11:33 pm

..
Last edited by eteream on Sat Jul 20, 2013 8:32 pm, edited 1 time in total.

Mask of Destiny
Very interested
Posts: 575
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Fri May 17, 2013 12:16 am

eteream wrote:So, if you are pushing the limits of the hardware (which you are going to do if you want a success) and your game has some liberty of action, sooner o later you will suffer a slowdown for some tens of frames, putting the music on the co-processor seems to be the easy way to hide it.

Of curse I can be wrong... let me now if you think differently.
Using the Z80 certainly avoids that problem and I think it's generally the best solution due to the PCM sample quality concerns I voiced above (and if you're not using samples, then using the Z80 for music/sound gets simple anyway).

That said, there are ways to deal with slowdown that don't require involving the Z80. For instance, you could run the music player off the vertical interrupt (presumably after you've done your DMA for the frame) and then have the game logic run outside of the interrupt handler. That way your music player keeps running at a consistent rate even if you're short of CPU time.

TechnoZealot
Interested
Posts: 30
Joined: Mon May 06, 2013 2:27 am
Location: Vermont, USA

Post by TechnoZealot » Fri May 17, 2013 12:35 am

That sounds like a fairly good idea, only the amount of processing that could be done would be limited by the refresh rate, so choosing 320x224 mode might be a good idea if I were to try that.

However, I've tried to find some code examples of how people do this, but I'm not really very good with asm, and regardless, there seems to be a distinct lack of availability of code specifically for the Sega Genesis/MegaDrive platform.

I'm thinking if I were to design my own system for rendering audio/music on Genesis, I'd create some sort of priority system for samples, so that if another sample is currently playing, the system would check the priority of the sample it was just sent to play against that of the sample it is currently playing and determine whether or not to interrupt it. It could even be as simple as having a boolean priority: Is the sample part of the game audio or backround music? This way, you could theoretically intermingle for example PCM drum samples from the music track with PCM noises from the game logic.

Would it be possible to interrupt a sample with a smaller-length sample and then once the smaller sample is finished playing, play whatever would be left of the larger sample it eclipsed?

eteream
Very interested
Posts: 81
Joined: Tue Dec 22, 2009 2:13 pm

Post by eteream » Fri May 17, 2013 12:56 am

..
Last edited by eteream on Sat Jul 20, 2013 8:32 pm, edited 1 time in total.

eteream
Very interested
Posts: 81
Joined: Tue Dec 22, 2009 2:13 pm

Post by eteream » Fri May 17, 2013 1:29 am

..
Last edited by eteream on Sat Jul 20, 2013 8:30 pm, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest