2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
2023-01-20 00:18:40 +00:00
|
|
|
* Copyright (C) 2021-2023 tildearrow and contributors
|
2022-02-15 03:12:20 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-05-15 21:42:48 +00:00
|
|
|
#ifndef _MACROINT_H
|
|
|
|
#define _MACROINT_H
|
|
|
|
|
|
|
|
#include "instrument.h"
|
2022-04-10 05:01:55 +00:00
|
|
|
|
2022-04-15 10:37:23 +00:00
|
|
|
class DivEngine;
|
|
|
|
|
2022-04-10 05:01:55 +00:00
|
|
|
struct DivMacroStruct {
|
2022-10-07 19:17:25 +00:00
|
|
|
int pos, lastPos, lfoPos, delay;
|
2022-04-10 05:01:55 +00:00
|
|
|
int val;
|
2022-12-17 05:09:56 +00:00
|
|
|
bool has, had, actualHad, finished, will, linger, began, masked;
|
2022-10-07 09:11:45 +00:00
|
|
|
unsigned int mode, type;
|
2022-04-15 19:38:25 +00:00
|
|
|
void doMacro(DivInstrumentMacro& source, bool released, bool tick);
|
2022-04-10 05:01:55 +00:00
|
|
|
void init() {
|
2022-10-07 19:17:25 +00:00
|
|
|
pos=lastPos=lfoPos=mode=type=delay=0;
|
2022-04-15 19:38:25 +00:00
|
|
|
has=had=actualHad=will=false;
|
2022-05-31 23:34:23 +00:00
|
|
|
linger=false;
|
2022-08-22 08:52:32 +00:00
|
|
|
began=true;
|
2022-04-15 08:37:16 +00:00
|
|
|
// TODO: test whether this breaks anything?
|
|
|
|
val=0;
|
2022-04-10 05:01:55 +00:00
|
|
|
}
|
2022-05-31 23:34:23 +00:00
|
|
|
void prepare(DivInstrumentMacro& source, DivEngine* e);
|
2022-04-10 05:01:55 +00:00
|
|
|
DivMacroStruct():
|
|
|
|
pos(0),
|
2022-08-22 08:52:32 +00:00
|
|
|
lastPos(0),
|
2022-10-07 19:17:25 +00:00
|
|
|
lfoPos(0),
|
2022-08-22 08:52:32 +00:00
|
|
|
delay(0),
|
2022-04-10 05:01:55 +00:00
|
|
|
val(0),
|
|
|
|
has(false),
|
|
|
|
had(false),
|
2022-04-15 19:38:25 +00:00
|
|
|
actualHad(false),
|
2022-04-10 05:01:55 +00:00
|
|
|
finished(false),
|
|
|
|
will(false),
|
2022-05-31 23:34:23 +00:00
|
|
|
linger(false),
|
2022-08-31 08:11:02 +00:00
|
|
|
began(true),
|
2022-12-17 05:09:56 +00:00
|
|
|
masked(false),
|
2022-10-07 09:11:45 +00:00
|
|
|
mode(0),
|
|
|
|
type(0) {}
|
2022-04-10 05:01:55 +00:00
|
|
|
};
|
|
|
|
|
2021-05-15 21:42:48 +00:00
|
|
|
class DivMacroInt {
|
2022-04-15 10:37:23 +00:00
|
|
|
DivEngine* e;
|
2021-05-15 21:42:48 +00:00
|
|
|
DivInstrument* ins;
|
2022-04-10 23:07:30 +00:00
|
|
|
DivMacroStruct* macroList[128];
|
|
|
|
DivInstrumentMacro* macroSource[128];
|
|
|
|
size_t macroListLen;
|
2022-04-15 10:37:23 +00:00
|
|
|
int subTick;
|
2022-02-08 08:50:42 +00:00
|
|
|
bool released;
|
2021-05-15 21:42:48 +00:00
|
|
|
public:
|
2022-04-10 05:01:55 +00:00
|
|
|
// common macro
|
|
|
|
DivMacroStruct vol;
|
|
|
|
DivMacroStruct arp;
|
|
|
|
DivMacroStruct duty, wave, pitch, ex1, ex2, ex3;
|
2022-04-10 21:52:03 +00:00
|
|
|
DivMacroStruct alg, fb, fms, ams;
|
2022-04-10 05:01:55 +00:00
|
|
|
DivMacroStruct panL, panR, phaseReset, ex4, ex5, ex6, ex7, ex8;
|
|
|
|
|
|
|
|
// FM operator macro
|
2022-01-23 08:27:44 +00:00
|
|
|
struct IntOp {
|
2022-04-10 05:01:55 +00:00
|
|
|
DivMacroStruct am, ar, dr, mult;
|
|
|
|
DivMacroStruct rr, sl, tl, dt2;
|
|
|
|
DivMacroStruct rs, dt, d2r, ssg;
|
|
|
|
DivMacroStruct dam, dvb, egt, ksl;
|
|
|
|
DivMacroStruct sus, vib, ws, ksr;
|
2022-01-23 08:27:44 +00:00
|
|
|
IntOp():
|
2022-04-10 05:01:55 +00:00
|
|
|
am(),
|
|
|
|
ar(),
|
|
|
|
dr(),
|
|
|
|
mult(),
|
|
|
|
rr(),
|
|
|
|
sl(),
|
|
|
|
tl(),
|
|
|
|
dt2(),
|
|
|
|
rs(),
|
|
|
|
dt(),
|
|
|
|
d2r(),
|
|
|
|
ssg(),
|
|
|
|
dam(),
|
|
|
|
dvb(),
|
|
|
|
egt(),
|
|
|
|
ksl(),
|
|
|
|
sus(),
|
|
|
|
vib(),
|
|
|
|
ws(),
|
|
|
|
ksr() {}
|
2022-01-23 08:27:44 +00:00
|
|
|
} op[4];
|
2022-03-16 03:05:55 +00:00
|
|
|
|
2022-06-05 21:24:12 +00:00
|
|
|
// state
|
|
|
|
bool hasRelease;
|
|
|
|
|
2022-12-17 05:09:56 +00:00
|
|
|
/**
|
|
|
|
* set mask on macro.
|
|
|
|
*/
|
|
|
|
void mask(unsigned char id, bool enabled);
|
|
|
|
|
2022-03-16 03:05:55 +00:00
|
|
|
/**
|
|
|
|
* trigger macro release.
|
|
|
|
*/
|
2022-02-08 08:50:42 +00:00
|
|
|
void release();
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* trigger next macro tick.
|
|
|
|
*/
|
2021-05-15 21:42:48 +00:00
|
|
|
void next();
|
2022-03-16 03:05:55 +00:00
|
|
|
|
2022-04-15 10:37:23 +00:00
|
|
|
/**
|
|
|
|
* set the engine.
|
|
|
|
* @param the engine
|
|
|
|
*/
|
|
|
|
void setEngine(DivEngine* eng);
|
|
|
|
|
2022-03-16 03:05:55 +00:00
|
|
|
/**
|
|
|
|
* initialize the macro interpreter.
|
|
|
|
* @param which an instrument, or NULL.
|
|
|
|
*/
|
2021-05-15 21:42:48 +00:00
|
|
|
void init(DivInstrument* which);
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* notify this macro interpreter that an instrument has been deleted.
|
|
|
|
* @param which the instrument in question.
|
|
|
|
*/
|
2022-01-14 00:36:02 +00:00
|
|
|
void notifyInsDeletion(DivInstrument* which);
|
2022-03-16 03:05:55 +00:00
|
|
|
|
2022-08-20 06:10:30 +00:00
|
|
|
/**
|
|
|
|
* get DivMacroStruct by macro name.
|
|
|
|
* @param which the macro name.
|
|
|
|
* @return a DivMacroStruct, or NULL if none found.
|
|
|
|
*/
|
|
|
|
DivMacroStruct* structByName(const String& name);
|
|
|
|
|
2021-05-15 21:42:48 +00:00
|
|
|
DivMacroInt():
|
2022-04-15 10:37:23 +00:00
|
|
|
e(NULL),
|
2021-05-15 21:42:48 +00:00
|
|
|
ins(NULL),
|
2022-04-10 23:07:30 +00:00
|
|
|
macroListLen(0),
|
2022-04-15 19:38:25 +00:00
|
|
|
subTick(1),
|
2022-02-08 08:50:42 +00:00
|
|
|
released(false),
|
2022-04-10 05:01:55 +00:00
|
|
|
vol(),
|
|
|
|
arp(),
|
|
|
|
duty(),
|
|
|
|
wave(),
|
|
|
|
pitch(),
|
|
|
|
ex1(),
|
|
|
|
ex2(),
|
|
|
|
ex3(),
|
|
|
|
alg(),
|
|
|
|
fb(),
|
|
|
|
fms(),
|
|
|
|
ams(),
|
|
|
|
panL(),
|
|
|
|
panR(),
|
|
|
|
phaseReset(),
|
|
|
|
ex4(),
|
|
|
|
ex5(),
|
|
|
|
ex6(),
|
|
|
|
ex7(),
|
2022-06-05 21:24:12 +00:00
|
|
|
ex8(),
|
|
|
|
hasRelease(false) {
|
2022-04-10 23:07:30 +00:00
|
|
|
memset(macroList,0,128*sizeof(void*));
|
|
|
|
memset(macroSource,0,128*sizeof(void*));
|
|
|
|
}
|
2021-05-15 21:42:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|