Sega Genesis Dev Kit (SGDK)

SGDK only sub forum

Moderator: Stef

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

Re: Sega Genesis Dev Kit (SGDK)

Post by djcouchycouch » Sat Aug 15, 2020 3:18 pm

Hi there!

I'd like some clarification on defining sound effects in a .res file.

The docs explain the format like this:

Code: Select all

WAV name wav_file [driver [outrate]]
and the simplified test app I cobbled together from the samples have .res file like this:

Code: Select all

XGM track1 "Casino Funk Zone.vgm"
XGM comix_zone_dfm_export "comix_zone_dfm_export.vgm"
WAV explode_16k "explode.wav" 2
WAV snare1_14k "snare1.wav" 5
WAV cri_14k "cri.wav" XGM
 
and main looks like this:

Code: Select all

#include <genesis.h>
#include "music.h"

static u16 joyState;
static u16 buttonsPressed;

static void joyEvent(u16 joy, u16 changed, u16 state)
{
    u16 pressed = changed & state;

    joyState = state;

    // keep buttons state
    if (buttonsPressed != state)
    {
        buttonsPressed = state;
        // reset press time
    }

    // PCM 1
    if (pressed & BUTTON_X)
    {
        XGM_startPlayPCM(64, 1, SOUND_PCM_CH2);
    }
    // PCM 2
    if (pressed & BUTTON_Y)
    {
        XGM_startPlayPCM(65, 1, SOUND_PCM_CH3);
    }
    // PCM 3
    if (pressed & BUTTON_Z)
    {
        XGM_startPlayPCM(66, 1, SOUND_PCM_CH4);
    }
}

int main()
{
	buttonsPressed = 0;

	XGM_setLoopNumber(-1);

	XGM_setPCM(64, explode_16k, sizeof(explode_16k));
    XGM_setPCM(65, snare1_14k, sizeof(snare1_14k));
    XGM_setPCM(66, cri_14k, sizeof(cri_14k));

	JOY_setEventHandler(joyEvent);

	XGM_startPlay(&track1);

    while(1)
    {
        VDP_waitVSync();
    }
    return (0);
}
Everything seems to work fine, but I'm not sure if the 2/5/XGM parameters in the .res file are supposed to do anything. They also appear optional so I'm not even sure if I need to specify anything there.

I wonder if it has something to do with playing sounds in mono/stereo.

Can you clear this up for me?

Thanks!
djcc

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Sun Aug 16, 2020 9:27 am

As you can read it in the documentation, the fourth parameter tells which sound driver the WAV / sample is intended to be used.
It's really important because all sound driver has their own specificities / features (sample playback rate for instance) but the thing is that only the XGM driver is usable in-game condition (music + SFX). So in the end you will probably use the XGM driver (you can use "5" or "XGM").
Note that XGM driver use 14 Khz sample playback so it's better to provide pre-filtered / adjusted sample rate WAV files, if not rescomp will do the conversion for you, but not as good than a dedicated tool !

In your example the explode sample is meant to be used on 4 PCM channel driver given the declaration in the .res file, which play at 16 Khz, so trying to use the sample with XGM driver will actually not play it correctly (14 Khz so lower pitch than intended).

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

Re: Sega Genesis Dev Kit (SGDK)

Post by djcouchycouch » Sun Aug 16, 2020 2:22 pm

It makes more sense now, thanks!

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

Re: Sega Genesis Dev Kit (SGDK)

Post by djcouchycouch » Mon Aug 17, 2020 3:38 am

About conversion, what's the suggested tool to convert to signed 8bit at 14 Khz? I downloaded Audacity assuming it could do it and its export settings don't seem to support that.

cero
Very interested
Posts: 286
Joined: Mon Nov 30, 2015 1:55 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by cero » Mon Aug 17, 2020 6:52 am

sox can do it, but using audacity to export at 16khz is close enough.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Mon Aug 17, 2020 8:28 am

Myself i'm using wavosaure, i believe it's a windows only tool. it's free, simple and has exactly what i need to convert / filter my WAV files.

Grind
Very interested
Posts: 69
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Re: Sega Genesis Dev Kit (SGDK)

Post by Grind » Mon Aug 17, 2020 11:46 pm

If the lower left corner of Audacity is the frequency. Click on it and type 14000. It will export as that frequency. I save it as 16-bit because there is no 8 bit option.

cero
Very interested
Posts: 286
Joined: Mon Nov 30, 2015 1:55 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by cero » Tue Aug 18, 2020 6:19 am

It's under the custom options in the export dialog.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by djcouchycouch » Tue Aug 18, 2020 2:34 pm

Thanks for the suggestions! I used wavosaure to trim the silence and then sox to batch convert to the right format. Worked like a charm.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by djcouchycouch » Thu Aug 20, 2020 2:06 am

When converting a VGM to a ROM with the xgmrombuilder, do samples used in the VGM have to be 8bit/14khz or does it convert automatically? I'm working with a music composer who's trying to their GENNY VST VGMs with the tool. They say the samples he's using are muddy and slow, so I'm thinking it's a format issue.

Post Reply