#if defined(BUILD_OPN) || defined(BUILD_OPNA) || defined (BUILD_OPNB) || defined(BUILD_OPN2)
-uint32 OPNBase::lfotable[8]; // OPNA/B 用
+__DECL_ALIGNED(16) uint32 OPNBase::lfotable[8]; // OPNA/B 用
OPNBase::OPNBase()
{
psg.SetChannelMask(mask >> 6);
}
+#define IStoSampleL(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_l) >> 14)
+#define IStoSampleR(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_r) >> 14)
+//#define IStoSampleL(s) ((s * fmvolume_l) >> 14)
+//#define IStoSampleR(s) ((s * fmvolume_r) >> 14)
// 合成(2ch)
void OPN::Mix(Sample* buffer, int nsamples)
{
-//#define IStoSampleL(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_l) >> 14)
-//#define IStoSampleR(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_r) >> 14)
-#define IStoSampleL(s) ((s * fmvolume_l) >> 14)
-#define IStoSampleR(s) ((s * fmvolume_r) >> 14)
psg.Mix(buffer, nsamples);
StoreSample(dest[1], s_r);
}
}
-#undef IStoSampleL
-#undef IStoSampleR
}
// ---------------------------------------------------------------------------
#if defined(BUILD_OPNA) || defined(BUILD_OPNB)
-int OPNABase::amtable[FM_LFOENTS] = { -1, };
-int OPNABase::pmtable[FM_LFOENTS];
+__DECL_ALIGNED(16) int OPNABase::amtable[FM_LFOENTS] = { -1, };
+__DECL_ALIGNED(16) int OPNABase::pmtable[FM_LFOENTS];
-int32 OPNABase::tltable[FM_TLENTS+FM_TLPOS];
+__DECL_ALIGNED(16) int32 OPNABase::tltable[FM_TLENTS+FM_TLPOS];
bool OPNABase::tablehasmade = false;
OPNABase::OPNABase()
void OPNABase::MixSubSL(int activech, ISample** dest)
{
+#if 1
+ int _mask = 0x001;
+ __LIKELY_IF((activech & _mask) != 0) {
+ *dest[0] = ch[0].CalcL();
+ }
+ _mask <<= 2;
+ for(int i = 1; i < 6; i++) {
+ __LIKELY_IF((activech & _mask) != 0) {
+ *dest[i] += ch[i].CalcL();
+ }
+ _mask <<= 2;
+ }
+#else
if (activech & 0x001) (*dest[0] = ch[0].CalcL());
if (activech & 0x004) (*dest[1] += ch[1].CalcL());
if (activech & 0x010) (*dest[2] += ch[2].CalcL());
if (activech & 0x040) (*dest[3] += ch[3].CalcL());
if (activech & 0x100) (*dest[4] += ch[4].CalcL());
if (activech & 0x400) (*dest[5] += ch[5].CalcL());
+#endif
}
inline void OPNABase::MixSubS(int activech, ISample** dest)
{
+#if 1
+ int _mask = 0x001;
+ __UNLIKELY_IF((activech & _mask) != 0) {
+ *dest[0] = ch[0].Calc();
+ }
+ _mask <<= 2;
+ for(int i = 1; i < 6; i++) {
+ __UNLIKELY_IF((activech & _mask) != 0) {
+ *dest[i] += ch[i].Calc();
+ }
+ _mask <<= 2;
+ }
+#else
if (activech & 0x001) (*dest[0] = ch[0].Calc());
if (activech & 0x004) (*dest[1] += ch[1].Calc());
if (activech & 0x010) (*dest[2] += ch[2].Calc());
if (activech & 0x040) (*dest[3] += ch[3].Calc());
if (activech & 0x100) (*dest[4] += ch[4].Calc());
if (activech & 0x400) (*dest[5] += ch[5].Calc());
+#endif
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// 合成
//
-//#define IStoSampleL(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_l) >> 14)
-//#define IStoSampleR(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_r) >> 14)
-#define IStoSampleL(s) ((s * fmvolume_l) >> 14)
-#define IStoSampleR(s) ((s * fmvolume_r) >> 14)
void OPNABase::Mix6(Sample* buffer, int nsamples, int activech)
{
// Mix
- ISample ibuf[4];
- ISample* idest[6];
+ __DECL_ALIGNED(16) ISample ibuf[4];
+ __DECL_ALIGNED(16) ISample* idest[6];
idest[0] = &ibuf[pan[0]];
idest[1] = &ibuf[pan[1]];
idest[2] = &ibuf[pan[2]];
idest[5] = &ibuf[pan[5]];
Sample* limit = buffer + nsamples * 2;
+
for (Sample* dest = buffer; dest < limit; dest+=2)
{
ibuf[1] = ibuf[2] = ibuf[3] = 0;
- if (activech & 0xaaa)
+ __LIKELY_IF(activech & 0xaaa)
LFO(), MixSubSL(activech, idest);
else
MixSubS(activech, idest);
for (int i=0; i<6; i++)
{
Rhythm& r = rhythm[i];
- if ((rhythmkey & (1 << i)) && r.level < 128)
+ if ((rhythmkey & (1 << i)) /*&& r.level < 128*/)
{
int db_l = Limit(rhythmtl+rhythmtvol_l+r.level+r.volume_l, 127, -31);
int db_r = Limit(rhythmtl+rhythmtvol_r+r.level+r.volume_r, 127, -31);
// ---------------------------------------------------------------------------
// YM2610
//
-int OPNB::jedi_table[(48+1)*16];
+__DECL_ALIGNED(16) int OPNB::jedi_table[(48+1)*16];
void OPNB::InitADPCMATable()
{
for (int i=0; i<6; i++)
{
ADPCMA& r = adpcma[i];
- if ((adpcmakey & (1 << i)) && r.level < 128)
+ if ((adpcmakey & (1 << i)) /*&& r.level < 128*/)
{
uint mask_l = r.pan & 2 ? -1 : 0;
uint mask_r = r.pan & 1 ? -1 : 0;
#if defined(BUILD_OPN2)
-int OPN2Base::amtable[FM_LFOENTS] = { -1, };
-int OPN2Base::pmtable[FM_LFOENTS];
+__DECL_ALIGNED(16) int OPN2Base::amtable[FM_LFOENTS] = { -1, };
+__DECL_ALIGNED(16) int OPN2Base::pmtable[FM_LFOENTS];
-int32 OPN2Base::tltable[FM_TLENTS+FM_TLPOS];
+__DECL_ALIGNED(16) int32 OPN2Base::tltable[FM_TLENTS+FM_TLPOS];
bool OPN2Base::tablehasmade = false;
OPN2Base::OPN2Base()
if (activech & 0x040) (*dest[3] += ch[3].CalcL());
if (activech & 0x100) (*dest[4] += ch[4].CalcL());
if (activech & 0x400) {
- ISample tmp = ((ISample) dac_data) << 5;
- if ((dac_enabled)) {
+ __UNLIKELY_IF ((dac_enabled)) {
+ ISample tmp = ((ISample) dac_data) << 5;
(*dest[5] += tmp);
} else {
(*dest[5] += ch[5].CalcL());
if (activech & 0x040) (*dest[3] += ch[3].Calc());
if (activech & 0x100) (*dest[4] += ch[4].Calc());
if (activech & 0x400) {
- ISample tmp = ((ISample) dac_data) << 5;
- if ((dac_enabled)) {
+ __UNLIKELY_IF ((dac_enabled)) {
+ ISample tmp = ((ISample) dac_data) << 5;
(*dest[5] += tmp);
} else {
(*dest[5] += ch[5].Calc());
// ---------------------------------------------------------------------------
// 合成
//
-//#define IStoSampleL(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_l) >> 14)
-//#define IStoSampleR(s) ((Limit(s, 0x7fff, -0x8000) * fmvolume_r) >> 14)
-
void OPN2Base::Mix6(Sample* buffer, int nsamples, int activech)
{
// Mix
- ISample ibuf[4];
- ISample* idest[6];
+ __DECL_ALIGNED(16) ISample ibuf[4];
+ __DECL_ALIGNED(16) ISample* idest[6];
idest[0] = &ibuf[pan[0]];
idest[1] = &ibuf[pan[1]];
idest[2] = &ibuf[pan[2]];
idest[4] = &ibuf[pan[4]];
idest[5] = &ibuf[pan[5]];
Sample* limit = buffer + nsamples * 2;
+
for (Sample* dest = buffer; dest < limit; dest+=2)
{
ibuf[1] = ibuf[2] = ibuf[3] = 0;
- if (activech & 0xaaa)
+ __LIKELY_IF (activech & 0xaaa)
LFO(), MixSubSL(activech, idest);
else
MixSubS(activech, idest);
StoreSample(dest[1], IStoSampleR(ibuf[1] + ibuf[3]));
}
}
+#undef IStoSampleL
+#undef IStoSampleR
+
// ---------------------------------------------------------------------------
// ステートセーブ
//