Page 56 of 57

Re: Sega Genesis Dev Kit (SGDK)

Posted: Sat Aug 15, 2020 3:18 pm
by djcouchycouch
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

Re: Sega Genesis Dev Kit (SGDK)

Posted: Sun Aug 16, 2020 9:27 am
by Stef
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).

Re: Sega Genesis Dev Kit (SGDK)

Posted: Sun Aug 16, 2020 2:22 pm
by djcouchycouch
It makes more sense now, thanks!

Re: Sega Genesis Dev Kit (SGDK)

Posted: Mon Aug 17, 2020 3:38 am
by djcouchycouch
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.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Mon Aug 17, 2020 6:52 am
by cero
sox can do it, but using audacity to export at 16khz is close enough.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Mon Aug 17, 2020 8:28 am
by Stef
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.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Mon Aug 17, 2020 11:46 pm
by Grind
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.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Tue Aug 18, 2020 6:19 am
by cero
It's under the custom options in the export dialog.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Tue Aug 18, 2020 2:34 pm
by djcouchycouch
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.

Re: Sega Genesis Dev Kit (SGDK)

Posted: Thu Aug 20, 2020 2:06 am
by djcouchycouch
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.

Re: Sega Genesis Dev Kit (SGDK)

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

Re: Sega Genesis Dev Kit (SGDK)

Posted: Fri Dec 04, 2020 9:17 am
by danibus
Stef wrote:
Thu Dec 03, 2020 10:57 pm
Just released SGDK 1.60 !
https://www.patreon.com/posts/44635938
Have fun :)
Yihaaaaaa :mrgreen:

Re: Sega Genesis Dev Kit (SGDK)

Posted: Mon Dec 07, 2020 5:27 am
by themrcul
Thanks so much Stef for your excellent work on this SDK. Best regards!

Re: Sega Genesis Dev Kit (SGDK)

Posted: Sun May 02, 2021 3:27 pm
by plee
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!

Re: Sega Genesis Dev Kit (SGDK)

Posted: Wed Dec 01, 2021 4:57 pm
by danibus
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: