VGM or TFM with PCM?
Moderator: BigEvilCorporation
-
- Interested
- Posts: 30
- Joined: Mon May 06, 2013 2:27 am
- Location: Vermont, USA
VGM or TFM with PCM?
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!
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!
-
- Interested
- Posts: 30
- Joined: Mon May 06, 2013 2:27 am
- Location: Vermont, USA
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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.
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 ![Wink ;)](./images/smilies/icon_wink.gif)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
![Wink ;)](./images/smilies/icon_wink.gif)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
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
The stuff Genesis developers managed to do with 30 year old hardware blows my freakin' mind sometimes I tell you what
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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 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?
-
- Very interested
- Posts: 615
- Joined: Thu Nov 30, 2006 6:30 am
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: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.
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: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.
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.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?
-
- Interested
- Posts: 30
- Joined: Mon May 06, 2013 2:27 am
- Location: Vermont, USA
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.
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.
-
- Very interested
- Posts: 615
- Joined: Thu Nov 30, 2006 6:30 am
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).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.
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.
-
- Interested
- Posts: 30
- Joined: Mon May 06, 2013 2:27 am
- Location: Vermont, USA
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?
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?