Is decent quality BGM possible with SFX in SGDK?

SGDK only sub forum

Moderator: Stef

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Is decent quality BGM possible with SFX in SGDK?

Post by POLYGAMe » Fri Oct 17, 2014 1:28 am

For my racing game, I want to be able to run music and SFX. The game is a 2.5D Out Run style game.

I think I have worked out how to do the visuals (thanks to forum members and Tiido) but before I get too deep into it... is doing the bgm with vgm files and pcm samples for the FX possible? At least, will I be able to obtain some decent speed?

The reason I ask is I have been messing about with the SGDK and my C skills are adequate enough for me to build the game, my problem is I really need decent music and sfx and if it's not possible I'll have to look into learning asm. Clearly I'd rather get away with doing the game in the language I know and love! And I'd like to know if this is possible before I get too far into the project. Haha.

The other option is I could write some sort of system to play pcm files for the music. If I use small samples, I may be able to get it done that way...

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Fri Oct 17, 2014 11:20 am

There are several sound engines that has support what you want.
Echo for example, it's free for use, developer of it somewhere around here.
Also there is info how to use sound engines from official SEGA games (SMPS, GEMS), but use it at your own risk, because no one knows situation about copyrights.
Image

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

Post by Stef » Fri Oct 17, 2014 12:06 pm

I'm also developing a new driver for SGDK but it won't be ready before a while. It will take VGM file as input for music and you will be able to play PCM SFX or PSG SFX (from 68000 side only) at same time.
VGM format is not very nice but as many trackers support VGM export it's an easy solution. The advantage of the incoming driver is that it will be able to play up to 4 PCM channels at fixed 14 Khz playback rate, also it should take care of the DMA contention which mean good PCM playback quality even when you have many DMA transfer occurring.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Fri Oct 17, 2014 3:17 pm

sounds like something impossible.
Image

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Fri Oct 17, 2014 3:24 pm

Stef wrote:It will take VGM file as input for music and you will be able to play PCM SFX or PSG SFX (from 68000 side only) at same time.
Do you mean playing only PSG SFX is 68000 side only? The driver and PCM SFX are on the z80?
VGM format is not very nice but as many trackers support VGM export it's an easy solution. The advantage of the incoming driver is that it will be able to play up to 4 PCM channels at fixed 14 Khz playback rate,
So up to four sound effects at the same time? That would be seriously nice for my needs.

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

Post by Stef » Fri Oct 17, 2014 5:31 pm

Actually the z80 will be able to play classic vgm with 5FM + 1PCM + 3/4 PSG or 6FM + 3/4 PSG as usual, PCM is fixed at 14 Khz. It would even be able to play 5FM + 4PCM + 3/4PSG music but there is no tracker supporting it. It will support PCM SFX with up to 16 priority level. For PSG SFX I just allow channel reservation so the Z80 don't use it anymore for the music allowing the 68k CPU to use a PSG channel to play some SFX. I did this way because the 68k has direct access to the PSG and also because the Z80 is already very busy with others stuff :P

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

Post by Stef » Fri Oct 17, 2014 5:39 pm

r57shell wrote:sounds like something impossible.
To be honest it is not yet completed and maybe I'm too optimist.
I already lowered the pcm playback rate to 14 Khz because 16 Khz was definitely too much (and more importantly above the 15.3 khz corresponding to a frame time for 256 bytes buffer). The driver is wrote so it can miss a frame or two and try to recover afterward... In this case the DMA contention won't be respected anymore but that is not a big deal, the deal is about the music quality itself, maybe it will sound completely distorted :P
Last edited by Stef on Fri Oct 17, 2014 7:33 pm, edited 1 time in total.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Post by POLYGAMe » Fri Oct 17, 2014 7:28 pm

Great, thanks for the reply. Definitely sounds worth sticking with the SGDK then. Makes it so much easier to code.

I've done a bit of digging and it seems vgm files run okay if you stay away from using samples. I can live with that!

4 channels of pcm would be nice too! Could do some very cool Amiga style stuff!

Cheers :)
Last edited by POLYGAMe on Fri Oct 17, 2014 7:41 pm, edited 2 times in total.

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

Post by Stef » Fri Oct 17, 2014 7:36 pm

About the 4 PCM channels, there is no envelop nor pitch support, it's just playing PCM as they get ! It's much more limited but we can't do that much with Z80...

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Post by POLYGAMe » Fri Oct 17, 2014 7:39 pm

Stef wrote:About the 4 PCM channels, there is no envelop nor pitch support, it's just playing PCM as they get ! It's much more limited but we can't do that much with Z80...
Ah, I see. No engine sound effects then! lol.

Is tone generation possible?

One more thing, am I right in assuming that currently pcm is the only option for sfx? That suits me fine but just wondering how many sample/channels it's possible to play currently? Just one? I'd like to have engine and tyre screeching noises at the same time but I suppose if it's possible I could look at some sort of tone generation for the engine instead of samples.

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

Post by Stef » Fri Oct 17, 2014 7:56 pm

You have 4 PCM channels so basically you can play 4 SFX at once if you use the PCM for that (but then you don't have anymore PCM for the music).
PCM is a recorded sample, if you need an explosion SFX just take a explosion WAV file as that is. You can also use the PSG to generate sound effect (by using the 68000 CPU), the only restriction is that you can't play any SFX with FM... Anyway right now there is none of that available, you have to use driver as Echo or the VGM driver, both allow to play SFX with PCM (single channel only), Echo does allow FM and PSG SFX as far i remember.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Post by POLYGAMe » Fri Oct 17, 2014 8:41 pm

Stef wrote:You have 4 PCM channels so basically you can play 4 SFX at once if you use the PCM for that (but then you don't have anymore PCM for the music).
PCM is a recorded sample, if you need an explosion SFX just take a explosion WAV file as that is. You can also use the PSG to generate sound effect (by using the 68000 CPU), the only restriction is that you can't play any SFX with FM... Anyway right now there is none of that available, you have to use driver as Echo or the VGM driver, both allow to play SFX with PCM (single channel only), Echo does allow FM and PSG SFX as far i remember.
Okay, thanks. I should be able to get something together that works :)

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Sat Oct 18, 2014 5:15 pm

I'll be excited to see a much more feature rich VGM driver, Stef. I agree that limiting compatibility a bit with all the existing vgm files out there is probably the right way to go in order to make a z80 driver that can do all what we want.

The existing vgm driver will allow FM music and PCM (sound effects or samples) on channel six and attempt to interleave these, but that's full of compromises, like an 8khz sample rate and only one PCM channel. (also not DMA friendly)

I was considering going back and rewriting the vgm driver a third time, but I think you are getting farther that I would anyways.

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

Post by Stef » Sun Oct 19, 2014 2:32 pm

Your VGM driver is already very useful, actually i recommend it when people want something easy to play music and have SFX support. Of course you're limited to single PCM and 8 Khz but that is already quite an achievement thinking the driver is actually wrote in C !
I don't know how much i will be able to keep the wanted features in my "extended" VGM driver, for instance i think i will remove the PSG channel reservation for speed reason (so you will have to do it manually by using only specific channels for music and others for SFX). My cycle budget is limited and i couldn't use the SP register which allow many possible code optimizations (i need to preserve it for interruption and not miss any frame), also my Z80 programming skill is really low, i really don't like coding with this CPU :-/

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Sun Oct 19, 2014 3:28 pm

My z80 skillz are lower. Lol.

I think having to reserve the PSG for SFX if that is what you choose (or FM channel 6) is a completely reasonable restriction.

I see two use cases for a VGM driver that are somewhat incompatible. In one case, the VGM driver attempts to play existing random VGM rips as is. That's roughly what the driver I wrote became (though not my original intention). I tried to support as much of the full VGM spec as the z80 and my patience allowed.

The other case is for new music (or rearranged music) that is created specifically for a purpose, such as a new demo or game. Having some restrictions makes sense here since the goal is speed and cool features.

Post Reply