more than one sound

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
elevationsnow
Posts: 22
Joined: Sat Sep 10, 2005 6:45 am

more than one sound

Post by elevationsnow »

is it possible to load more than one sound at a time if so how would i do it
do i have to load them on different chanels or what?
also is it possible to compile a sound into a c file and play it from there?
RCON
Posts: 16
Joined: Wed Aug 03, 2005 1:02 am
Contact:

Post by RCON »

Yes you can have multiple sounds play on one audio channel. check out the WAVLoader software on this site http://labs.wonderbyte.com/.
That loader will load the wave files into memory so you don't need to convert it to C.
Brunni
Posts: 186
Joined: Sat Oct 08, 2005 10:27 pm

Post by Brunni »

You can simply transform binary sound data into a C table. There are some programs for that.
However, if you do this, beware, GCC compiles large tables extremely slowly. Instead of including it into a .h file, use preferably another source (.c) file, and compile it once.
You can also render your own sound stream, as emulators do. Basically, mixing of two sounds is simply an addition of both, so rendering of signed 16-bit sound data could be something like this (in an unoptimized form):

Code: Select all

void RenderSound (s16 *soundbuffer, s16 **voicesdata, u32 streamoffset, u32 streamsize)
{
    u32 i, curstreamdata;
    s32 curdata;
    //We must render a certain number of 16-bit values for each frame (streamsize). At each frame, the offset of each voice data is incremented (from streamsize), but data are always written to the same location (soundbuffer).
    for &#40;curstreamdata=0; curstreamdata<streamsize; curstreamdata++&#41;
    &#123;
        curdata = 0;
        //Add together the current 16-bit value from each voice
        for &#40;i=0; i<NUMBER_OF_VOICES; i++&#41;
        &#123;
             //Here, no sound decoding, just plain copy
             curdata += voicesdata&#91;i&#93;&#91;curstreamdata+streamoffset&#93;;
        &#125;
        //Verify if there is an overflow
        if &#40;curdata > SIGNED16_MAX_VALUE&#41;
             curdata = SIGNED16_MAX_VALUE;
        if &#40;curdata < SIGNED16_MIN_VALUE&#41;
             curdata = SIGNED16_MIN_VALUE;
        //Copy it next to the buffer
        *soundbuffer++ = curdata;
    &#125;
&#125;
But I don't think there are any advantage doing this, except for emulators, or if you will use your own sound format or a format not supported by the PSP sound hardware, such as modules, or spc data.

Just my 2 cents ^^
Brunni
Sorry for my bad english
Image Oldschool library for PSP - PC version released
Post Reply