# Amuse: include/amuse/SoundMacroState.hpp Source File

SoundMacroState.hpp
#ifndef __AMUSE_SOUNDMACROSTATE_HPP__
#define __AMUSE_SOUNDMACROSTATE_HPP__
#include <stdint.h>
#include <vector>
#include <list>
#include "Entity.hpp"
namespace amuse
{
class Voice;
class SoundMacroState
{
friend class Voice;
struct Header
{
uint32_t m_size;
ObjectId m_macroId;
uint8_t m_volume;
uint8_t m_pan;
void swapBig();
} m_header;
enum class Op : uint8_t
{
End,
Stop,
SplitKey,
SplitVel,
WaitTicks,
Loop,
Goto,
WaitMs,
PlayMacro,
SendKeyOff,
SplitMod,
PianoPan,
SetAdsr,
ScaleVolume,
Panning,
Envelope,
StartSample,
StopSample,
KeyOff,
SplitRnd,
FadeIn,
Spanning,
SetAdsrCtrl,
RndNote,
AddNote,
SetNote,
LastNote,
Portamento,
Vibrato,
PitchSweep1,
PitchSweep2,
SetPitch,
SetPitchAdsr,
ScaleVolumeDLS,
Mod2Vibrange,
SetupTremolo,
Return,
GoSub,
TrapEvent = 0x28,
UntrapEvent,
SendMessage,
GetMessage,
GetVid,
AddAgeCount = 0x30,
SetAgeCount,
SendFlag,
PitchWheelR,
SetPriority,
AddPriority,
AgeCntSpeed,
AgeCntVel,
VolSelect = 0x40,
PanSelect,
PitchWheelSelect,
ModWheelSelect,
PedalSelect,
PortamentoSelect,
ReverbSelect,
SpanSelect,
DopplerSelect,
TremoloSelect,
PreASelect,
PreBSelect,
PostBSelect,
AuxAFXSelect,
AuxBFXSelect,
SetupLFO = 0x50,
ModeSelect = 0x58,
SetKeygroup,
SRCmodeSelect,
AddVars = 0x60,
SubVars,
MulVars,
DivVars,
AddIVars,
IfEqual = 0x70,
IfLess,
};
struct Command
{
Op m_op;
char m_data[7];
void swapBig();
};
std::vector<std::pair<const unsigned char*, int>> m_pc;
double m_ticksPerSec;
uint8_t m_initVel;
uint8_t m_initMod;
uint8_t m_initKey;
uint8_t m_curVel;
uint8_t m_curMod;
uint32_t m_curPitch;
double m_execTime;
bool m_keyoff;
bool m_sampleEnd;
bool m_inWait = false;
bool m_indefiniteWait = false;
bool m_keyoffWait = false;
bool m_sampleEndWait = false;
double m_waitCountdown;
int m_loopCountdown = -1;
int m_lastPlayMacroVid = -1;
bool m_useAdsrControllers;
uint8_t m_midiAttack;
uint8_t m_midiDecay;
uint8_t m_midiSustain;
uint8_t m_midiRelease;
uint8_t m_portamentoMode;
uint8_t m_portamentoType;
float m_portamentoTime;
struct Evaluator
{
enum class Combine : uint8_t
{
Set,
Add,
Mult
};
enum class VarType : uint8_t
{
Ctrl,
Var
};
struct Component
{
uint8_t m_midiCtrl;
float m_scale;
Combine m_combine;
VarType m_varType;
Component(uint8_t midiCtrl, float scale, Combine combine, VarType varType)
: m_midiCtrl(midiCtrl), m_scale(scale), m_combine(combine), m_varType(varType) {}
};
std::vector<Component> m_comps;
void addComponent(uint8_t midiCtrl, float scale,
Combine combine, VarType varType);
float evaluate(const Voice& vox, const SoundMacroState& st) const;
operator bool() const {return m_comps.size() != 0;}
};
Evaluator m_volumeSel;
Evaluator m_panSel;
Evaluator m_pitchWheelSel;
Evaluator m_modWheelSel;
Evaluator m_pedalSel;
Evaluator m_portamentoSel;
Evaluator m_reverbSel;
Evaluator m_preAuxASel;
Evaluator m_preAuxBSel;
Evaluator m_auxAFxSel;
Evaluator m_auxBFxSel;
Evaluator m_postAuxB;
Evaluator m_spanSel;
Evaluator m_dopplerSel;
Evaluator m_tremoloSel;
int32_t m_variables[256];
struct EventTrap
{
ObjectId macroId = 0xffff;
uint16_t macroStep;
};
public:
void initialize(const unsigned char* ptr, int step);
void initialize(const unsigned char* ptr, int step, double ticksPerSec,
uint8_t midiKey, uint8_t midiVel, uint8_t midiMod);
bool advance(Voice& vox, double dt);
void keyoffNotify(Voice& vox);
void sampleEndNotify(Voice& vox);
};
}
#endif // __AMUSE_SOUNDMACROSTATE_HPP__
amuse::SoundMacroState::Evaluator::Component
Definition: SoundMacroState.hpp:168
amuse::SoundMacroState::initialize
void initialize(const unsigned char *ptr, int step)
amuse
Definition: AudioGroup.hpp:8
amuse::Voice
Definition: Voice.hpp:30
amuse::SoundMacroState::sampleEndNotify
void sampleEndNotify(Voice &vox)
amuse::SoundMacroState::advance
bool advance(Voice &vox, double dt)
amuse::SoundMacroState
Definition: SoundMacroState.hpp:14
amuse::Envelope
Definition: Envelope.hpp:10
amuse::SoundMacroState::keyoffNotify
void keyoffNotify(Voice &vox)