Massive fmtlib refactor

This commit is contained in:
Jack Andersen 2019-07-19 18:23:25 -10:00
parent a74caa5fb0
commit b0e4973c64
32 changed files with 441 additions and 513 deletions

View File

@ -815,7 +815,7 @@ ADSRControls::ADSRControls(QWidget* parent) : QFrame(parent) {
QGridLayout* leftLayout = new QGridLayout;
QPalette palette = QWidget::palette();
palette.setColor(QPalette::Base, palette.color(QPalette::Background));
palette.setColor(QPalette::Base, palette.color(QPalette::Window));
palette.setColor(QPalette::Text, Red);
QLabel* lab = new QLabel(tr("Attack"));

View File

@ -204,7 +204,7 @@ CurveControls::CurveControls(QWidget* parent) : QFrame(parent) {
m_lineEdit = new QLineEdit;
m_lineEdit->setDisabled(true);
QPalette palette = m_lineEdit->palette();
palette.setColor(QPalette::Base, palette.color(QPalette::Background));
palette.setColor(QPalette::Base, palette.color(QPalette::Window));
m_lineEdit->setPalette(palette);
connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(exprCommit()));
leftLayout->addWidget(m_lineEdit, 1, 0);

View File

@ -142,11 +142,11 @@ KeymapEditor* KeymapControls::getEditor() const { return qobject_cast<KeymapEdit
void KeymapControls::setPaintIdx(int idx) {
QPalette palette = m_paintButton->palette();
if (idx < 0) {
palette.setColor(QPalette::Background, QWidget::palette().color(QPalette::Background));
palette.setColor(QPalette::Window, QWidget::palette().color(QPalette::Window));
palette.setColor(QPalette::Button, QWidget::palette().color(QPalette::Button));
} else {
const QColor* keyPalette = getEditor()->m_paintPalette;
palette.setColor(QPalette::Background, keyPalette[idx]);
palette.setColor(QPalette::Window, keyPalette[idx]);
palette.setColor(QPalette::Button, keyPalette[idx].darker(300));
}
m_paintButton->setPalette(palette);
@ -241,7 +241,7 @@ KeymapControls::KeymapControls(QWidget* parent) : QFrame(parent) {
setAutoFillBackground(true);
QPalette palette = QWidget::palette();
palette.setColor(QPalette::Base, palette.color(QPalette::Background));
palette.setColor(QPalette::Base, palette.color(QPalette::Window));
QHBoxLayout* mainLayout = new QHBoxLayout;

View File

@ -53,7 +53,7 @@ public:
switch (m_index.column()) {
case 0:
m_undoVal = layer.macro.id;
m_undoVal = layer.macro.id.id;
layer.macro.id = m_redoVal;
break;
case 1:

View File

@ -47,7 +47,7 @@ MainWindow::MainWindow(QWidget* parent)
m_ui.setupUi(this);
m_ui.splitter->setCollapsible(1, false);
QPalette palette = m_ui.projectOutlineFilter->palette();
palette.setColor(QPalette::Base, palette.color(QPalette::Background));
palette.setColor(QPalette::Base, palette.color(QPalette::Window));
m_ui.projectOutlineFilter->setPalette(palette);
m_ui.projectOutline->setItemDelegate(&m_treeDelegate);
connect(m_ui.projectOutline, SIGNAL(activated(const QModelIndex&)), this,
@ -190,7 +190,7 @@ MainWindow::MainWindow(QWidget* parent)
MainWindow::~MainWindow() {
m_backgroundThread.quit();
m_backgroundThread.wait();
printf("IM DYING\n");
fmt::print(fmt("IM DYING\n"));
}
void MainWindow::connectMessenger(UIMessenger* messenger, Qt::ConnectionType type) {

View File

@ -640,11 +640,8 @@ void ProjectModel::saveSongsIndex() {
if (!m_midiFiles.empty()) {
QFileInfo songsFile(m_dir, QStringLiteral("!songs.yaml"));
athena::io::YAMLDocWriter dw("amuse::Songs");
for (auto& p : amuse::SortUnorderedMap(m_midiFiles)) {
char id[16];
snprintf(id, 16, "%04X", p.first.id);
dw.writeString(id, p.second.get().m_path.toUtf8().data());
}
for (auto& p : amuse::SortUnorderedMap(m_midiFiles))
dw.writeString(fmt::format(fmt("{}"), p.first).c_str(), p.second.get().m_path.toUtf8().data());
athena::io::FileWriter w(QStringToSysString(songsFile.filePath()));
if (!w.hasError())
dw.finish(&w);
@ -1320,33 +1317,33 @@ ProjectModel::SongGroupNode* ProjectModel::newSongGroup(GroupNode* group, const
return node.get();
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::SoundMacroNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::SoundMacroNode*) {
return ProjectModel::INode::Type::SoundMacro;
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::ADSRNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::ADSRNode*) {
return ProjectModel::INode::Type::ADSR;
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::CurveNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::CurveNode*) {
return ProjectModel::INode::Type::Curve;
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::KeymapNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::KeymapNode*) {
return ProjectModel::INode::Type::Keymap;
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::LayersNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::LayersNode*) {
return ProjectModel::INode::Type::Layer;
}
static constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::SampleNode*) {
constexpr ProjectModel::INode::Type GetINodeType(ProjectModel::SampleNode*) {
return ProjectModel::INode::Type::Sample;
}
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::SoundMacroNode*) {
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::SoundMacroNode*) {
return amuse::NameDB::Type::SoundMacro;
}
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::ADSRNode*) { return amuse::NameDB::Type::Table; }
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::CurveNode*) { return amuse::NameDB::Type::Table; }
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::KeymapNode*) { return amuse::NameDB::Type::Keymap; }
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::LayersNode*) { return amuse::NameDB::Type::Layer; }
static constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::SampleNode*) { return amuse::NameDB::Type::Sample; }
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::ADSRNode*) { return amuse::NameDB::Type::Table; }
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::CurveNode*) { return amuse::NameDB::Type::Table; }
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::KeymapNode*) { return amuse::NameDB::Type::Keymap; }
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::LayersNode*) { return amuse::NameDB::Type::Layer; }
constexpr amuse::NameDB::Type GetNameDBType(ProjectModel::SampleNode*) { return amuse::NameDB::Type::Sample; }
template <class NT>
inline amuse::NameDB* GetNameDB() {

View File

@ -670,7 +670,7 @@ SampleControls::SampleControls(QWidget* parent) : QFrame(parent) {
setAutoFillBackground(true);
QPalette palette = QWidget::palette();
palette.setColor(QPalette::Base, palette.color(QPalette::Background));
palette.setColor(QPalette::Base, palette.color(QPalette::Window));
QHBoxLayout* mainLayout = new QHBoxLayout;

View File

@ -73,7 +73,7 @@ public:
break;
}
case 1:
m_undoVal = entry.objId.id;
m_undoVal = entry.objId.id.id;
entry.objId.id = m_redoVal;
break;
case 2:
@ -834,22 +834,22 @@ QVariant SetupListModel::data(const QModelIndex& index, int role) const {
auto entry = m_sorted[index.row()];
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::TextColorRole) {
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ForegroundRole) {
if (index.column() == 0) {
if (role == Qt::TextColorRole)
if (role == Qt::ForegroundRole)
return QVariant();
g_MainWindow->projectModel()->setIdDatabases(m_node.get());
return amuse::SongId::CurNameDB->resolveNameFromId(entry->first.id).data();
} else if (index.column() == 1) {
QString songPath = g_MainWindow->projectModel()->getMIDIPathOfSong(entry.m_it->first);
if (songPath.isEmpty()) {
if (role == Qt::TextColorRole)
if (role == Qt::ForegroundRole)
return g_MainWindow->palette().color(QPalette::Disabled, QPalette::Text);
else if (role == Qt::EditRole)
return QVariant();
return tr("Double-click to select file");
}
if (role == Qt::TextColorRole)
if (role == Qt::ForegroundRole)
return QVariant();
return songPath;
}
@ -1139,7 +1139,7 @@ QVariant SetupModel::headerData(int section, Qt::Orientation orientation, int ro
} else {
return section + 1;
}
} else if (role == Qt::BackgroundColorRole && orientation == Qt::Vertical) {
} else if (role == Qt::BackgroundRole && orientation == Qt::Vertical) {
if (section == 9)
return QColor(64, 0, 0);
return QColor(0, 64, 0);

View File

@ -49,7 +49,7 @@ public:
switch (m_column) {
case 1:
m_undoVal = entry.objId.id;
m_undoVal = entry.objId.id.id;
entry.objId.id = m_redoVal;
break;
case 2:

View File

@ -105,7 +105,7 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus
QFont titleFont = m_titleLabel.font();
titleFont.setWeight(QFont::Bold);
m_titleLabel.setFont(titleFont);
m_titleLabel.setForegroundRole(QPalette::Background);
m_titleLabel.setForegroundRole(QPalette::Window);
m_titleLabel.setContentsMargins(46, 0, 0, 0);
m_titleLabel.setFixedHeight(20);
m_numberText.setTextOption(QTextOption(Qt::AlignRight));
@ -351,7 +351,7 @@ public:
case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep:
case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId:
case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId:
m_undoVal = amuse::AccessField<amuse::SoundMacroIdDNA<athena::Little>>(m_cmd, m_field).id;
m_undoVal = amuse::AccessField<amuse::SoundMacroIdDNA<athena::Little>>(m_cmd, m_field).id.id;
amuse::AccessField<amuse::SoundMacroIdDNA<athena::Little>>(m_cmd, m_field).id = uint16_t(m_redoVal);
break;
default:
@ -430,7 +430,7 @@ void CommandWidget::paintEvent(QPaintEvent* event) {
QPoint points[] = {
{1, 20}, {1, 99}, {width() - 1, 99}, {width() - 1, 1}, {20, 1}, {1, 20},
};
painter.setBrush(palette().brush(QPalette::Background));
painter.setBrush(palette().brush(QPalette::Window));
painter.drawPolygon(points, 6);
painter.setPen(QPen(QColor(127, 127, 127), 2.0));
painter.drawPolyline(points, 6);
@ -445,7 +445,7 @@ void CommandWidget::paintEvent(QPaintEvent* event) {
rotate.rotate(-45.0).translate(-15, 8);
painter.setTransform(rotate);
painter.setFont(m_numberFont);
painter.setPen(palette().color(QPalette::Background));
painter.setPen(palette().color(QPalette::Window));
painter.drawStaticText(0, 0, m_numberText);
}

View File

@ -208,7 +208,7 @@ EffectWidget::EffectWidget(QWidget* parent, amuse::EffectBaseTypeless* effect, a
QFont titleFont = m_titleLabel.font();
titleFont.setWeight(QFont::Bold);
m_titleLabel.setFont(titleFont);
m_titleLabel.setForegroundRole(QPalette::Background);
m_titleLabel.setForegroundRole(QPalette::Window);
m_titleLabel.setContentsMargins(46, 0, 0, 0);
m_titleLabel.setFixedHeight(20);
m_numberText.setTextOption(QTextOption(Qt::AlignRight));
@ -298,7 +298,7 @@ void EffectWidget::paintEvent(QPaintEvent* event) {
QPoint points[] = {
{1, 20}, {1, 99}, {width() - 1, 99}, {width() - 1, 1}, {20, 1}, {1, 20},
};
painter.setBrush(palette().brush(QPalette::Background));
painter.setBrush(palette().brush(QPalette::Window));
painter.drawPolygon(points, 6);
painter.setPen(QPen(QColor(127, 127, 127), 2.0));
painter.drawPolyline(points, 6);
@ -313,7 +313,7 @@ void EffectWidget::paintEvent(QPaintEvent* event) {
rotate.rotate(-45.0).translate(-15, 8);
painter.setTransform(rotate);
painter.setFont(m_numberFont);
painter.setPen(palette().color(QPalette::Background));
painter.setPen(palette().color(QPalette::Window));
painter.drawStaticText(0, 0, m_numberText);
}

View File

@ -1231,341 +1231,341 @@
<context>
<name>ProjectModel</name>
<message>
<location filename="../ProjectModel.cpp" line="700"/>
<location filename="../ProjectModel.cpp" line="710"/>
<location filename="../ProjectModel.cpp" line="719"/>
<location filename="../ProjectModel.cpp" line="729"/>
<location filename="../ProjectModel.cpp" line="737"/>
<location filename="../ProjectModel.cpp" line="775"/>
<location filename="../ProjectModel.cpp" line="697"/>
<location filename="../ProjectModel.cpp" line="707"/>
<location filename="../ProjectModel.cpp" line="716"/>
<location filename="../ProjectModel.cpp" line="726"/>
<location filename="../ProjectModel.cpp" line="734"/>
<location filename="../ProjectModel.cpp" line="772"/>
<source>Export Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="700"/>
<location filename="../ProjectModel.cpp" line="750"/>
<location filename="../ProjectModel.cpp" line="775"/>
<location filename="../ProjectModel.cpp" line="697"/>
<location filename="../ProjectModel.cpp" line="747"/>
<location filename="../ProjectModel.cpp" line="772"/>
<source>Unable to find group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="710"/>
<location filename="../ProjectModel.cpp" line="707"/>
<source>Unable to export %1.proj</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="719"/>
<location filename="../ProjectModel.cpp" line="716"/>
<source>Unable to export %1.pool</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="729"/>
<location filename="../ProjectModel.cpp" line="726"/>
<source>Unable to export %1.sdir</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="737"/>
<location filename="../ProjectModel.cpp" line="734"/>
<source>Unable to export %1.samp</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="750"/>
<location filename="../ProjectModel.cpp" line="747"/>
<source>Import Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="760"/>
<location filename="../ProjectModel.cpp" line="757"/>
<source>Export Header Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="760"/>
<location filename="../ProjectModel.cpp" line="757"/>
<source>Unable to open %1 for reading</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="781"/>
<location filename="../ProjectModel.cpp" line="778"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="781"/>
<location filename="../ProjectModel.cpp" line="778"/>
<source>%1 already exists. Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="830"/>
<location filename="../ProjectModel.cpp" line="827"/>
<source>Sound Macros</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="831"/>
<location filename="../ProjectModel.cpp" line="828"/>
<source>ADSRs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="832"/>
<location filename="../ProjectModel.cpp" line="829"/>
<source>Curves</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="833"/>
<location filename="../ProjectModel.cpp" line="830"/>
<source>Keymaps</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="834"/>
<location filename="../ProjectModel.cpp" line="831"/>
<source>Layers</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="835"/>
<location filename="../ProjectModel.cpp" line="832"/>
<source>Samples</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1082"/>
<location filename="../ProjectModel.cpp" line="1079"/>
<source>Naming Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1083"/>
<location filename="../ProjectModel.cpp" line="1080"/>
<source>%1 already exists in this context</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1087"/>
<location filename="../ProjectModel.cpp" line="1084"/>
<source>Rename %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1206"/>
<location filename="../ProjectModel.cpp" line="1203"/>
<source>Subproject Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1207"/>
<location filename="../ProjectModel.cpp" line="1204"/>
<source>The subproject %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1214"/>
<location filename="../ProjectModel.cpp" line="1753"/>
<location filename="../ProjectModel.cpp" line="1876"/>
<location filename="../ProjectModel.cpp" line="1211"/>
<location filename="../ProjectModel.cpp" line="1750"/>
<location filename="../ProjectModel.cpp" line="1873"/>
<source>Add Subproject %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1295"/>
<location filename="../ProjectModel.cpp" line="1292"/>
<source>Sound Group Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1295"/>
<location filename="../ProjectModel.cpp" line="1315"/>
<location filename="../ProjectModel.cpp" line="1292"/>
<location filename="../ProjectModel.cpp" line="1312"/>
<source>The group %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1299"/>
<location filename="../ProjectModel.cpp" line="1610"/>
<location filename="../ProjectModel.cpp" line="1883"/>
<location filename="../ProjectModel.cpp" line="1296"/>
<location filename="../ProjectModel.cpp" line="1607"/>
<location filename="../ProjectModel.cpp" line="1880"/>
<source>Add Sound Group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1315"/>
<location filename="../ProjectModel.cpp" line="1312"/>
<source>Song Group Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1319"/>
<location filename="../ProjectModel.cpp" line="1602"/>
<location filename="../ProjectModel.cpp" line="1890"/>
<location filename="../ProjectModel.cpp" line="1316"/>
<location filename="../ProjectModel.cpp" line="1599"/>
<location filename="../ProjectModel.cpp" line="1887"/>
<source>Add Song Group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1422"/>
<location filename="../ProjectModel.cpp" line="1419"/>
<source>Sound Macro Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1422"/>
<location filename="../ProjectModel.cpp" line="1419"/>
<source>The macro %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1431"/>
<location filename="../ProjectModel.cpp" line="1899"/>
<location filename="../ProjectModel.cpp" line="1428"/>
<location filename="../ProjectModel.cpp" line="1896"/>
<source>Add Sound Macro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1447"/>
<location filename="../ProjectModel.cpp" line="1444"/>
<source>ADSR Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1447"/>
<location filename="../ProjectModel.cpp" line="1444"/>
<source>The ADSR %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1453"/>
<location filename="../ProjectModel.cpp" line="1635"/>
<location filename="../ProjectModel.cpp" line="1906"/>
<location filename="../ProjectModel.cpp" line="1450"/>
<location filename="../ProjectModel.cpp" line="1632"/>
<location filename="../ProjectModel.cpp" line="1903"/>
<source>Add ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1469"/>
<location filename="../ProjectModel.cpp" line="1466"/>
<source>Curve Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1469"/>
<location filename="../ProjectModel.cpp" line="1466"/>
<source>The Curve %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1475"/>
<location filename="../ProjectModel.cpp" line="1643"/>
<location filename="../ProjectModel.cpp" line="1913"/>
<location filename="../ProjectModel.cpp" line="1472"/>
<location filename="../ProjectModel.cpp" line="1640"/>
<location filename="../ProjectModel.cpp" line="1910"/>
<source>Add Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1491"/>
<location filename="../ProjectModel.cpp" line="1488"/>
<source>Keymap Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1491"/>
<location filename="../ProjectModel.cpp" line="1488"/>
<source>The Keymap %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1496"/>
<location filename="../ProjectModel.cpp" line="1658"/>
<location filename="../ProjectModel.cpp" line="1920"/>
<location filename="../ProjectModel.cpp" line="1493"/>
<location filename="../ProjectModel.cpp" line="1655"/>
<location filename="../ProjectModel.cpp" line="1917"/>
<source>Add Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1512"/>
<location filename="../ProjectModel.cpp" line="1509"/>
<source>Layers Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1512"/>
<location filename="../ProjectModel.cpp" line="1509"/>
<source>Layers %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1517"/>
<location filename="../ProjectModel.cpp" line="1674"/>
<location filename="../ProjectModel.cpp" line="1927"/>
<location filename="../ProjectModel.cpp" line="1514"/>
<location filename="../ProjectModel.cpp" line="1671"/>
<location filename="../ProjectModel.cpp" line="1924"/>
<source>Add Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1522"/>
<location filename="../ProjectModel.cpp" line="1531"/>
<location filename="../ProjectModel.cpp" line="1519"/>
<location filename="../ProjectModel.cpp" line="1528"/>
<source>-copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1620"/>
<location filename="../ProjectModel.cpp" line="1617"/>
<source>Add SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1806"/>
<location filename="../ProjectModel.cpp" line="1803"/>
<source>Cut SongGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1809"/>
<location filename="../ProjectModel.cpp" line="1806"/>
<source>Cut SFXGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1812"/>
<location filename="../ProjectModel.cpp" line="1809"/>
<source>Cut SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1815"/>
<location filename="../ProjectModel.cpp" line="1812"/>
<source>Cut ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1818"/>
<location filename="../ProjectModel.cpp" line="1815"/>
<source>Cut Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1821"/>
<location filename="../ProjectModel.cpp" line="1818"/>
<source>Cut Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1824"/>
<location filename="../ProjectModel.cpp" line="1821"/>
<source>Cut Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1948"/>
<location filename="../ProjectModel.cpp" line="1945"/>
<source>Delete Subproject</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1949"/>
<location filename="../ProjectModel.cpp" line="1946"/>
<source>&lt;p&gt;The subproject %1 will be permanently deleted from the project. Sample files will be permanently removed from the file system.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1963"/>
<location filename="../ProjectModel.cpp" line="1960"/>
<source>Delete SongGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1966"/>
<location filename="../ProjectModel.cpp" line="1963"/>
<source>Delete SFXGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1969"/>
<location filename="../ProjectModel.cpp" line="1966"/>
<source>Delete SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1972"/>
<location filename="../ProjectModel.cpp" line="1969"/>
<source>Delete ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1975"/>
<location filename="../ProjectModel.cpp" line="1972"/>
<source>Delete Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1978"/>
<location filename="../ProjectModel.cpp" line="1975"/>
<source>Delete Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1981"/>
<location filename="../ProjectModel.cpp" line="1978"/>
<source>Delete Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1985"/>
<location filename="../ProjectModel.cpp" line="1982"/>
<source>Delete Sample</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1986"/>
<location filename="../ProjectModel.cpp" line="1983"/>
<source>&lt;p&gt;The sample %1 will be permanently deleted from the file system. &lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>

View File

@ -265,9 +265,8 @@ void VSTEditor::addAction() {
std::vector<std::pair<std::wstring, amuse::IntrusiveAudioGroupData>> data =
amuse::ContainerRegistry::LoadContainer(path.c_str(), containerType);
if (data.empty()) {
wchar_t msg[512];
SNPrintf(msg, 512, L"Unable to load Audio Groups from %s", path.c_str());
MessageBoxW(nullptr, msg, L"Invalid Data File", MB_OK | MB_ICONERROR);
std::wstring msg = fmt::format(L"Unable to load Audio Groups from {}", path);
MessageBoxW(nullptr, msg.c_str(), L"Invalid Data File", MB_OK | MB_ICONERROR);
return;
}

View File

@ -12,14 +12,14 @@ enum ConvType { ConvN64, ConvGCN, ConvPC };
static void ReportConvType(ConvType tp) {
switch (tp) {
case ConvN64:
Log.report(logvisor::Info, _SYS_STR("using N64 format"));
Log.report(logvisor::Info, fmt(_SYS_STR("using N64 format")));
break;
case ConvPC:
Log.report(logvisor::Info, _SYS_STR("using PC format"));
Log.report(logvisor::Info, fmt(_SYS_STR("using PC format")));
break;
case ConvGCN:
default:
Log.report(logvisor::Info, _SYS_STR("using GameCube format"));
Log.report(logvisor::Info, fmt(_SYS_STR("using GameCube format")));
break;
}
}
@ -31,13 +31,13 @@ static bool ExtractAudioGroup(amuse::SystemStringView inPath, amuse::SystemStrin
auto groups = amuse::ContainerRegistry::LoadContainer(inPath.data(), type);
if (groups.size()) {
Log.report(logvisor::Info, _SYS_STR("Found '%s'"), amuse::ContainerRegistry::TypeToName(type));
Log.report(logvisor::Info, fmt(_SYS_STR("Found '{}'")), amuse::ContainerRegistry::TypeToName(type));
amuse::Mkdir(targetPath.data(), 0755);
Log.report(logvisor::Info, _SYS_STR("Established directory at %s"), targetPath.data());
Log.report(logvisor::Info, fmt(_SYS_STR("Established directory at {}")), targetPath);
for (auto& group : groups) {
Log.report(logvisor::Info, _SYS_STR("Extracting %s"), group.first.c_str());
Log.report(logvisor::Info, fmt(_SYS_STR("Extracting {}")), group.first);
}
}
@ -54,7 +54,7 @@ static bool ExtractAudioGroup(amuse::SystemStringView inPath, amuse::SystemStrin
amuse::SystemString songPath = songsDir + _SYS_STR('/') + pair.first + _SYS_STR(".mid");
FILE* fp = amuse::FOpen(songPath.c_str(), _SYS_STR("wb"));
if (fp) {
Log.report(logvisor::Info, _SYS_STR("Extracting %s"), pair.first.c_str());
Log.report(logvisor::Info, fmt(_SYS_STR("Extracting {}")), pair.first);
int extractedVersion;
bool isBig;
std::vector<uint8_t> mid = amuse::SongConverter::SongToMIDI(pair.second.m_data.get(), extractedVersion, isBig);
@ -123,7 +123,7 @@ int main(int argc, const amuse::SystemChar** argv)
logvisor::RegisterConsoleLogger();
if (argc < 3) {
printf("Usage: amuseconv <in-file> <out-file> [n64|pc|gcn]\n");
fmt::print(fmt("Usage: amuseconv <in-file> <out-file> [n64|pc|gcn]\n"));
return 0;
}
@ -136,7 +136,7 @@ int main(int argc, const amuse::SystemChar** argv)
else if (!amuse::CompareCaseInsensitive(argv[3], _SYS_STR("pc")))
type = ConvPC;
else {
Log.report(logvisor::Error, _SYS_STR("unrecognized format: %s"), argv[3]);
Log.report(logvisor::Error, fmt(_SYS_STR("unrecognized format: {}")), argv[3]);
return 1;
}
}
@ -175,7 +175,7 @@ int main(int argc, const amuse::SystemChar** argv)
}
if (!good) {
Log.report(logvisor::Error, _SYS_STR("unable to convert %s to %s"), argv[1], argv[2]);
Log.report(logvisor::Error, fmt(_SYS_STR("unable to convert {} to {}")), argv[1], argv[2]);
return 1;
}

View File

@ -83,9 +83,9 @@ struct AppCallback : boo::IApplicationCallback {
voxCount = m_seq->getVoiceCount();
program = m_seq->getChanProgram(m_chanId);
}
printf(
fmt::print(fmt(
"\r "
"\r %" PRISize " Setup %d, Chan %d, Prog %d, Octave: %d, Vel: %d, VOL: %d%%\r",
"\r {} Setup {}, Chan {}, Prog {}, Octave: {}, Vel: {}, VOL: {}%\r"),
voxCount, m_setupId, m_chanId, program, m_octave, m_velocity, int(std::rint(m_volume * 100)));
fflush(stdout);
}
@ -106,7 +106,7 @@ struct AppCallback : boo::IApplicationCallback {
}
void SongLoop(const amuse::SongGroupIndex& index) {
printf(
fmt::print(fmt(
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n"
"░░░ ████ ████ ┃ ████ ████ ████ ┃ ████ ████ ░░░\n"
"░░░ ████ ████ ┃ ████ ████ ████ ┃ ████ ████ ░░░\n"
@ -116,20 +116,20 @@ struct AppCallback : boo::IApplicationCallback {
"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n"
"<left/right>: cycle MIDI setup, <up/down>: volume, <space>: PANIC\n"
"<tab>: sustain pedal, <window-Y>: pitch wheel, <window-X>: mod wheel\n"
"<Z/X>: octave, <C/V>: velocity, <B/N>: channel, <,/.>: program, <Q>: quit\n");
"<Z/X>: octave, <C/V>: velocity, <B/N>: channel, <,/.>: program, <Q>: quit\n"));
std::map<amuse::SongId, std::array<amuse::SongGroupIndex::MIDISetup, 16>> sortEntries(index.m_midiSetups.cbegin(),
index.m_midiSetups.cend());
auto setupIt = sortEntries.cbegin();
if (setupIt != sortEntries.cend()) {
if (m_setupId == -1)
SelectSong(setupIt->first);
SelectSong(setupIt->first.id);
else {
while (setupIt != sortEntries.cend() && setupIt->first != m_setupId)
++setupIt;
if (setupIt == sortEntries.cend())
setupIt = sortEntries.cbegin();
SelectSong(setupIt->first);
SelectSong(setupIt->first.id);
}
}
@ -142,7 +142,7 @@ struct AppCallback : boo::IApplicationCallback {
++nextIt;
if (nextIt != sortEntries.cend()) {
++setupIt;
SelectSong(setupIt->first);
SelectSong(setupIt->first.id);
m_updateDisp = false;
}
}
@ -151,7 +151,7 @@ struct AppCallback : boo::IApplicationCallback {
m_wantsPrev = false;
if (setupIt != sortEntries.cbegin()) {
--setupIt;
SelectSong(setupIt->first);
SelectSong(setupIt->first.id);
m_updateDisp = false;
}
}
@ -205,9 +205,9 @@ struct AppCallback : boo::IApplicationCallback {
"\r %c SFX %d, VOL: %d%% POS: (%f,%f)\r",
playing ? '>' : ' ', m_sfxId, int(std::rint(m_volume * 100)), m_pos[0], m_pos[1]);
#else
printf(
fmt::print(fmt(
"\r "
"\r %c SFX %d, VOL: %d%%\r",
"\r {:c} SFX {}, VOL: {}%\r"),
playing ? '>' : ' ', m_sfxId, int(std::rint(m_volume * 100)));
#endif
fflush(stdout);
@ -233,7 +233,7 @@ struct AppCallback : boo::IApplicationCallback {
}
void SFXLoop(const amuse::SFXGroupIndex& index) {
printf("<space>: keyon/keyoff, <left/right>: cycle SFX, <up/down>: volume, <Q>: quit\n");
fmt::print(fmt("<space>: keyon/keyoff, <left/right>: cycle SFX, <up/down>: volume, <Q>: quit\n"));
m_seq = m_engine->seqPlay(m_groupId, 0, nullptr);
@ -241,7 +241,7 @@ struct AppCallback : boo::IApplicationCallback {
index.m_sfxEntries.cend());
auto sfxIt = sortEntries.cbegin();
if (sfxIt != sortEntries.cend())
SelectSFX(sfxIt->first);
SelectSFX(sfxIt->first.id);
#if EMITTER_TEST
float emitterTheta = 0.f;
@ -270,7 +270,7 @@ struct AppCallback : boo::IApplicationCallback {
++nextIt;
if (nextIt != sortEntries.cend()) {
++sfxIt;
SelectSFX(sfxIt->first);
SelectSFX(sfxIt->first.id);
m_updateDisp = false;
}
}
@ -279,7 +279,7 @@ struct AppCallback : boo::IApplicationCallback {
m_wantsPrev = false;
if (sfxIt != sortEntries.cbegin()) {
--sfxIt;
SelectSFX(sfxIt->first);
SelectSFX(sfxIt->first.id);
m_updateDisp = false;
}
}
@ -577,21 +577,21 @@ struct AppCallback : boo::IApplicationCallback {
/* Load data */
if (m_argc < 2) {
Log.report(logvisor::Error, "needs group path argument");
Log.report(logvisor::Error, fmt("needs group path argument"));
return 1;
}
amuse::ContainerRegistry::Type cType = amuse::ContainerRegistry::DetectContainerType(m_argv[1]);
if (cType == amuse::ContainerRegistry::Type::Invalid) {
Log.report(logvisor::Error, "invalid/no data at path argument");
Log.report(logvisor::Error, fmt("invalid/no data at path argument"));
return 1;
}
Log.report(logvisor::Info, _SYS_STR("Found '%s' Audio Group data"), amuse::ContainerRegistry::TypeToName(cType));
Log.report(logvisor::Info, fmt(_SYS_STR("Found '%s' Audio Group data")), amuse::ContainerRegistry::TypeToName(cType));
std::vector<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>> data =
amuse::ContainerRegistry::LoadContainer(m_argv[1]);
if (data.empty()) {
Log.report(logvisor::Error, "invalid/no data at path argument");
Log.report(logvisor::Error, fmt("invalid/no data at path argument"));
return 1;
}
@ -634,7 +634,7 @@ struct AppCallback : boo::IApplicationCallback {
bool prompt = true;
while (true) {
if (prompt) {
printf("Play Song? (Y/N): ");
fmt::print(fmt("Play Song? (Y/N): "));
prompt = false;
}
char userSel;
@ -655,7 +655,7 @@ struct AppCallback : boo::IApplicationCallback {
/* Get song selection from user */
if (songs.size() > 1) {
/* Ask user to specify which song */
printf("Multiple Songs discovered:\n");
fmt::print(fmt("Multiple Songs discovered:\n"));
int idx = 0;
for (const auto& pair : songs) {
const amuse::ContainerRegistry::SongData& sngData = pair.second;
@ -665,7 +665,7 @@ struct AppCallback : boo::IApplicationCallback {
for (const auto& pair : allSongGroups) {
for (const auto& setup : pair.second.second->m_midiSetups) {
if (setup.first == sngData.m_setupId) {
grpId = pair.first;
grpId = pair.first.id;
break;
}
}
@ -673,13 +673,13 @@ struct AppCallback : boo::IApplicationCallback {
break;
}
}
amuse::Printf(_SYS_STR(" %d %s (Group %d, Setup %d)\n"), idx++, pair.first.c_str(), grpId, setupId);
fmt::print(fmt(_SYS_STR(" {} {} (Group {}, Setup {})\n")), idx++, pair.first, grpId, setupId);
}
int userSel = 0;
printf("Enter Song Number: ");
fmt::print(fmt("Enter Song Number: "));
if (scanf("%d", &userSel) <= 0) {
Log.report(logvisor::Error, "unable to parse prompt");
Log.report(logvisor::Error, fmt("unable to parse prompt"));
return 1;
}
@ -688,7 +688,7 @@ struct AppCallback : boo::IApplicationCallback {
m_groupId = m_arrData->m_groupId;
m_setupId = m_arrData->m_setupId;
} else {
Log.report(logvisor::Error, "unable to find Song %d", userSel);
Log.report(logvisor::Error, fmt("unable to find Song {}"), userSel);
return 1;
}
} else if (songs.size() == 1) {
@ -704,7 +704,7 @@ struct AppCallback : boo::IApplicationCallback {
for (const auto& pair : allSongGroups) {
for (const auto& setup : pair.second.second->m_midiSetups) {
if (setup.first == m_setupId) {
m_groupId = pair.first;
m_groupId = pair.first.id;
break;
}
}
@ -720,27 +720,26 @@ struct AppCallback : boo::IApplicationCallback {
else if (allSFXGroups.find(m_groupId) != allSFXGroups.end())
m_sfxGroup = true;
else {
Log.report(logvisor::Error, "unable to find Group %d", m_groupId);
Log.report(logvisor::Error, fmt("unable to find Group {}"), m_groupId);
return 1;
}
} else if (totalGroups > 1) {
/* Ask user to specify which group in project */
printf("Multiple Audio Groups discovered:\n");
fmt::print(fmt("Multiple Audio Groups discovered:\n"));
for (const auto& pair : allSFXGroups) {
amuse::Printf(_SYS_STR(" %d %s (SFXGroup) %" PRISize " sfx-entries\n"), pair.first.id,
pair.second.first->first.c_str(), pair.second.second->m_sfxEntries.size());
fmt::print(fmt(_SYS_STR(" {} {} (SFXGroup) {} sfx-entries\n")), pair.first,
pair.second.first->first, pair.second.second->m_sfxEntries.size());
}
for (const auto& pair : allSongGroups) {
amuse::Printf(_SYS_STR(" %d %s (SongGroup) %" PRISize " normal-pages, %" PRISize " drum-pages, %" PRISize
" MIDI-setups\n"),
pair.first.id, pair.second.first->first.c_str(), pair.second.second->m_normPages.size(),
pair.second.second->m_drumPages.size(), pair.second.second->m_midiSetups.size());
fmt::print(fmt(_SYS_STR(" {} {} (SongGroup) {} normal-pages, {} drum-pages, {} MIDI-setups\n")),
pair.first, pair.second.first->first, pair.second.second->m_normPages.size(),
pair.second.second->m_drumPages.size(), pair.second.second->m_midiSetups.size());
}
int userSel = 0;
printf("Enter Group Number: ");
fmt::print(fmt("Enter Group Number: "));
if (scanf("%d", &userSel) <= 0) {
Log.report(logvisor::Error, "unable to parse prompt");
Log.report(logvisor::Error, fmt("unable to parse prompt"));
return 1;
}
@ -751,22 +750,22 @@ struct AppCallback : boo::IApplicationCallback {
m_groupId = userSel;
m_sfxGroup = true;
} else {
Log.report(logvisor::Error, "unable to find Group %d", userSel);
Log.report(logvisor::Error, fmt("unable to find Group {}"), userSel);
return 1;
}
} else if (totalGroups == 1) {
/* Load one and only group */
if (allSongGroups.size()) {
const auto& pair = *allSongGroups.cbegin();
m_groupId = pair.first;
m_groupId = pair.first.id;
m_sfxGroup = false;
} else {
const auto& pair = *allSFXGroups.cbegin();
m_groupId = pair.first;
m_groupId = pair.first.id;
m_sfxGroup = true;
}
} else {
Log.report(logvisor::Error, "empty project");
Log.report(logvisor::Error, fmt("empty project"));
return 1;
}
@ -787,7 +786,7 @@ struct AppCallback : boo::IApplicationCallback {
}
if (!selData) {
Log.report(logvisor::Error, "unable to select audio group data");
Log.report(logvisor::Error, fmt("unable to select audio group data"));
return 1;
}
@ -799,7 +798,7 @@ struct AppCallback : boo::IApplicationCallback {
/* Load group into engine */
const amuse::AudioGroup* group = m_engine->addAudioGroup(*selData);
if (!group) {
Log.report(logvisor::Error, "unable to add audio group");
Log.report(logvisor::Error, fmt("unable to add audio group"));
return 1;
}
@ -813,7 +812,7 @@ struct AppCallback : boo::IApplicationCallback {
m_seq.reset();
m_engine.reset();
m_booBackend.reset();
printf("\n\n");
fmt::print(fmt("\n\n"));
}
return 0;
@ -909,7 +908,7 @@ int main(int argc, const boo::SystemChar** argv)
AppCallback app(argc, argv);
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, app, _SYS_STR("amuseplay"),
_SYS_STR("Amuse Player"), argc, argv, {}, 1, 1, false);
printf("IM DYING!!\n");
fmt::print(fmt("IM DYING!!\n"));
return ret;
}

View File

@ -17,21 +17,6 @@
static logvisor::Module Log("amuserender");
#if __GNUC__
__attribute__((__format__(__printf__, 3, 4)))
#endif
static inline void
SNPrintf(boo::SystemChar* str, size_t maxlen, const boo::SystemChar* format, ...) {
va_list va;
va_start(va, format);
#if _WIN32
_vsnwprintf(str, maxlen, format, va);
#else
vsnprintf(str, maxlen, format, va);
#endif
va_end(va);
}
#if _WIN32
#include <DbgHelp.h>
#pragma comment(lib, "Dbghelp.lib")
@ -151,22 +136,22 @@ int main(int argc, const boo::SystemChar** argv)
/* Load data */
if (m_args.size() < 1) {
Log.report(logvisor::Error,
"Usage: amuserender <group-file> [<songs-file>] [-r <sample-rate>] [-c <channel-count>] [-v <volume "
"0.0-1.0>]");
fmt("Usage: amuserender <group-file> [<songs-file>] [-r <sample-rate>] [-c <channel-count>] [-v <volume "
"0.0-1.0>]"));
return 1;
}
amuse::ContainerRegistry::Type cType = amuse::ContainerRegistry::DetectContainerType(m_args[0].c_str());
if (cType == amuse::ContainerRegistry::Type::Invalid) {
Log.report(logvisor::Error, "invalid/no data at path argument");
Log.report(logvisor::Error, fmt("invalid/no data at path argument"));
return 1;
}
Log.report(logvisor::Info, _SYS_STR("Found '%s' Audio Group data"), amuse::ContainerRegistry::TypeToName(cType));
Log.report(logvisor::Info, fmt(_SYS_STR("Found '{}' Audio Group data")), amuse::ContainerRegistry::TypeToName(cType));
std::vector<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>> data =
amuse::ContainerRegistry::LoadContainer(m_args[0].c_str());
if (data.empty()) {
Log.report(logvisor::Error, "invalid/no data at path argument");
Log.report(logvisor::Error, fmt("invalid/no data at path argument"));
return 1;
}
@ -178,11 +163,11 @@ int main(int argc, const boo::SystemChar** argv)
bool m_sfxGroup = false;
std::list<amuse::AudioGroupProject> m_projs;
std::map<int, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
amuse::ObjToken<amuse::SongGroupIndex>>>
std::map<amuse::GroupId, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
amuse::ObjToken<amuse::SongGroupIndex>>>
allSongGroups;
std::map<int, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
amuse::ObjToken<amuse::SFXGroupIndex>>>
std::map<amuse::GroupId, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
amuse::ObjToken<amuse::SFXGroupIndex>>>
allSFXGroups;
size_t totalGroups = 0;
@ -212,7 +197,7 @@ int main(int argc, const boo::SystemChar** argv)
bool prompt = true;
while (true) {
if (prompt) {
printf("Render Song? (Y/N): ");
fmt::print(fmt("Render Song? (Y/N): "));
prompt = false;
}
char userSel;
@ -233,7 +218,7 @@ int main(int argc, const boo::SystemChar** argv)
/* Get song selection from user */
if (songs.size() > 1) {
/* Ask user to specify which song */
printf("Multiple Songs discovered:\n");
fmt::print(fmt("Multiple Songs discovered:\n"));
int idx = 0;
for (const auto& pair : songs) {
const amuse::ContainerRegistry::SongData& sngData = pair.second;
@ -243,7 +228,7 @@ int main(int argc, const boo::SystemChar** argv)
for (const auto& pair : allSongGroups) {
for (const auto& setup : pair.second.second->m_midiSetups) {
if (setup.first == sngData.m_setupId) {
grpId = pair.first;
grpId = pair.first.id;
break;
}
}
@ -251,13 +236,13 @@ int main(int argc, const boo::SystemChar** argv)
break;
}
}
amuse::Printf(_SYS_STR(" %d %s (Group %d, Setup %d)\n"), idx++, pair.first.c_str(), grpId, setupId);
fmt::print(fmt(_SYS_STR(" {} {} (Group {}, Setup {})\n")), idx++, pair.first, grpId, setupId);
}
int userSel = 0;
printf("Enter Song Number: ");
fmt::print(fmt("Enter Song Number: "));
if (scanf("%d", &userSel) <= 0) {
Log.report(logvisor::Error, "unable to parse prompt");
Log.report(logvisor::Error, fmt("unable to parse prompt"));
return 1;
}
@ -267,7 +252,7 @@ int main(int argc, const boo::SystemChar** argv)
m_setupId = m_arrData->m_setupId;
m_songName = &songs[userSel].first;
} else {
Log.report(logvisor::Error, "unable to find Song %d", userSel);
Log.report(logvisor::Error, fmt("unable to find Song {}"), userSel);
return 1;
}
} else if (songs.size() == 1) {
@ -284,7 +269,7 @@ int main(int argc, const boo::SystemChar** argv)
for (const auto& pair : allSongGroups) {
for (const auto& setup : pair.second.second->m_midiSetups) {
if (setup.first == m_setupId) {
m_groupId = pair.first;
m_groupId = pair.first.id;
m_groupName = &pair.second.first->first;
break;
}
@ -305,27 +290,26 @@ int main(int argc, const boo::SystemChar** argv)
m_sfxGroup = true;
m_groupName = &sfxSearch->second.first->first;
} else {
Log.report(logvisor::Error, "unable to find Group %d", m_groupId);
Log.report(logvisor::Error, fmt("unable to find Group {}"), m_groupId);
return 1;
}
} else if (totalGroups > 1) {
/* Ask user to specify which group in project */
printf("Multiple Audio Groups discovered:\n");
fmt::print(fmt("Multiple Audio Groups discovered:\n"));
for (const auto& pair : allSFXGroups) {
amuse::Printf(_SYS_STR(" %d %s (SFXGroup) %" PRISize " sfx-entries\n"), pair.first,
pair.second.first->first.c_str(), pair.second.second->m_sfxEntries.size());
fmt::print(fmt(_SYS_STR(" {} {} (SFXGroup) {} sfx-entries\n")), pair.first,
pair.second.first->first, pair.second.second->m_sfxEntries.size());
}
for (const auto& pair : allSongGroups) {
amuse::Printf(_SYS_STR(" %d %s (SongGroup) %" PRISize " normal-pages, %" PRISize " drum-pages, %" PRISize
" MIDI-setups\n"),
pair.first, pair.second.first->first.c_str(), pair.second.second->m_normPages.size(),
pair.second.second->m_drumPages.size(), pair.second.second->m_midiSetups.size());
fmt::print(fmt(_SYS_STR(" {} {} (SongGroup) {} normal-pages, {} drum-pages, {} MIDI-setups\n")),
pair.first, pair.second.first->first, pair.second.second->m_normPages.size(),
pair.second.second->m_drumPages.size(), pair.second.second->m_midiSetups.size());
}
int userSel = 0;
printf("Enter Group Number: ");
fmt::print(fmt("Enter Group Number: "));
if (scanf("%d", &userSel) <= 0) {
Log.report(logvisor::Error, "unable to parse prompt");
Log.report(logvisor::Error, fmt("unable to parse prompt"));
return 1;
}
@ -340,24 +324,24 @@ int main(int argc, const boo::SystemChar** argv)
m_groupName = &sfxSearch->second.first->first;
m_sfxGroup = true;
} else {
Log.report(logvisor::Error, "unable to find Group %d", userSel);
Log.report(logvisor::Error, fmt("unable to find Group {}"), userSel);
return 1;
}
} else if (totalGroups == 1) {
/* Load one and only group */
if (allSongGroups.size()) {
const auto& pair = *allSongGroups.cbegin();
m_groupId = pair.first;
m_groupId = pair.first.id;
m_groupName = &pair.second.first->first;
m_sfxGroup = false;
} else {
const auto& pair = *allSFXGroups.cbegin();
m_groupId = pair.first;
m_groupId = pair.first.id;
m_groupName = &pair.second.first->first;
m_sfxGroup = true;
}
} else {
Log.report(logvisor::Error, "empty project");
Log.report(logvisor::Error, fmt("empty project"));
return 1;
}
@ -369,24 +353,24 @@ int main(int argc, const boo::SystemChar** argv)
if (songSearch != allSongGroups.end()) {
selData = &songSearch->second.first->second;
songIndex = songSearch->second.second;
std::set<int> sortSetups;
std::set<amuse::SongId> sortSetups;
for (auto& pair : songIndex->m_midiSetups)
sortSetups.insert(pair.first);
if (m_setupId == -1) {
/* Ask user to specify which group in project */
printf("Multiple MIDI Setups:\n");
for (int setup : sortSetups)
printf(" %d\n", setup);
fmt::print(fmt("Multiple MIDI Setups:\n"));
for (auto setup : sortSetups)
fmt::print(fmt(" {}\n"), setup);
int userSel = 0;
printf("Enter Setup Number: ");
fmt::print(fmt("Enter Setup Number: "));
if (scanf("%d", &userSel) <= 0) {
Log.report(logvisor::Error, "unable to parse prompt");
Log.report(logvisor::Error, fmt("unable to parse prompt"));
return 1;
}
m_setupId = userSel;
}
if (sortSetups.find(m_setupId) == sortSetups.cend()) {
Log.report(logvisor::Error, "unable to find setup %d", m_setupId);
Log.report(logvisor::Error, fmt("unable to find setup {}"), m_setupId);
return 1;
}
} else {
@ -398,22 +382,21 @@ int main(int argc, const boo::SystemChar** argv)
}
if (!selData) {
Log.report(logvisor::Error, "unable to select audio group data");
Log.report(logvisor::Error, fmt("unable to select audio group data"));
return 1;
}
if (m_sfxGroup) {
Log.report(logvisor::Error, "amuserender is currently only able to render SongGroups");
Log.report(logvisor::Error, fmt("amuserender is currently only able to render SongGroups"));
return 1;
}
/* WAV out path */
amuse::SystemChar pathOut[1024];
SNPrintf(pathOut, 1024, _SYS_STR("%s-%s.wav"), m_groupName->c_str(), m_songName->c_str());
Log.report(logvisor::Info, _SYS_STR("Writing to %s"), pathOut);
amuse::SystemString pathOut = fmt::format(fmt("{}-{}.wav"), *m_groupName, *m_songName);
Log.report(logvisor::Info, fmt(_SYS_STR("Writing to {}")), pathOut);
/* Build voice engine */
std::unique_ptr<boo::IAudioVoiceEngine> voxEngine = boo::NewWAVAudioVoiceEngine(pathOut, rate, chCount);
std::unique_ptr<boo::IAudioVoiceEngine> voxEngine = boo::NewWAVAudioVoiceEngine(pathOut.c_str(), rate, chCount);
amuse::BooBackendVoiceAllocator booBackend(*voxEngine);
amuse::Engine engine(booBackend, amuse::AmplitudeMode::PerSample);
engine.setVolume(float(amuse::clamp(0.0, volume, 1.0)));
@ -421,7 +404,7 @@ int main(int argc, const boo::SystemChar** argv)
/* Load group into engine */
const amuse::AudioGroup* group = engine.addAudioGroup(*selData);
if (!group) {
Log.report(logvisor::Error, "unable to add audio group");
Log.report(logvisor::Error, fmt("unable to add audio group"));
return 1;
}
@ -432,11 +415,11 @@ int main(int argc, const boo::SystemChar** argv)
do {
voxEngine->pumpAndMixVoices();
wroteFrames += voxEngine->get5MsFrames();
printf("\rFrame %" PRISize, wroteFrames);
fmt::print(fmt("\rFrame {}"), wroteFrames);
fflush(stdout);
} while (!g_BreakLoop && (seq->state() == amuse::SequencerState::Playing || seq->getVoiceCount() != 0));
printf("\n");
fmt::print(fmt("\n"));
return 0;
}

View File

@ -1051,19 +1051,19 @@ struct SoundMacro {
};
template <typename T>
static inline T& AccessField(SoundMacro::ICmd* cmd, const SoundMacro::CmdIntrospection::Field& field) {
inline T& AccessField(SoundMacro::ICmd* cmd, const SoundMacro::CmdIntrospection::Field& field) {
return *reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(std::addressof(*cmd)) + field.m_offset);
}
/** Converts time-cents representation to seconds */
static inline double TimeCentsToSeconds(int32_t tc) {
inline double TimeCentsToSeconds(int32_t tc) {
if (uint32_t(tc) == 0x80000000)
return 0.0;
return std::exp2(tc / (1200.0 * 65536.0));
}
/** Converts seconds representation to time-cents */
static inline int32_t SecondsToTimeCents(double sec) {
inline int32_t SecondsToTimeCents(double sec) {
if (sec == 0.0)
return 0x80000000;
return int32_t(std::log2(sec) * (1200.0 * 65536.0));
@ -1205,7 +1205,7 @@ struct Keymap : BigDNA {
}
uint64_t configKey() const {
return uint64_t(macro.id) | (uint64_t(transpose) << 16) | (uint64_t(pan) << 24) | (uint64_t(prioOffset) << 32);
return uint64_t(macro.id.id) | (uint64_t(transpose) << 16) | (uint64_t(pan) << 24) | (uint64_t(prioOffset) << 32);
}
};

View File

@ -192,8 +192,8 @@ public:
static AudioGroupProject CreateAudioGroupProject(const AudioGroupProject& oldProj);
static void BootstrapObjectIDs(const AudioGroupData& data);
const SongGroupIndex* getSongGroupIndex(int groupId) const;
const SFXGroupIndex* getSFXGroupIndex(int groupId) const;
const SongGroupIndex* getSongGroupIndex(GroupId groupId) const;
const SFXGroupIndex* getSFXGroupIndex(GroupId groupId) const;
const std::unordered_map<GroupId, ObjToken<SongGroupIndex>>& songGroups() const { return m_songGroups; }
const std::unordered_map<GroupId, ObjToken<SFXGroupIndex>>& sfxGroups() const { return m_sfxGroups; }

View File

@ -11,6 +11,7 @@
#include <atomic>
#include <unordered_map>
#include "athena/DNA.hpp"
#include "logvisor/logvisor.hpp"
#ifndef _WIN32
#include <strings.h>
@ -47,13 +48,16 @@ using LittleDNAV = athena::io::DNAVYaml<athena::Little>;
* SoundMacros, Tables, Keymaps, Layers, Samples, SFX, Songs */
struct ObjectId {
uint16_t id = 0xffff;
operator uint16_t() const { return id; }
ObjectId() = default;
ObjectId(uint16_t idIn) : id(idIn) {}
ObjectId& operator=(uint16_t idIn) {
id = idIn;
return *this;
}
bool operator==(const ObjectId& other) const { return id == other.id; }
bool operator!=(const ObjectId& other) const { return id != other.id; }
bool operator<(const ObjectId& other) const { return id < other.id; }
bool operator>(const ObjectId& other) const { return id > other.id; }
static thread_local NameDB* CurNameDB;
};
template <athena::Endian DNAEn>
@ -313,8 +317,8 @@ using SystemChar = wchar_t;
#define _SYS_STR(val) L##val
#endif
typedef struct _stat Sstat;
static inline int Mkdir(const wchar_t* path, int) { return _wmkdir(path); }
static inline int Stat(const wchar_t* path, Sstat* statout) { return _wstat(path, statout); }
inline int Mkdir(const wchar_t* path, int) { return _wmkdir(path); }
inline int Stat(const wchar_t* path, Sstat* statout) { return _wstat(path, statout); }
#else
using SystemString = std::string;
using SystemStringView = std::string_view;
@ -323,11 +327,11 @@ using SystemChar = char;
#define _SYS_STR(val) val
#endif
typedef struct stat Sstat;
static inline int Mkdir(const char* path, mode_t mode) { return mkdir(path, mode); }
static inline int Stat(const char* path, Sstat* statout) { return stat(path, statout); }
inline int Mkdir(const char* path, mode_t mode) { return mkdir(path, mode); }
inline int Stat(const char* path, Sstat* statout) { return stat(path, statout); }
#endif
static inline int Rename(const SystemChar* oldpath, const SystemChar* newpath) {
inline int Rename(const SystemChar* oldpath, const SystemChar* newpath) {
#if _WIN32
// return _wrename(oldpath, newpath);
return MoveFileExW(oldpath, newpath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0;
@ -337,10 +341,10 @@ static inline int Rename(const SystemChar* oldpath, const SystemChar* newpath) {
}
#if _WIN32
static inline int CompareCaseInsensitive(const char* a, const char* b) { return _stricmp(a, b); }
inline int CompareCaseInsensitive(const char* a, const char* b) { return _stricmp(a, b); }
#endif
static inline int CompareCaseInsensitive(const SystemChar* a, const SystemChar* b) {
inline int CompareCaseInsensitive(const SystemChar* a, const SystemChar* b) {
#if _WIN32
return _wcsicmp(a, b);
#else
@ -349,12 +353,12 @@ static inline int CompareCaseInsensitive(const SystemChar* a, const SystemChar*
}
template <typename T>
static inline T clamp(T a, T val, T b) {
constexpr T clamp(T a, T val, T b) {
return std::max<T>(a, std::min<T>(b, val));
}
template <typename T>
inline T ClampFull(float in) {
constexpr T ClampFull(float in) {
if (std::is_floating_point<T>()) {
return in;
} else {
@ -374,37 +378,7 @@ inline T ClampFull(float in) {
#define M_PIF 3.14159265358979323846f /* pi */
#endif
#if __GNUC__
__attribute__((__format__(__printf__, 1, 2)))
#endif
static inline void
Printf(const SystemChar* fmt, ...) {
va_list args;
va_start(args, fmt);
#if _WIN32
vwprintf(fmt, args);
#else
vprintf(fmt, args);
#endif
va_end(args);
}
#if __GNUC__
__attribute__((__format__(__printf__, 3, 4)))
#endif
static inline void
SNPrintf(SystemChar* str, size_t maxlen, const SystemChar* format, ...) {
va_list va;
va_start(va, format);
#if _WIN32
_vsnwprintf(str, maxlen, format, va);
#else
vsnprintf(str, maxlen, format, va);
#endif
va_end(va);
}
static inline const SystemChar* StrRChr(const SystemChar* str, SystemChar ch) {
inline const SystemChar* StrRChr(const SystemChar* str, SystemChar ch) {
#if _WIN32
return wcsrchr(str, ch);
#else
@ -412,7 +386,7 @@ static inline const SystemChar* StrRChr(const SystemChar* str, SystemChar ch) {
#endif
}
static inline SystemChar* StrRChr(SystemChar* str, SystemChar ch) {
inline SystemChar* StrRChr(SystemChar* str, SystemChar ch) {
#if _WIN32
return wcsrchr(str, ch);
#else
@ -420,7 +394,7 @@ static inline SystemChar* StrRChr(SystemChar* str, SystemChar ch) {
#endif
}
static inline int FSeek(FILE* fp, int64_t offset, int whence) {
inline int FSeek(FILE* fp, int64_t offset, int whence) {
#if _WIN32
return _fseeki64(fp, offset, whence);
#elif __APPLE__ || __FreeBSD__
@ -430,7 +404,7 @@ static inline int FSeek(FILE* fp, int64_t offset, int whence) {
#endif
}
static inline int64_t FTell(FILE* fp) {
inline int64_t FTell(FILE* fp) {
#if _WIN32
return _ftelli64(fp);
#elif __APPLE__ || __FreeBSD__
@ -440,7 +414,7 @@ static inline int64_t FTell(FILE* fp) {
#endif
}
static inline FILE* FOpen(const SystemChar* path, const SystemChar* mode) {
inline FILE* FOpen(const SystemChar* path, const SystemChar* mode) {
#if _WIN32
FILE* fp = _wfopen(path, mode);
if (!fp)
@ -453,7 +427,7 @@ static inline FILE* FOpen(const SystemChar* path, const SystemChar* mode) {
return fp;
}
static inline void Unlink(const SystemChar* file) {
inline void Unlink(const SystemChar* file) {
#if _WIN32
_wunlink(file);
#else
@ -469,7 +443,7 @@ bool Copy(const SystemChar* from, const SystemChar* to);
/* Type-sensitive byte swappers */
template <typename T>
static inline T bswap16(T val) {
constexpr T bswap16(T val) {
#if __GNUC__
return __builtin_bswap16(val);
#elif _WIN32
@ -480,7 +454,7 @@ static inline T bswap16(T val) {
}
template <typename T>
static inline T bswap32(T val) {
constexpr T bswap32(T val) {
#if __GNUC__
return __builtin_bswap32(val);
#elif _WIN32
@ -493,7 +467,7 @@ static inline T bswap32(T val) {
}
template <typename T>
static inline T bswap64(T val) {
constexpr T bswap64(T val) {
#if __GNUC__
return __builtin_bswap64(val);
#elif _WIN32
@ -507,18 +481,18 @@ static inline T bswap64(T val) {
}
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
static inline int16_t SBig(int16_t val) { return bswap16(val); }
static inline uint16_t SBig(uint16_t val) { return bswap16(val); }
static inline int32_t SBig(int32_t val) { return bswap32(val); }
static inline uint32_t SBig(uint32_t val) { return bswap32(val); }
static inline int64_t SBig(int64_t val) { return bswap64(val); }
static inline uint64_t SBig(uint64_t val) { return bswap64(val); }
inline float SBig(float val) {
constexpr int16_t SBig(int16_t val) { return bswap16(val); }
constexpr uint16_t SBig(uint16_t val) { return bswap16(val); }
constexpr int32_t SBig(int32_t val) { return bswap32(val); }
constexpr uint32_t SBig(uint32_t val) { return bswap32(val); }
constexpr int64_t SBig(int64_t val) { return bswap64(val); }
constexpr uint64_t SBig(uint64_t val) { return bswap64(val); }
constexpr float SBig(float val) {
union { float f; atInt32 i; } uval1 = {val};
union { atInt32 i; float f; } uval2 = {bswap32(uval1.i)};
return uval2.f;
}
inline double SBig(double val) {
constexpr double SBig(double val) {
union { double f; atInt64 i; } uval1 = {val};
union { atInt64 i; double f; } uval2 = {bswap64(uval1.i)};
return uval2.f;
@ -527,29 +501,29 @@ inline double SBig(double val) {
#define SBIG(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)
#endif
static inline int16_t SLittle(int16_t val) { return val; }
static inline uint16_t SLittle(uint16_t val) { return val; }
static inline int32_t SLittle(int32_t val) { return val; }
static inline uint32_t SLittle(uint32_t val) { return val; }
static inline int64_t SLittle(int64_t val) { return val; }
static inline uint64_t SLittle(uint64_t val) { return val; }
static inline float SLittle(float val) { return val; }
static inline double SLittle(double val) { return val; }
constexpr int16_t SLittle(int16_t val) { return val; }
constexpr uint16_t SLittle(uint16_t val) { return val; }
constexpr int32_t SLittle(int32_t val) { return val; }
constexpr uint32_t SLittle(uint32_t val) { return val; }
constexpr int64_t SLittle(int64_t val) { return val; }
constexpr uint64_t SLittle(uint64_t val) { return val; }
constexpr float SLittle(float val) { return val; }
constexpr double SLittle(double val) { return val; }
#ifndef SLITTLE
#define SLITTLE(q) (q)
#endif
#else
static inline int16_t SLittle(int16_t val) { return bswap16(val); }
static inline uint16_t SLittle(uint16_t val) { return bswap16(val); }
static inline int32_t SLittle(int32_t val) { return bswap32(val); }
static inline uint32_t SLittle(uint32_t val) { return bswap32(val); }
static inline int64_t SLittle(int64_t val) { return bswap64(val); }
static inline uint64_t SLittle(uint64_t val) { return bswap64(val); }
static inline float SLittle(float val) {
constexpr int16_t SLittle(int16_t val) { return bswap16(val); }
constexpr uint16_t SLittle(uint16_t val) { return bswap16(val); }
constexpr int32_t SLittle(int32_t val) { return bswap32(val); }
constexpr uint32_t SLittle(uint32_t val) { return bswap32(val); }
constexpr int64_t SLittle(int64_t val) { return bswap64(val); }
constexpr uint64_t SLittle(uint64_t val) { return bswap64(val); }
constexpr float SLittle(float val) {
int32_t ival = bswap32(*((int32_t*)(&val)));
return *((float*)(&ival));
}
static inline double SLittle(double val) {
constexpr double SLittle(double val) {
int64_t ival = bswap64(*((int64_t*)(&val)));
return *((double*)(&ival));
}
@ -557,14 +531,14 @@ static inline double SLittle(double val) {
#define SLITTLE(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)
#endif
static inline int16_t SBig(int16_t val) { return val; }
static inline uint16_t SBig(uint16_t val) { return val; }
static inline int32_t SBig(int32_t val) { return val; }
static inline uint32_t SBig(uint32_t val) { return val; }
static inline int64_t SBig(int64_t val) { return val; }
static inline uint64_t SBig(uint64_t val) { return val; }
static inline float SBig(float val) { return val; }
static inline double SBig(double val) { return val; }
constexpr int16_t SBig(int16_t val) { return val; }
constexpr uint16_t SBig(uint16_t val) { return val; }
constexpr int32_t SBig(int32_t val) { return val; }
constexpr uint32_t SBig(uint32_t val) { return val; }
constexpr int64_t SBig(int64_t val) { return val; }
constexpr uint64_t SBig(uint64_t val) { return val; }
constexpr float SBig(float val) { return val; }
constexpr double SBig(double val) { return val; }
#ifndef SBIG
#define SBIG(q) (q)
#endif
@ -583,7 +557,7 @@ struct N64DataTag {};
struct PCDataTag {};
template <class T>
static std::vector<std::pair<typename T::key_type, std::reference_wrapper<typename T::mapped_type>>>
inline std::vector<std::pair<typename T::key_type, std::reference_wrapper<typename T::mapped_type>>>
SortUnorderedMap(T& um) {
std::vector<std::pair<typename T::key_type, std::reference_wrapper<typename T::mapped_type>>> ret;
ret.reserve(um.size());
@ -594,7 +568,7 @@ SortUnorderedMap(T& um) {
}
template <class T>
static std::vector<std::pair<typename T::key_type, std::reference_wrapper<const typename T::mapped_type>>>
inline std::vector<std::pair<typename T::key_type, std::reference_wrapper<const typename T::mapped_type>>>
SortUnorderedMap(const T& um) {
std::vector<std::pair<typename T::key_type, std::reference_wrapper<const typename T::mapped_type>>> ret;
ret.reserve(um.size());
@ -605,7 +579,7 @@ SortUnorderedMap(const T& um) {
}
template <class T>
static std::vector<typename T::key_type> SortUnorderedSet(T& us) {
inline std::vector<typename T::key_type> SortUnorderedSet(T& us) {
std::vector<typename T::key_type> ret;
ret.reserve(us.size());
for (auto& p : us)
@ -615,7 +589,7 @@ static std::vector<typename T::key_type> SortUnorderedSet(T& us) {
}
template <class T>
static std::vector<typename T::key_type> SortUnorderedSet(const T& us) {
inline std::vector<typename T::key_type> SortUnorderedSet(const T& us) {
std::vector<typename T::key_type> ret;
ret.reserve(us.size());
for (const auto& p : us)
@ -664,3 +638,13 @@ struct NameDB {
void rename(ObjectId id, std::string_view str);
};
} // namespace amuse
FMT_CUSTOM_FORMATTER(amuse::ObjectId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::SoundMacroId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::SampleId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::TableId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::KeymapId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::LayersId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::SongId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::SFXId, fmt("{:04X}"), obj.id)
FMT_CUSTOM_FORMATTER(amuse::GroupId, fmt("{:04X}"), obj.id)

View File

@ -3,7 +3,7 @@
#include <cstdint>
#include <cfloat>
static inline int16_t DSPSampClamp(int32_t val) {
constexpr int16_t DSPSampClamp(int32_t val) {
if (val < -32768)
val = -32768;
else if (val > 32767)

View File

@ -12,15 +12,15 @@ class Listener;
using Vector3f = float[3];
static inline float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
inline float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
static inline float Length(const Vector3f& a) {
inline float Length(const Vector3f& a) {
if (std::fabs(a[0]) <= FLT_EPSILON && std::fabs(a[1]) <= FLT_EPSILON && std::fabs(a[2]) <= FLT_EPSILON)
return 0.f;
return std::sqrt(Dot(a, a));
}
static inline float Normalize(Vector3f& out) {
inline float Normalize(Vector3f& out) {
float dist = Length(out);
if (dist == 0.f)
return 0.f;

View File

@ -2,7 +2,7 @@
#include <cstdint>
static inline int16_t N64MusyXSampClamp(int32_t val) {
constexpr int16_t N64MusyXSampClamp(int32_t val) {
if (val < -32768)
val = -32768;
else if (val > 32767)

View File

@ -194,8 +194,8 @@ class Voice : public Entity {
public:
~Voice();
Voice(Engine& engine, const AudioGroup& group, int groupId, int vid, bool emitter, ObjToken<Studio> studio);
Voice(Engine& engine, const AudioGroup& group, int groupId, ObjectId oid, int vid, bool emitter,
Voice(Engine& engine, const AudioGroup& group, GroupId groupId, int vid, bool emitter, ObjToken<Studio> studio);
Voice(Engine& engine, const AudioGroup& group, GroupId groupId, ObjectId oid, int vid, bool emitter,
ObjToken<Studio> studio);
/** Called before each supplyAudio invocation to prepare voice

View File

@ -2,6 +2,8 @@
#include "amuse/AudioGroupData.hpp"
#include <regex>
#include <athena/FileReader.hpp>
#include <fmt/ostream.h>
#include <sstream>
using namespace std::literals;
@ -113,11 +115,8 @@ void AudioGroupDatabase::_recursiveRenameMacro(SoundMacroId id, std::string_view
if (const SoundMacro* macro = getPool().soundMacro(id)) {
if (!strncmp(SoundMacroId::CurNameDB->resolveNameFromId(id).data(), "macro", 5)) {
std::string macroName("macro"sv);
if (macroIdx) {
char num[16];
snprintf(num, 16, "%d", macroIdx);
macroName += num;
}
if (macroIdx)
macroName += fmt::format(fmt("{}"), macroIdx);
macroName += '_';
macroName += str;
++macroIdx;
@ -130,11 +129,8 @@ void AudioGroupDatabase::_recursiveRenameMacro(SoundMacroId id, std::string_view
SoundMacro::CmdStartSample* ss = static_cast<SoundMacro::CmdStartSample*>(cmd.get());
if (!strncmp(SampleId::CurNameDB->resolveNameFromId(ss->sample.id).data(), "sample", 6)) {
std::string sampleName("sample"sv);
if (sampleIdx) {
char num[16];
snprintf(num, 16, "%d", sampleIdx);
sampleName += num;
}
if (sampleIdx)
sampleName += fmt::format(fmt("{}"), sampleIdx);
sampleName += '_';
sampleName += macroName;
++sampleIdx;
@ -236,29 +232,22 @@ void AudioGroupDatabase::importCHeader(std::string_view header) {
}
}
static void WriteDefineLine(std::string& ret, std::string_view typeStr, std::string_view name, ObjectId id) {
ret += "#define "sv;
ret += typeStr;
ret += name;
ret += ' ';
char idStr[16];
snprintf(idStr, 16, "%d", id.id);
ret += idStr;
ret += '\n';
static void WriteDefineLine(std::stringstream& ret, std::string_view typeStr, std::string_view name, ObjectId id) {
fmt::print(ret, fmt("#define {}{} {}\n"), typeStr, name, id);
}
std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std::string_view groupName) const {
std::string ret;
ret +=
std::stringstream ret;
ret <<
"/* Auto-generated Amuse Defines\n"
" *\n"
" * Project: "sv;
ret += projectName;
ret +=
ret << projectName;
ret <<
"\n"
" * Subproject: "sv;
ret += groupName;
ret +=
ret << groupName;
ret <<
"\n"
" * Date: "sv;
time_t curTime = time(nullptr);
@ -275,8 +264,8 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
#endif
if (char* ch = strchr(curTmStr, '\n'))
*ch = '\0';
ret += curTmStr;
ret +=
ret << curTmStr;
ret <<
"\n"
" */\n\n\n"sv;
@ -293,7 +282,7 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
}
if (addLF)
ret += "\n\n"sv;
ret << "\n\n"sv;
addLF = false;
std::unordered_set<amuse::SongId> songIds;
@ -307,7 +296,7 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
}
if (addLF)
ret += "\n\n"sv;
ret << "\n\n"sv;
addLF = false;
for (const auto& sg : SortUnorderedMap(getProj().sfxGroups())) {
@ -319,8 +308,8 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
}
if (addLF)
ret += "\n\n"sv;
ret << "\n\n"sv;
return ret;
return ret.str();
}
} // namespace amuse

View File

@ -319,7 +319,7 @@ int SoundMacro::assertPC(int pc) const {
if (pc < 0)
return -1;
if (size_t(pc) >= m_cmds.size()) {
fprintf(stderr, "SoundMacro PC bounds exceeded [%d/%d]\n", pc, int(m_cmds.size()));
fmt::print(stderr, fmt("SoundMacro PC bounds exceeded [{}/{}]\n"), pc, int(m_cmds.size()));
abort();
}
return pc;
@ -1103,17 +1103,17 @@ template std::vector<uint8_t> AudioGroupPool::toData<athena::Little>() const;
template <>
void amuse::Curve::Enumerate<LittleDNA::Read>(athena::io::IStreamReader& r) {
Log.report(logvisor::Fatal, "Curve binary DNA read not supported");
Log.report(logvisor::Fatal, fmt("Curve binary DNA read not supported"));
}
template <>
void amuse::Curve::Enumerate<LittleDNA::Write>(athena::io::IStreamWriter& w) {
Log.report(logvisor::Fatal, "Curve binary DNA write not supported");
Log.report(logvisor::Fatal, fmt("Curve binary DNA write not supported"));
}
template <>
void amuse::Curve::Enumerate<LittleDNA::BinarySize>(size_t& sz) {
Log.report(logvisor::Fatal, "Curve binary DNA size not supported");
Log.report(logvisor::Fatal, fmt("Curve binary DNA size not supported"));
}
template <>

View File

@ -58,9 +58,9 @@ static void WriteRangedObjectIds(athena::io::IStreamWriter& w, const T& list) {
if (list.cbegin() == list.cend())
return;
bool inRange = false;
uint16_t lastId = list.cbegin()->first & 0x3fff;
uint16_t lastId = list.cbegin()->first.id & 0x3fff;
for (auto it = list.cbegin() + 1; it != list.cend(); ++it) {
uint16_t thisId = it->first & 0x3fff;
uint16_t thisId = it->first.id & 0x3fff;
if (thisId == lastId + 1) {
if (!inRange) {
inRange = true;
@ -417,11 +417,8 @@ static ObjectId RegisterDedupedName(ObjectId origId, amuse::NameDB* db, NameDB::
std::string dupeName = std::string(db->resolveNameFromId(origId)) + "-copy";
std::string useName = dupeName;
int dupeIdx = 1;
while (db->m_stringToId.find(useName) != db->m_stringToId.cend()) {
char num[16];
snprintf(num, 16, "%d", dupeIdx++);
useName = dupeName + num;
}
while (db->m_stringToId.find(useName) != db->m_stringToId.cend())
useName = fmt::format(fmt("{}{}"), dupeName, dupeIdx++);
ObjectId ret = db->generateId(tp);
db->registerPair(useName, ret);
return ret;
@ -592,14 +589,14 @@ void AudioGroupProject::BootstrapObjectIDs(const AudioGroupData& data) {
}
}
const SongGroupIndex* AudioGroupProject::getSongGroupIndex(int groupId) const {
const SongGroupIndex* AudioGroupProject::getSongGroupIndex(GroupId groupId) const {
auto search = m_songGroups.find(groupId);
if (search != m_songGroups.cend())
return search->second.get();
return nullptr;
}
const SFXGroupIndex* AudioGroupProject::getSFXGroupIndex(int groupId) const {
const SFXGroupIndex* AudioGroupProject::getSFXGroupIndex(GroupId groupId) const {
auto search = m_sfxGroups.find(groupId);
if (search != m_sfxGroups.cend())
return search->second.get();
@ -610,9 +607,7 @@ void SongGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const {
if (!m_normPages.empty()) {
if (auto __v2 = w.enterSubRecord("normPages")) {
for (const auto& pg : SortUnorderedMap(m_normPages)) {
char name[16];
snprintf(name, 16, "%d", pg.first);
if (auto __r2 = w.enterSubRecord(name)) {
if (auto __r2 = w.enterSubRecord(fmt::format(fmt("{}"), pg.first).c_str())) {
w.setStyle(athena::io::YAMLNodeStyle::Flow);
pg.second.get().write(w);
}
@ -622,9 +617,7 @@ void SongGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const {
if (!m_drumPages.empty()) {
if (auto __v2 = w.enterSubRecord("drumPages")) {
for (const auto& pg : SortUnorderedMap(m_drumPages)) {
char name[16];
snprintf(name, 16, "%d", pg.first);
if (auto __r2 = w.enterSubRecord(name)) {
if (auto __r2 = w.enterSubRecord(fmt::format(fmt("{}"), pg.first).c_str())) {
w.setStyle(athena::io::YAMLNodeStyle::Flow);
pg.second.get().write(w);
}
@ -634,10 +627,9 @@ void SongGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const {
if (!m_midiSetups.empty()) {
if (auto __v2 = w.enterSubRecord("songs")) {
for (const auto& song : SortUnorderedMap(m_midiSetups)) {
char songString[64];
snprintf(songString, 64, "%s/0x%04X", SongId::CurNameDB->resolveNameFromId(song.first).data(),
int(song.first.id));
if (auto __v3 = w.enterSubVector(songString))
std::string songString = fmt::format(fmt("{}/0x{}"),
SongId::CurNameDB->resolveNameFromId(song.first), song.first);
if (auto __v3 = w.enterSubVector(songString.c_str()))
for (int i = 0; i < 16; ++i)
if (auto __r2 = w.enterSubRecord(nullptr)) {
w.setStyle(athena::io::YAMLNodeStyle::Flow);
@ -650,9 +642,9 @@ void SongGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const {
void SFXGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const {
for (const auto& sfx : SortUnorderedMap(m_sfxEntries)) {
char sfxString[64];
snprintf(sfxString, 64, "%s/0x%04X", SFXId::CurNameDB->resolveNameFromId(sfx.first).data(), int(sfx.first.id));
if (auto __r2 = w.enterSubRecord(sfxString)) {
std::string sfxString = fmt::format(fmt("{}/0x{}"),
SFXId::CurNameDB->resolveNameFromId(sfx.first), sfx.first);
if (auto __r2 = w.enterSubRecord(sfxString.c_str())) {
w.setStyle(athena::io::YAMLNodeStyle::Flow);
sfx.second.get().write(w);
}
@ -665,9 +657,9 @@ std::vector<uint8_t> AudioGroupProject::toYAML() const {
if (!m_songGroups.empty()) {
if (auto __v = w.enterSubRecord("songGroups")) {
for (const auto& p : SortUnorderedMap(m_songGroups)) {
char groupString[64];
snprintf(groupString, 64, "%s/0x%04X", GroupId::CurNameDB->resolveNameFromId(p.first).data(), int(p.first.id));
if (auto __r = w.enterSubRecord(groupString)) {
std::string groupString = fmt::format(fmt("{}/0x{}"),
GroupId::CurNameDB->resolveNameFromId(p.first), p.first);
if (auto __r = w.enterSubRecord(groupString.c_str())) {
p.second.get()->toYAML(w);
}
}
@ -677,9 +669,9 @@ std::vector<uint8_t> AudioGroupProject::toYAML() const {
if (!m_sfxGroups.empty()) {
if (auto __v = w.enterSubRecord("sfxGroups")) {
for (const auto& p : SortUnorderedMap(m_sfxGroups)) {
char groupString[64];
snprintf(groupString, 64, "%s/0x%04X", GroupId::CurNameDB->resolveNameFromId(p.first).data(), int(p.first.id));
if (auto __r = w.enterSubRecord(groupString)) {
std::string groupString = fmt::format(fmt("{}/0x{}"),
GroupId::CurNameDB->resolveNameFromId(p.first), p.first);
if (auto __r = w.enterSubRecord(groupString.c_str())) {
p.second.get()->toYAML(w);
}
}

View File

@ -49,7 +49,7 @@ bool Copy(const SystemChar* from, const SystemChar* to) {
template <> \
template <> \
void type##DNA<athena::Little>::Enumerate<BigDNA::Write>(athena::io::IStreamWriter & writer) { \
writer.writeUint16Little(id); \
writer.writeUint16Little(id.id); \
} \
template <> \
template <> \
@ -74,7 +74,7 @@ bool Copy(const SystemChar* from, const SystemChar* to) {
template <> \
template <> \
void type##DNA<athena::Big>::Enumerate<BigDNA::Write>(athena::io::IStreamWriter & writer) { \
writer.writeUint16Big(id); \
writer.writeUint16Big(id.id); \
} \
template <> \
template <> \
@ -95,7 +95,7 @@ bool Copy(const SystemChar* from, const SystemChar* to) {
void type##DNA<DNAE>::_read(athena::io::YAMLDocReader& r) { \
std::string name = r.readString(nullptr); \
if (!type::CurNameDB) \
Log.report(logvisor::Fatal, "Unable to resolve " typeName " name %s, no database present", name.c_str()); \
Log.report(logvisor::Fatal, fmt("Unable to resolve " typeName " name {}, no database present"), name); \
if (name.empty()) { \
id.id = 0xffff; \
return; \
@ -105,7 +105,7 @@ bool Copy(const SystemChar* from, const SystemChar* to) {
template <athena::Endian DNAE> \
void type##DNA<DNAE>::_write(athena::io::YAMLDocWriter& w) { \
if (!type::CurNameDB) \
Log.report(logvisor::Fatal, "Unable to resolve " typeName " ID %d, no database present", id.id); \
Log.report(logvisor::Fatal, fmt("Unable to resolve " typeName " ID {}, no database present"), id); \
if (id.id == 0xffff) \
return; \
std::string_view name = type::CurNameDB->resolveNameFromId(id); \
@ -137,7 +137,7 @@ void PageObjectIdDNA<athena::Little>::Enumerate<BigDNA::Read>(athena::io::IStrea
template <>
template <>
void PageObjectIdDNA<athena::Little>::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
writer.writeUint16Little(id);
writer.writeUint16Little(id.id);
}
template <>
template <>
@ -162,7 +162,7 @@ void PageObjectIdDNA<athena::Big>::Enumerate<BigDNA::Read>(athena::io::IStreamRe
template <>
template <>
void PageObjectIdDNA<athena::Big>::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
writer.writeUint16Big(id);
writer.writeUint16Big(id.id);
}
template <>
template <>
@ -183,7 +183,7 @@ template <athena::Endian DNAE>
void PageObjectIdDNA<DNAE>::_read(athena::io::YAMLDocReader& r) {
std::string name = r.readString(nullptr);
if (!KeymapId::CurNameDB || !LayersId::CurNameDB)
Log.report(logvisor::Fatal, "Unable to resolve keymap or layers name %s, no database present", name.c_str());
Log.report(logvisor::Fatal, fmt("Unable to resolve keymap or layers name {}, no database present"), name);
if (name.empty()) {
id.id = 0xffff;
return;
@ -194,7 +194,7 @@ void PageObjectIdDNA<DNAE>::_read(athena::io::YAMLDocReader& r) {
if (search == LayersId::CurNameDB->m_stringToId.cend()) {
search = SoundMacroId::CurNameDB->m_stringToId.find(name);
if (search == SoundMacroId::CurNameDB->m_stringToId.cend()) {
Log.report(logvisor::Error, "Unable to resolve name %s", name.c_str());
Log.report(logvisor::Error, fmt("Unable to resolve name {}"), name);
id.id = 0xffff;
return;
}
@ -205,7 +205,7 @@ void PageObjectIdDNA<DNAE>::_read(athena::io::YAMLDocReader& r) {
template <athena::Endian DNAE>
void PageObjectIdDNA<DNAE>::_write(athena::io::YAMLDocWriter& w) {
if (!KeymapId::CurNameDB || !LayersId::CurNameDB)
Log.report(logvisor::Fatal, "Unable to resolve keymap or layers ID %d, no database present", id.id);
Log.report(logvisor::Fatal, fmt("Unable to resolve keymap or layers ID {}, no database present"), id);
if (id.id == 0xffff)
return;
if (id.id & 0x8000) {
@ -293,43 +293,32 @@ ObjectId NameDB::generateId(Type tp) const {
else if (tp == Type::Keymap)
maxMatch = 0x4000;
for (const auto& p : m_idToString)
if (p.first >= maxMatch)
maxMatch = p.first + 1;
if (p.first.id >= maxMatch)
maxMatch = p.first.id + 1;
return maxMatch;
}
std::string NameDB::generateName(ObjectId id, Type tp) {
char name[32];
switch (tp) {
case Type::SoundMacro:
snprintf(name, 32, "macro%04X", id.id);
break;
return fmt::format(fmt("macro{}"), id);
case Type::Table:
snprintf(name, 32, "table%04X", id.id);
break;
return fmt::format(fmt("table{}"), id);
case Type::Keymap:
snprintf(name, 32, "keymap%04X", id.id);
break;
return fmt::format(fmt("keymap{}"), id);
case Type::Layer:
snprintf(name, 32, "layers%04X", id.id);
break;
return fmt::format(fmt("layers{}"), id);
case Type::Song:
snprintf(name, 32, "song%04X", id.id);
break;
return fmt::format(fmt("song{}"), id);
case Type::SFX:
snprintf(name, 32, "sfx%04X", id.id);
break;
return fmt::format(fmt("sfx{}"), id);
case Type::Group:
snprintf(name, 32, "group%04X", id.id);
break;
return fmt::format(fmt("group{}"), id);
case Type::Sample:
snprintf(name, 32, "sample%04X", id.id);
break;
return fmt::format(fmt("sample{}"), id);
default:
snprintf(name, 32, "obj%04X", id.id);
break;
return fmt::format(fmt("obj{}"), id);
}
return name;
}
std::string NameDB::generateDefaultName(Type tp) const { return generateName(generateId(tp), tp); }
@ -342,7 +331,7 @@ std::string_view NameDB::registerPair(std::string_view str, ObjectId id) {
std::string_view NameDB::resolveNameFromId(ObjectId id) const {
auto search = m_idToString.find(id);
if (search == m_idToString.cend()) {
Log.report(logvisor::Error, "Unable to resolve ID 0x%04X", id.id);
Log.report(logvisor::Error, fmt("Unable to resolve ID {}"), id);
return ""sv;
}
return search->second;
@ -351,7 +340,7 @@ std::string_view NameDB::resolveNameFromId(ObjectId id) const {
ObjectId NameDB::resolveIdFromName(std::string_view str) const {
auto search = m_stringToId.find(std::string(str));
if (search == m_stringToId.cend()) {
Log.report(logvisor::Error, "Unable to resolve name %s", str.data());
Log.report(logvisor::Error, fmt("Unable to resolve name {}"), str);
return {};
}
return search->second;

View File

@ -425,9 +425,8 @@ static std::vector<std::pair<SystemString, ContainerRegistry::SongData>> LoadMP1
ret.emplace_back(std::move(search->second),
ContainerRegistry::SongData(std::move(song), sonLength, groupId, midiSetup));
else {
SystemChar name[128];
SNPrintf(name, 128, _SYS_STR("%08X"), id);
ret.emplace_back(name, ContainerRegistry::SongData(std::move(song), sonLength, groupId, midiSetup));
SystemString name = fmt::format(fmt(_SYS_STR("{:08X}")), id);
ret.emplace_back(std::move(name), ContainerRegistry::SongData(std::move(song), sonLength, groupId, midiSetup));
}
FSeek(fp, origPos, SEEK_SET);
@ -1345,11 +1344,11 @@ static std::vector<std::pair<SystemString, IntrusiveAudioGroupData>> LoadRS2(FIL
memmove(samp.get(), audData.get() + head.sampOff, head.sampLen);
if (head.projLen && head.poolLen && head.sdirLen && head.sampLen) {
SystemChar name[128];
SNPrintf(name, 128, _SYS_STR("GroupFile%02u"), j);
ret.emplace_back(name, IntrusiveAudioGroupData{proj.release(), head.projLen, pool.release(), head.poolLen,
sdir.release(), head.sdirLen, samp.release(), head.sampLen,
GCNDataTag{}});
SystemString name = fmt::format(fmt(_SYS_STR("GroupFile{:02d}")), j);
ret.emplace_back(std::move(name),
IntrusiveAudioGroupData{proj.release(), head.projLen, pool.release(), head.poolLen,
sdir.release(), head.sdirLen, samp.release(), head.sampLen,
GCNDataTag{}});
}
}
@ -1401,12 +1400,11 @@ static std::vector<std::pair<SystemString, ContainerRegistry::SongData>> LoadRS2
RS23SONHead sonHead = sonData[s];
sonHead.swapBig();
SystemChar name[128];
SNPrintf(name, 128, _SYS_STR("GroupFile%02u-%u"), j, s);
SystemString name = fmt::format(fmt(_SYS_STR("GroupFile{:02d}-{}")), j, s);
std::unique_ptr<uint8_t[]> song(new uint8_t[sonHead.length]);
memmove(song.get(), audData.get() + sonHead.offset, sonHead.length);
ret.emplace_back(
name, ContainerRegistry::SongData(std::move(song), sonHead.length, sonHead.groupId, sonHead.setupId));
ret.emplace_back(std::move(name),
ContainerRegistry::SongData(std::move(song), sonHead.length, sonHead.groupId, sonHead.setupId));
}
}
@ -1505,11 +1503,11 @@ static std::vector<std::pair<SystemString, IntrusiveAudioGroupData>> LoadRS3(FIL
memmove(samp.get(), audData.get() + head.sampOff, head.sampLen);
if (head.projLen && head.poolLen && head.sdirLen && head.sampLen) {
SystemChar name[128];
SNPrintf(name, 128, _SYS_STR("GroupFile%02u"), j);
ret.emplace_back(name, IntrusiveAudioGroupData{proj.release(), head.projLen, pool.release(), head.poolLen,
sdir.release(), head.sdirLen, samp.release(), head.sampLen,
GCNDataTag{}});
SystemString name = fmt::format(fmt(_SYS_STR("GroupFile{:02d}")), j);
ret.emplace_back(std::move(name),
IntrusiveAudioGroupData{proj.release(), head.projLen, pool.release(), head.poolLen,
sdir.release(), head.sdirLen, samp.release(), head.sampLen,
GCNDataTag{}});
}
}
@ -1568,11 +1566,10 @@ static std::vector<std::pair<SystemString, ContainerRegistry::SongData>> LoadSta
if (len == 0)
break;
SystemChar name[128];
SNPrintf(name, 128, _SYS_STR("Song%u"), unsigned(i));
SystemString name = fmt::format(fmt(_SYS_STR("Song{}")), unsigned(i));
std::unique_ptr<uint8_t[]> song(new uint8_t[len]);
memmove(song.get(), data.get() + cur, len);
ret.emplace_back(name, ContainerRegistry::SongData(std::move(song), len, -1, i));
ret.emplace_back(std::move(name), ContainerRegistry::SongData(std::move(song), len, -1, i));
cur += len;
cur = ((cur + 31) & ~31);
@ -1648,47 +1645,47 @@ ContainerRegistry::Type ContainerRegistry::DetectContainerType(const SystemChar*
/* See if provided file is one of four raw chunks */
const SystemChar* dot = nullptr;
if (IsChunkExtension(path, dot)) {
SystemChar newpath[1024];
SystemString newpath;
/* Project */
SNPrintf(newpath, 1024, _SYS_STR("%.*s.pro"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.pro")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(newpath, 1024, _SYS_STR("%.*s.proj"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.proj")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp)
return Type::Invalid;
}
fclose(fp);
/* Pool */
SNPrintf(newpath, 1024, _SYS_STR("%.*s.poo"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.poo")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(newpath, 1024, _SYS_STR("%.*s.pool"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.pool")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp)
return Type::Invalid;
}
fclose(fp);
/* Sample Directory */
SNPrintf(newpath, 1024, _SYS_STR("%.*s.sdi"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.sdi")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(newpath, 1024, _SYS_STR("%.*s.sdir"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.sdir")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp)
return Type::Invalid;
}
fclose(fp);
/* Sample */
SNPrintf(newpath, 1024, _SYS_STR("%.*s.sam"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.sam")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(newpath, 1024, _SYS_STR("%.*s.samp"), int(dot - path), path);
fp = FOpen(newpath, _SYS_STR("rb"));
newpath = fmt::format(fmt(_SYS_STR("{:.{}}.samp")), path, int(dot - path));
fp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (!fp)
return Type::Invalid;
}
@ -1763,75 +1760,75 @@ std::vector<std::pair<SystemString, IntrusiveAudioGroupData>> ContainerRegistry:
baseName = SystemString(path, dot - path);
/* Project */
SystemChar projPath[1024];
SNPrintf(projPath, 1024, _SYS_STR("%.*s.pro"), int(dot - path), path);
fp = FOpen(projPath, _SYS_STR("rb"));
SystemString projPath;
projPath = fmt::format(fmt(_SYS_STR("{:.{}}.pro")), path, int(dot - path));
fp = FOpen(projPath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(projPath, 1024, _SYS_STR("%.*s.proj"), int(dot - path), path);
fp = FOpen(projPath, _SYS_STR("rb"));
projPath = fmt::format(fmt(_SYS_STR("{:.{}}.proj")), path, int(dot - path));
fp = FOpen(projPath.c_str(), _SYS_STR("rb"));
if (!fp)
return ret;
}
fclose(fp);
/* Pool */
SystemChar poolPath[1024];
SNPrintf(poolPath, 1024, _SYS_STR("%.*s.poo"), int(dot - path), path);
fp = FOpen(poolPath, _SYS_STR("rb"));
SystemString poolPath;
poolPath = fmt::format(fmt(_SYS_STR("{:.{}}.poo")), path, int(dot - path));
fp = FOpen(poolPath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(poolPath, 1024, _SYS_STR("%.*s.pool"), int(dot - path), path);
fp = FOpen(poolPath, _SYS_STR("rb"));
poolPath = fmt::format(fmt(_SYS_STR("{:.{}}.pool")), path, int(dot - path));
fp = FOpen(poolPath.c_str(), _SYS_STR("rb"));
if (!fp)
return ret;
}
fclose(fp);
/* Sample Directory */
SystemChar sdirPath[1024];
SNPrintf(sdirPath, 1024, _SYS_STR("%.*s.sdi"), int(dot - path), path);
fp = FOpen(sdirPath, _SYS_STR("rb"));
SystemString sdirPath;
sdirPath = fmt::format(fmt(_SYS_STR("{:.{}}.sdi")), path, int(dot - path));
fp = FOpen(sdirPath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(sdirPath, 1024, _SYS_STR("%.*s.sdir"), int(dot - path), path);
fp = FOpen(sdirPath, _SYS_STR("rb"));
sdirPath = fmt::format(fmt(_SYS_STR("{:.{}}.sdir")), path, int(dot - path));
fp = FOpen(sdirPath.c_str(), _SYS_STR("rb"));
if (!fp)
return ret;
}
fclose(fp);
/* Sample */
SystemChar sampPath[1024];
SNPrintf(sampPath, 1024, _SYS_STR("%.*s.sam"), int(dot - path), path);
fp = FOpen(sampPath, _SYS_STR("rb"));
SystemString sampPath;
sampPath = fmt::format(fmt(_SYS_STR("{:.{}}.sam")), path, int(dot - path));
fp = FOpen(sampPath.c_str(), _SYS_STR("rb"));
if (!fp) {
SNPrintf(sampPath, 1024, _SYS_STR("%.*s.samp"), int(dot - path), path);
fp = FOpen(sampPath, _SYS_STR("rb"));
sampPath = fmt::format(fmt(_SYS_STR("{:.{}}.samp")), path, int(dot - path));
fp = FOpen(sampPath.c_str(), _SYS_STR("rb"));
if (!fp)
return ret;
}
fclose(fp);
fp = FOpen(projPath, _SYS_STR("rb"));
fp = FOpen(projPath.c_str(), _SYS_STR("rb"));
size_t projLen = FileLength(fp);
if (!projLen)
return ret;
std::unique_ptr<uint8_t[]> proj(new uint8_t[projLen]);
fread(proj.get(), 1, projLen, fp);
fp = FOpen(poolPath, _SYS_STR("rb"));
fp = FOpen(poolPath.c_str(), _SYS_STR("rb"));
size_t poolLen = FileLength(fp);
if (!poolLen)
return ret;
std::unique_ptr<uint8_t[]> pool(new uint8_t[poolLen]);
fread(pool.get(), 1, poolLen, fp);
fp = FOpen(sdirPath, _SYS_STR("rb"));
fp = FOpen(sdirPath.c_str(), _SYS_STR("rb"));
size_t sdirLen = FileLength(fp);
if (!sdirLen)
return ret;
std::unique_ptr<uint8_t[]> sdir(new uint8_t[sdirLen]);
fread(sdir.get(), 1, sdirLen, fp);
fp = FOpen(sampPath, _SYS_STR("rb"));
fp = FOpen(sampPath.c_str(), _SYS_STR("rb"));
size_t sampLen = FileLength(fp);
if (!sampLen)
return ret;
@ -1978,10 +1975,9 @@ std::vector<std::pair<SystemString, ContainerRegistry::SongData>> ContainerRegis
if (ValidatePaperMarioTTYDSongs(fp)) {
/* Song Description */
SystemChar newpath[1024];
dot = StrRChr(path, _SYS_STR('.'));
SNPrintf(newpath, 1024, _SYS_STR("%.*s.stbl"), int(dot - path), path);
FILE* descFp = FOpen(newpath, _SYS_STR("rb"));
SystemString newpath = fmt::format(fmt(_SYS_STR("{:.{}}.stbl")), path, int(dot - path));
FILE* descFp = FOpen(newpath.c_str(), _SYS_STR("rb"));
if (descFp) {
auto ret = LoadPaperMarioTTYDSongs(fp, descFp);
fclose(fp);

View File

@ -163,7 +163,7 @@ unsigned DSPDecompressFrameRangedStateOnly(const uint8_t* in, const int16_t coef
*/
typedef double tvec[3];
static inline void InnerProductMerge(tvec vecOut, short pcmBuf[14]) {
inline void InnerProductMerge(tvec vecOut, short pcmBuf[14]) {
for (int i = 0; i <= 2; i++) {
vecOut[i] = 0.0f;
for (int x = 0; x < 14; x++)
@ -171,7 +171,7 @@ static inline void InnerProductMerge(tvec vecOut, short pcmBuf[14]) {
}
}
static inline void OuterProductMerge(tvec mtxOut[3], short pcmBuf[14]) {
inline void OuterProductMerge(tvec mtxOut[3], short pcmBuf[14]) {
for (int x = 1; x <= 2; x++)
for (int y = 1; y <= 2; y++) {
mtxOut[x][y] = 0.0;

View File

@ -61,7 +61,7 @@ Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, c
Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, const SFXGroupIndex* sfxGroup,
ObjToken<Studio> studio)
: Entity(engine, group, groupId), m_sfxGroup(sfxGroup), m_studio(studio) {
std::map<uint16_t, const SFXGroupIndex::SFXEntry*> sortSFX;
std::map<ObjectId, const SFXGroupIndex::SFXEntry*> sortSFX;
for (const auto& sfx : sfxGroup->m_sfxEntries)
sortSFX[sfx.first] = &sfx.second;
@ -354,9 +354,9 @@ void Sequencer::setCtrlValue(uint8_t chan, uint8_t ctrl, int8_t val) {
return;
if (ctrl == 0x66) {
printf("Loop Start\n");
fmt::print(fmt("Loop Start\n"));
} else if (ctrl == 0x67) {
printf("Loop End\n");
fmt::print(fmt("Loop End\n"));
}
if (!m_chanStates[chan])

View File

@ -6,7 +6,7 @@
namespace amuse {
static inline uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
constexpr uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
enum class Status {
NoteOff = 0x80,

View File

@ -41,12 +41,12 @@ Voice::~Voice() {
// fprintf(stderr, "DEALLOC %d\n", m_vid);
}
Voice::Voice(Engine& engine, const AudioGroup& group, int groupId, int vid, bool emitter, ObjToken<Studio> studio)
Voice::Voice(Engine& engine, const AudioGroup& group, GroupId groupId, int vid, bool emitter, ObjToken<Studio> studio)
: Entity(engine, group, groupId), m_vid(vid), m_emitter(emitter), m_studio(studio) {
// fprintf(stderr, "ALLOC %d\n", m_vid);
}
Voice::Voice(Engine& engine, const AudioGroup& group, int groupId, ObjectId oid, int vid, bool emitter,
Voice::Voice(Engine& engine, const AudioGroup& group, GroupId groupId, ObjectId oid, int vid, bool emitter,
ObjToken<Studio> studio)
: Entity(engine, group, groupId, oid), m_vid(vid), m_emitter(emitter), m_studio(studio) {
// fprintf(stderr, "ALLOC %d\n", m_vid);