add phase invesrion for left/right channel and feedback
This commit is contained in:
parent
f5877abafe
commit
65d65ef81e
7 changed files with 107 additions and 9 deletions
|
|
@ -3061,6 +3061,11 @@ void sid3_clock(SID3* sid3)
|
|||
ch->noise_accumulator += ch->phase_mod_source == SID3_NUM_CHANNELS - 1 ? ((uint64_t)sid3->wave_channel_output << 18) : ((uint64_t)sid3->channel_output[ch->phase_mod_source] << 18);
|
||||
}
|
||||
|
||||
if(ch->feedback)
|
||||
{
|
||||
ch->accumulator += (ch->prev_output + ch->prev_output2) * ch->feedback;
|
||||
}
|
||||
|
||||
ch->accumulator &= SID3_ACC_MASK;
|
||||
|
||||
if((prev_noise_acc & ((uint32_t)1 << (SID3_ACC_BITS - 6))) != (ch->noise_accumulator & ((uint32_t)1 << (SID3_ACC_BITS - 6))))
|
||||
|
|
@ -3097,11 +3102,17 @@ void sid3_clock(SID3* sid3)
|
|||
{
|
||||
output = ch->output_before_filter;
|
||||
}
|
||||
|
||||
if(ch->feedback)
|
||||
{
|
||||
ch->prev_output2 = ch->prev_output;
|
||||
ch->prev_output = output + 0xffff;
|
||||
}
|
||||
|
||||
if(!sid3->muted[i])
|
||||
{
|
||||
sid3->output_l += output * ch->panning_left / 0x8f0;
|
||||
sid3->output_r += output * ch->panning_right / 0x8f0;
|
||||
sid3->output_l += output * ch->panning_left / 0x8f0 * ((ch->phase_inv & SID3_INV_SIGNAL_LEFT) ? -1 : 1);
|
||||
sid3->output_r += output * ch->panning_right / 0x8f0 * ((ch->phase_inv & SID3_INV_SIGNAL_RIGHT) ? -1 : 1);
|
||||
}
|
||||
|
||||
sid3->channel_output[i] = output;
|
||||
|
|
@ -3189,8 +3200,8 @@ void sid3_clock(SID3* sid3)
|
|||
|
||||
if(!sid3->muted[SID3_NUM_CHANNELS - 1])
|
||||
{
|
||||
sid3->output_l += output * ch->panning_left / 0x8f0;
|
||||
sid3->output_r += output * ch->panning_right / 0x8f0;
|
||||
sid3->output_l += output * ch->panning_left / 0x8f0 * ((ch->phase_inv & SID3_INV_SIGNAL_LEFT) ? -1 : 1);
|
||||
sid3->output_r += output * ch->panning_right / 0x8f0 * ((ch->phase_inv & SID3_INV_SIGNAL_RIGHT) ? -1 : 1);
|
||||
}
|
||||
|
||||
sid3->wave_channel_output = output;
|
||||
|
|
@ -3726,6 +3737,26 @@ void sid3_write(SID3* sid3, uint16_t address, uint8_t data)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SID3_REGISTER_PHASE_INVERSION:
|
||||
{
|
||||
if(channel != SID3_NUM_CHANNELS - 1)
|
||||
{
|
||||
sid3->chan[channel].phase_inv = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
sid3->wave_chan.phase_inv = data;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SID3_REGISTER_FEEDBACK:
|
||||
{
|
||||
if(channel != SID3_NUM_CHANNELS - 1)
|
||||
{
|
||||
sid3->chan[channel].feedback = (uint32_t)data * (uint32_t)data;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ enum Flags
|
|||
SID3_CHAN_1_BIT_NOISE = 128,
|
||||
};
|
||||
|
||||
enum PhaseInversion
|
||||
{
|
||||
SID3_INV_SIGNAL_RIGHT = 1,
|
||||
SID3_INV_SIGNAL_LEFT = 2,
|
||||
};
|
||||
|
||||
enum Waveforms
|
||||
{
|
||||
SID3_WAVE_TRIANGLE = 1,
|
||||
|
|
@ -127,6 +133,10 @@ enum Registers
|
|||
|
||||
SID3_REGISTER_STREAMED_SAMPLE_HIGH = SID3_REGISTER_AFTER_FILT_1ST_REG + 10,
|
||||
SID3_REGISTER_STREAMED_SAMPLE_LOW = SID3_REGISTER_AFTER_FILT_1ST_REG + 11,
|
||||
|
||||
SID3_REGISTER_PHASE_INVERSION = SID3_REGISTER_AFTER_FILT_1ST_REG + 12,
|
||||
|
||||
SID3_REGISTER_FEEDBACK = SID3_REGISTER_AFTER_FILT_1ST_REG + 13,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
|
@ -200,9 +210,13 @@ typedef struct
|
|||
uint8_t clock_filter;
|
||||
|
||||
uint8_t panning_left, panning_right;
|
||||
bool invert_left, invert_right; //invert channel signal
|
||||
|
||||
int32_t output_before_filter;
|
||||
|
||||
uint8_t phase_inv;
|
||||
uint32_t feedback;
|
||||
|
||||
int32_t prev_output, prev_output2;
|
||||
} sid3_channel;
|
||||
|
||||
typedef struct
|
||||
|
|
@ -229,9 +243,10 @@ typedef struct
|
|||
uint8_t clock_filter;
|
||||
|
||||
uint8_t panning_left, panning_right;
|
||||
bool invert_left, invert_right; //invert channel signal
|
||||
|
||||
int32_t output_before_filter;
|
||||
|
||||
uint8_t phase_inv;
|
||||
} sid3_wavetable_chan;
|
||||
|
||||
typedef struct
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue