Based on UAE. * Original comment in UAE: * * Amiga has two separate filtering circuits per channel, a static RC filter * on A500 and the LED filter. This code emulates both. * * The Amiga filtering circuitry depends on Amiga model. Older Amigas seem * to have a 6 dB/oct RC filter with cutoff frequency such that the -6 dB * point for filter is reached at 6 kHz, while newer Amigas have no fi
| 135 | * and to 1 dB with the filter off. |
| 136 | */ |
| 137 | inline int32 filter(int32 input, Paula::FilterState &state, int voice) { |
| 138 | float normalOutput, ledOutput; |
| 139 | |
| 140 | switch (state.mode) { |
| 141 | case Paula::kFilterModeA500: |
| 142 | state.rc[voice][0] = state.a0[0] * input + (1 - state.a0[0]) * state.rc[voice][0] + DENORMAL_OFFSET; |
| 143 | state.rc[voice][1] = state.a0[1] * state.rc[voice][0] + (1-state.a0[1]) * state.rc[voice][1]; |
| 144 | normalOutput = state.rc[voice][1]; |
| 145 | |
| 146 | state.rc[voice][2] = state.a0[2] * normalOutput + (1 - state.a0[2]) * state.rc[voice][2]; |
| 147 | state.rc[voice][3] = state.a0[2] * state.rc[voice][2] + (1 - state.a0[2]) * state.rc[voice][3]; |
| 148 | state.rc[voice][4] = state.a0[2] * state.rc[voice][3] + (1 - state.a0[2]) * state.rc[voice][4]; |
| 149 | |
| 150 | ledOutput = state.rc[voice][4]; |
| 151 | break; |
| 152 | |
| 153 | case Paula::kFilterModeA1200: |
| 154 | normalOutput = input; |
| 155 | |
| 156 | state.rc[voice][1] = state.a0[2] * normalOutput + (1 - state.a0[2]) * state.rc[voice][1] + DENORMAL_OFFSET; |
| 157 | state.rc[voice][2] = state.a0[2] * state.rc[voice][1] + (1 - state.a0[2]) * state.rc[voice][2]; |
| 158 | state.rc[voice][3] = state.a0[2] * state.rc[voice][2] + (1 - state.a0[2]) * state.rc[voice][3]; |
| 159 | |
| 160 | ledOutput = state.rc[voice][3]; |
| 161 | break; |
| 162 | |
| 163 | case Paula::kFilterModeNone: |
| 164 | default: |
| 165 | return input; |
| 166 | |
| 167 | } |
| 168 | |
| 169 | return CLIP<int32>(state.ledFilter ? ledOutput : normalOutput, -32768, 32767); |
| 170 | } |
| 171 | |
| 172 | template<bool stereo> |
| 173 | inline int mixBuffer(int16 *&buf, const int8 *data, Paula::Offset &offset, frac_t rate, int neededSamples, unsigned int bufSize, uint8 volume, uint8 panning, Paula::FilterState &filterState, int voice) { |