Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Fri Oct 21, 2005 5:56 am Post subject: |
|
|
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 |
|