furnace/src/engine/waveSynth.h

92 lines
2.5 KiB
C
Raw Normal View History

2022-04-07 20:46:48 +00:00
/**
* Furnace Tracker - multi-system chiptune tracker
* Copyright (C) 2021-2022 tildearrow and contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _WAVESYNTH_H
#define _WAVESYNTH_H
#include "instrument.h"
#include "wavetable.h"
2022-04-07 23:27:17 +00:00
class DivEngine;
2022-04-07 20:46:48 +00:00
class DivWaveSynth {
2022-04-07 23:27:17 +00:00
DivEngine* e;
DivInstrumentWaveSynth state;
int pos, stage, divCounter, width, height, subDivCounter;
2022-05-21 19:05:23 +00:00
bool first, activeChangedB, stageDir;
2022-04-07 23:27:17 +00:00
unsigned char wave1[256];
unsigned char wave2[256];
2022-04-07 20:46:48 +00:00
public:
/**
* the output.
*/
int output[256];
/**
* check whether the "active" status has changed.
* @return truth.
*/
bool activeChanged();
2022-04-07 20:46:48 +00:00
/**
* tick this DivWaveSynth.
* @return whether the wave has changed.
*/
2022-05-22 08:14:46 +00:00
bool tick(bool skipSubDiv=false);
/**
* set the wave width.
* @param value the width.
*/
void setWidth(int val);
/**
* change the first wave.
* @param num wavetable number.
*/
void changeWave1(int num);
/**
* change the second wave.
* @param num wavetable number.
*/
void changeWave2(int num);
/**
* initialize this DivWaveSynth.
* @param which the instrument.
* @param width the system's wave width.
* @param height the system's wave height.
* @param insChanged whether the instrument has changed.
*/
2022-04-07 23:27:17 +00:00
void init(DivInstrument* which, int width, int height, bool insChanged=false);
void setEngine(DivEngine* engine, int waveFloor=0);
2022-04-07 20:46:48 +00:00
DivWaveSynth():
2022-04-07 23:27:17 +00:00
e(NULL),
2022-04-07 20:46:48 +00:00
pos(0),
stage(0),
2022-04-07 23:27:17 +00:00
divCounter(0),
width(32),
height(31),
subDivCounter(0),
first(false),
2022-05-21 19:05:23 +00:00
activeChangedB(false),
stageDir(false) {
2022-04-08 17:21:42 +00:00
memset(wave1,0,256);
memset(wave2,0,256);
2022-04-07 20:46:48 +00:00
memset(output,0,sizeof(int)*256);
}
};
#endif