Finish SoundMacro command introspection. Initial work on SoundMacro

editor
This commit is contained in:
Jack Andersen 2018-07-19 20:38:09 -10:00
parent f50ee6e8f1
commit 321c2d9a3c
11 changed files with 2639 additions and 264 deletions

View File

@ -17,11 +17,6 @@
#include "KeymapEditor.hpp"
#include "LayersEditor.hpp"
static void connectMessenger(UIMessenger* messenger, Qt::ConnectionType type)
{
}
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent),
m_treeDelegate(*this, this),
@ -151,9 +146,7 @@ bool MainWindow::setProjectPath(const QString& path)
m_ui.projectOutline->setModel(m_projectModel);
m_ui.actionExport_GameCube_Groups->setEnabled(true);
setWindowFilePath(path);
#ifndef __APPLE__
setWindowTitle(QString("Amuse - %1").arg(dir.dirName()));
#endif
setWindowTitle(QString("Amuse [%1]").arg(dir.dirName()));
setFocusAudioGroup(nullptr);
onFocusChanged(nullptr, focusWidget());
@ -357,7 +350,7 @@ void MainWindow::openAction()
QFileInfo(dir, QStringLiteral("!pool.yaml")).exists())
dir.cdUp();
if (!setProjectPath(path))
if (!setProjectPath(dir.path()))
return;
ProjectModel* model = m_projectModel;
@ -525,9 +518,7 @@ bool TreeDelegate::editorEvent(QEvent* event,
return false;
if ((event->type() == QEvent::MouseButtonDblClick &&
static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton) ||
(event->type() == QEvent::KeyPress &&
static_cast<QKeyEvent*>(event)->key() == Qt::Key_Enter))
static_cast<QMouseEvent*>(event)->button() == Qt::LeftButton))
{
// Open in editor
return m_window.openEditor(node);

View File

@ -311,7 +311,7 @@
<normaloff>:/icons/IconNewSoundGroup.svg</normaloff>:/icons/IconNewSoundGroup.svg</iconset>
</property>
<property name="text">
<string>&amp;New SFX Group</string>
<string>New SF&amp;X Group</string>
</property>
</action>
<action name="actionNew_Song_Group">
@ -323,7 +323,7 @@
<normaloff>:/icons/IconNewSongGroup.svg</normaloff>:/icons/IconNewSongGroup.svg</iconset>
</property>
<property name="text">
<string>New &amp;Song Group</string>
<string>New Son&amp;g Group</string>
</property>
</action>
<action name="actionNew_Sound_Macro">
@ -409,7 +409,7 @@
<normaloff>:/icons/IconNewGroup.svg</normaloff>:/icons/IconNewGroup.svg</iconset>
</property>
<property name="text">
<string>N&amp;ew Subproject</string>
<string>&amp;New Subproject</string>
</property>
</action>
<action name="actionNew_ADSR">
@ -421,7 +421,7 @@
<normaloff>:/icons/IconNewADSR.svg</normaloff>:/icons/IconNewADSR.svg</iconset>
</property>
<property name="text">
<string>Ne&amp;w ADSR</string>
<string>New &amp;ADSR</string>
</property>
</action>
<action name="actionNew_Curve">

View File

@ -1,10 +1,140 @@
#include "SoundMacroEditor.hpp"
#include <QLabel>
#include <QPainter>
#include <QPropertyAnimation>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QLineEdit>
#include <QSpinBox>
CommandWidget::CommandWidget(QWidget* parent, const QString& text)
: QWidget(parent), m_numberText(text), m_titleText("Command")
{
m_titleFont.setWeight(QFont::Bold);
m_numberText.setTextOption(QTextOption(Qt::AlignRight));
m_numberText.setTextWidth(25);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setMinimumHeight(100);
m_numberFont.setWeight(QFont::Bold);
m_numberFont.setStyleHint(QFont::Monospace);
m_numberFont.setPointSize(16);
#if 0
const amuse::SoundMacro::CmdIntrospection* introspection = amuse::SoundMacro::GetCmdIntrospection(cmd->Isa());
if (introspection)
{
for (int f = 0; f < 7; ++f)
{
introspection->m_fields[f];
}
}
#endif
setContentsMargins(54, 4, 0, 4);
QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->addStretch();
QGridLayout* layout = new QGridLayout;
layout->addWidget(new QLabel("One"), 0, 0);
layout->addWidget(new QSpinBox, 1, 0);
layout->addWidget(new QLabel("Two"), 0, 1);
layout->addWidget(new QSpinBox, 1, 1);
layout->addWidget(new QLabel("Three"), 0, 2);
layout->addWidget(new QSpinBox, 1, 2);
mainLayout->addLayout(layout);
setLayout(mainLayout);
}
void CommandWidget::animateOpen()
{
QPropertyAnimation* animation = new QPropertyAnimation(this, "minimumHeight");
animation->setDuration(abs(minimumHeight() - 200) * 3);
animation->setStartValue(minimumHeight());
animation->setEndValue(200);
animation->setEasingCurve(QEasingCurve::InOutExpo);
connect(animation, SIGNAL(valueChanged(const QVariant&)), parentWidget(), SLOT(update()));
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void CommandWidget::animateClosed()
{
QPropertyAnimation* animation = new QPropertyAnimation(this, "minimumHeight");
animation->setDuration(abs(minimumHeight() - 100) * 3);
animation->setStartValue(minimumHeight());
animation->setEndValue(100);
animation->setEasingCurve(QEasingCurve::InOutExpo);
connect(animation, SIGNAL(valueChanged(const QVariant&)), parentWidget(), SLOT(update()));
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void CommandWidget::paintEvent(QPaintEvent* event)
{
/* Rounded frame */
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(QPen(QColor(127, 127, 127), 2.0));
painter.setBrush(QColor(127, 127, 127));
QTransform mainXf = QTransform::fromTranslate(0, rect().bottom() - 99);
painter.setTransform(mainXf);
QPoint points[] =
{
{1, 20},
{1, 99},
{width() - 1, 99},
{width() - 1, 1},
{20, 1},
{1, 20}
};
painter.drawPolyline(points, 6);
QPoint headPoints[] =
{
{1, 20},
{1, 55},
{35, 20},
{width() - 1, 20},
{width() - 1, 1},
{20, 1},
{1, 20}
};
painter.drawPolygon(headPoints, 7);
painter.drawRect(17, 51, 32, 32);
painter.setPen(palette().color(QPalette::Background));
painter.setFont(m_titleFont);
painter.drawStaticText(40, -1, m_titleText);
QTransform rotate;
rotate.rotate(-45.0);
painter.setTransform(rotate * mainXf);
painter.setFont(m_numberFont);
painter.drawStaticText(-15, 10, m_numberText);
QWidget::paintEvent(event);
}
void CommandWidget::mousePressEvent(QMouseEvent* event)
{
animateOpen();
}
void CommandWidget::mouseReleaseEvent(QMouseEvent* event)
{
animateClosed();
}
SoundMacroEditor::SoundMacroEditor(ProjectModel::SoundMacroNode* node, QWidget* parent)
: EditorWidget(parent)
{
QLabel* lab = new QLabel;
lab->setText(node->m_name);
lab->setParent(this);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(new CommandWidget(this, "1"));
layout->addWidget(new CommandWidget(this, "42"));
layout->addWidget(new CommandWidget(this, "99"));
layout->addStretch();
setLayout(layout);
}

View File

@ -2,6 +2,24 @@
#define AMUSE_SOUND_MACRO_EDITOR_HPP
#include "EditorWidget.hpp"
#include <QStaticText>
class CommandWidget : public QWidget
{
Q_OBJECT
QFont m_numberFont;
QFont m_titleFont;
QStaticText m_numberText;
QStaticText m_titleText;
void animateOpen();
void animateClosed();
public:
CommandWidget(QWidget* parent, const QString& text);
void paintEvent(QPaintEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
};
class SoundMacroEditor : public EditorWidget
{

View File

@ -13,7 +13,11 @@ class StatusBarWidget : public QStatusBar
QLabel* m_normalMessage;
StatusBarFocus* m_curFocus = nullptr;
public:
explicit StatusBarWidget(QWidget* parent = Q_NULLPTR) : QStatusBar(parent) {}
explicit StatusBarWidget(QWidget* parent = Q_NULLPTR) : QStatusBar(parent)
{
m_normalMessage = new QLabel(this);
addWidget(m_normalMessage);
}
void setNormalMessage(const QString& message) { m_normalMessage->setText(message); }
};

View File

@ -124,6 +124,37 @@ struct SoundMacro
Invalid = 0xff
};
/** Introspection structure used by editors to define user interactivity per command */
struct CmdIntrospection
{
struct Field
{
enum class Type
{
Invalid,
Bool,
Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
SoundMacroId,
TableId,
SampleId,
Choice
};
Type m_tp;
size_t m_offset;
std::string_view m_name;
int64_t m_min, m_max, m_default;
std::string_view m_choices[4];
};
std::string_view m_name;
std::string_view m_description;
Field m_fields[7];
};
/** Base command interface. All versions of MusyX encode little-endian parameters */
struct ICmd : LittleDNAV
{
@ -136,6 +167,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::End; }
};
@ -143,6 +175,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::Stop; }
};
@ -150,6 +183,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> key;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -160,6 +194,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> velocity;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -170,12 +205,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> keyOff;
Value<bool> random;
Value<bool> sampleEnd;
Value<bool> absolute;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::WaitTicks; }
};
@ -183,6 +219,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> keyOff;
Value<bool> random;
Value<bool> sampleEnd;
@ -195,6 +232,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> dummy;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -205,6 +243,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> keyOff;
Value<bool> random;
Value<bool> sampleEnd;
@ -218,6 +257,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> addNote;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -230,6 +270,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> variable;
Value<bool> lastStarted;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -239,11 +280,10 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> modValue;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
Value<atUint8> priority;
Value<atUint8> maxVoices;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SplitMod; }
};
@ -251,6 +291,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> scale;
Value<atInt8> centerKey;
Value<atInt8> centerPan;
@ -261,6 +302,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
TableIdDNA<athena::Little> table;
Value<bool> dlsMode;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -270,6 +312,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> scale;
Value<atInt8> add;
TableIdDNA<athena::Little> table;
@ -281,6 +324,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> panPosition;
Value<atUint16> timeMs;
Value<atInt8> width;
@ -291,11 +335,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> scale;
Value<atInt8> add;
TableIdDNA<athena::Little> table;
Value<bool> msSwitch;
Value<atUint16> fadeTime;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::Envelope; }
};
@ -303,8 +348,15 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
enum class Mode : atInt8
{
NoScale = 0,
Negative = 1,
Positive = 2
};
SampleIdDNA<athena::Little> sample;
Value<atInt8> mode;
Value<Mode> mode;
Value<atUint32> offset;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::StartSample; }
@ -313,6 +365,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::StopSample; }
};
@ -320,6 +373,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::KeyOff; }
};
@ -327,6 +381,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> rnd;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -337,11 +392,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> scale;
Value<atInt8> add;
TableIdDNA<athena::Little> table;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::FadeIn; }
};
@ -349,6 +405,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> spanPosition;
Value<atUint16> timeMs;
Value<atInt8> width;
@ -359,6 +416,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> attack;
Value<atUint8> decay;
Value<atUint8> sustain;
@ -370,6 +428,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> noteLo;
Value<atInt8> detune;
Value<atInt8> noteHi;
@ -382,12 +441,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> add;
Value<atInt8> detune;
Value<bool> originalKey;
Seek<1, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AddNote; }
};
@ -395,11 +455,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> key;
Value<atInt8> detune;
Seek<2, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SetNote; }
};
@ -407,11 +468,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> add;
Value<atInt8> detune;
Seek<2, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::LastNote; }
};
@ -419,11 +481,23 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
Value<atInt8> portState;
Value<atInt8> portType;
static const CmdIntrospection Introspective;
enum class PortState : atInt8
{
Disable,
Enable,
MIDIControlled
};
Value<PortState> portState;
enum class PortType : atInt8
{
LastPressed,
Always
};
Value<PortType> portType;
Seek<2, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::Portamento; }
};
@ -431,12 +505,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> levelNote;
Value<atUint8> levelFine;
Value<bool> modwheelFlag;
Seek<1, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::Vibrato; }
};
@ -444,11 +519,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> times;
Value<atInt16> add;
Seek<1, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PitchSweep1; }
};
@ -456,11 +532,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> times;
Value<atInt16> add;
Seek<1, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
Value<atUint16> ticksPerMs;
Value<atUint16> ticksOrMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PitchSweep2; }
};
@ -468,6 +545,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
LittleUInt24 hz;
Value<atUint16> fine;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -477,6 +555,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
TableIdDNA<athena::Little> table;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atInt8> keys;
@ -488,6 +567,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt16> scale;
Value<bool> originalVol;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -497,6 +577,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> keys;
Value<atInt8> cents;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -506,6 +587,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt16> scale;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atInt16> modwAddScale;
@ -516,6 +598,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::Return; }
};
@ -523,6 +606,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> seek;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
@ -533,7 +617,14 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
Value<atUint8> event;
static const CmdIntrospection Introspective;
enum class EventType : atInt8
{
KeyOff,
SampleEnd,
MessageRecv
};
Value<EventType> event;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint16> macroStep;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -543,7 +634,8 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
Value<atUint8> event;
static const CmdIntrospection Introspective;
Value<CmdTrapEvent::EventType> event;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::UntrapEvent; }
};
@ -551,10 +643,11 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> isVar;
SoundMacroIdDNA<athena::Little> macro;
Value<atUint8> vid;
Value<atUint8> variable;
Value<atUint8> voiceVar;
Value<atUint8> valueVar;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SendMessage; }
};
@ -562,6 +655,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> variable;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::GetMessage; }
@ -570,6 +664,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> variable;
Value<bool> playMacro;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -579,8 +674,9 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atUint16> add;
Value<atInt16> add;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AddAgeCount; }
};
@ -588,6 +684,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atUint16> counter;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -597,8 +694,9 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> flagId;
Value<atInt8> value;
Value<atUint8> value;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SendFlag; }
};
@ -606,6 +704,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atInt8> rangeUp;
Value<atInt8> rangeDown;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -615,7 +714,8 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
Value<atInt8> prio;
static const CmdIntrospection Introspective;
Value<atUint8> prio;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SetPriority; }
};
@ -623,6 +723,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atInt16> prio;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -632,6 +733,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<3, athena::SeekOrigin::Current> seek;
Value<atUint32> time;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -641,21 +743,29 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Seek<1, athena::SeekOrigin::Current> seek;
Value<atUint16> ageBase;
Value<atUint16> ageScale;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AgeCntVel; }
};
enum class Combine : atInt8
{
Set,
Add,
Mult
};
struct CmdVolSelect : ICmd
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::VolSelect; }
};
@ -663,11 +773,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PanSelect; }
};
@ -675,11 +786,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PitchWheelSelect; }
};
@ -687,11 +799,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::ModWheelSelect; }
};
@ -699,11 +812,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PedalSelect; }
};
@ -711,11 +825,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PortamentoSelect; }
};
@ -723,11 +838,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::ReverbSelect; }
};
@ -735,11 +851,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SpanSelect; }
};
@ -747,11 +864,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::DopplerSelect; }
};
@ -759,11 +877,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::TremoloSelect; }
};
@ -771,11 +890,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PreASelect; }
};
@ -783,11 +903,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PreBSelect; }
};
@ -795,11 +916,12 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::PostBSelect; }
};
@ -807,11 +929,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
Value<atUint8> paramIndex;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AuxAFXSelect; }
};
@ -819,11 +943,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> midiControl;
Value<atUint16> scalingPercentage;
Value<atInt8> combine;
Value<atInt16> scalingPercentage;
Value<Combine> combine;
Value<bool> isVar;
Value<atUint8> fineScaling;
Value<atInt8> fineScaling;
Value<atUint8> paramIndex;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AuxBFXSelect; }
};
@ -831,8 +957,9 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> lfoNumber;
Value<atUint16> periodInMs;
Value<atInt16> periodInMs;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SetupLFO; }
};
@ -840,8 +967,9 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
Value<atUint8> dlsVol;
Value<atUint8> itd;
static const CmdIntrospection Introspective;
Value<bool> dlsVol;
Value<bool> itd;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::ModeSelect; }
};
@ -849,6 +977,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> group;
Value<bool> killNow;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -858,6 +987,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> srcType;
Value<atUint8> type0SrcFilter;
bool Do(SoundMacroState& st, Voice& vox) const;
@ -867,12 +997,13 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<atUint8> a;
Value<bool> varCtrlB;
Value<atInt8> b;
Value<atUint8> b;
Value<bool> varCtrlC;
Value<atInt8> c;
Value<atUint8> c;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::AddVars; }
};
@ -880,6 +1011,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -893,6 +1025,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -906,6 +1039,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -919,6 +1053,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -931,6 +1066,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Seek<1, athena::Current> pad;
@ -942,6 +1078,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -955,6 +1092,7 @@ struct SoundMacro
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> varCtrlA;
Value<atInt8> a;
Value<bool> varCtrlB;
@ -965,8 +1103,9 @@ struct SoundMacro
CmdOp Isa() const { return CmdOp::IfLess; }
};
template <class R>
static std::unique_ptr<ICmd> MakeCmd(R& r);
template <class Op, class O, class... _Args>
static O CmdDo(_Args&&... args);
static const CmdIntrospection* GetCmdIntrospection(CmdOp op);
static std::string_view CmdOpToStr(CmdOp op);
static CmdOp CmdStrToOp(std::string_view op);

View File

@ -53,8 +53,10 @@ struct SoundMacroState
uint8_t m_midiSustain; /**< Sustain MIDI controller */
uint8_t m_midiRelease; /**< Release MIDI controller */
uint8_t m_portamentoMode = 2; /**< (0: Off, 1: On, 2: MIDI specified) */
uint8_t m_portamentoType = 0; /**< (0: New key pressed while old key pressed, 1: Always) */
SoundMacro::CmdPortamento::PortState m_portamentoMode =
SoundMacro::CmdPortamento::PortState::MIDIControlled; /**< (0: Off, 1: On, 2: MIDI specified) */
SoundMacro::CmdPortamento::PortType m_portamentoType =
SoundMacro::CmdPortamento::PortType::LastPressed; /**< (0: New key pressed while old key pressed, 1: Always) */
float m_portamentoTime = 0.5f; /**< portamento transition time, 0.f will perform legato */
/** Used to build a multi-component formula for overriding controllers */
@ -106,14 +108,14 @@ struct SoundMacroState
Evaluator m_reverbSel;
Evaluator m_preAuxASel;
Evaluator m_preAuxBSel;
Evaluator m_auxAFxSel;
Evaluator m_auxBFxSel;
Evaluator m_auxAFxSel[3];
Evaluator m_auxBFxSel[3];
Evaluator m_postAuxB;
Evaluator m_spanSel;
Evaluator m_dopplerSel;
Evaluator m_tremoloSel;
int32_t m_variables[256]; /**< 32-bit variables set with relevant commands */
int32_t m_variables[32]; /**< 32-bit variables set with relevant commands */
/** Event registration data for TRAP_EVENT */
struct EventTrap

View File

@ -54,7 +54,7 @@ class Voice : public Entity
SoundMacroState::EventTrap m_keyoffTrap; /**< Trap for keyoff (SoundMacro overrides default envelope behavior) */
SoundMacroState::EventTrap m_sampleEndTrap; /**< Trap for sampleend (SoundMacro overrides voice removal) */
SoundMacroState::EventTrap m_messageTrap; /**< Trap for messages sent from other SoundMacros */
std::list<int32_t> m_messageQueue; /**< Messages pending processing for SoundMacros in this voice */
int32_t m_latestMessage = 0; /**< Latest message received on voice */
std::list<std::shared_ptr<Voice>> m_childVoices; /**< Child voices for PLAYMACRO usage */
uint8_t m_keygroup = 0; /**< Keygroup voice is a member of */

View File

@ -12,6 +12,26 @@ namespace amuse
{
static logvisor::Module Log("amuse::AudioGroupPool");
struct MakeCmdOp
{
template <class Tp, class R>
static std::unique_ptr<SoundMacro::ICmd> Do(R& r)
{
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
static_cast<Tp&>(*ret).read(r);
return ret;
}
};
struct IntrospectCmdOp
{
template <class Tp>
static const SoundMacro::CmdIntrospection* Do(SoundMacro::CmdOp)
{
return &Tp::Introspective;
}
};
static bool AtEnd(athena::io::IStreamReader& r)
{
uint32_t v = r.readUint32Big();
@ -195,7 +215,7 @@ AudioGroupPool AudioGroupPool::CreateAudioGroupPool(SystemStringView groupPath)
smOut.m_cmds.reserve(cmdCount);
for (int c = 0; c < cmdCount; ++c)
if (auto __r2 = r.enterSubRecord(nullptr))
smOut.m_cmds.push_back(SoundMacro::MakeCmd(r));
smOut.m_cmds.push_back(SoundMacro::CmdDo<MakeCmdOp, std::unique_ptr<SoundMacro::ICmd>>(r));
}
}
}
@ -290,7 +310,7 @@ void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size)
uint32_t data[2];
athena::io::Read<athena::io::PropType::None>::Do<decltype(data), DNAE>({}, data, r);
athena::io::MemoryReader r(data, 8);
m_cmds.push_back(MakeCmd(r));
m_cmds.push_back(CmdDo<MakeCmdOp, std::unique_ptr<SoundMacro::ICmd>>(r));
}
}
template void SoundMacro::readCmds<athena::Big>(athena::io::IStreamReader& r, uint32_t size);
@ -344,14 +364,6 @@ const Curve* AudioGroupPool::tableAsCurves(ObjectId id) const
return static_cast<const Curve*>(search->second.get());
}
template <class Tp, class R>
static std::unique_ptr<SoundMacro::ICmd> _MakeCmd(R& r)
{
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
static_cast<Tp&>(*ret).read(r);
return ret;
}
static SoundMacro::CmdOp _ReadCmdOp(athena::io::MemoryReader& r)
{
return SoundMacro::CmdOp(r.readUByte());
@ -362,175 +374,184 @@ static SoundMacro::CmdOp _ReadCmdOp(athena::io::YAMLDocReader& r)
return SoundMacro::CmdStrToOp(r.readString("cmdOp"));
}
template <class R>
std::unique_ptr<SoundMacro::ICmd> SoundMacro::MakeCmd(R& r)
static SoundMacro::CmdOp _ReadCmdOp(SoundMacro::CmdOp& op)
{
std::unique_ptr<ICmd> cmd;
switch (_ReadCmdOp(r))
return op;
}
template <class Op, class O, class... _Args>
O SoundMacro::CmdDo(_Args&&... args)
{
switch (_ReadCmdOp(std::forward<_Args>(args)...))
{
case CmdOp::End:
cmd = _MakeCmd<CmdEnd>(r); break;
return Op::template Do<CmdEnd>(std::forward<_Args>(args)...);
case CmdOp::Stop:
cmd = _MakeCmd<CmdStop>(r); break;
return Op::template Do<CmdStop>(std::forward<_Args>(args)...);
case CmdOp::SplitKey:
cmd = _MakeCmd<CmdSplitKey>(r); break;
return Op::template Do<CmdSplitKey>(std::forward<_Args>(args)...);
case CmdOp::SplitVel:
cmd = _MakeCmd<CmdSplitVel>(r); break;
return Op::template Do<CmdSplitVel>(std::forward<_Args>(args)...);
case CmdOp::WaitTicks:
cmd = _MakeCmd<CmdWaitTicks>(r); break;
return Op::template Do<CmdWaitTicks>(std::forward<_Args>(args)...);
case CmdOp::Loop:
cmd = _MakeCmd<CmdLoop>(r); break;
return Op::template Do<CmdLoop>(std::forward<_Args>(args)...);
case CmdOp::Goto:
cmd = _MakeCmd<CmdGoto>(r); break;
return Op::template Do<CmdGoto>(std::forward<_Args>(args)...);
case CmdOp::WaitMs:
cmd = _MakeCmd<CmdWaitMs>(r); break;
return Op::template Do<CmdWaitMs>(std::forward<_Args>(args)...);
case CmdOp::PlayMacro:
cmd = _MakeCmd<CmdPlayMacro>(r); break;
return Op::template Do<CmdPlayMacro>(std::forward<_Args>(args)...);
case CmdOp::SendKeyOff:
cmd = _MakeCmd<CmdSendKeyOff>(r); break;
return Op::template Do<CmdSendKeyOff>(std::forward<_Args>(args)...);
case CmdOp::SplitMod:
cmd = _MakeCmd<CmdSplitMod>(r); break;
return Op::template Do<CmdSplitMod>(std::forward<_Args>(args)...);
case CmdOp::PianoPan:
cmd = _MakeCmd<CmdPianoPan>(r); break;
return Op::template Do<CmdPianoPan>(std::forward<_Args>(args)...);
case CmdOp::SetAdsr:
cmd = _MakeCmd<CmdSetAdsr>(r); break;
return Op::template Do<CmdSetAdsr>(std::forward<_Args>(args)...);
case CmdOp::ScaleVolume:
cmd = _MakeCmd<CmdScaleVolume>(r); break;
return Op::template Do<CmdScaleVolume>(std::forward<_Args>(args)...);
case CmdOp::Panning:
cmd = _MakeCmd<CmdPanning>(r); break;
return Op::template Do<CmdPanning>(std::forward<_Args>(args)...);
case CmdOp::Envelope:
cmd = _MakeCmd<CmdEnvelope>(r); break;
return Op::template Do<CmdEnvelope>(std::forward<_Args>(args)...);
case CmdOp::StartSample:
cmd = _MakeCmd<CmdStartSample>(r); break;
return Op::template Do<CmdStartSample>(std::forward<_Args>(args)...);
case CmdOp::StopSample:
cmd = _MakeCmd<CmdStopSample>(r); break;
return Op::template Do<CmdStopSample>(std::forward<_Args>(args)...);
case CmdOp::KeyOff:
cmd = _MakeCmd<CmdKeyOff>(r); break;
return Op::template Do<CmdKeyOff>(std::forward<_Args>(args)...);
case CmdOp::SplitRnd:
cmd = _MakeCmd<CmdSplitRnd>(r); break;
return Op::template Do<CmdSplitRnd>(std::forward<_Args>(args)...);
case CmdOp::FadeIn:
cmd = _MakeCmd<CmdFadeIn>(r); break;
return Op::template Do<CmdFadeIn>(std::forward<_Args>(args)...);
case CmdOp::Spanning:
cmd = _MakeCmd<CmdSpanning>(r); break;
return Op::template Do<CmdSpanning>(std::forward<_Args>(args)...);
case CmdOp::SetAdsrCtrl:
cmd = _MakeCmd<CmdSetAdsrCtrl>(r); break;
return Op::template Do<CmdSetAdsrCtrl>(std::forward<_Args>(args)...);
case CmdOp::RndNote:
cmd = _MakeCmd<CmdRndNote>(r); break;
return Op::template Do<CmdRndNote>(std::forward<_Args>(args)...);
case CmdOp::AddNote:
cmd = _MakeCmd<CmdAddNote>(r); break;
return Op::template Do<CmdAddNote>(std::forward<_Args>(args)...);
case CmdOp::SetNote:
cmd = _MakeCmd<CmdSetNote>(r); break;
return Op::template Do<CmdSetNote>(std::forward<_Args>(args)...);
case CmdOp::LastNote:
cmd = _MakeCmd<CmdLastNote>(r); break;
return Op::template Do<CmdLastNote>(std::forward<_Args>(args)...);
case CmdOp::Portamento:
cmd = _MakeCmd<CmdPortamento>(r); break;
return Op::template Do<CmdPortamento>(std::forward<_Args>(args)...);
case CmdOp::Vibrato:
cmd = _MakeCmd<CmdVibrato>(r); break;
return Op::template Do<CmdVibrato>(std::forward<_Args>(args)...);
case CmdOp::PitchSweep1:
cmd = _MakeCmd<CmdPitchSweep1>(r); break;
return Op::template Do<CmdPitchSweep1>(std::forward<_Args>(args)...);
case CmdOp::PitchSweep2:
cmd = _MakeCmd<CmdPitchSweep2>(r); break;
return Op::template Do<CmdPitchSweep2>(std::forward<_Args>(args)...);
case CmdOp::SetPitch:
cmd = _MakeCmd<CmdSetPitch>(r); break;
return Op::template Do<CmdSetPitch>(std::forward<_Args>(args)...);
case CmdOp::SetPitchAdsr:
cmd = _MakeCmd<CmdSetPitchAdsr>(r); break;
return Op::template Do<CmdSetPitchAdsr>(std::forward<_Args>(args)...);
case CmdOp::ScaleVolumeDLS:
cmd = _MakeCmd<CmdScaleVolumeDLS>(r); break;
return Op::template Do<CmdScaleVolumeDLS>(std::forward<_Args>(args)...);
case CmdOp::Mod2Vibrange:
cmd = _MakeCmd<CmdMod2Vibrange>(r); break;
return Op::template Do<CmdMod2Vibrange>(std::forward<_Args>(args)...);
case CmdOp::SetupTremolo:
cmd = _MakeCmd<CmdSetupTremolo>(r); break;
return Op::template Do<CmdSetupTremolo>(std::forward<_Args>(args)...);
case CmdOp::Return:
cmd = _MakeCmd<CmdReturn>(r); break;
return Op::template Do<CmdReturn>(std::forward<_Args>(args)...);
case CmdOp::GoSub:
cmd = _MakeCmd<CmdGoSub>(r); break;
return Op::template Do<CmdGoSub>(std::forward<_Args>(args)...);
case CmdOp::TrapEvent:
cmd = _MakeCmd<CmdTrapEvent>(r); break;
return Op::template Do<CmdTrapEvent>(std::forward<_Args>(args)...);
case CmdOp::UntrapEvent:
cmd = _MakeCmd<CmdUntrapEvent>(r); break;
return Op::template Do<CmdUntrapEvent>(std::forward<_Args>(args)...);
case CmdOp::SendMessage:
cmd = _MakeCmd<CmdSendMessage>(r); break;
return Op::template Do<CmdSendMessage>(std::forward<_Args>(args)...);
case CmdOp::GetMessage:
cmd = _MakeCmd<CmdGetMessage>(r); break;
return Op::template Do<CmdGetMessage>(std::forward<_Args>(args)...);
case CmdOp::GetVid:
cmd = _MakeCmd<CmdGetVid>(r); break;
return Op::template Do<CmdGetVid>(std::forward<_Args>(args)...);
case CmdOp::AddAgeCount:
cmd = _MakeCmd<CmdAddAgeCount>(r); break;
return Op::template Do<CmdAddAgeCount>(std::forward<_Args>(args)...);
case CmdOp::SetAgeCount:
cmd = _MakeCmd<CmdSetAgeCount>(r); break;
return Op::template Do<CmdSetAgeCount>(std::forward<_Args>(args)...);
case CmdOp::SendFlag:
cmd = _MakeCmd<CmdSendFlag>(r); break;
return Op::template Do<CmdSendFlag>(std::forward<_Args>(args)...);
case CmdOp::PitchWheelR:
cmd = _MakeCmd<CmdPitchWheelR>(r); break;
return Op::template Do<CmdPitchWheelR>(std::forward<_Args>(args)...);
case CmdOp::SetPriority:
cmd = _MakeCmd<CmdSetPriority>(r); break;
return Op::template Do<CmdSetPriority>(std::forward<_Args>(args)...);
case CmdOp::AddPriority:
cmd = _MakeCmd<CmdAddPriority>(r); break;
return Op::template Do<CmdAddPriority>(std::forward<_Args>(args)...);
case CmdOp::AgeCntSpeed:
cmd = _MakeCmd<CmdAgeCntSpeed>(r); break;
return Op::template Do<CmdAgeCntSpeed>(std::forward<_Args>(args)...);
case CmdOp::AgeCntVel:
cmd = _MakeCmd<CmdAgeCntVel>(r); break;
return Op::template Do<CmdAgeCntVel>(std::forward<_Args>(args)...);
case CmdOp::VolSelect:
cmd = _MakeCmd<CmdVolSelect>(r); break;
return Op::template Do<CmdVolSelect>(std::forward<_Args>(args)...);
case CmdOp::PanSelect:
cmd = _MakeCmd<CmdPanSelect>(r); break;
return Op::template Do<CmdPanSelect>(std::forward<_Args>(args)...);
case CmdOp::PitchWheelSelect:
cmd = _MakeCmd<CmdPitchWheelSelect>(r); break;
return Op::template Do<CmdPitchWheelSelect>(std::forward<_Args>(args)...);
case CmdOp::ModWheelSelect:
cmd = _MakeCmd<CmdModWheelSelect>(r); break;
return Op::template Do<CmdModWheelSelect>(std::forward<_Args>(args)...);
case CmdOp::PedalSelect:
cmd = _MakeCmd<CmdPedalSelect>(r); break;
return Op::template Do<CmdPedalSelect>(std::forward<_Args>(args)...);
case CmdOp::PortamentoSelect:
cmd = _MakeCmd<CmdPortamentoSelect>(r); break;
return Op::template Do<CmdPortamentoSelect>(std::forward<_Args>(args)...);
case CmdOp::ReverbSelect:
cmd = _MakeCmd<CmdReverbSelect>(r); break;
return Op::template Do<CmdReverbSelect>(std::forward<_Args>(args)...);
case CmdOp::SpanSelect:
cmd = _MakeCmd<CmdSpanSelect>(r); break;
return Op::template Do<CmdSpanSelect>(std::forward<_Args>(args)...);
case CmdOp::DopplerSelect:
cmd = _MakeCmd<CmdDopplerSelect>(r); break;
return Op::template Do<CmdDopplerSelect>(std::forward<_Args>(args)...);
case CmdOp::TremoloSelect:
cmd = _MakeCmd<CmdTremoloSelect>(r); break;
return Op::template Do<CmdTremoloSelect>(std::forward<_Args>(args)...);
case CmdOp::PreASelect:
cmd = _MakeCmd<CmdPreASelect>(r); break;
return Op::template Do<CmdPreASelect>(std::forward<_Args>(args)...);
case CmdOp::PreBSelect:
cmd = _MakeCmd<CmdPreBSelect>(r); break;
return Op::template Do<CmdPreBSelect>(std::forward<_Args>(args)...);
case CmdOp::PostBSelect:
cmd = _MakeCmd<CmdPostBSelect>(r); break;
return Op::template Do<CmdPostBSelect>(std::forward<_Args>(args)...);
case CmdOp::AuxAFXSelect:
cmd = _MakeCmd<CmdAuxAFXSelect>(r); break;
return Op::template Do<CmdAuxAFXSelect>(std::forward<_Args>(args)...);
case CmdOp::AuxBFXSelect:
cmd = _MakeCmd<CmdAuxBFXSelect>(r); break;
return Op::template Do<CmdAuxBFXSelect>(std::forward<_Args>(args)...);
case CmdOp::SetupLFO:
cmd = _MakeCmd<CmdSetupLFO>(r); break;
return Op::template Do<CmdSetupLFO>(std::forward<_Args>(args)...);
case CmdOp::ModeSelect:
cmd = _MakeCmd<CmdModeSelect>(r); break;
return Op::template Do<CmdModeSelect>(std::forward<_Args>(args)...);
case CmdOp::SetKeygroup:
cmd = _MakeCmd<CmdSetKeygroup>(r); break;
return Op::template Do<CmdSetKeygroup>(std::forward<_Args>(args)...);
case CmdOp::SRCmodeSelect:
cmd = _MakeCmd<CmdSRCmodeSelect>(r); break;
return Op::template Do<CmdSRCmodeSelect>(std::forward<_Args>(args)...);
case CmdOp::AddVars:
cmd = _MakeCmd<CmdAddVars>(r); break;
return Op::template Do<CmdAddVars>(std::forward<_Args>(args)...);
case CmdOp::SubVars:
cmd = _MakeCmd<CmdSubVars>(r); break;
return Op::template Do<CmdSubVars>(std::forward<_Args>(args)...);
case CmdOp::MulVars:
cmd = _MakeCmd<CmdMulVars>(r); break;
return Op::template Do<CmdMulVars>(std::forward<_Args>(args)...);
case CmdOp::DivVars:
cmd = _MakeCmd<CmdDivVars>(r); break;
return Op::template Do<CmdDivVars>(std::forward<_Args>(args)...);
case CmdOp::AddIVars:
cmd = _MakeCmd<CmdAddIVars>(r); break;
return Op::template Do<CmdAddIVars>(std::forward<_Args>(args)...);
case CmdOp::SetVar:
cmd = _MakeCmd<CmdSetVar>(r); break;
return Op::template Do<CmdSetVar>(std::forward<_Args>(args)...);
case CmdOp::IfEqual:
cmd = _MakeCmd<CmdIfEqual>(r); break;
return Op::template Do<CmdIfEqual>(std::forward<_Args>(args)...);
case CmdOp::IfLess:
cmd = _MakeCmd<CmdIfLess>(r); break;
return Op::template Do<CmdIfLess>(std::forward<_Args>(args)...);
default:
break;
return {};
}
return cmd;
}
template std::unique_ptr<SoundMacro::ICmd> SoundMacro::MakeCmd(athena::io::MemoryReader& r);
template std::unique_ptr<SoundMacro::ICmd> SoundMacro::MakeCmd(athena::io::YAMLDocReader& r);
template std::unique_ptr<SoundMacro::ICmd> SoundMacro::CmdDo<MakeCmdOp>(athena::io::MemoryReader& r);
template std::unique_ptr<SoundMacro::ICmd> SoundMacro::CmdDo<MakeCmdOp>(athena::io::YAMLDocReader& r);
template const SoundMacro::CmdIntrospection* SoundMacro::CmdDo<IntrospectCmdOp>(SoundMacro::CmdOp& op);
const SoundMacro::CmdIntrospection* SoundMacro::GetCmdIntrospection(CmdOp op)
{
return CmdDo<IntrospectCmdOp, const SoundMacro::CmdIntrospection*>(op);
}
std::string_view SoundMacro::CmdOpToStr(CmdOp op)
{

File diff suppressed because it is too large Load Diff

View File

@ -354,6 +354,16 @@ uint32_t Voice::_GetBlockSampleCount(SampleFormat fmt)
}
}
static float TriangleWave(float t)
{
t = std::fmod(t, 1.f);
if (t < 0.25f)
return t / 0.25f;
if (t >= 0.75f)
return (t - 0.75f) / 0.25f - 1.f;
return (t - 0.25f) / 0.5f * -2.f + 1.f;
}
void Voice::preSupplyAudio(double dt)
{
/* Process SoundMacro; bootstrapping sample if needed */
@ -452,7 +462,7 @@ void Voice::preSupplyAudio(double dt)
if (m_vibratoTime >= 0.f)
{
m_vibratoTime += dt;
float vibrato = std::sin(m_vibratoTime / m_vibratoPeriod * (2.f * M_PIF));
float vibrato = TriangleWave(m_vibratoTime / m_vibratoPeriod);
if (m_vibratoModWheel)
newPitch += m_vibratoModLevel * vibrato * (m_state.m_curMod / 127.f);
else
@ -464,7 +474,13 @@ void Voice::preSupplyAudio(double dt)
if (m_pitchSweep1It < m_pitchSweep1Times)
{
++m_pitchSweep1It;
m_pitchSweep1 = m_pitchSweep1Add * m_pitchSweep1It / m_pitchSweep1Times;
m_pitchSweep1 = m_pitchSweep1Add * m_pitchSweep1It;
refresh = true;
}
else if (m_pitchSweep1Times != 0)
{
m_pitchSweep1It = 0;
m_pitchSweep1 = 0;
refresh = true;
}
@ -472,7 +488,13 @@ void Voice::preSupplyAudio(double dt)
if (m_pitchSweep2It < m_pitchSweep2Times)
{
++m_pitchSweep2It;
m_pitchSweep2 = m_pitchSweep2Add * m_pitchSweep2It / m_pitchSweep2Times;
m_pitchSweep2 = m_pitchSweep2Add * m_pitchSweep2It;
refresh = true;
}
else if (m_pitchSweep2Times != 0)
{
m_pitchSweep2It = 0;
m_pitchSweep2 = 0;
refresh = true;
}
@ -891,7 +913,7 @@ void Voice::message(int32_t val)
if (m_destroyed)
return;
m_messageQueue.push_back(val);
m_latestMessage = val;
if (m_messageTrap.macroId != 0xffff)
{
@ -1358,14 +1380,14 @@ bool Voice::doPortamento(uint8_t newNote)
bool pState;
switch (m_state.m_portamentoMode)
{
case 0:
case SoundMacro::CmdPortamento::PortState::Disable:
default:
pState = false;
break;
case 1:
case SoundMacro::CmdPortamento::PortState::Enable:
pState = true;
break;
case 2:
case SoundMacro::CmdPortamento::PortState::MIDIControlled:
pState = m_state.m_portamentoSel ? (m_state.m_portamentoSel.evaluate(m_voiceTime, *this, m_state) >= 1.f)
: (getCtrlValue(65) >= 64);
break;