forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

more than one sound

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
elevationsnow



Joined: 10 Sep 2005
Posts: 22

PostPosted: Tue Oct 18, 2005 8:05 am    Post subject: more than one sound Reply with quote

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?
Back to top
View user's profile Send private message
RCON



Joined: 03 Aug 2005
Posts: 16

PostPosted: Fri Oct 21, 2005 3:26 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Brunni



Joined: 08 Oct 2005
Posts: 186

PostPosted: Fri Oct 21, 2005 5:56 am    Post subject: Reply with quote

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:
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 (curstreamdata=0; curstreamdata<streamsize; curstreamdata++)
    {
        curdata = 0;
        //Add together the current 16-bit value from each voice
        for (i=0; i<NUMBER_OF_VOICES; i++)
        {
             //Here, no sound decoding, just plain copy
             curdata += voicesdata[i][curstreamdata+streamoffset];
        }
        //Verify if there is an overflow
        if (curdata > SIGNED16_MAX_VALUE)
             curdata = SIGNED16_MAX_VALUE;
        if (curdata < SIGNED16_MIN_VALUE)
             curdata = SIGNED16_MIN_VALUE;
        //Copy it next to the buffer
        *soundbuffer++ = curdata;
    }
}

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
Oldschool library for PSP - PC version released
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group