PA_Sound.h

Go to the documentation of this file.
00001 #ifndef _PA_Sound9
00002 #define _PA_Sound9
00003 
00004 
00005 
00013 #include "../Sound9.h"
00014 #include "PA_Timer.h"
00015 #include "PA_GBFS.h"
00016 #include "PA_FS.h"
00017 #include <PA9.h>
00018 
00019        // 256KB to load MOD files into. Actual size necessary is the size 
00020        // of your largest MOD file (probably less than 256KB).
00021 #define SND_MEM_POOL_SIZE   256*1024
00022 
00023 
00024 
00025 extern TransferSound snd;
00026 extern u32 *sndMemPool;
00027 
00028 typedef struct{ // Default sound format
00029        u8 volume;
00030        s16 freq;
00031        s16 format;
00032 } PA_SoundOptions;
00033 
00034 extern PA_SoundOptions PA_SoundOption;
00035 
00036 extern u32 *FS_mod;
00037 extern u32 *FS_wav[16]; // 16 channels...
00038 
00039 
00040 
00041 //Stream vars
00042 extern u32 *Stream_Gap[16];
00043 extern u32 *Stream_End[16];
00044 extern u32 *Stream_Datas[16]; 
00045 extern u32 *Stream_Regen_Ptr[16];
00046 extern s64    Stream_Length[16];
00047 extern u32    Stream_Last_Tick[16];
00048 extern s32    Stream_Repeat[16];
00049 extern u8     Stream_Timer[16];
00050 
00051 //plays an 8 bit mono sample at 11025Hz
00052 
00053 
00054 
00055 
00056 
00057 
00078 void PA_SetDefaultSound(u8 volume, int freq, s16 format);
00079 
00080 
00086 extern inline void PA_InitSound(void) {
00087        SndInit9 ();
00088        sndMemPool = (u32*)0x2200000;
00089        SndSetMemPool(sndMemPool, SND_MEM_POOL_SIZE);
00090        PA_SetDefaultSound(127, 11025, 1);
00091        FS_mod = NULL; // Initialise a small portion of memory, will make it bigger later on...
00092        u8 i;
00093        for (i = 0; i < 16; i++)
00094        {
00095               FS_wav[i] = NULL; // to be able to free
00096        }
00097 
00098 }
00099 
00105 extern void PA_InitStreamSound(void);
00106 
00112 extern void PA_RegenStream(void);
00113 
00119 extern void FillTheGap(u8 PA_Channel, u32 size);
00120 
00150 void PA_PlaySoundEx2(u8 PA_Channel, const void* data, s32 length, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint);
00151 
00175 extern inline void PA_PlaySoundEx(u8 PA_Channel, const void* data, s32 length, u8 volume, int freq, s16 format){
00176 PA_PlaySoundEx2(PA_Channel, data, length, volume, freq, format,false,0);
00177 }
00178 
00199 extern inline void PA_PlayGBFSSoundEx(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format){
00200 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00201        free(FS_wav[PA_Channel]);
00202        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00203        
00204        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00205 
00206        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00207 }
00208 
00235 extern inline void PA_PlayGBFSSoundEx2(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint){
00236 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00237        free(FS_wav[PA_Channel]);
00238        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00239        
00240        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00241 
00242        PA_PlaySoundEx2(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format, repeat, repeatPoint);
00243 
00244 }
00245 
00272 void PA_PlayGBFSStreamSoundEx2(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint);
00273 
00274 
00295 extern inline void PA_PlayFSSoundEx(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, int freq, s16 format){
00296        PA_Malloc((void**)&FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length+4);
00297 
00298        s32 i;
00299        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00300        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00301        
00302        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00303 }
00304 
00331 extern inline void PA_PlayFSSoundEx2(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint){
00332        PA_Malloc((void**)&FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length+4);
00333 
00334        s32 i;
00335        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00336        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00337        
00338        PA_PlaySoundEx2(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format, repeat, repeatPoint);
00339 }
00340 
00361 extern inline void PA_PlaySound(u8 PA_Channel, const void* data, s32 length, u8 volume, u32 freq){
00362 PA_PlaySoundEx2(PA_Channel, data, length, volume, freq, 1,false,0);
00363 }
00364 
00382 extern inline void PA_PlayGBFSSound(u8 PA_Channel, u16 FS_wav_number, u8 volume, u32 freq){
00383 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00384        free(FS_wav[PA_Channel]);
00385        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00386        
00387        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00388 
00389        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00390 
00391        SndPlay(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, 0, false, 0);
00392 }
00393 
00394 
00412 extern inline void PA_PlayFSSound(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, u32 freq){
00413        PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00414 
00415        s32 i;
00416        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00417        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00418        
00419        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00420 }
00421 
00422 
00423 
00436 #define PA_PlaySimpleSound(PA_Channel, sound) PA_PlaySoundEx(PA_Channel, (void*)sound, (u32)sound##_size, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format)
00437 
00438 
00450 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 FS_wav_number){
00451 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00452        free(FS_wav[PA_Channel]);
00453        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00454        
00455        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00456 
00457        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00458 }
00459 
00460 
00461 
00462 
00474 extern inline void PA_PlayFSSimpleSound(u8 PA_Channel, u16 PAFS_wav_number){
00475        PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00476 
00477        s32 i;
00478        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00479        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00480        
00481        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length, PA_SoundOption.volume, PA_SoundOption.freq);
00482 }
00483 
00484 
00485 
00486 
00487 
00488 
00497 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00498 
00499 
00508 extern inline void PA_PlayGBFSMod(u16 FS_mod_number){
00509 s32 length = (PA_GBFSfile[FS_mod_number].Length >> 2) + 1; // Pour etre sur...
00510        free(FS_mod);
00511        FS_mod = (u32*)malloc(length << 2);
00512 
00513        DMA_Copy(PA_GBFSfile[FS_mod_number].File, FS_mod, length, DMA_32NOW);
00514 
00515        PA_PlayMod(FS_mod);
00516 }
00517 
00518 
00527 extern inline void PA_PlayFSMod(u16 PAFS_mod_number){
00528        PA_Malloc((void**)((u32)(&FS_mod)), PA_FSFile[PAFS_mod_number].Length+4);
00529 
00530        s32 i;
00531        s32 length = (PA_FSFile[PAFS_mod_number].Length>>2) + 1; // Pour etre sur...
00532        for (i = 0; i < length; i++) FS_mod[i] = ((u32*)PA_PAFSFile(PAFS_mod_number))[i];
00533        
00534        PA_PlayMod(FS_mod);
00535 }
00536 
00537 
00538 
00544 #define PA_StopMod() SndStopMOD()
00545 
00546 
00555 #define PA_PauseMod(bool) SndPauseMOD(bool)
00556 
00557 
00558 
00567 void PA_StopStream(u8 PA_Channel);
00568 
00577 void PA_PauseStream(u8 PA_Channel);
00578 
00587 void PA_UnpauseStream(u8 PA_Channel);
00588 
00589 
00601 extern inline void PA_MicStartRecording(s8* buffer, int length){StartRecording(buffer, length);}
00602 
00608 #define PA_MicStopRecording() StopRecording()
00609  // end of SoundARM9
00611 
00612 
00613 
00614 #endif

Generated on Tue Jan 31 17:31:30 2006 for PAlib by  doxygen 1.3.9.1