PA_Sound.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_Sound9
00002 #define _PA_Sound9
00003 
00011 #include "../Sound9.h"
00012 #include "PA_GBFS.h"
00013 #include <PA9.h>
00014 
00015        // 256KB to load MOD files into. Actual size necessary is the size 
00016        // of your largest MOD file (probably less than 256KB).
00017 #define SND_MEM_POOL_SIZE   256*1024
00018 
00019 
00020 
00021 extern TransferSound snd;
00022 extern u32 *sndMemPool;
00023 
00024 typedef struct{ // Default sound format
00025        u8 volume;
00026        s16 freq;
00027        s16 format;
00028 } PA_SoundOptions;
00029 
00030 extern PA_SoundOptions PA_SoundOption;
00031 
00032 extern u8 *GBFS_mod;
00033 extern u8 *GBFS_wav[16]; // 16 channels...
00034 
00035 //plays an 8 bit mono sample at 11025Hz
00036 
00037 
00038 
00039 
00040 
00041 
00062 void PA_SetDefaultSound(u8 volume, s16 freq, s16 format);
00063 
00064 
00070 extern inline void PA_InitSound(void) {
00071        SndInit9 ();
00072        sndMemPool = (u32*)0x2200000;
00073        SndSetMemPool(sndMemPool, SND_MEM_POOL_SIZE);
00074        PA_SetDefaultSound(127, 11025, 1);
00075        GBFS_mod = (u8*)malloc(2); // Initialise a small portion of memory, will make it bigger later on...
00076 }
00077 
00078 
00079 
00103 void PA_PlaySoundEx(u8 PA_Channel, const void* data, u32 length, u8 volume, s16 freq, s16 format);
00104 
00125 extern inline void PA_PlayGBFSSoundEx(u8 PA_Channel, u16 GBFS_wav_number, u8 volume, s16 freq, s16 format){
00126 s32 length = (PA_GBFSfile[GBFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00127        free(GBFS_wav[PA_Channel]);
00128        GBFS_wav[PA_Channel] = (u8*)malloc(length << 2);
00129        
00130        DMA_Copy(PA_GBFSfile[GBFS_wav_number].File, GBFS_wav[PA_Channel], length, DMA_32NOW);
00131 
00132        PA_PlaySoundEx(PA_Channel, (void*)GBFS_wav[PA_Channel], length << 2, volume, freq, format);
00133 }
00134 
00155 extern inline void PA_PlaySound(u8 PA_Channel, const void* data, u32 length, u8 volume, s16 freq){
00156 PA_PlaySoundEx(PA_Channel, data, length, volume, freq, 1);
00157 }
00158 
00176 extern inline void PA_PlayGBFSSound(u8 PA_Channel, u16 GBFS_wav_number, u8 volume, s16 freq){
00177 s32 length = (PA_GBFSfile[GBFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00178        free(GBFS_wav[PA_Channel]);
00179        GBFS_wav[PA_Channel] = (u8*)malloc(length << 2);
00180        
00181        DMA_Copy(PA_GBFSfile[GBFS_wav_number].File, GBFS_wav[PA_Channel], length, DMA_32NOW);
00182 
00183        PA_PlaySound(PA_Channel, (void*)GBFS_wav[PA_Channel], length << 2, volume, freq);
00184 }
00185 
00198 #define PA_PlaySimpleSound(PA_Channel, sound) PA_PlaySoundEx(PA_Channel, (void*)sound, (u32)sound##_size, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format)
00199 
00200 
00212 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 GBFS_wav_number){
00213 s32 length = (PA_GBFSfile[GBFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00214        free(GBFS_wav[PA_Channel]);
00215        GBFS_wav[PA_Channel] = (u8*)malloc(length << 2);
00216        
00217        DMA_Copy(PA_GBFSfile[GBFS_wav_number].File, GBFS_wav[PA_Channel], length, DMA_32NOW);
00218        
00219        PA_PlaySound(PA_Channel, (void*)GBFS_wav[PA_Channel], length << 2, PA_SoundOption.volume, PA_SoundOption.freq);
00220 }
00221 
00222 
00223 
00232 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00233 
00234 
00243 extern inline void PA_PlayGBFSMod(u16 GBFS_mod_number){
00244 s32 length = (PA_GBFSfile[GBFS_mod_number].Length >> 2) + 1; // Pour etre sur...
00245        free(GBFS_mod);
00246        GBFS_mod = (u8*)malloc(length << 2);
00247 
00248        DMA_Copy(PA_GBFSfile[GBFS_mod_number].File, GBFS_mod, length, DMA_32NOW);
00249 /*     s32 i; 
00250        u32 *mod = (u32*)PA_GBFSfile[GBFS_mod_number].File;     
00251        for (i = 0; i < length; i++) // Copy the file in RAM
00252               GBFS_mod[i] = mod[i];*/
00253        PA_PlayMod(GBFS_mod);
00254 }
00255 
00261 #define PA_StopMod() SndStopMOD()
00262 
00263 
00272 #define PA_PauseMod(bool) SndPauseMOD(bool)
00273 
00274  // end of SoundARM9
00276 
00277 
00278 
00279 
00280 #endif
00281 
00282 

Généré le Wed Dec 14 11:50:58 2005 pour PAlib par  doxygen 1.3.9.1