| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 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 along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef _WAVESYNTH_H |
| 21 |
#define _WAVESYNTH_H |
| 22 |
|
| 23 |
#include "instrument.h" |
| 24 |
#include "wavetable.h" |
| 25 |
|
| 26 |
class DivEngine; |
| 27 |
|
| 28 |
class DivWaveSynth { |
| 29 |
DivEngine* e; |
| 30 |
DivInstrumentWaveSynth state; |
| 31 |
int pos, stage, divCounter, width, height, subDivCounter; |
| 32 |
bool first, activeChangedB, stageDir; |
| 33 |
unsigned char wave1[256]; |
| 34 |
unsigned char wave2[256]; |
| 35 |
public: |
| 36 |
/** |
| 37 |
* the output. |
| 38 |
*/ |
| 39 |
int output[256]; |
| 40 |
/** |
| 41 |
* check whether the "active" status has changed. |
| 42 |
* @return truth. |
| 43 |
*/ |
| 44 |
bool activeChanged(); |
| 45 |
/** |
| 46 |
* tick this DivWaveSynth. |
| 47 |
* @return whether the wave has changed. |
| 48 |
*/ |
| 49 |
bool tick(bool skipSubDiv=false); |
| 50 |
/** |
| 51 |
* set the wave width. |
| 52 |
* @param value the width. |
| 53 |
*/ |
| 54 |
void setWidth(int val); |
| 55 |
/** |
| 56 |
* change the first wave. |
| 57 |
* @param num wavetable number. |
| 58 |
* @param force whether to force overwriting the current wave. |
| 59 |
*/ |
| 60 |
void changeWave1(int num, bool force=false); |
| 61 |
/** |
| 62 |
* change the second wave. |
| 63 |
* @param num wavetable number. |
| 64 |
*/ |
| 65 |
void changeWave2(int num); |
| 66 |
/** |
| 67 |
* initialize this DivWaveSynth. |
| 68 |
* @param which the instrument. |
| 69 |
* @param width the system's wave width. |
| 70 |
* @param height the system's wave height. |
| 71 |
* @param insChanged whether the instrument has changed. |
| 72 |
*/ |
| 73 |
void init(DivInstrument* which, int width, int height, bool insChanged=false); |
| 74 |
void setEngine(DivEngine* engine, int waveFloor=0); |
| 75 |
DivWaveSynth(): |
| 76 |
e(NULL), |
| 77 |
pos(0), |
| 78 |
stage(0), |
| 79 |
divCounter(0), |
| 80 |
width(32), |
| 81 |
height(31), |
| 82 |
subDivCounter(0), |
| 83 |
first(false), |
| 84 |
activeChangedB(false), |
| 85 |
stageDir(false) { |
| 86 |
memset(wave1,0,256); |
| 87 |
memset(wave2,0,256); |
| 88 |
memset(output,0,sizeof(int)*256); |
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
#endif |