34 namespace libsidplayfp
48 static const int_least32_t SCALE_FACTOR = 1 << 16;
50 static constexpr
double SQRT_0_5 = 0.70710678118654746;
52 # define SQRT_0_5 0.70710678118654746
54 static const int_least32_t C1 =
static_cast<int_least32_t
>(1.0 / (1.0 + SQRT_0_5) * SCALE_FACTOR);
55 static const int_least32_t C2 =
static_cast<int_least32_t
>(SQRT_0_5 / (1.0 + SQRT_0_5) * SCALE_FACTOR);
58 typedef int_least32_t (
Mixer::*mixer_func_t)()
const;
65 std::vector<sidemu*> m_chips;
66 std::vector<short*> m_buffers;
68 std::vector<int_least32_t> m_iSamples;
69 std::vector<int_least32_t> m_volume;
71 std::vector<mixer_func_t> m_mix;
74 int m_fastForwardFactor;
77 short *m_sampleBuffer;
78 uint_least32_t m_sampleCount;
79 uint_least32_t m_sampleIndex;
86 int triangularDithering()
88 const int prevValue = oldRandomValue;
90 return oldRandomValue - prevValue;
116 int_least32_t mono()
const
118 int_least32_t res = 0;
119 for (
int i = 0; i < Chips; i++)
120 res += m_iSamples[i];
125 int_least32_t stereo_OneChip()
const {
return m_iSamples[0]; }
127 int_least32_t stereo_ch1_TwoChips()
const {
return m_iSamples[0]; }
128 int_least32_t stereo_ch2_TwoChips()
const {
return m_iSamples[1]; }
130 int_least32_t stereo_ch1_ThreeChips()
const {
return (C1*m_iSamples[0] + C2*m_iSamples[1]) / SCALE_FACTOR; }
131 int_least32_t stereo_ch2_ThreeChips()
const {
return (C2*m_iSamples[1] + C1*m_iSamples[2]) / SCALE_FACTOR; }
139 m_fastForwardFactor(1),
143 m_mix.push_back(&Mixer::mono<1>);
167 void begin(
short *buffer, uint_least32_t count);
187 sidemu*
getSid(
unsigned int i)
const {
return (i < m_chips.size()) ? m_chips[i] :
nullptr; }
203 void setVolume(int_least32_t left, int_least32_t right);
215 bool notFinished()
const {
return m_sampleIndex != m_sampleCount; }