libsidplayfp 3.0.0
SID.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright (C) 2025-2026 Leandro Nini
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21// Based on cRSID lightweight RealSID by Hermit (Mihaly Horvath)
22
23#ifndef SIDLITE_SID_H
24#define SIDLITE_SID_H
25
26#include "ADSR.h"
27#include "Filter.h"
28#include "WavGen.h"
29#include "sl_settings.h"
30
31#include <array>
32
33namespace SIDLite
34{
35
36class SID
37{
38public:
39 enum class model_t
40 {
41 MOS6581,
42 MOS8580
43 };
44
45public:
46 SID();
47 void reset();
48 void write(int addr, int value);
49 int read(int addr) const;
50 int clock(unsigned int cycles, short* buf);
51
52 void setChipModel(model_t model);
53 void setRealSIDmode(bool mode);
54 bool setSamplingParameters(unsigned int clockFrequency, unsigned short samplingFrequency);
55
56 int getLevel() const { return filter.getLevel(); }
57
58private:
59 unsigned char regs[0x20] = {0};
60
61 ADSR adsr;
62 Filter filter;
63 WavGen wavgen;
64 settings s;
65
66 short SampleCycleCnt;
67
68private:
69 inline bool generateSample(unsigned int &cycles, short &output);
70};
71
72}
73
74#endif // SIDLITE_SID_H
Definition ADSR.h:30
Definition Filter.h:32
Definition WavGen.h:37
Definition sl_settings.h:32