| 1 | // --------------------------------------------------------------------------- |
| 2 | // This file is part of reSID, a MOS6581 SID emulator engine. |
| 3 | // Copyright (C) 2004 Dag Lem <[email protected]> |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU General Public License as published by |
| 7 | // the Free Software Foundation; either version 2 of the License, or |
| 8 | // (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | // GNU General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with this program; if not, write to the Free Software |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | // --------------------------------------------------------------------------- |
| 19 | |
| 20 | #ifndef __SIDFP_H__ |
| 21 | #define __SIDFP_H__ |
| 22 | |
| 23 | #include "siddefsfp.h" |
| 24 | #include "voicefp.h" |
| 25 | #include "filterfp.h" |
| 26 | #include "extfiltfp.h" |
| 27 | #include "potfp.h" |
| 28 | |
| 29 | class SIDFP |
| 30 | { |
| 31 | public: |
| 32 | SIDFP(); |
| 33 | ~SIDFP(); |
| 34 | |
| 35 | static float kinked_dac(const int x, const float nonlinearity, const int bits); |
| 36 | |
| 37 | void set_chip_model(chip_model model); |
| 38 | FilterFP& get_filter() { return filter; } |
| 39 | void enable_filter(bool enable); |
| 40 | bool set_sampling_parameters(double clock_freq, sampling_method method, |
| 41 | double sample_freq, double pass_freq = 20000); |
| 42 | void set_voice_nonlinearity(float nl); |
| 43 | |
| 44 | void clock(); |
| 45 | int clock(cycle_count& delta_t, short* buf, int n, int interleave = 1); |
| 46 | int clock_fast(cycle_count& delta_t, short* buf, int n, int interleave = 1); |
| 47 | void reset(); |
| 48 | |
| 49 | // Read/write registers. |
| 50 | reg8 read(reg8 offset); |
| 51 | void write(reg8 offset, reg8 value); |
| 52 | void mute(reg8 channel, bool enable); |
| 53 | |
| 54 | // 16-bit input (EXT IN). |
| 55 | void input(int sample); |
| 56 | |
| 57 | // 16-bit output (AUDIO OUT). |
| 58 | float output(); |
| 59 | |
| 60 | // Ring buffer with overflow for contiguous storage of RINGSIZE samples. |
| 61 | float* sample; |
| 62 | |
| 63 | private: |
| 64 | static double I0(double x); |
| 65 | inline int clock_interpolate(cycle_count& delta_t, short* buf, int n, |
| 66 | int interleave); |
| 67 | inline int clock_resample_interpolate(cycle_count& delta_t, short* buf, |
| 68 | int n, int interleave); |
| 69 | inline void age_bus_value(cycle_count); |
| 70 | |
| 71 | VoiceFP voice[3]; |
| 72 | FilterFP filter; |
| 73 | ExternalFilterFP extfilt; |
| 74 | PotentiometerFP potx; |
| 75 | PotentiometerFP poty; |
| 76 | |
| 77 | reg8 bus_value; |
| 78 | cycle_count bus_value_ttl; |
| 79 | |
| 80 | // External audio input. |
| 81 | float ext_in; |
| 82 | |
| 83 | // Sampling variables. |
| 84 | sampling_method sampling; |
| 85 | float cycles_per_sample; |
| 86 | float sample_offset; |
| 87 | int sample_index; |
| 88 | int fir_N; |
| 89 | int fir_RES; |
| 90 | /* for linear interpolation mode */ |
| 91 | float sample_prev; |
| 92 | |
| 93 | // FIR_RES filter tables (FIR_N*FIR_RES). |
| 94 | float* fir; |
| 95 | |
| 96 | /* analog parts are run at half the rate of digital ones. */ |
| 97 | float lastsample[3]; |
| 98 | unsigned char filtercyclegate; |
| 99 | }; |
| 100 | |
| 101 | #endif // not __SIDFP_H__ |