LMMS
Loading...
Searching...
No Matches
surroundopl.h
Go to the documentation of this file.
1/*
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2010 Simon Peter, <dn.tlp@gmx.net>, et al.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * surroundopl.h - Wrapper class to provide a surround/harmonic effect
20 * for another OPL emulator, by Adam Nielsen <malvineous@shikadi.net>
21 *
22 * Stereo harmonic algorithm by Adam Nielsen <malvineous@shikadi.net>
23 * Please give credit if you use this algorithm elsewhere :-)
24 */
25
26#ifndef H_ADPLUG_SURROUNDOPL
27#define H_ADPLUG_SURROUNDOPL
28
29#include <stdint.h> // for uintxx_t
30#include "opl.h"
31
32// The right-channel is increased in frequency by itself divided by this amount.
33// The right value should not noticeably change the pitch, but it should provide
34// a nice stereo harmonic effect.
35#define FREQ_OFFSET 128.0//96.0
36
37// Number of FNums away from the upper/lower limit before switching to the next
38// block (octave.) By rights it should be zero, but for some reason this seems
39// to cut it too close and the transposed OPL doesn't hit the right note all the
40// time. Setting it higher means it will switch blocks sooner and that seems
41// to help. Don't set it too high or it'll get stuck in an infinite loop if
42// one block is too high and the adjacent block is too low ;-)
43#define NEWBLOCK_LIMIT 32
44
45class CSurroundopl: public Copl
46{
47 private:
49 short bufsize;
50 short *lbuf, *rbuf;
51 Copl *a, *b;
52 uint8_t iFMReg[2][256];
54 uint8_t iCurrentTweakedBlock[2][9]; // Current value of the Block in the tweaked OPL chip
55 uint8_t iCurrentFNum[2][9]; // Current value of the FNum in the tweaked OPL chip
56
57 public:
58
59 CSurroundopl(Copl *a, Copl *b, bool use16bit);
61
62 void update(short *buf, int samples);
63 void write(int reg, int val);
64
65 void init();
66 void setchip(int n);
67};
68
69#endif
CSurroundopl(Copl *a, Copl *b, bool use16bit)
Definition surroundopl.cpp:30
short * lbuf
Definition surroundopl.h:50
uint8_t iFMReg[2][256]
Definition surroundopl.h:52
~CSurroundopl()
Definition surroundopl.cpp:40
short bufsize
Definition surroundopl.h:49
void write(int reg, int val)
Definition surroundopl.cpp:74
void init()
Definition surroundopl.cpp:193
uint8_t iCurrentFNum[2][9]
Definition surroundopl.h:55
void update(short *buf, int samples)
Definition surroundopl.cpp:48
uint8_t iTweakedFMReg[2][256]
Definition surroundopl.h:53
Copl * a
Definition surroundopl.h:51
void setchip(int n)
Definition surroundopl.cpp:209
Copl * b
Definition surroundopl.h:51
short * rbuf
Definition surroundopl.h:50
bool use16bit
Definition surroundopl.h:48
uint8_t iCurrentTweakedBlock[2][9]
Definition surroundopl.h:54
Copl()
Definition opl.h:32
int val
Definition jpeglib.h:956
unsigned char uint8_t
Definition mid.cpp:98
int n
Definition crypt.c:458