Type PatchStruct

From Uzebox Wiki
Jump to navigation Jump to search

PatchStruct (combined with the data it points to) contains all the information required to guide the Uzebox sound engine in regards to how your sound effects and music will be played. After passing your array of PatchStruct structs to InitMusicPlayer, you can utilize the sound API for your game's audio requirements.

struct PatchStruct {
    unsigned char type;
    const char *pcmData;
    const char *cmdStream;
    unsigned int loopStart;
    unsigned int loopEnd;   		       
};

Example:

const char monsterMoveA[] PROGMEM ={	
    0,PC_WAVE,1,
    0,PC_PITCH,75,
    0,PC_NOTE_DOWN,26, 
    1,PC_NOTE_UP,3,
    1,PC_NOTE_UP,3, 
    1,PC_NOTE_UP,3, 
    1,PC_NOTE_DOWN,16, 
    1,PC_NOTE_CUT,0,
    0,PATCH_END
};

const char monsterMoveB[] PROGMEM ={	
    0,PC_WAVE,1,
    0,PC_PITCH,75,
    0,PC_NOTE_DOWN,29, 
    1,PC_NOTE_UP,3,
    1,PC_NOTE_UP,3, 
    1,PC_NOTE_UP,3, 
    1,PC_NOTE_DOWN,13, 
    1,PC_NOTE_CUT,0,
    0,PATCH_END
};

const struct PatchStruct patches[] PROGMEM = {
    {0,NULL,alienMoveA,0,0},
    {0,NULL,alienMoveB,0,0},
};

#define SFX_ALIEN_MOVE_A       0
#define SFX_VOL_ALIEN_MOVE_A   0xA0
#define SFX_ALIEN_MOVE_B       1
#define SFX_VOL_ALIEN_MOVE_B   0xB0

int main(void) {
    InitMusicPlayer(patches);
    SetMasterVolume(0xc0);
    TriggerFx(SFX_ALIEN_MOVE_A, SFX_VOL_ALIEN_MOVE_A, true);
    TriggerFx(SFX_ALIEN_MOVE_B, SFX_VOL_ALIEN_MOVE_B, true);
}
  • Video Modes: All