gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > Boyscout Playback Library

#38615 - SNES-lover - Tue Mar 29, 2005 4:47 pm

Hi.
I've started using Boyscout in the days, but as you all propably know, the playback library that comes with it doesn't work properly onm hardware, as Channel 3 doesn't make any sound at all.

Is there anyone out there that has a solution to this, or maybe someone has made their own code for playback(I'm programming in C using Devkit Advance).

I think many would be really grateful if code working on hardware would be made public.
_________________
In a realm beyond sight,
the sky shines gold, not blue.
There, the Triforce might
make mortal dreams come true.

#38749 - Bowser - Thu Mar 31, 2005 10:22 am

Yes, that would be nice! I'm using Devkitadv also with Boyscout, and no sound on channel 3 when runing on my real GBA SP!

And it's a pain in the butt, to get the Boyscout code to work in Multiboot mode. However, I did get it to work in Multiboot mode without editing the Boyscout code!

I can post what I did and my code, if you guys want?

Edit: Wow! This is my first post, since I joined here last year!

#38752 - SNES-lover - Thu Mar 31, 2005 11:01 am

Bowser wrote:
However, I did get it to work in Multiboot mode without editing the Boyscout code!

I can post what I did and my code, if you guys want?


Yes, I have that problem too.. If you care to post it, that would be pretty nice =)
_________________
In a realm beyond sight,
the sky shines gold, not blue.
There, the Triforce might
make mortal dreams come true.

#38753 - Bowser - Thu Mar 31, 2005 11:51 am

Bowser wrote:
And it's a pain in the butt, to get the Boyscout code to work in Multiboot mode. However, I did get it to work in Multiboot mode without editing the Boyscout code!


Oops! You DO need to edit one line of code in the Boyscout.cpp file:

Quote:
// Default memory to beginning of external RAM
g_nBoyScoutMemoryArea = 0x02000000;

Change to:

g_nBoyScoutMemoryArea = 0x02FA0000;


That way, Boyscout uses that memory area for it's ram buffer, and not right over the multiboot program. Then put:

Quote:
int __gba_multiboot;


At the top off your main code file.

#38760 - FluBBa - Thu Mar 31, 2005 12:42 pm

The EWRAM is 0x02000000-0x0203FFFF, so use g_nBoyScoutMemoryArea = 0x02020000 instead.
Is the source available for the BoyScout player, the problem with channel 3 is probably due to swapping of the wave ram banks.
_________________
I probably suck, my not is a programmer.

#38764 - wintermute - Thu Mar 31, 2005 1:06 pm

source can be found here -> http://www.pidelipom.com/boyscout/

as for the memory use the provided functions instead

Code:

///////////////////////////////////////////////////////////////////////
// Function: BoyScoutSetMemoryArea                                   //
//                                                                   //
// Description: Sets the address to the beginning of a memory area   //
//            that BoyScout may use. This is basically for storing //
//            pattern description for faster access times.         //
//                                                                   //
// Parameters: Address to the memory area beginning.                 //
//                                                                   //
void BoyScoutSetMemoryArea(unsigned int nMemoryAddress) ///////////////
{
   // Set it
   g_nBoyScoutMemoryArea = nMemoryAddress;
}
// End of BoyScoutSetMemoryArea




You can use BoyScoutSetMemoryArea(0x02020000); after the BoyScoutInitialize(); call.

You should really malloc a buffer though.

From the BoyScout manual

Code:

void AgbMain(void)
{
     unsigned int nBSSongSize;

// Initialize BoyScout
BoyScoutInitialize();

// Get needed song memory
nBSSongSize = BoyScoutGetNeededSongMemory((unsigned char *)SongData);

// Allocate and set BoyScout memory area
BoyScoutSetMemoryArea((unsigned int)malloc(nBSSongSize));

// Open song
BoyScoutOpenSong((unsigned char *)SongData);

// Play song and loop
BoyScoutPlaySong(1);

while(1)
{
     // Wait for vertical blank
WaitForVSync();

// Update song
BoyScoutUpdateSong();
     }

// This part will never be reached but just for completion
// Free memory
free((void *)BoyScoutGetMemoryArea());
}

#38842 - Bowser - Fri Apr 01, 2005 10:33 am

I put together a simple program, Edited one line o code in Boyscout.cpp , included a some test music I made, and renamed some files. It also works with Multiboot but, still no sound 3. And, I got it to come out REALY small: 8.25KBs :)

Download it from my site:
*Right click, Save Target As...*

http://www.VirtualMario.com/download/R.B.J-BSTestTune.zip


Last edited by Bowser on Wed Apr 13, 2005 6:22 am; edited 1 time in total

#38851 - FluBBa - Fri Apr 01, 2005 1:41 pm

They only set the waveram bank to 1 and never switch it.

from line 612:
Code:

         // Copy waveform to bank 0
         SG30L = SG30LSTEP32   | SG30LSETBANK1;

            // WK add conditional define, and fix software copy

            #if(USE_DMA)

            DMA3Copy32((unsigned int)&g_pSound3WaveForms[4*g_nSound3PlayWaveForm], (unsigned int)&SGWRAM, 4);

            #else

         pSrc = (unsigned int*)&g_pSound3WaveForms[4*g_nSound3PlayWaveForm];
         pDst = (unsigned int*)&SGWRAM;
         pDst[0] = pSrc[0];
         pDst[1] = pSrc[1];
         pDst[2] = pSrc[2];
         pDst[3] = pSrc[3];

            #endif
      }


You should probably insert
SG30L = SG30LSTEP32 | SG30LSETBANK0;
after the copy so the GBA actually uses the new waveram...
_________________
I probably suck, my not is a programmer.

#38890 - wintermute - Fri Apr 01, 2005 5:34 pm

FluBBa wrote:
They only set the waveram bank to 1 and never switch it.

from line 612:

You should probably insert
SG30L = SG30LSTEP32 | SG30LSETBANK0;
after the copy so the GBA actually uses the new waveram...


That's the initial wave loading, the switching is done at line 841

Code:

            // Set to correct bank
            if(g_iSound3PlayBank == 1)
               SG30L = SG30LSTEP32 | SG30LSETBANK1;
            else
               SG30L = SG30LSTEP32 | SG30LSETBANK0;


and waveform updating done at 1071

Code:

   // UPDATE SOUND3 WAVE FORM DATA //

   // If a new waveform is set
   if(g_aRLESound3[2].nValue != g_nSound3PlayWaveForm && g_aRLESound3[2].nValue != PATTERN_PARAMETER_EMPTY)
   {
      // If a valid wave form
      if(g_aRLESound3[2].nValue < g_cSound3WaveForms)
      {
         unsigned int *pDst, *pSrc;
         // Set wave form
         g_nSound3PlayWaveForm = g_aRLESound3[2].nValue;


            // WK add conditional define, and fix software copy

         // Copy wave form to WRAM
            #if(USE_DMA)
           
         DMA3Copy32((unsigned int)&g_pSound3WaveForms[4*g_nSound3PlayWaveForm], (unsigned int)&SGWRAM, 4);

            #else

         pSrc = (unsigned int*)&g_pSound3WaveForms[4*g_nSound3PlayWaveForm];
         pDst = (unsigned int*)&SGWRAM;
         pDst[0] = pSrc[0];
         pDst[1] = pSrc[1];
         pDst[2] = pSrc[2];
         pDst[3] = pSrc[3];

            #endif

         // Set current play bank
         if(g_iSound3PlayBank == 1)
            g_iSound3PlayBank = 0;
         else
            g_iSound3PlayBank = 1;
      }
   }



I submitted a couple of fixes to Christer just now

the problem with hardware playback is at line 875

Code:

            SG31  = SG31FREQUENCY(canNoteFrequencies[g_anSound3Params[3]-36]) | SG31PLAYONCE;

            SG31  |= SG31INIT;
            SG30L |= SG30LPLAY;



which should read

Code:

            SG30L |= SG30LPLAY;
            SG31  = SG31FREQUENCY(canNoteFrequencies[g_anSound3Params[3]-36]) | SG31PLAYONCE;

            SG31  |= SG31INIT;

#38891 - wintermute - Fri Apr 01, 2005 5:44 pm

Bowser wrote:
I put together a simple program, Edited one line o code in Boyscout.cpp , included a some test music I made, and renamed some files. It also works with Multiboot but, still no sound 3. And, I got it to come out REALY small: 8.25KBs :)

Download it from my site:
*Right click, Save Target As...*

http://www.virtualmario.com/BSLib.zip


that's such a horrible build system

devkitARM_r11 makes a binary of 6,528 bytes with your tune


http://l33t.spod.org/~WntrMute/Boyscout.zip

#39148 - Bowser - Tue Apr 05, 2005 5:31 am

Boyscout lib sets, sound 3 notes, step, ect... Just fine but, it does NOT set the Wave form data when on a real GBA/SP or it sets it to FF FF FF ect...!

Wintermute, your Makefile won't work for me at all! I set things right but, it just won't work!

And your BoyS example, all sounds work fine on a emulater but not the real thing, and sound 4 sounds fine on both with your example but, sound 4 only sounds good on a emulater with my example! Kinda weard... Must be DevKitAdv with the memory! :P

I also tried the code fix you said starting at line 875 but, it did'nt work.

I'm sure somebody can fix the sound 3 playback! ;)

#39212 - wintermute - Wed Apr 06, 2005 1:23 am

Bowser wrote:
Boyscout lib sets, sound 3 notes, step, ect... Just fine but, it does NOT set the Wave form data when on a real GBA/SP or it sets it to FF FF FF ect...!


well, the last attempt sounded like it wasn't setting the notes properly to me.

Quote:

Wintermute, your Makefile won't work for me at all! I set things right but, it just won't work!


well, devkitadvance is a bit behind the times now :P

Quote:

I'm sure somebody can fix the sound 3 playback! ;)


yeah, try this

http://l33t.spod.org/~WntrMute/WorkingBoyscout.zip

#39226 - Bowser - Wed Apr 06, 2005 5:28 am

Wintermute, you did it!!! You MUST send it to the Boyscout owner! Now it's time to start making music using Boyscout!

As for your makefiles, I DID use DevkitArm with makesys but, it came up with lots of dir errors and can't find file errors! I'll try again later.

To everyone: I know this is a little bit offtopic but, I finished my BoyS test tune, download below (Right click, Save As):


http://www.VirtualMario.com/download/R.B.J-BSTestTune.zip

Great job Wintermute, on the Boyscout Lib!!!


Last edited by Bowser on Wed Apr 13, 2005 6:21 am; edited 1 time in total

#39233 - SNES-lover - Wed Apr 06, 2005 9:31 am

wintermute, I tested out your updated library and the code in my project this morning, but it made no difference to the distorted sounds at all(in multiboot at least). I will check it out properly when I come home from school and meetings tonight.
_________________
In a realm beyond sight,
the sky shines gold, not blue.
There, the Triforce might
make mortal dreams come true.

#39234 - Bowser - Wed Apr 06, 2005 10:04 am

SNES-lover wrote:
wintermute, I tested out your updated library and the code in my project this morning, but it made no difference to the distorted sounds at all(in multiboot at least). I will check it out properly when I come home from school and meetings tonight.


Yep! It is DevKitAdv! We need to start using DevkitArm! *Go's and Trys using DevkitArm again!* :P

And I updated my tune cause, I set the notes to lood on sound 4 in the music. :)

#39236 - SNES-lover - Wed Apr 06, 2005 10:54 am

Yep, it is DevKitAdvance I'm using, as I'm going with HAM and the HAMlib.. Maybe I'll try to go DevKitARM with the HAMlib if it's possible ;/
_________________
In a realm beyond sight,
the sky shines gold, not blue.
There, the Triforce might
make mortal dreams come true.