1 // ---------------------------------------------------------------------------
2 // This file is part of reSID, a MOS6581 SID emulator engine.
3 // Copyright (C) 2004 Dag Lem <resid@nimrod.no>
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.
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.
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 // ---------------------------------------------------------------------------
35 void set_chip_model(chip_model model
);
36 void enable_filter(bool enable
);
37 void enable_external_filter(bool enable
);
38 bool set_sampling_parameters(double clock_freq
, sampling_method method
,
39 double sample_freq
, double pass_freq
= -1,
40 double filter_scale
= 0.97);
41 void adjust_sampling_frequency(double sample_freq
);
43 void fc_default(const fc_point
*& points
, int& count
);
44 PointPlotter
<sound_sample
> fc_plotter();
47 void clock(cycle_count delta_t
);
48 int clock(cycle_count
& delta_t
, short* buf
, int n
, int interleave
= 1);
51 // Read/write registers.
52 reg8
read(reg8 offset
);
53 void write(reg8 offset
, reg8 value
);
61 char sid_register
[0x20];
64 cycle_count bus_value_ttl
;
67 reg24 shift_register
[3];
68 reg16 rate_counter
[3];
69 reg16 rate_counter_period
[3];
70 reg16 exponential_counter
[3];
71 reg16 exponential_counter_period
[3];
72 reg8 envelope_counter
[3];
73 EnvelopeGenerator::State envelope_state
[3];
78 void write_state(const State
& state
);
80 // 16-bit input (EXT IN).
81 void input(int sample
);
83 // 16-bit output (AUDIO OUT).
89 static double I0(double x
);
90 RESID_INLINE
int clock_fast(cycle_count
& delta_t
, short* buf
, int n
,
92 RESID_INLINE
int clock_interpolate(cycle_count
& delta_t
, short* buf
, int n
,
94 RESID_INLINE
int clock_resample_interpolate(cycle_count
& delta_t
, short* buf
,
95 int n
, int interleave
);
96 RESID_INLINE
int clock_resample_fast(cycle_count
& delta_t
, short* buf
,
97 int n
, int interleave
);
101 ExternalFilter extfilt
;
106 cycle_count bus_value_ttl
;
108 double clock_frequency
;
110 // External audio input.
113 // Resampling constants.
114 // The error in interpolated lookup is bounded by 1.234/L^2,
115 // while the error in non-interpolated lookup is bounded by
116 // 0.7854/L + 0.4113/L^2, see
117 // http://www-ccrma.stanford.edu/~jos/resample/Choice_Table_Size.html
118 // For a resolution of 16 bits this yields L >= 285 and L >= 51473,
120 static const int FIR_N
;
121 static const int FIR_RES_INTERPOLATE
;
122 static const int FIR_RES_FAST
;
123 static const int FIR_SHIFT
;
124 static const int RINGSIZE
;
126 // Fixpoint constants (16.16 bits).
127 static const int FIXP_SHIFT
;
128 static const int FIXP_MASK
;
130 // Sampling variables.
131 sampling_method sampling
;
132 cycle_count cycles_per_sample
;
133 cycle_count sample_offset
;
139 // Ring buffer with overflow for contiguous storage of RINGSIZE samples.
142 // FIR_RES filter tables (FIR_N*FIR_RES).
146 #endif // not __SID_H__