Page 1 of 2
VGM or TFM with PCM?
Posted: 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?
Posted: 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.
Posted: 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.
Posted: Tue May 07, 2013 7:44 pm
Posted: 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.
Posted: 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
Posted: 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).
Posted: Fri May 10, 2013 10:48 pm
Posted: 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.
Posted: 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.
Posted: Thu May 16, 2013 11:33 pm
Posted: 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.
Posted: 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?
Posted: Fri May 17, 2013 12:56 am
Posted: Fri May 17, 2013 1:29 am