PA_Sound.h

Go to the documentation of this file.
00001 #ifndef _PA_Sound9
00002 #define _PA_Sound9
00003 
00011 #include "../Sound9.h"
00012 #include "PA_GBFS.h"
00013 #include "PA_FS.h"
00014 #include <PA9.h>
00015 
00016        // 256KB to load MOD files into. Actual size necessary is the size 
00017        // of your largest MOD file (probably less than 256KB).
00018 #define SND_MEM_POOL_SIZE   256*1024
00019 
00020 
00021 
00022 extern TransferSound snd;
00023 extern u32 *sndMemPool;
00024 
00025 typedef struct{ // Default sound format
00026        u8 volume;
00027        s16 freq;
00028        s16 format;
00029 } PA_SoundOptions;
00030 
00031 extern PA_SoundOptions PA_SoundOption;
00032 
00033 extern u8 *FS_mod;
00034 extern u8 *FS_wav[16]; // 16 channels...
00035 
00036 //plays an 8 bit mono sample at 11025Hz
00037 
00038 
00039 
00040 
00041 
00042 
00063 void PA_SetDefaultSound(u8 volume, s16 freq, s16 format);
00064 
00065 
00071 extern inline void PA_InitSound(void) {
00072        SndInit9 ();
00073        sndMemPool = (u32*)0x2200000;
00074        SndSetMemPool(sndMemPool, SND_MEM_POOL_SIZE);
00075        PA_SetDefaultSound(127, 11025, 1);
00076        FS_mod = (u8*)malloc(2); // Initialise a small portion of memory, will make it bigger later on...
00077 }
00078 
00079 
00080 
00104 void PA_PlaySoundEx(u8 PA_Channel, const void* data, u32 length, u8 volume, s16 freq, s16 format);
00105 
00126 extern inline void PA_PlayGBFSSoundEx(u8 PA_Channel, u16 FS_wav_number, u8 volume, s16 freq, s16 format){
00127 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00128        free(FS_wav[PA_Channel]);
00129        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00130        
00131        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00132 
00133        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00134 }
00135 
00136 
00137 
00158 extern inline void PA_PlayFSSoundEx(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, s16 freq, s16 format){
00159 s32 length = (PA_FSFile[PAFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00160        free(FS_wav[PA_Channel]);
00161        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00162        
00163        DMA_Copy(PA_PAFSFile(PAFS_wav_number), FS_wav[PA_Channel], length, DMA_32NOW);
00164 
00165        PA_PlaySoundEx(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq, format);
00166 }
00167 
00168 
00189 extern inline void PA_PlaySound(u8 PA_Channel, const void* data, u32 length, u8 volume, s16 freq){
00190 PA_PlaySoundEx(PA_Channel, data, length, volume, freq, 1);
00191 }
00192 
00210 extern inline void PA_PlayGBFSSound(u8 PA_Channel, u16 FS_wav_number, u8 volume, s16 freq){
00211 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00212        free(FS_wav[PA_Channel]);
00213        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00214        
00215        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00216 
00217        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00218 }
00219 
00220 
00221 
00239 extern inline void PA_PlayFSSound(u8 PA_Channel, u16 PAFS_wav_number, u8 volume, s16 freq){
00240 s32 length = (PA_FSFile[PAFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00241        free(FS_wav[PA_Channel]);
00242        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00243        
00244        DMA_Copy(PA_PAFSFile(PAFS_wav_number), FS_wav[PA_Channel], length, DMA_32NOW);
00245 
00246        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, volume, freq);
00247 }
00248 
00249 
00250 
00263 #define PA_PlaySimpleSound(PA_Channel, sound) PA_PlaySoundEx(PA_Channel, (void*)sound, (u32)sound##_size, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format)
00264 
00265 
00277 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 FS_wav_number){
00278 s32 length = (PA_GBFSfile[FS_wav_number].Length >> 2) + 1; // Pour etre sur...
00279        free(FS_wav[PA_Channel]);
00280        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00281        
00282        DMA_Copy(PA_GBFSfile[FS_wav_number].File, FS_wav[PA_Channel], length, DMA_32NOW);
00283        
00284        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00285 }
00286 
00287 
00288 
00289 
00301 extern inline void PA_PlayFSSimpleSound(u8 PA_Channel, u16 PAFS_wav_number){
00302 s32 length = (PA_FSFile[PAFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00303        free(FS_wav[PA_Channel]);
00304        FS_wav[PA_Channel] = (u8*)malloc(length << 2);
00305        
00306        DMA_Copy(PA_PAFSFile(PAFS_wav_number), FS_wav[PA_Channel], length, DMA_32NOW);
00307        
00308        PA_PlaySound(PA_Channel, (void*)FS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00309 }
00310 
00311 
00312 
00313 
00314 
00315 
00324 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00325 
00326 
00335 extern inline void PA_PlayGBFSMod(u16 FS_mod_number){
00336 s32 length = (PA_GBFSfile[FS_mod_number].Length >> 2) + 1; // Pour etre sur...
00337        free(FS_mod);
00338        FS_mod = (u8*)malloc(length << 2);
00339 
00340        DMA_Copy(PA_GBFSfile[FS_mod_number].File, FS_mod, length, DMA_32NOW);
00341 
00342        PA_PlayMod(FS_mod);
00343 }
00344 
00345 
00354 extern inline void PA_PlayFSMod(u16 PAFS_mod_number){
00355 s32 length = (PA_FSFile[PAFS_mod_number].Length >> 2) + 1; // Pour etre sur...
00356        free(FS_mod);
00357        FS_mod = (u8*)malloc(length << 2);
00358        u8 *file = (u8*)PA_PAFSFile(PAFS_mod_number);
00359        file = file+4;
00360 
00361        s32 i;
00362        for (i = 0; i < length<<2; i++) FS_mod[i] = file[i];
00363 
00364        PA_PlayMod(FS_mod);
00365 }
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00378 #define PA_StopMod() SndStopMOD()
00379 
00380 
00389 #define PA_PauseMod(bool) SndPauseMOD(bool)
00390 
00391  // end of SoundARM9
00393 
00394 
00395 
00396 
00397 #endif
00398 
00399 

Generated on Wed Dec 21 17:41:56 2005 for PAlib by  doxygen 1.3.9.1