 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Mon Jul 18, 2005 4:02 pm Post subject: audio help |
|
|
I've modified the audio sample in svn (polyphonic example) to load one a wav file and play at the start of my program. So far it works great but I am having two issues:
1) What is the size limit? I can load a 2.5 mb wav file but 3mb and above fail.
2) I attempted to turn looping on on one of my wav files but this does not seem to work:
| Code: |
wavout_wavinfo_t *wav_intro;
/* main routine */
int main(int argc, char *argv[])
{
...
wavInit();
wav_intro = wavLoad("intro.wav");
wav_intro->playloop = 1;
wavPlay(wav_intro);
|
I even attempted to hardcode playloop to 1 within wave.h
Am I wrong in assuming this is not implemented yet?
Thanks in advance...[/code] _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Jul 18, 2005 5:16 pm Post subject: Re: audio help |
|
|
| The polyphonic example doesn't have wavInit(), wavLoad() and wavPlay(), but looks like some useful functions. Can you post the source of it? This might help discovering the bug, too :-) |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Mon Jul 18, 2005 10:03 pm Post subject: Re: audio help |
|
|
| Shine wrote: | | The polyphonic example doesn't have wavInit(), wavLoad() and wavPlay(), but looks like some useful functions. Can you post the source of it? This might help discovering the bug, too :-) |
Really? I could've sworn that's where I got it from... :p I need more sleep!
OK, basically it's two files; wave.c and wave.h - both seem to be derived from the pre-SDK sound.c however I am noticing that not everything is implemented (looping is a good example).
wave.c:
| Code: |
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspaudiolib.h>
#include <pspaudio.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include "wave.h"
#define printf pspDebugScreenPrintf
extern char *g_boot_path;
#define SND_MAXSLOT 16
wavout_wavinfo_t wavout_snd_wavinfo[SND_MAXSLOT];
int wavout_snd_playing[SND_MAXSLOT];
short *samples;
unsigned long req;
static void wavout_snd_callback(short *_buf, unsigned long _reqn)
{
int i,slot;
wavout_wavinfo_t *wi;
unsigned long ptr,frac;
short *buf=_buf;
samples = _buf;
req = _reqn;
for (slot=0; slot<SND_MAXSLOT; slot++)
{
pspDebugScreenSetXY(0,3+slot);
if (wavout_snd_playing[slot])
printf("%02d active ",slot);
else
printf("%02d inactive",slot);
}
for (i=0; i<_reqn; i++)
{
int outr=0,outl=0;
for (slot=0; slot<SND_MAXSLOT; slot++)
{
if (!wavout_snd_playing[slot]) continue;
wi=&wavout_snd_wavinfo[slot];
frac=wi->playptr_frac+wi->rateratio;
wi->playptr=ptr=wi->playptr+(frac>>16);
wi->playptr_frac=(frac&0xffff);
if (ptr>=wi->samplecount)
{
wavout_snd_playing[slot]=0;
break;
}
short *src=(short *)wi->wavdata;
if (wi->channels==1)
{
outl+=src[ptr];
outr+=src[ptr];
}
else
{
outl+=src[ptr*2];
outr+=src[ptr*2+1];
}
}
if (outl<-32768)
outl=-32768;
else if (outl>32767)
outl=32767;
if (outr<-32768)
outr=-32768;
else if (outr>32767)
outr=32767;
*(buf++)=outl;
*(buf++)=outr;
}
}
void wavHalt(char *string,char *name)
{
pspDebugScreenInit();
pspDebugScreenSetBackColor(0x00FF0000);
pspDebugScreenSetTextColor(0xFFFFFFFF);
pspDebugScreenClear();
printf("I regret to inform you file %s\nfailed with error %s\n",name,string);
}
int wavInit()
{
int i;
pspAudioInit();
pspAudioSetChannelCallback(0, wavout_snd_callback);
for (i=0; i<SND_MAXSLOT; i++)
{
wavout_snd_playing[i]=0;
}
return 0;
}
//stop all
void wavoutStopPlay()
{
int i;
for (i=0; i<SND_MAXSLOT; i++)
wavout_snd_playing[i]=0;
}
//return 0 if success
int wavPlay(wavout_wavinfo_t *wi)
{
int i;
wavout_wavinfo_t *wid;
for (i=0; i<SND_MAXSLOT; i++) if (wavout_snd_playing[i]==0) break;
if (i==SND_MAXSLOT) return -1;
wid=&wavout_snd_wavinfo[i];
wid->channels=wi->channels;
wid->samplerate=wi->samplerate;
wid->samplecount=wi->samplecount;
wid->datalength=wi->datalength;
wid->wavdata=wi->wavdata;
wid->rateratio=wi->rateratio;
wid->playptr=0;
wid->playptr_frac=0;
wid->playloop=0;
wavout_snd_playing[i]=1;
return 0;
}
//return waveinfo * if success
wavout_wavinfo_t *wavLoad(char *filename)
{
unsigned int filelen;
int fd;
unsigned long channels;
unsigned long samplerate;
unsigned long blocksize;
unsigned long bitpersample;
unsigned long datalength;
unsigned long samplecount;
char *wavfile;
char path_name[256];
wavout_wavinfo_t *wi;
SceIoStat stat;
sprintf(path_name,"%s%s",g_boot_path,filename);
fd = sceIoOpen(path_name, PSP_O_RDONLY, 0777);
if (fd<0)
{
wavHalt("file failed",path_name);
return NULL;
}
sceIoGetstat(path_name,&stat);
wi = malloc(stat.st_size + sizeof(wavout_wavinfo_t));
wavfile = (char*)(wi+sizeof(wavout_wavinfo_t));
filelen = sceIoRead(fd, wavfile, stat.st_size);
sceIoClose(fd);
if (memcmp(wavfile,"RIFF",4)!=0)
{
wavHalt("format error not RIFF",path_name);
free(wi);
return NULL;
}
if (memcmp(wavfile+8,"WAVEfmt \x10\x00\x00\x00\x01\x00",14)!=0)
{
wavHalt("format error no WAVEfmt string",path_name);
free(wi);
return NULL;
}
channels=*(short *)(wavfile+0x16);
samplerate=*(long *)(wavfile+0x18);
blocksize=*(short *)(wavfile+0x20);
bitpersample=*(short *)(wavfile+0x22);
if (memcmp(wavfile+0x24,"data",4)!=0)
{
wavHalt("no data chunk found",path_name);
free(wi);
return NULL;
}
datalength=*(unsigned long *)(wavfile+0x28);
if (datalength+0x2c>filelen)
{
wavHalt("buffer is supposed to be bigger than this",path_name);
free(wi);
return NULL;
}
if (channels!=2 && channels!=1)
{
wavHalt("not Mono or Stereo sample",path_name);
free(wi);
return NULL;
}
if (samplerate>100000 || samplerate<2000)
{
wavHalt("sample rate is wrong",path_name);
free(wi);
return NULL;
}
if (blocksize!=channels*2)
{
wavHalt("BLOCKSIZE MISMATCH",path_name);
free(wi);
return NULL;
}
if (bitpersample!=16)
{
wavHalt("Bits Per Sample Error",path_name);
free(wi);
return NULL;
}
if (channels==2)
{
samplecount=datalength/4;
}
else
{
samplecount=datalength/2;
}
if (samplecount<=0)
{
wavHalt("no samples",path_name);
free(wi);
return NULL;
}
wi->channels=channels;
wi->samplerate=samplerate;
wi->samplecount=samplecount;
wi->datalength=datalength;
wi->wavdata=wavfile+0x2c;
wi->rateratio=(samplerate*0x4000)/11025;
wi->playptr=0;
wi->playptr_frac=0;
wi->playloop=0;
return wi;
}
|
wave.h:
| Code: |
typedef struct {
unsigned long channels;
unsigned long samplerate;
unsigned long samplecount;
unsigned long datalength;
unsigned long rateratio; // samplerate / 44100 * 0x10000
unsigned long playptr;
unsigned long playptr_frac;
int playloop;
char *wavdata;
} wavout_wavinfo_t;
int wavInit();
int wavPlay(wavout_wavinfo_t *wi);
wavout_wavinfo_t *wavLoad(char *filename);
|
Then in your main.c add to the top:
| Code: |
#include <pspaudiolib.h>
#include "wave.h"
|
and to load a wav file from the current directory:
| Code: |
wavInit();
wav_intro = wavLoad("test.wav");
wav_intro->playloop = 1;
wavPlay(wav_intro);
|
and last but not least - adding for comparison - sound.c:
| Code: |
#define PGA_CHANNELS 3
#define PGA_SAMPLES 256
#define MAXVOLUME 0x8000
#define SND1_MAXSLOT 16
#define PB_N 32
#define WAVFILEMAX_BG 8*1024*1024
#define O_RDONLY 0x0001
#define O_WRONLY 0x0002
#define O_RDWR 0x0003
#define O_NBLOCK 0x0010
#define O_APPEND 0x0100
#define O_CREAT 0x0200
#define O_TRUNC 0x0400
#define O_NOWAIT 0x8000
#define MAX_PATH 512
#define NULL 0
//---------- variables
int pga_ready=0;
int pga_handle[PGA_CHANNELS];
short pga_sndbuf[PGA_CHANNELS][2][PGA_SAMPLES][2];
int pga_threadhandle[PGA_CHANNELS];
volatile int pga_terminate=0;
typedef int (*pg_threadfunc_t)(int args, void *argp);
typedef struct {
unsigned long channels;
unsigned long samplerate;
unsigned long samplecount;
unsigned long datalength;
char *wavdata;
unsigned long rateratio; // samplerate / 44100 * 0x10000
unsigned long playptr;
unsigned long playptr_frac;
int playloop;
} wavout_wavinfo_t;
wavout_wavinfo_t *wavout_snd0_wavinfo=0;
wavout_wavinfo_t wavout_snd1_wavinfo[SND1_MAXSLOT];
int wavout_snd1_playing[SND1_MAXSLOT];
int wavout_snd0_ready=0;
unsigned long wavout_snd0_playptr=0;
int wavout_snd0_playend=0;
short powerbuf[PB_N][256];
unsigned int powerbuf_in=0;
short powersrc[256];
short powersrc2[256];
char wavdata_bg[WAVFILEMAX_BG];
wavout_wavinfo_t wavinfo_bg;
char pg_mypath[MAX_PATH];
char pg_workdir[MAX_PATH];
//------------ Tableau de merde
int brtbl[]={
0,128, 64,192, 32,160, 96,224, 16,144, 80,208, 48,176,112,240, 8,136, 72,200, 40,168,104,232, 24,152, 88,216, 56,184,120,248,
4,132, 68,196, 36,164,100,228, 20,148, 84,212, 52,180,116,244, 12,140, 76,204, 44,172,108,236, 28,156, 92,220, 60,188,124,252,
2,130, 66,194, 34,162, 98,226, 18,146, 82,210, 50,178,114,242, 10,138, 74,202, 42,170,106,234, 26,154, 90,218, 58,186,122,250,
6,134, 70,198, 38,166,102,230, 22,150, 86,214, 54,182,118,246, 14,142, 78,206, 46,174,110,238, 30,158, 94,222, 62,190,126,254,
1,129, 65,193, 33,161, 97,225, 17,145, 81,209, 49,177,113,241, 9,137, 73,201, 41,169,105,233, 25,153, 89,217, 57,185,121,249,
5,133, 69,197, 37,165,101,229, 21,149, 85,213, 53,181,117,245, 13,141, 77,205, 45,173,109,237, 29,157, 93,221, 61,189,125,253,
3,131, 67,195, 35,163, 99,227, 19,147, 83,211, 51,179,115,243, 11,139, 75,203, 43,171,107,235, 27,155, 91,219, 59,187,123,251,
7,135, 71,199, 39,167,103,231, 23,151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 15678, 15136, 14449, 13622, 12665, 11585, 10393, 9102, 7723, 6269, 4756, 3196, 1605, 0, -1605, -3196, -4756, -6269, -7723, -9102,-10393,-11585,-12665,-13622,-14449,-15136,-15678,-16069,-16305, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 16384, 16364, 16305, 16206, 16069, 15892, 15678, 15426, 15136, 14810, 14449, 14053, 13622, 13159, 12665, 12139, 11585, 11002, 10393, 9759, 9102, 8423, 7723, 7005, 6269, 5519, 4756, 3980, 3196, 2404, 1605, 803, 0, -803, -1605, -2404, -3196, -3980, -4756, -5519, -6269, -7005, -7723, -8423, -9102, -9759,-10393,-11002,-11585,-12139,-12665,-13159,-13622,-14053,-14449,-14810,-15136,-15426,-15678,-15892,-16069,-16206,-16305,-16364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 16384, 16379, 16364, 16339, 16305, 16260, 16206, 16142, 16069, 15985, 15892, 15790, 15678, 15557, 15426, 15286, 15136, 14978, 14810, 14634, 14449, 14255, 14053, 13842, 13622, 13395, 13159, 12916, 12665, 12406, 12139, 11866, 11585, 11297, 11002, 10701, 10393, 10079, 9759, 9434, 9102, 8765, 8423, 8075, 7723, 7366, 7005, 6639, 6269, 5896, 5519, 5139, 4756, 4369, 3980, 3589, 3196, 2801, 2404, 2005, 1605, 1205, 803, 402, 0, -402, -803, -1205, -1605, -2005, -2404, -2801, -3196, -3589, -3980, -4369, -4756, -5139, -5519, -5896, -6269, -6639, -7005, -7366, -7723, -8075, -8423, -8765, -9102, -9434, -9759,-10079,-10393,-10701,-11002,-11297,-11585,-11866,-12139,-12406,-12665,-12916,-13159,-13395,-13622,-13842,-14053,-14255,-14449,-14634,-14810,-14978,-15136,-15286,-15426,-15557,-15678,-15790,-15892,-15985,-16069,-16142,-16206,-16260,-16305,-16339,-16364,-16379, },
};
int mm2[8][128]={
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 0,-16384, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 0, -1605, -3196, -4756, -6269, -7723, -9102,-10393,-11585,-12665,-13622,-14449,-15136,-15678,-16069,-16305,-16384,-16305,-16069,-15678,-15136,-14449,-13622,-12665,-11585,-10393, -9102, -7723, -6269, -4756, -3196, -1605, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 0, -803, -1605, -2404, -3196, -3980, -4756, -5519, -6269, -7005, -7723, -8423, -9102, -9759,-10393,-11002,-11585,-12139,-12665,-13159,-13622,-14053,-14449,-14810,-15136,-15426,-15678,-15892,-16069,-16206,-16305,-16364,-16384,-16364,-16305,-16206,-16069,-15892,-15678,-15426,-15136,-14810,-14449,-14053,-13622,-13159,-12665,-12139,-11585,-11002,-10393, -9759, -9102, -8423, -7723, -7005, -6269, -5519, -4756, -3980, -3196, -2404, -1605, -803, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
{ 0, -402, -803, -1205, -1605, -2005, -2404, -2801, -3196, -3589, -3980, -4369, -4756, -5139, -5519, -5896, -6269, -6639, -7005, -7366, -7723, -8075, -8423, -8765, -9102, -9434, -9759,-10079,-10393,-10701,-11002,-11297,-11585,-11866,-12139,-12406,-12665,-12916,-13159,-13395,-13622,-13842,-14053,-14255,-14449,-14634,-14810,-14978,-15136,-15286,-15426,-15557,-15678,-15790,-15892,-15985,-16069,-16142,-16206,-16260,-16305,-16339,-16364,-16379,-16384,-16379,-16364,-16339,-16305,-16260,-16206,-16142,-16069,-15985,-15892,-15790,-15678,-15557,-15426,-15286,-15136,-14978,-14810,-14634,-14449,-14255,-14053,-13842,-13622,-13395,-13159,-12916,-12665,-12406,-12139,-11866,-11585,-11297,-11002,-10701,-10393,-10079, -9759, -9434, -9102, -8765, -8423, -8075, -7723, -7366, -7005, -6639, -6269, -5896, -5519, -5139, -4756, -4369, -3980, -3589, -3196, -2801, -2404, -2005, -1605, -1205, -803, -402, },
};
const unsigned char sqrtbl[]={
0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
};
//---------- proto
int pgaInit();
void (*pga_channel_callback[PGA_CHANNELS])(void *buf, unsigned long reqn);
static int pga_channel_thread(int args, void *argp);
void pga_channel_thread_callback(int channel, void *buf, unsigned long reqn);
void pgaSetChannelCallback(int channel, void *callback);
int pgaOutBlocking(unsigned long channel,unsigned long vol1,unsigned long vol2,void *buf);
static void wavout_snd0_callback(short *_buf, unsigned long _reqn);
static void wavout_snd1_callback(short *_buf, unsigned long _reqn);
void powercalc(short *in);
unsigned long sqri(unsigned long d);
int wavoutLoadWav(const char *filename, wavout_wavinfo_t *wi, void *buf, unsigned long buflen);
int pgfOpen(const char *filename, unsigned long flag);
void pgfClose(int fd);
int pgfRead(int fd, void *data, int size);
void wavoutStopPlay0();
void wavoutStartPlay0(wavout_wavinfo_t *wi);
//---------- function
int pgaInit()
{
int i,ret;
int failed=0;
char str[32];
pga_terminate=0;
pga_ready=0;
for (i=0; i<PGA_CHANNELS; i++) {
pga_handle[i]=-1;
pga_threadhandle[i]=-1;
pga_channel_callback[i]=0;
}
for (i=0; i<PGA_CHANNELS; i++) {
if ((pga_handle[i]=sceAudio_3(-1,PGA_SAMPLES,0))<0) failed=1;
}
if (failed) {
for (i=0; i<PGA_CHANNELS; i++) {
if (pga_handle[i]!=-1) sceAudio_4(pga_handle[i]);
pga_handle[i]=-1;
}
return -1;
}
pga_ready=1;
strcpy(str,"pgasnd0");
for (i=0; i<PGA_CHANNELS; i++) {
str[6]='0'+i;
pga_threadhandle[i]=sceKernelCreateThread(str,(pg_threadfunc_t)&pga_channel_thread,0x12,0x10000,0,NULL);
if (pga_threadhandle[i]<0) {
pga_threadhandle[i]=-1;
failed=1;
break;
}
ret=sceKernelStartThread(pga_threadhandle[i],sizeof(i),&i);
if (ret!=0) {
failed=1;
break;
}
}
if (failed) {
pga_terminate=1;
for (i=0; i<PGA_CHANNELS; i++) {
if (pga_threadhandle[i]!=-1) {
sceKernelWaitThreadEnd(pga_threadhandle[i],NULL);
sceKernelDeleteThread(pga_threadhandle[i]);
}
pga_threadhandle[i]=-1;
}
pga_ready=0;
return -1;
}
return 0;
}
static int pga_channel_thread(int args, void *argp)
{
volatile int bufidx=0;
int channel=*(int *)argp;
while (pga_terminate==0) {
void *bufptr=&pga_sndbuf[channel][bufidx];
void (*callback)(void *buf, unsigned long reqn);
callback=pga_channel_callback[channel];
if (callback) {
callback(bufptr,PGA_SAMPLES);
} else {
unsigned long *ptr=bufptr;
int i;
for (i=0; i<PGA_SAMPLES; ++i) *(ptr++)=0;
}
pgaOutBlocking(channel,0x8000,0x8000,bufptr);
bufidx=(bufidx?0:1);
}
sceKernelExitThread(0);
return 0;
}
void pga_channel_thread_callback(int channel, void *buf, unsigned long reqn)
{
void (*callback)(void *buf, unsigned long reqn);
callback=pga_channel_callback[channel];
}
void pgaSetChannelCallback(int channel, void *callback)
{
pga_channel_callback[channel]=callback;
}
int pgaOutBlocking(unsigned long channel,unsigned long vol1,unsigned long vol2,void *buf)
{
if (!pga_ready) return -1;
if (channel>=PGA_CHANNELS) return -1;
if (vol1>MAXVOLUME) vol1=MAXVOLUME;
if (vol2>MAXVOLUME) vol2=MAXVOLUME;
return sceAudio_2(pga_handle[channel],vol1,vol2,buf);
}
int wavoutInit()
{
int i;
wavout_snd0_wavinfo=0;
for (i=0; i<SND1_MAXSLOT; i++) {
wavout_snd1_playing[i]=0;
}
pgaSetChannelCallback(0,wavout_snd0_callback);
pgaSetChannelCallback(1,wavout_snd1_callback);
return 0;
}
static void wavout_snd0_callback(short *_buf, unsigned long _reqn)
{
static int power[128];
unsigned long i;
unsigned long ptr,frac,rr,max;
int channels;
char *src;
short *buf=_buf;
unsigned long reqn=_reqn;
wavout_wavinfo_t *wi=wavout_snd0_wavinfo;
if (wi==0) {
wavout_snd0_ready=1;
memset(buf,0,reqn*4);
return;
}
wavout_snd0_ready=0;
ptr=wi->playptr;
frac=wi->playptr_frac;
rr=wi->rateratio;
max=wi->samplecount;
channels=wi->channels;
src=wi->wavdata;
for (; reqn>0; --reqn) {
frac+=rr;
ptr+=(frac>>16);
frac&=0xffff;
if (ptr>=max) {
if (wi->playloop) {
ptr=0;
} else {
for (; reqn>0; --reqn) {
*(buf++)=0;
*(buf++)=0;
}
goto playend;
}
}
if (channels==1) {
buf[0]=buf[1]=*(short *)(src+ptr*2);
buf+=2;
} else {
buf[0]=*(short *)(src+ptr*4);
buf[1]=*(short *)(src+ptr*4+2);
buf+=2;
}
}
powercalc(_buf); //’P‚Éwave‚ðo‚·‚¾‚¯‚È‚ç•s—v
wavout_snd0_playptr=ptr;
wi->playptr=ptr;
wi->playptr_frac=frac;
return;
playend:
wavout_snd0_playend=1;
return;
}
static void wavout_snd1_callback(short *_buf, unsigned long _reqn)
{
unsigned long i,slot;
wavout_wavinfo_t *wi;
unsigned long ptr,frac;
short *buf=_buf;
for (i=0; i<_reqn; i++) {
int outr=0,outl=0;
for (slot=0; slot<SND1_MAXSLOT; slot++) {
if (!wavout_snd1_playing[slot]) continue;
wi=&wavout_snd1_wavinfo[slot];
frac=wi->playptr_frac+wi->rateratio;
wi->playptr=ptr=wi->playptr+(frac>>16);
wi->playptr_frac=(frac&0xffff);
if (ptr>=wi->samplecount) {
wavout_snd1_playing[slot]=0;
break;
}
short *src=(short *)wi->wavdata;
if (wi->channels==1) {
outl+=src[ptr];
outr+=src[ptr];
} else {
outl+=src[ptr*2];
outr+=src[ptr*2+1];
}
}
if (outl<-32768) outl=-32768;
else if (outl>32767) outl=32767;
if (outr<-32768) outr=-32768;
else if (outr>32767) outr=32767;
*(buf++)=outl;
*(buf++)=outr;
}
}
unsigned long sqri(unsigned long d)
{
unsigned char c;
unsigned long r;
if (d==0) return 0;
r= (c=sqrtbl[((unsigned char *)&d)[3]])?((unsigned long)c<<12):(
(c=sqrtbl[((unsigned char *)&d)[2]])?((unsigned long)c<<8):(
(c=sqrtbl[((unsigned char *)&d)[1]])?((unsigned long)c<<4):(
sqrtbl[((unsigned char *)&d)[0]] )));
r=(d/r+r)>>1;
r=(d/r+r)>>1;
r=(d/r+r)>>1;
r=(d/r+r)>>1;
return r;
}
void powercalc(short *in)
{
{//work with sources
int i,j,sum;
for (i=0; i<256-16; i++) powersrc[i]=powersrc[i+16];
sum=0;
for (i=0; i<16; i++) {
powersrc[256-16+i]=( (int)in[i*32]+(int)in[i*32+8]+(int)in[i*32+16]+(int)in[i*32+24] )/4;
}
}
{
int i;
for (i=0; i<256; i++) powersrc2[i]=powersrc[i];
for (i=0; i<32; i++) {
powersrc2[i]=((int)powersrc2[i])*i/32;
powersrc2[255-i]=((int)powersrc2[255-i])*i/32;
}
}
long m=8;
long n=256;
long m1,m2;
long i,i1,j,k,i2,l,l1,l2;
int ix[256],iy[256];
int tx,ty,pw;
//shuffle
for (i=0; i<256; i++) {
ix[i]=(int)(powersrc2[brtbl[i]]>>1);
iy[i]=0;
}
//fft main
l2 = 1;
for (l=0; l<8; l++) {
l1 = l2;
l2 <<= 1;
for (j=0; j<l1; j++) {
m1=mm1[l][j]/64;
m2=mm2[l][j]/64;
for (i=j; i<n; i+=l2) {
i1 = i + l1;
tx = ( m1 * ix[i1] - m2 * iy[i1] )/256;
ty = ( m1 * iy[i1] + m2 * ix[i1] )/256;
ix[i1] = ix[i] - tx;
iy[i1] = iy[i] - ty;
ix[i] += tx;
iy[i] += ty;
}
}
}
//scale & normalize
short *pp=powerbuf[powerbuf_in];
for (i=0; i<128; i++) {
//tx,ty : re,im forward fft scaling=256, fixed point +-16384
tx=ix[i]/256;
ty=iy[i]/256;
pw=(sqri(tx*tx+ty*ty));
//normalize it
pw=pw*(j+8)/512;
if (pw>127) pw=127;
*(pp++)=pw;
}
powerbuf_in=((powerbuf_in+1)&(PB_N-1));
return;
}
int wavoutLoadWav(const char *filename, wavout_wavinfo_t *wi, void *buf, unsigned long buflen)
{
unsigned int filelen;
int fd;
unsigned long channels;
unsigned long samplerate;
unsigned long blocksize;
unsigned long bitpersample;
unsigned long datalength;
unsigned long samplecount;
unsigned long i;
char *wavfile=buf;
wi->wavdata=NULL;
fd=pgfOpen(filename,O_RDONLY);
if (fd<0) return -1;
filelen=pgfRead(fd,wavfile,buflen);
pgfClose(fd);
if (filelen>=buflen) {
//too long
return -1;
}
if (memcmp(wavfile,"RIFF",4)!=0) {
// pgcPuts("format err");
return -1;
}
if (memcmp(wavfile+8,"WAVEfmt \x10\x00\x00\x00\x01\x00",14)!=0) {
// pgcPuts("format err");
return -1;
}
channels=*(short *)(wavfile+0x16);
samplerate=*(long *)(wavfile+0x18);
blocksize=*(short *)(wavfile+0x20);
bitpersample=*(short *)(wavfile+0x22);
if (memcmp(wavfile+0x24,"data",4)!=0) {
// pgcPuts("format err");
return -1;
}
datalength=*(unsigned long *)(wavfile+0x28);
if (datalength+0x2c>filelen) {
// pgcPuts("format err");
return -1;
}
if (channels!=2 && channels!=1) {
// pgcPuts("format err, channel");
return -1;
}
// if (samplerate!=44100 && samplerate!=22050 && samplerate!=11025) {
if (samplerate>100000 || samplerate<2000) {
// pgcPuts("format err, samplerate");
return -1;
}
if (blocksize!=channels*2) {
// pgcPuts("format err, blocksize");
return -1;
}
if (bitpersample!=16) {
// pgcPuts("format err, bitpersample");
return -1;
}
if (channels==2) {
samplecount=datalength/4;
} else {
samplecount=datalength/2;
}
if (samplecount<=0) {
// pgcPuts("format err, samplecount");
return -1;
}
wi->channels=channels;
wi->samplerate=samplerate;
wi->samplecount=samplecount;
wi->datalength=datalength;
wi->wavdata=wavfile+0x2c;
wi->rateratio=(samplerate*0x4000)/11025;
wi->playptr=0;
wi->playptr_frac=0;
wi->playloop=0;
return 0;
}
int pgfOpen(const char *filename, unsigned long flag)
{
char fn[MAX_PATH*2];
if (strchr(filename,':')!=NULL || *filename=='/' || *filename=='\\') {
return sceIoOpen(filename,flag);
} else {
strcpy(fn,pg_workdir);
strcat(fn,filename);
return sceIoOpen(fn,flag);
}
}
void pgfClose(int fd)
{
sceIoClose(fd);
}
int pgfRead(int fd, void *data, int size)
{
return sceIoRead(fd,data,size);
}
void wavoutStopPlay0()
{
if (wavout_snd0_wavinfo!=0) {
while (wavout_snd0_ready) sceDisplayWaitVblankStart();;
wavout_snd0_wavinfo=0;
while (!wavout_snd0_ready) sceDisplayWaitVblankStart();;
}
}
void wavoutStartPlay0(wavout_wavinfo_t *wi)
{
wavoutStopPlay0();
while (!wavout_snd0_ready) sceDisplayWaitVblankStart();;
wavout_snd0_playptr=0;
wavout_snd0_playend=0;
wavout_snd0_wavinfo=wi;
while (wavout_snd0_ready) sceDisplayWaitVblankStart();;
}
|
ok, so from the source's wave.c and sound.c you can see that the looping part within the wavout_snd?_callback function is lacking in wave.c - I attempted adding checks - resetting ptr = 0 etc like in sound.c but that doesn't help...I also attempted to add "is_playing" to the wavinfo struct but i think i messed up as that just caused the same wav to play overlapped over all the channels/slots but still died after one iteration of playing it... time to go to work! _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Mon Jul 18, 2005 10:04 pm Post subject: |
|
|
almmost forgot:
Makefile:
| Code: |
TARGET = sexdwarf_demo
OBJS = main.o wave.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspumd -lpspaudiolib -lpspaudio -lm -lpspgu
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sexdwarf Demo
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
_________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
fantomasfr
Joined: 08 Jul 2005 Posts: 11
|
Posted: Mon Jul 18, 2005 10:38 pm Post subject: |
|
|
| Quote: | | //------------ Tableau de merde |
hahahaha :) |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Tue Jul 19, 2005 1:56 am Post subject: |
|
|
here's what i've narrowed it down to at this point -
on line 58 to 62 in wave.c:
| Code: | if (ptr>=wi->samplecount)
{
wavout_snd_playing[slot]=0;
break;
} |
here it basically sees if the current sample is at the end of the audio file loaded, if it is, it simply turns playing off...
using the sound.c as a reference i notice that it checks the playloop variable to determine if it should restart the playback; so i made the following modification to my wave.c:
| Code: | if (ptr>=wi->samplecount)
{
if (wi->playloop)
{
ptr=0;
}
else
{
wavout_snd_playing[slot]=0;
wi->playing = 0;
break;
}
} |
however this does not seem to be enough to get looping to work (then again, who am i kidding, there's no reason it should be that simple ;)) but it was worth a try... _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Tue Jul 19, 2005 3:21 am Post subject: |
|
|
oops, my bad for saying it was from the svn/samples (though, imho, it should be since i believe wave loading is something that people want/need)
| Quote: | i just ported Nem's wav loader , so i never tested looping will look at that i've had a 5mb sample work . so maybe its a specific sample issue
maybe you could post a link to the sample so i can check it out ? |
i'll upload it to my server in a little bit - i do recall comparing the bit rate/channels etc with one of the tests waves in your zip file, and i know they were the same in that sence... tried a few wav's and had issues with any files that were bigger than 3mb...good work on the port, hopefully we can figure the looping stuff out ;) _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Tue Jul 19, 2005 3:45 am Post subject: |
|
|
try this
| Code: | if (wi->playloop)
{
wi->playptr=0;
wi->playptr_frac=0;
ptr = 0;
}
else
{
wavout_snd_playing[slot]=0;
break;
}
|
its a pain to test while at work ( and am crunching 12 hrs daily right now )
NOTE i've update the Zip file on my site with these changes
Last edited by jpadams on Tue Jul 19, 2005 4:55 am; edited 1 time in total |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Tue Jul 19, 2005 3:49 am Post subject: |
|
|
| jpadams wrote: | | its a pain to test while at work ( and am crunching 12 hrs daily right now ) |
great will have to test when i get home - know all about those 12 hour days sadly enough - thanks again :) _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
shifty
Joined: 16 Jun 2005 Posts: 32 Location: MIT
|
Posted: Tue Jul 19, 2005 4:54 am Post subject: nem's wav loader, bug |
|
|
hey all, just wanted to let you know, there's a bug in
nem's wav loader. It uses almost exclusively hardcoded
offsets...and from time to time you will find exceptions.
One of the most painful I found while coding PSPKick is
that the WAVE header length is not always 0x10. Sometimes
it's 0x12. Therefore, you might want to update your code
like this:
// size of WAVE chunk, typically 0x10, sometimes 0x12
WAVElen =*(unsigned long *)(wavfile+0x10);
When the WAVE Chunk header is offset, everything else gets
offset by the same amount! No more hardcoded offsets!
This also has interesting ramifications
when you compute later headers, because you can't read the lengths
of e.g. the "data" header with a 32-bit read...why? because it's
no longer 32-bit word-aligned! You'll want something like this:
// location of datalength
idx = 0x14 + WAVElen + 4; // 0x10 = WAVElen, +4 for the len, +4 for "data"
datalength=
(*(unsigned short *)(wavfile+idx)) +
(*(unsigned short *)(wavfile+idx+2))*65536;
// where the good stuff is
datastart = idx + 4; // typically 0x2c. sometimes 0x2e
I hope this helps! BTW WAVElen is about the only field
that can't get moved around.
happy music making. |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Tue Jul 19, 2005 9:05 pm Post subject: |
|
|
ok the looping worked, thanks!
do you mind if i rework your files? first of all i would like to remove the hardcoded offsets as stated by shifty, additonally i would like to incorporate a proper chunk extraction routine, i.e. to handle non-PCM files, and to handle the RIFF format properly...
the reason my larger files weren't playing was not because of the size, but due to WAV1 encoding instead of PCM... the WAV1 structure requires an additional FACT chunk before the DATA chunk which interferes with the current wave.c... to ensure that the WAV1 format plays on the PSP i removed the FACT chunk manually, and the playback worked perfectly with a 6.5 mb file... _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 20, 2005 2:36 am Post subject: |
|
|
re-work away
and pm me or mail me a copy when your done :)
- j |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Wed Jul 20, 2005 12:42 pm Post subject: |
|
|
ive been playing with your wave.c and wave.h files..trying to use them to play sound effects in my game..
but first i just tried using your sample main.c and using my own wav files...
it froze quite often if i loaded 4 of my own wav files..all under 100kb..so size isnt the problem... all 44kHz...it would just freeze..but if i only loaded 1 at a time..it would playback just fine..
sometimes i could load 2..its weird
i dont understand why its so unstable..
could you maybe help me out.. |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 20, 2005 1:05 pm Post subject: |
|
|
put the waves somewhere we can test them
i never claimed the code was stable ( it works fine for me )
i'll look into it for you if you can supply samples that break it
- J |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 20, 2005 1:18 pm Post subject: |
|
|
they are mono samples
interesting i never tried them :)
- J |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Wed Jul 20, 2005 1:31 pm Post subject: |
|
|
| ...the 4 test.wav files in your sample are mono files as well?? |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Wed Jul 20, 2005 1:49 pm Post subject: |
|
|
| did you get it to work? |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 20, 2005 1:50 pm Post subject: |
|
|
yes i stopped everything i was doing to fix this :)
still looking , hold tight could be a while
- J |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Wed Jul 20, 2005 2:19 pm Post subject: |
|
|
is that sarcastic? i cant really tell..maybe your just really devoted to this..haha
=) |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Thu Jul 21, 2005 12:13 am Post subject: |
|
|
| jpadams wrote: | re-work away
and pm me or mail me a copy when your done :)
- j |
will do - i have started on it, but with a busy scheduale at work i prolly won't be done until the weekend... it properly detects 11 wave/riff formats, and will be setup for most of the options listed in the following specs:
http://www.sonicspot.com/guide/wavefiles.html
http://www.borg.com/~jglatt/tech/wave.htm
i'm also going to see about integrating some kind of stream buffering so it doesn't require waiting for the full file to load before playing - not to mention that would allow for signicantly larger files to be played (for testing purposes I tried a 14.6, 29.7 and 48.9 mb files, all three crashed the system, which isn't that much of a suprise really, but still) _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Sun Jul 24, 2005 5:10 am Post subject: |
|
|
| JJPeerless wrote: | is that sarcastic? i cant really tell..maybe your just really devoted to this..haha
=) |
erm yes a tad sarcastic
you gave me less than 30 mins to look into the problem ,
assuming i was doing it right away ,
which i wasn't i was tangled in real work :)
- j |
|
| Back to top |
|
 |
sexdwarf
Joined: 14 Jul 2005 Posts: 34
|
Posted: Tue Jul 26, 2005 1:02 pm Post subject: |
|
|
ok due to a little personal issue i got delayed - but i am near completion - it can load 5 formats (that i test, could load others too), stereo and mono, has looping etc... only issue i am having is loading more than one file at a time....once i have that straightened out it'll be available! _________________ ...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Tue Jul 26, 2005 1:49 pm Post subject: |
|
|
sweet
if you need any help lemme know
then maybe we can get it in the svn :) |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 27, 2005 3:12 am Post subject: |
|
|
this fixed the bug with jjpeerless's samples not working
line 218
| Code: |
wi = memalign(8,stat.st_size + sizeof(wavout_wavinfo_t));
wavfile = (char*)(wi)+sizeof(wavout_wavinfo_t);
|
|
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Wed Jul 27, 2005 6:29 am Post subject: |
|
|
thats already how it is in the wave.c file..
or did you already update the wave.c that is in that zip file... |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Wed Jul 27, 2005 7:36 am Post subject: |
|
|
| yes i updated the zip |
|
| Back to top |
|
 |
jpadams

Joined: 02 Jul 2005 Posts: 23 Location: Los Angeles
|
Posted: Thu Aug 25, 2005 7:36 am Post subject: |
|
|
i've removed all psp related projects
including the wavloader source
from deadsoul.com to
http://labs.wonderbyte.com
cheers
- j |
|
| Back to top |
|
 |
3rddek
Joined: 15 Aug 2006 Posts: 1
|
Posted: Tue Aug 15, 2006 4:36 pm Post subject: |
|
|
| hey JP is your wavloader still around somewhere? All your hrefs are dead. Did it end up in the PSPSDK samples? |
|
| Back to top |
|
 |
|
|
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
|