Original Post

Hi to everyone, I’m getting almost done with my game but it doesn’t have any sound yet… I don’t really know nothing about waves and that stuff so like to know if there is someone out there who has made some sound programming for the VB and would like to share his code.

jorgeche

7 Replies

I wish I had some nice code, but for the most part all of my sound programming code is really ugly. If you haven’t already, read through the sound chapter in the official development manual. It’s not particularly difficult to program, there’s just no functionality like “play this sound” or “continuously loop this song in the background”, etc. It’d be possible to make a function that does that, but nobody has AFAIK. I don’t think anyone has made any functions to convert audio files to work on the VB either (like the BMP to VB converter in VIDE), so you’ll have to compose your music from scratch or make a converter.

DogP

I plan to just output some very simple sounds… maybe when I release the code someone else or maybe myself be able to add proper sound functionality. I will really appreciate if you can share whatever you have, it would be help to know where to start, thats the way I came to understand how to display stuff in the VB.

Regards
jorgeche

I just emailed you the code and app that I created… it’s nothing special, but hopefully it’ll help.

DogP

Thanks DogP I will check it out.

Regards
jorgeche

Here’s a bit of code that plays Mario’s jump effect from SMB. Boing!

Has anyone had a look to see if there are any NES/Game Boy/GBA sound tools we could convert?

// SOUND 5
#define REG_S5INT		*(vu8*)(0x01000500)
#define REG_S5LRV		*(vu8*)(0x01000504)
#define REG_S5FQL		*(vu8*)(0x01000508)
#define REG_S5FQH		*(vu8*)(0x0100050C)
#define REG_S5EV0		*(vu8*)(0x01000510)
#define REG_S5EV1		*(vu8*)(0x01000514)
#define REG_S5RAM		*(vu8*)(0x01000518)
#define REG_S5SWP		*(vu8*)(0x0100051C)

#define WAVE_RAM1		((vu8*)0x01000000)	// array

const u8 sqrwave[]=
{	
    0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
    0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
}

void play()
{
        REG_S5EV0= 0xF1;
        REG_S5EV1= 0x41;
        REG_S5SWP= 0xAF;

        REG_S5FQL= 0x40;
        REG_S5FQH= 0x05; 

        REG_S5INT= 0x80; // play
}

void main()
{
    int ii;

    for(ii=0; ii<32; ii++)
        WAVE_RAM1[ii*4]= sqrwave[ii];

    REG_S5LRV= 0xFF;
    REG_S5RAM= 0; 

    while(1)
    {
        vbWaitFrame(1); // wait for end of drawing
        key_poll();
        
        if(key_hit(K_A))
            play();
    }
}

Refs
Virtual Boy Dev Manual Section 6 - Sound Processor
http://belogic.com/gba/
http://www.coranac.com/tonc/text/sndsqr.htm

Hey cool!, will include it in my demo ASAP.

jorgeche

The frequency should probably be a bit higher, maybe 0x05A0.

 

Write a reply

You must be logged in to reply to this topic.