Sega Genesis Dev Kit (SGDK)

SGDK only sub forum

Moderator: Stef

djcouchycouch
Very interested
Posts: 710
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: 3131
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: 710
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: 710
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: 340
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: 3131
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: 340
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: 710
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: 710
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.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Thu Dec 03, 2020 10:57 pm

Just released SGDK 1.60 !
https://www.patreon.com/posts/44635938
Have fun :)

danibus
Very interested
Posts: 140
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Fri Dec 04, 2020 9:17 am

Stef wrote:
Thu Dec 03, 2020 10:57 pm
Just released SGDK 1.60 !
https://www.patreon.com/posts/44635938
Have fun :)
Yihaaaaaa :mrgreen:

themrcul
Very interested
Posts: 119
Joined: Fri Apr 15, 2016 2:21 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by themrcul » Mon Dec 07, 2020 5:27 am

Thanks so much Stef for your excellent work on this SDK. Best regards!

plee
Very interested
Posts: 66
Joined: Wed Nov 29, 2006 11:32 am
Location: Houston, Texas

Re: Sega Genesis Dev Kit (SGDK)

Post by plee » Sun May 02, 2021 3:27 pm

Stef wrote:
Thu Dec 03, 2020 10:57 pm
Just released SGDK 1.60 !
https://www.patreon.com/posts/44635938
Have fun :)
Great work! Been a looonnng time since I checked on the genny stuff!

danibus
Very interested
Posts: 140
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Wed Dec 01, 2021 4:57 pm

Hi there

This is a question about Tilesets.

If I have one background...

Code: Select all

RES file  ->   IMAGE  background  "background.png"  BEST
Then in code I use to do this:

Code: Select all

    

    Map *mymap = unpackMap(background.map, NULL);
    VDP_loadTileSet(background.tileset, TILE_USERINDEX , DMA);  

   //later
   VDP_setMapEx(PLAN_A, mymap, TILE_ATTR_FULL(PAL1, TRUE, FALSE, FALSE, TILE_USERINDEX), 0, 0, 0, 0, 40, 1);
   
   //lateeeer, finishing
   MEM_free(mymap);
   mymap = NULL;   

That's fine I think (pls tell my if it's something wrong)


Then my question. What about if RES file is NOT compressed.

Code: Select all

RES file  ->   IMAGE  background2  "background2.png"  NONE
I can't do unpackMap(..) as image is not compressed, then how to "call" map in VDP_setMapEx(..), I mean, 2nd parameter.
Also can't do MEM_Free(..).

PD: I'm using older SGDK version, I think now it's Free() not MEM_free(), but that's not relevant.

I'm facing some problems and I think I'm doing something wrong with Tilesets, but not sure what :oops:

Post Reply