unsigned int period_time = buffer_time / 4;
int err;
- if (iDisStereo) pchannels = 1;
- else pchannels=2;
+ pchannels=2;
pspeed = 44100;
format = SND_PCM_FORMAT_S16;
if (snd_pcm_state(handle) == SND_PCM_STATE_XRUN)
snd_pcm_prepare(handle);
- snd_pcm_writei(handle,pSound,
- iDisStereo ? lBytes / 2 : lBytes / 4);
+ snd_pcm_writei(handle,pSound, lBytes / 4);
}
if(iUseInterpolation<0) iUseInterpolation=0; \r
if(iUseInterpolation>3) iUseInterpolation=3; \r
\r
- strcpy(t,"\nDisStereo");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p) iDisStereo=atoi(p+len); \r
- if(iDisStereo<0) iDisStereo=0; \r
- if(iDisStereo>1) iDisStereo=1; \r
-\r
free(pB);\r
}\r
\r
iUseTimer=2;\r
iUseReverb=2;\r
iUseInterpolation=2;\r
- iDisStereo=0;\r
\r
ReadConfigFile();\r
}\r
extern int iRecordMode;\r
extern int iUseReverb;\r
extern int iUseInterpolation;\r
-extern int iDisStereo;\r
// MISC\r
\r
extern int iSpuAsyncWait;\r
int myfrag;
int oss_speed, oss_stereo;
- if(iDisStereo) pstereo=OSS_MODE_MONO;
- else pstereo=OSS_MODE_STEREO;
-
+ pstereo = OSS_MODE_STEREO;
oss_speed = pspeed;
oss_stereo = pstereo;
return;
}
- if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1)
+ if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1 || !oss_stereo)
{
printf("Stereo mode not supported!\n");
return;
}
- if(oss_stereo!=1)
- {
- iDisStereo=1;
- }
-
if(ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&oss_speed)==-1)
{
printf("Sound frequency not supported\n");
// Set sample spec ////////////////////////////////////////////////////////
device.spec.format = PA_SAMPLE_S16NE;
- if (iDisStereo)
- device.spec.channels = 1;
- else
- device.spec.channels = 2;
+ device.spec.channels = 2;
device.spec.rate = settings.frequency;
pa_buffer_attr buffer_attributes;
spec.freq = 44100;
spec.format = AUDIO_S16SYS;
- spec.channels = iDisStereo ? 1 : 2;
+ spec.channels = 2;
spec.samples = 512;
spec.callback = SOUND_FillAudio;
}
iBufSize = BUFFER_SIZE;
- if (iDisStereo) iBufSize /= 2;
pSndBuffer = (short *)malloc(iBufSize * sizeof(short));
if (pSndBuffer == NULL) {
int iRecordMode=0;
int iUseReverb=2;
int iUseInterpolation=2;
-int iDisStereo=0;
// MAIN infos struct for each channel
{ 115, -52 },
{ 98, -55 },
{ 122, -60 } };
-int SSumR[NSSIZE];
-int SSumL[NSSIZE];
+int SSumLR[NSSIZE*2];
int iFMod[NSSIZE];
int iCycle = 0;
short * pS;
//////////////////////////////////////////////
// ok, left/right sound volume (psx volume goes from 0 ... 0x3fff)
- SSumL[ns]+=(sval*s_chan[ch].iLeftVolume)/0x4000L;
- SSumR[ns]+=(sval*s_chan[ch].iRightVolume)/0x4000L;
+ SSumLR[ns*2] +=(sval*s_chan[ch].iLeftVolume)/0x4000L;
+ SSumLR[ns*2+1]+=(sval*s_chan[ch].iRightVolume)/0x4000L;
//////////////////////////////////////////////
// now let us store sound data for reverb
///////////////////////////////////////////////////////
// mix all channels (including reverb) into one buffer
- if(iDisStereo) // no stereo?
+ for (ns = 0; ns < NSSIZE*2; )
{
- int dl, dr;
- for (ns = 0; ns < NSSIZE; ns++)
- {
- SSumL[ns] += MixREVERBLeft(ns);
-
- dl = SSumL[ns] / voldiv; SSumL[ns] = 0;
- if (dl < -32767) dl = -32767; if (dl > 32767) dl = 32767;
-
- SSumR[ns] += MixREVERBRight();
-
- dr = SSumR[ns] / voldiv; SSumR[ns] = 0;
- if (dr < -32767) dr = -32767; if (dr > 32767) dr = 32767;
- *pS++ = (dl + dr) / 2;
- }
- }
- else // stereo:
- for (ns = 0; ns < NSSIZE; ns++)
- {
- SSumL[ns] += MixREVERBLeft(ns);
+ SSumLR[ns] += MixREVERBLeft(ns/2);
- d = SSumL[ns] / voldiv; SSumL[ns] = 0;
+ d = SSumLR[ns] / voldiv; SSumLR[ns] = 0;
if (d < -32767) d = -32767; if (d > 32767) d = 32767;
*pS++ = d;
+ ns++;
- SSumR[ns] += MixREVERBRight();
+ SSumLR[ns] += MixREVERBRight();
- d = SSumR[ns] / voldiv; SSumR[ns] = 0;
+ d = SSumLR[ns] / voldiv; SSumLR[ns] = 0;
if(d < -32767) d = -32767; if(d > 32767) d = 32767;
*pS++ = d;
+ ns++;
}
//////////////////////////////////////////////////////
// SETUPTIMER: init of certain buffers and threads/timers
void SetupTimer(void)
{
- memset(SSumR,0,NSSIZE*sizeof(int)); // init some mixing buffers
- memset(SSumL,0,NSSIZE*sizeof(int));
+ memset(SSumLR,0,sizeof(SSumLR)); // init some mixing buffers
memset(iFMod,0,NSSIZE*sizeof(int));
pS=(short *)pSpuBuffer; // setup soundbuffer pointer
// will be included from spu.c
#ifdef _IN_SPU
+#define XA_HACK
+
////////////////////////////////////////////////////////////////////////
// XA GLOBALS
////////////////////////////////////////////////////////////////////////
int ns;
uint32_t l;
- for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++)
+ for(ns=0;ns<NSSIZE*2 && XAPlay!=XAFeed;)
{
XALastVal=*XAPlay++;
if(XAPlay==XAEnd) XAPlay=XAStart;
#ifdef XA_HACK
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
#else
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
#endif
}
if(XAPlay==XAFeed && XARepeat)
{
XARepeat--;
- for(;ns<NSSIZE;ns++)
+ for(;ns<NSSIZE*2;)
{
#ifdef XA_HACK
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
#else
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
#endif
}
}
- for(ns=0;ns<NSSIZE && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);ns++)
+ for(ns=0;ns<NSSIZE*2 && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);)
{
l=*CDDAPlay++;
if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart;
- SSumL[ns]+=(((short)(l&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(l&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767;
}
}
xapGlobal = xap; // store info for save states
XARepeat = 100; // set up repeat
-#ifdef XA_HACK
+#if 0//def XA_HACK
iSize=((45500*xap->nsamples)/xap->freq); // get size
#else
iSize=((44100*xap->nsamples)/xap->freq); // get size