head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 PAlibDoc:1.1.1; locks ; strict; comment @# @; 1.1 date 2005.11.02.08.30.22; author jandujar; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2005.11.02.08.30.22; author jandujar; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @ PA_lib: PA_Sound.h Source File

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 <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 
00200 extern inline void PA_PlaySimpleSound(u8 PA_Channel, const void* data, u32 length){
00201 PA_PlaySoundEx(PA_Channel, data, length, PA_SoundOption.volume, PA_SoundOption.freq, PA_SoundOption.format);
00202 }
00203 
00204 
00216 extern inline void PA_PlayGBFSSimpleSound(u8 PA_Channel, u16 GBFS_wav_number){
00217 s32 length = (PA_GBFSfile[GBFS_wav_number].Length >> 2) + 1; // Pour etre sur...
00218        free(GBFS_wav[PA_Channel]);
00219        GBFS_wav[PA_Channel] = (u8*)malloc(length << 2);
00220        
00221        DMA_Copy(PA_GBFSfile[GBFS_wav_number].File, GBFS_wav[PA_Channel], length, DMA_32NOW);
00222 
00223        PA_PlaySimpleSound(PA_Channel, (void*)GBFS_wav[PA_Channel], length << 2);
00224 }
00225 
00226 
00227 
00236 #define PA_PlayMod(mod_snd) SndPlayMOD((u8*)mod_snd)
00237 
00238 
00247 extern inline void PA_PlayGBFSMod(u16 GBFS_mod_number){
00248 s32 length = (PA_GBFSfile[GBFS_mod_number].Length >> 2) + 1; // Pour etre sur...
00249        free(GBFS_mod);
00250        GBFS_mod = (u8*)malloc(length << 2);
00251 
00252        DMA_Copy(PA_GBFSfile[GBFS_mod_number].File, GBFS_mod, length, DMA_32NOW);
00253 /*     s32 i; 
00254        u32 *mod = (u32*)PA_GBFSfile[GBFS_mod_number].File;     
00255        for (i = 0; i < length; i++) // Copy the file in RAM
00256               GBFS_mod[i] = mod[i];*/
00257        PA_PlayMod(GBFS_mod);
00258 }
00259 
00265 #define PA_StopMod() SndStopMOD()
00266 
00267 
00276 #define PA_PauseMod(bool) SndPauseMOD(bool)
00277 
00278  // end of SoundARM9
00280 
00281 
00282 
00283 
00284 #endif
00285 
00286 

Generated on Fri Oct 28 23:16:50 2005 for PA_lib by  doxygen 1.3.9.1
@ 1.1.1.1 log @Initial import of PalibDoc, begin on PAlib0.64b @ text @@