hi joyrider,
thanks for your ideas. you should get the code from svn and try yourself. you can create a patch file and send it to me. i will add it to svn.
until the end of this week i hav no time to add sound.
stay tuned
Welcome | |
---|---|
Welcome to a320
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today! |
Moderator: Moderators
//added globals from original source
AudioData *Sound;
short *backbuffer;
int * rawSoundBuf = 0;
unsigned framesPerSecond = 60; //PacmanMachine::VideoFrequency;
unsigned samplesPerSecond = 44100; // Valid values: 11025, 22050, 44100
unsigned samplesPerFrame = samplesPerSecond / framesPerSecond;
unsigned bytesPerSample = 2;
//add this in game engine::init
rawSoundBuf = new int[ samplesPerFrame ];
backbuffer=(short*)malloc(A320_SCREEN_WIDTH*A320_SCREEN_HEIGHT*sizeof(short));
memset((char*)backbuffer,0x00,A320_SCREEN_WIDTH*A320_SCREEN_HEIGHT*sizeof(short));
Sound = new AudioData();
Sound->LoadPCM(_LS("dummy.snd"));
//Add this in the render function, below the screen drawing part
int i;
int * rawBuf = rawSoundBuf;
char * sndBuf = (char *) Sound->GetBuf();
if( bytesPerSample == 1 ) {
for( i=0; i<(int)samplesPerFrame; i++ ) {
*sndBuf++ = (unsigned char) (*rawBuf++ / 3) + 0x80;
}
}
else {
for( i=0; i<(int)samplesPerFrame; i++ ) {
unsigned short w = (unsigned short)(*rawBuf++ * 85);
*sndBuf++ = (unsigned char) (w);
*sndBuf++ = (unsigned char) (w >> 8);
}
}
m_pAudioPlayer->Play(Sound,1,(int)samplesPerFrame,200,false);
//add this in the exit function
SAFE_DELETE(Sound);
Users browsing this forum: No registered users and 0 guests