It's pretty simple, first, you need to create and get sound data. Use
http://www.yodasvideoarcade.com/gamebuino.php%20FX-SYNTH. Mess around with this "game". When you're done and happy with the sound, save the sound. How to save the sound? Use this for example:
- Code: Select all
const int soundfx[8][8] = {
{1,27,90,2,7,7,3,7}, //jump <
{1,27,112,1,1,1,6,4}, // walljump <
{0,27,57,1,1,1,6,4}, // unlockdoor <
{0,9,57,1,6,8,7,8}, // land
{0,46,57,1,0,18,7,47}, // getkey <
{0,38,79,3,6,7,7,20}, // finish <
{0,30,68,3,0,0,7,5}, // click <
{0,30,55,1,7,0,7,15} //death <
};
All your sound will be saved this way. In FX-SYNTH, you can see the numbers, write them in the array this way: WAVEFORM, PITCH, PMD, PMT, VMD, VMT, VOL, LENGTH. If you want to play a sound, use this function
- Code: Select all
void sfx(int fxno, int channel) {
gb.sound.command(0, soundfx[fxno][6], 0, channel); // set volume
gb.sound.command(1, soundfx[fxno][0], 0, channel); // set waveform
gb.sound.command(2, soundfx[fxno][5], -soundfx[fxno][4], channel); // set volume slide
gb.sound.command(3, soundfx[fxno][3], soundfx[fxno][2] - 58, channel); // set pitch slide
gb.sound.playNote(soundfx[fxno][1], soundfx[fxno][7], channel); // play note
//WAVEFORM, PITCH, PMD, PMT, VMD, VMT, VOL, LENGTH
}
and call it this way:
- Code: Select all
sfx(/*The id of the sound, for exemple "jump" is 0, land is 3...*/, /*The channel need to be in the range of 0 to 3, if you haven't modify setting.c to change the NUM_CHANNEL, you can use only the first channel (0)*/);
'Hope it will work, if you don't understand something I have said (I normally speak french), please ask it.