PA_Sound.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_Sound9
00002 #define _PA_Sound9
00003 
00004 
00005 
00013 #include "../Sound9.h"
00014 #include "PA_GBFS.h"
00015 #include "PA_FS.h"
00016 #include <PA9.h>
00017 
00018        // 256KB to load MOD files into. Actual size necessary is the size 
00019        // of your largest MOD file (probably less than 256KB).
00020 #define SND_MEM_POOL_SIZE   256*1024
00021 
00022 
00023 
00024 extern TransferSound snd;
00025 extern u32 *sndMemPool;
00026 
00027 typedef struct{ // Default sound format
00028        u8 volume;
00029        s16 freq;
00030        s16 format;
00031 } PA_SoundOptions;
00032 
00033 extern PA_SoundOptions PA_SoundOption;
00034 
00035 extern u32 *FS_mod;
00036 extern u32 *FS_wav[16]; // 16 channels...
00037 
00038 
00039 
00040 //Stream vars
00041 extern u32 *Stream_Gap[16];
00042 extern u32 *Stream_End[16];
00043 extern u32 *Stream_Datas[16]; 
00044 extern u32 *Stream_Regen_Ptr[16];
00045 extern s64    Stream_Length[16];
00046 extern u32    Stream_Last_Tick[16];
00047 extern s32    Stream_Repeat[16];
00048 extern u8     Stream_Timer[16];
00049 
00050 //plays an 8 bit mono sample at 11025Hz
00051 
00052 
00053 
00054 
00055 
00056 
00077 void PA_SetDefaultSound(u8 volume, int freq, s16 format);
00078 
00079 
00085 extern inline void PA_InitSound(void) {
00086        SndInit9 ();
00087        sndMemPool = (u32*)0x2200000;
00088        SndSetMemPool(sndMemPool, SND_MEM_POOL_SIZE);
00089        PA_SetDefaultSound(127, 11025, 0);
00090        FS_mod = NULL; // Initialise a small portion of memory, will make it bigger later on...
00091        u8 i;
00092        for (i = 0; i < 16; i++)
00093        {
00094               FS_wav[i] = NULL; // to be able to free
00095        }
00096 
00097 }
00098 
00104 extern void PA_InitStreamSound(void);
00105 
00111 extern void PA_RegenStream(void);
00112 
00118 extern void FillTheGap(u8 PA_Channel, u32 size);
00119 
00149 void PA_PlaySoundEx2(u8 PA_Channel, const void* data, s32 length, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint);
00150 
00174 extern inline void PA_PlaySoundEx(u8 PA_Channel, const void* data, s32 length, u8 volume, int freq, s16 format){
00175 PA_PlaySoundEx2(PA_Channel, data, length, volume, freq, format,false,0);
00176 }
00177 
00198 extern inline void PA_PlayGBFSSoundEx(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format){
00199 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00200        free(FS_wav[PA_Channel]);
00201        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00202        
00203        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00204 
00205        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00206 }
00207 
00234 extern inline void PA_PlayGBFSSoundEx2(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint){
00235 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00236        free(FS_wav[PA_Channel]);
00237        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00238        
00239        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00240 
00241        PA_PlaySoundEx2(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format, repeat, repeatPoint);
00242 
00243 }
00244 
00271 void PA_PlayGBFSStreamSoundEx2(u8 PA_Channel, u16 FS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint);
00272 
00273 
00294 extern inline void PA_PlayFSSoundEx(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, int freq, s16 format){
00295        PA_Malloc((void**)&FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length+4);
00296 
00297        s32 i;
00298        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00299        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00300        
00301        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00302 }
00303 
00330 extern inline void PA_PlayFSSoundEx2(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint){
00331        PA_Malloc((void**)&FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length+4);
00332 
00333        s32 i;
00334        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00335        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00336        
00337        PA_PlaySoundEx2(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format, repeat, repeatPoint);
00338 }
00339 
00366 extern inline void PA_PlayFSStreamSoundEx2(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, int freq, s16 format, BOOL repeat, int repeatPoint);
00367 
00388 extern inline void PA_PlaySound(u8 PA_Channel, const void* data, s32 length, u8 volume, u32 freq){
00389 PA_PlaySoundEx2(PA_Channel, data, length, volume, freq, 1,false,0);
00390 }
00391 
00409 extern inline void PA_PlayGBFSSound(u8 PA_Channel, u16 FS_wav_number, u8 volume, u32 freq){
00410 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00411        free(FS_wav[PA_Channel]);
00412        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00413        
00414        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00415 
00416        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00417 
00418        SndPlay(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, 0, false, 0);
00419 }
00420 
00421 
00439 extern inline void PA_PlayFSSound(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, u32 freq){
00440        PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00441 
00442        s32 i;
00443        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00444        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00445        
00446        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00447 }
00448 
00449 
00450 
00463 #define PA_PlaySimpleSound(PA_Channel, sound) PA_PlaySoundEx(PA_Channel, (void*)sound, (u32)sound##_size, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format)
00464 
00465 
00477 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 FS_wav_number){
00478 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00479        free(FS_wav[PA_Channel]);
00480        FS_wav[PA_Channel] = (u32*)malloc(length << 2);
00481        
00482        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00483 
00484        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00485 }
00486 
00487 
00488 
00489 
00501 extern inline void PA_PlayFSSimpleSound(u8 PA_Channel, u16 PAFS_wav_number){
00502        PA_Malloc((void**)(&FS_wav[PA_Channel]), PA_FSFile[PAFS_wav_number].Length+4);
00503 
00504        s32 i;
00505        s32 length = (PA_FSFile[PAFS_wav_number].Length>>2) + 1; // Pour etre sur...
00506        for (i = 0; i < length; i++) FS_wav[PA_Channel][i] = ((u32*)PA_PAFSFile(PAFS_wav_number))[i];
00507        
00508        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], PA_FSFile[PAFS_wav_number].Length, PA_SoundOption.volume, PA_SoundOption.freq);
00509 }
00510 
00511 
00512 
00513 
00514 
00515 
00524 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00525 
00526 
00535 extern inline void PA_PlayGBFSMod(u16 FS_mod_number){
00536 s32 length = (PA_GBFSfile[FS_mod_number].Length >> 2) + 1; // Pour etre sur...
00537        free(FS_mod);
00538        FS_mod = (u32*)malloc(length << 2);
00539 
00540        DMA_Copy(PA_GBFSfile[FS_mod_number].File, FS_mod, length, DMA_32NOW);
00541 
00542        PA_PlayMod(FS_mod);
00543 }
00544 
00545 
00554 extern inline void PA_PlayFSMod(u16 PAFS_mod_number){
00555        PA_Malloc((void**)((u32)(&FS_mod)), PA_FSFile[PAFS_mod_number].Length+4);
00556 
00557        s32 i;
00558        s32 length = (PA_FSFile[PAFS_mod_number].Length>>2) + 1; // Pour etre sur...
00559        for (i = 0; i < length; i++) FS_mod[i] = ((u32*)PA_PAFSFile(PAFS_mod_number))[i];
00560        
00561        PA_PlayMod(FS_mod);
00562 }
00563 
00564 
00565 
00571 #define PA_StopMod() SndStopMOD()
00572 
00573 
00582 #define PA_PauseMod(bool) SndPauseMOD(bool)
00583 
00584 
00585 
00594 void PA_StopStream(u8 PA_Channel);
00595 
00604 void PA_PauseStream(u8 PA_Channel);
00605 
00614 void PA_UnpauseStream(u8 PA_Channel);
00615 
00616 
00628 extern inline void PA_MicStartRecording(s8* buffer, int length){StartRecording(buffer, length);}
00629 
00635 #define PA_MicStopRecording() StopRecording()
00636  // end of SoundARM9
00638 
00639 
00640 
00641 #endif

Généré le Sat Feb 4 17:33:05 2006 pour PAlib par  doxygen 1.3.9.1