00001
00025 #include <SDL/SDL.h>
00026 #include <SDL/SDL_mixer.h>
00027
00028 #include "sound.h"
00029 #include "movies.h"
00030 #include "main.h"
00031 #include "resources.h"
00032 #include "hqrdepack.h"
00033
00034
00036 int channel;
00038 Mix_Chunk *sample;
00039
00043 void sample_volume(int channel, int volume)
00044 {
00045 Mix_Volume(channel,volume/2);
00046 }
00047
00054 void play_fla_sample(int index,int frequency, int repeat, int x, int y)
00055 {
00056 if(!cfgfile.NoSound)
00057 {
00058 int sampSize = 0;
00059 char sampfile[256];
00060 SDL_RWops *rw;
00061 unsigned char* sampPtr;
00062
00063 sprintf(sampfile, FLA_DIR "//%s",HQR_FLASAMP_FILE);
00064
00065 sampSize = hqr_entry_size(sampfile,index);
00066 sampPtr = (unsigned char*)malloc(sampSize);
00067 hqr_get_entry(sampPtr, sampfile, index);
00068
00069
00070 if(*sampPtr!='C')
00071 *sampPtr = 'C';
00072
00073 rw = SDL_RWFromMem(sampPtr,sampSize);
00074 sample=Mix_LoadWAV_RW(rw,1);
00075
00076 sample_volume(-1, cfgfile.WaveVolume);
00077
00078 if(Mix_PlayChannel(-1, sample, repeat-1)==-1)
00079 printf("Error while playing VOC: Sample %d \n",index);
00080
00081 if(cfgfile.Debug)
00082 printf("Playing VOC: Sample %d\n",index);
00083 free(sampPtr);
00084 }
00085 }
00086
00088 void stop_sample()
00089 {
00090 if(!cfgfile.NoSound)
00091 {
00092 Mix_HaltChannel(-1);
00093
00094 Mix_FreeChunk(sample);
00095 sample=NULL;
00096 if(cfgfile.Debug)
00097 printf("Stop VOC sample\n");
00098 }
00099 }