Bug fixes for MP2 extraction

This commit is contained in:
Jack Andersen 2018-09-02 14:43:05 -10:00
parent 9cc4bdefd0
commit 6a7f32a29d
16 changed files with 334 additions and 199 deletions

View File

@ -717,8 +717,20 @@ bool ProjectModel::importGroupData(const QString& groupName, const amuse::AudioG
break;
}
grp.getProj().toYAML(sysDir);
grp.getPool().toYAML(sysDir);
{
auto proj = grp.getProj().toYAML();
athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!project.yaml")).filePath()));
if (fo.hasError())
return false;
fo.writeUBytes(proj.data(), proj.size());
}
{
auto pool = grp.getPool().toYAML();
athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!pool.yaml")).filePath()));
if (fo.hasError())
return false;
fo.writeUBytes(pool.data(), pool.size());
}
m_needsReset = true;
return true;
@ -756,9 +768,21 @@ bool ProjectModel::saveToFile(UIMessenger& messenger)
return false;
g.second->setIdDatabases();
amuse::SystemString groupPath = QStringToSysString(dir.path());
g.second->getProj().toYAML(groupPath);
g.second->getPool().toYAML(groupPath);
{
auto proj = g.second->getProj().toYAML();
athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!project.yaml")).filePath()));
if (fo.hasError())
return false;
fo.writeUBytes(proj.data(), proj.size());
}
{
auto pool = g.second->getPool().toYAML();
athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!pool.yaml")).filePath()));
if (fo.hasError())
return false;
fo.writeUBytes(pool.data(), pool.size());
}
}
saveSongsIndex();
@ -780,6 +804,8 @@ QStringList ProjectModel::getGroupList() const
bool ProjectModel::exportGroup(const QString& path, const QString& groupName, UIMessenger& messenger) const
{
if (!MkPath(path, messenger))
return false;
auto search = m_groups.find(groupName);
if (search == m_groups.cend())
{
@ -788,22 +814,48 @@ bool ProjectModel::exportGroup(const QString& path, const QString& groupName, UI
}
const amuse::AudioGroupDatabase& group = *search->second;
m_projectDatabase.setIdDatabases();
auto basePath = QStringToSysString(QFileInfo(QDir(path), groupName).filePath());
QString basePath = QFileInfo(QDir(path), groupName).filePath();
group.setIdDatabases();
if (!group.getProj().toGCNData(basePath, group.getPool(), group.getSdir()))
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.proj").arg(groupName));
return false;
auto proj = group.getProj().toGCNData(group.getPool(), group.getSdir());
athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".proj")));
if (fo.hasError())
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.proj").arg(groupName));
return false;
}
fo.writeUBytes(proj.data(), proj.size());
}
if (!group.getPool().toData<athena::Big>(basePath))
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.pool").arg(groupName));
return false;
auto pool = group.getPool().toData<athena::Big>();
athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".pool")));
if (fo.hasError())
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.pool").arg(groupName));
return false;
}
fo.writeUBytes(pool.data(), pool.size());
}
if (!group.getSdir().toGCNData(basePath, group))
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.sdir").arg(groupName));
return false;
auto sdirSamp = group.getSdir().toGCNData(group);
{
athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".sdir")));
if (fo.hasError())
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.sdir").arg(groupName));
return false;
}
fo.writeUBytes(sdirSamp.first.data(), sdirSamp.first.size());
}
{
athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".samp")));
if (fo.hasError())
{
messenger.critical(tr("Export Error"), tr("Unable to export %1.samp").arg(groupName));
return false;
}
fo.writeUBytes(sdirSamp.second.data(), sdirSamp.second.size());
}
}
return true;
}

View File

@ -1273,7 +1273,6 @@ void PageTableView::setModel(QAbstractItemModel* model)
PageTableView::PageTableView(QWidget* parent)
: QTableView(parent)
{
setObjectName("amusetable");
setSelectionBehavior(QAbstractItemView::SelectRows);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setGridStyle(Qt::NoPen);

View File

@ -503,11 +503,11 @@ void CommandWidget::paintEvent(QPaintEvent* event)
painter.drawRect(17, 51, 32, 32);
QTransform rotate;
rotate.rotate(-45.0);
rotate.rotate(-45.0).translate(-15, 8);
painter.setTransform(rotate);
painter.setFont(m_numberFont);
painter.setPen(palette().color(QPalette::Background));
painter.drawStaticText(-15, 10, m_numberText);
painter.drawStaticText(0, 0, m_numberText);
}
void CommandWidgetContainer::animateOpen()

View File

@ -468,11 +468,11 @@ void EffectWidget::paintEvent(QPaintEvent* event)
painter.drawRect(17, 51, 32, 32);
QTransform rotate;
rotate.rotate(-45.0);
rotate.rotate(-45.0).translate(-15, 8);
painter.setTransform(rotate);
painter.setFont(m_numberFont);
painter.setPen(palette().color(QPalette::Background));
painter.drawStaticText(-15, 10, m_numberText);
painter.drawStaticText(0, 0, m_numberText);
}
EffectWidget::EffectWidget(QWidget* parent, amuse::EffectBaseTypeless* cmd)

View File

@ -58,6 +58,7 @@ MainWindow* g_MainWindow = nullptr;
int main(int argc, char* argv[])
{
QApplication::setAttribute(Qt::AA_Use96Dpi);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);

View File

@ -427,13 +427,13 @@
<context>
<name>MIDIPlayerWidget</name>
<message>
<location filename="../SongGroupEditor.cpp" line="1400"/>
<location filename="../SongGroupEditor.cpp" line="1399"/>
<source>Stop</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1414"/>
<location filename="../SongGroupEditor.cpp" line="1449"/>
<location filename="../SongGroupEditor.cpp" line="1413"/>
<location filename="../SongGroupEditor.cpp" line="1448"/>
<source>Play</source>
<translation type="unfinished"></translation>
</message>
@ -1221,335 +1221,341 @@
<context>
<name>ProjectModel</name>
<message>
<location filename="../ProjectModel.cpp" line="786"/>
<location filename="../ProjectModel.cpp" line="795"/>
<location filename="../ProjectModel.cpp" line="800"/>
<location filename="../ProjectModel.cpp" line="805"/>
<location filename="../ProjectModel.cpp" line="812"/>
<location filename="../ProjectModel.cpp" line="824"/>
<location filename="../ProjectModel.cpp" line="834"/>
<location filename="../ProjectModel.cpp" line="845"/>
<location filename="../ProjectModel.cpp" line="854"/>
<location filename="../ProjectModel.cpp" line="897"/>
<source>Export Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="786"/>
<location filename="../ProjectModel.cpp" line="817"/>
<location filename="../ProjectModel.cpp" line="845"/>
<location filename="../ProjectModel.cpp" line="812"/>
<location filename="../ProjectModel.cpp" line="869"/>
<location filename="../ProjectModel.cpp" line="897"/>
<source>Unable to find group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="795"/>
<location filename="../ProjectModel.cpp" line="824"/>
<source>Unable to export %1.proj</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="800"/>
<location filename="../ProjectModel.cpp" line="834"/>
<source>Unable to export %1.pool</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="805"/>
<location filename="../ProjectModel.cpp" line="845"/>
<source>Unable to export %1.sdir</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="817"/>
<location filename="../ProjectModel.cpp" line="854"/>
<source>Unable to export %1.samp</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="869"/>
<source>Import Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="828"/>
<location filename="../ProjectModel.cpp" line="880"/>
<source>Export Header Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="828"/>
<location filename="../ProjectModel.cpp" line="880"/>
<source>Unable to open %1 for reading</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="852"/>
<location filename="../ProjectModel.cpp" line="904"/>
<source>File Exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="853"/>
<location filename="../ProjectModel.cpp" line="905"/>
<source>%1 already exists. Overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="912"/>
<location filename="../ProjectModel.cpp" line="964"/>
<source>Sound Macros</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="913"/>
<location filename="../ProjectModel.cpp" line="965"/>
<source>ADSRs</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="914"/>
<location filename="../ProjectModel.cpp" line="966"/>
<source>Curves</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="915"/>
<location filename="../ProjectModel.cpp" line="967"/>
<source>Keymaps</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="916"/>
<location filename="../ProjectModel.cpp" line="968"/>
<source>Layers</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="917"/>
<location filename="../ProjectModel.cpp" line="969"/>
<source>Samples</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1200"/>
<location filename="../ProjectModel.cpp" line="1252"/>
<source>Naming Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1201"/>
<location filename="../ProjectModel.cpp" line="1253"/>
<source>%1 already exists in this context</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1205"/>
<location filename="../ProjectModel.cpp" line="1257"/>
<source>Rename %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1337"/>
<location filename="../ProjectModel.cpp" line="1389"/>
<source>Subproject Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1337"/>
<location filename="../ProjectModel.cpp" line="1389"/>
<source>The subproject %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1344"/>
<location filename="../ProjectModel.cpp" line="1952"/>
<location filename="../ProjectModel.cpp" line="2085"/>
<location filename="../ProjectModel.cpp" line="1396"/>
<location filename="../ProjectModel.cpp" line="2004"/>
<location filename="../ProjectModel.cpp" line="2137"/>
<source>Add Subproject %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1436"/>
<location filename="../ProjectModel.cpp" line="1488"/>
<source>Sound Group Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1436"/>
<location filename="../ProjectModel.cpp" line="1461"/>
<location filename="../ProjectModel.cpp" line="1488"/>
<location filename="../ProjectModel.cpp" line="1513"/>
<source>The group %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1440"/>
<location filename="../ProjectModel.cpp" line="1786"/>
<location filename="../ProjectModel.cpp" line="2093"/>
<location filename="../ProjectModel.cpp" line="1492"/>
<location filename="../ProjectModel.cpp" line="1838"/>
<location filename="../ProjectModel.cpp" line="2145"/>
<source>Add Sound Group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1461"/>
<location filename="../ProjectModel.cpp" line="1513"/>
<source>Song Group Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1465"/>
<location filename="../ProjectModel.cpp" line="1777"/>
<location filename="../ProjectModel.cpp" line="2101"/>
<location filename="../ProjectModel.cpp" line="1517"/>
<location filename="../ProjectModel.cpp" line="1829"/>
<location filename="../ProjectModel.cpp" line="2153"/>
<source>Add Song Group %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1559"/>
<location filename="../ProjectModel.cpp" line="1611"/>
<source>Sound Macro Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1559"/>
<location filename="../ProjectModel.cpp" line="1611"/>
<source>The macro %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1569"/>
<location filename="../ProjectModel.cpp" line="2111"/>
<location filename="../ProjectModel.cpp" line="1621"/>
<location filename="../ProjectModel.cpp" line="2163"/>
<source>Add Sound Macro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1590"/>
<location filename="../ProjectModel.cpp" line="1642"/>
<source>ADSR Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1590"/>
<location filename="../ProjectModel.cpp" line="1642"/>
<source>The ADSR %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1596"/>
<location filename="../ProjectModel.cpp" line="1816"/>
<location filename="../ProjectModel.cpp" line="2119"/>
<location filename="../ProjectModel.cpp" line="1648"/>
<location filename="../ProjectModel.cpp" line="1868"/>
<location filename="../ProjectModel.cpp" line="2171"/>
<source>Add ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1617"/>
<location filename="../ProjectModel.cpp" line="1669"/>
<source>Curve Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1617"/>
<location filename="../ProjectModel.cpp" line="1669"/>
<source>The Curve %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1623"/>
<location filename="../ProjectModel.cpp" line="1825"/>
<location filename="../ProjectModel.cpp" line="2127"/>
<location filename="../ProjectModel.cpp" line="1675"/>
<location filename="../ProjectModel.cpp" line="1877"/>
<location filename="../ProjectModel.cpp" line="2179"/>
<source>Add Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1644"/>
<location filename="../ProjectModel.cpp" line="1696"/>
<source>Keymap Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1644"/>
<location filename="../ProjectModel.cpp" line="1696"/>
<source>The Keymap %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1649"/>
<location filename="../ProjectModel.cpp" line="1844"/>
<location filename="../ProjectModel.cpp" line="2135"/>
<location filename="../ProjectModel.cpp" line="1701"/>
<location filename="../ProjectModel.cpp" line="1896"/>
<location filename="../ProjectModel.cpp" line="2187"/>
<source>Add Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1670"/>
<location filename="../ProjectModel.cpp" line="1722"/>
<source>Layers Conflict</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1670"/>
<location filename="../ProjectModel.cpp" line="1722"/>
<source>Layers %1 is already defined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1675"/>
<location filename="../ProjectModel.cpp" line="1864"/>
<location filename="../ProjectModel.cpp" line="2143"/>
<location filename="../ProjectModel.cpp" line="1727"/>
<location filename="../ProjectModel.cpp" line="1916"/>
<location filename="../ProjectModel.cpp" line="2195"/>
<source>Add Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1681"/>
<location filename="../ProjectModel.cpp" line="1691"/>
<location filename="../ProjectModel.cpp" line="1733"/>
<location filename="../ProjectModel.cpp" line="1743"/>
<source>-copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="1797"/>
<location filename="../ProjectModel.cpp" line="1849"/>
<source>Add SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2010"/>
<location filename="../ProjectModel.cpp" line="2062"/>
<source>Cut SongGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2013"/>
<location filename="../ProjectModel.cpp" line="2065"/>
<source>Cut SFXGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2016"/>
<location filename="../ProjectModel.cpp" line="2068"/>
<source>Cut SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2019"/>
<location filename="../ProjectModel.cpp" line="2071"/>
<source>Cut ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2022"/>
<location filename="../ProjectModel.cpp" line="2074"/>
<source>Cut Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2025"/>
<location filename="../ProjectModel.cpp" line="2077"/>
<source>Cut Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2028"/>
<location filename="../ProjectModel.cpp" line="2080"/>
<source>Cut Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2166"/>
<location filename="../ProjectModel.cpp" line="2218"/>
<source>Delete Subproject</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2167"/>
<location filename="../ProjectModel.cpp" line="2219"/>
<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="2180"/>
<location filename="../ProjectModel.cpp" line="2232"/>
<source>Delete SongGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2183"/>
<location filename="../ProjectModel.cpp" line="2235"/>
<source>Delete SFXGroup %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2186"/>
<location filename="../ProjectModel.cpp" line="2238"/>
<source>Delete SoundMacro %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2189"/>
<location filename="../ProjectModel.cpp" line="2241"/>
<source>Delete ADSR %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2192"/>
<location filename="../ProjectModel.cpp" line="2244"/>
<source>Delete Curve %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2195"/>
<location filename="../ProjectModel.cpp" line="2247"/>
<source>Delete Keymap %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2198"/>
<location filename="../ProjectModel.cpp" line="2250"/>
<source>Delete Layers %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2202"/>
<location filename="../ProjectModel.cpp" line="2254"/>
<source>Delete Sample</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ProjectModel.cpp" line="2203"/>
<location filename="../ProjectModel.cpp" line="2255"/>
<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>
@ -1803,12 +1809,12 @@
<context>
<name>SetupTableView</name>
<message>
<location filename="../SongGroupEditor.cpp" line="1322"/>
<location filename="../SongGroupEditor.cpp" line="1321"/>
<source>Delete Setup Entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1322"/>
<location filename="../SongGroupEditor.cpp" line="1321"/>
<source>Delete Setup Entry</source>
<translation type="unfinished"></translation>
</message>
@ -1816,37 +1822,37 @@
<context>
<name>SongGroupEditor</name>
<message>
<location filename="../SongGroupEditor.cpp" line="1520"/>
<location filename="../SongGroupEditor.cpp" line="1519"/>
<source>Add Page Entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1532"/>
<location filename="../SongGroupEditor.cpp" line="1531"/>
<source>Add Setup Entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1713"/>
<location filename="../SongGroupEditor.cpp" line="1712"/>
<source>Normal Pages</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1714"/>
<location filename="../SongGroupEditor.cpp" line="1713"/>
<source>Drum Pages</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1715"/>
<location filename="../SongGroupEditor.cpp" line="1714"/>
<source>MIDI Setups</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1756"/>
<location filename="../SongGroupEditor.cpp" line="1755"/>
<source>Add new page entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../SongGroupEditor.cpp" line="1758"/>
<location filename="../SongGroupEditor.cpp" line="1757"/>
<source>Remove selected page entries</source>
<translation type="unfinished"></translation>
</message>

View File

@ -114,6 +114,8 @@ struct SoundMacro
ModeSelect = 0x58,
SetKeygroup,
SRCmodeSelect, /* unimplemented */
WiiUnknown = 0x5E,
WiiUnknown2 = 0x5F,
AddVars = 0x60,
SubVars,
MulVars,
@ -522,8 +524,8 @@ struct SoundMacro
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<atUint8> levelNote;
Value<atUint8> levelFine;
Value<atInt8> levelNote;
Value<atInt8> levelFine;
Value<bool> modwheelFlag;
Seek<1, athena::SeekOrigin::Current> seek;
Value<bool> msSwitch;
@ -1009,6 +1011,24 @@ struct SoundMacro
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::SRCmodeSelect; }
};
struct CmdWiiUnknown : ICmd
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> flag;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::WiiUnknown; }
};
struct CmdWiiUnknown2 : ICmd
{
AT_DECL_DNA_YAML
AT_DECL_DNAV
static const CmdIntrospection Introspective;
Value<bool> flag;
bool Do(SoundMacroState& st, Voice& vox) const;
CmdOp Isa() const { return CmdOp::WiiUnknown2; }
};
struct CmdAddVars : ICmd
{
AT_DECL_DNA_YAML
@ -1428,9 +1448,9 @@ public:
const ADSRDLS* tableAsAdsrDLS(ObjectId id) const;
const Curve* tableAsCurves(ObjectId id) const;
bool toYAML(SystemStringView groupPath) const;
std::vector<uint8_t> toYAML() const;
template <athena::Endian DNAE>
bool toData(SystemStringView groupPath) const;
std::vector<uint8_t> toData() const;
AudioGroupPool(const AudioGroupPool&) = delete;
AudioGroupPool& operator=(const AudioGroupPool&) = delete;

View File

@ -216,8 +216,8 @@ public:
std::unordered_map<GroupId, ObjToken<SongGroupIndex>>& songGroups() { return m_songGroups; }
std::unordered_map<GroupId, ObjToken<SFXGroupIndex>>& sfxGroups() { return m_sfxGroups; }
bool toYAML(SystemStringView groupPath) const;
bool toGCNData(SystemStringView groupPath, const AudioGroupPool& pool, const AudioGroupSampleDirectory& sdir) const;
std::vector<uint8_t> toYAML() const;
std::vector<uint8_t> toGCNData(const AudioGroupPool& pool, const AudioGroupSampleDirectory& sdir) const;
AudioGroupProject(const AudioGroupProject&) = delete;
AudioGroupProject& operator=(const AudioGroupProject&) = delete;

View File

@ -358,7 +358,7 @@ public:
void reloadSampleData(SystemStringView groupPath);
bool toGCNData(SystemStringView groupPath, const AudioGroupDatabase& group) const;
std::pair<std::vector<uint8_t>, std::vector<uint8_t>> toGCNData(const AudioGroupDatabase& group) const;
AudioGroupSampleDirectory(const AudioGroupSampleDirectory&) = delete;
AudioGroupSampleDirectory& operator=(const AudioGroupSampleDirectory&) = delete;

View File

@ -5,6 +5,7 @@
#include <cstdlib>
#include <memory>
#include <list>
#include <queue>
#include "SoundMacroState.hpp"
#include "Entity.hpp"
#include "AudioGroupSampleDirectory.hpp"
@ -53,6 +54,14 @@ class Voice : public Entity
float getCachedVolume() const { return m_curVolLUTVal; }
};
struct Panning
{
float m_time; /**< time of PANNING command */
float m_dur; /**< requested duration of PANNING command */
uint8_t m_pos; /**< initial pan value of PANNING command */
int8_t m_width; /**< delta pan value to target of PANNING command */
};
void _setObjectId(ObjectId id) { m_objectId = id; }
int m_vid; /**< VoiceID of this voice instance */
@ -129,15 +138,8 @@ class Voice : public Entity
uint8_t m_pitchSweep1It = 0; /**< Current iteration of PITCHSWEEP1 controller */
uint8_t m_pitchSweep2It = 0; /**< Current iteration of PITCHSWEEP2 controller */
float m_panningTime = -1.f; /**< time since last PANNING command, -1 for no active pan-sweep */
float m_panningDur; /**< requested duration of last PANNING command */
uint8_t m_panPos; /**< initial pan value of last PANNING command */
int8_t m_panWidth; /**< delta pan value to target of last PANNING command */
float m_spanningTime = -1.f; /**< time since last SPANNING command, -1 for no active span-sweep */
float m_spanningDur; /**< requested duration of last SPANNING command */
uint8_t m_spanPos; /**< initial pan value of last SPANNING command */
int8_t m_spanWidth; /**< delta pan value to target of last SPANNING command */
std::queue<Panning> m_panningQueue; /**< Queue of PANNING commands */
std::queue<Panning> m_spanningQueue; /**< Queue of SPANNING commands */
float m_vibratoTime = -1.f; /**< time since last VIBRATO command, -1 for no active vibrato */
int32_t m_vibratoLevel = 0; /**< scale of vibrato effect (in cents) */

View File

@ -175,6 +175,7 @@ void AudioGroupDatabase::_recursiveRenameMacro(SoundMacroId id, std::string_view
++sampleIdx;
renameSample(ss->sample.id, sampleName);
}
break;
}
case SoundMacro::CmdOp::SplitKey:
_recursiveRenameMacro(static_cast<SoundMacro::CmdSplitKey*>(cmd.get())->macro, str, macroIdx, renamedIds);
@ -324,18 +325,23 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
ret += "\n"
" */\n\n\n"sv;
bool addLF = false;
for (const auto& sg : SortUnorderedMap(getProj().songGroups()))
{
auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first);
WriteDefineLine(ret, "GRP"sv, name, sg.first);
addLF = true;
}
for (const auto& sg : SortUnorderedMap(getProj().sfxGroups()))
{
auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first);
WriteDefineLine(ret, "GRP"sv, name, sg.first);
addLF = true;
}
ret += "\n\n"sv;
if (addLF)
ret += "\n\n"sv;
addLF = false;
std::unordered_set<amuse::SongId> songIds;
for (const auto& sg : getProj().songGroups())
@ -345,9 +351,12 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
{
auto name = amuse::SongId::CurNameDB->resolveNameFromId(id);
WriteDefineLine(ret, "SNG"sv, name, id);
addLF = true;
}
ret += "\n\n"sv;
if (addLF)
ret += "\n\n"sv;
addLF = false;
for (const auto& sg : SortUnorderedMap(getProj().sfxGroups()))
{
@ -355,9 +364,13 @@ std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std:
{
auto name = amuse::SFXId::CurNameDB->resolveNameFromId(sfx.first);
WriteDefineLine(ret, "SFX"sv, name, sfx.first.id);
addLF = true;
}
}
if (addLF)
ret += "\n\n"sv;
return ret;
}
}

View File

@ -6,6 +6,7 @@
#include "logvisor/logvisor.hpp"
#include "athena/FileWriter.hpp"
#include "athena/FileReader.hpp"
#include "athena/VectorWriter.hpp"
using namespace std::literals;
@ -204,6 +205,8 @@ template AudioGroupPool AudioGroupPool::_AudioGroupPool<athena::Little>(athena::
AudioGroupPool AudioGroupPool::CreateAudioGroupPool(const AudioGroupData& data)
{
if (data.getPoolSize() < 16)
return {};
athena::io::MemoryReader r(data.getPool(), data.getPoolSize());
switch (data.getDataFormat())
{
@ -503,7 +506,8 @@ static SoundMacro::CmdOp _ReadCmdOp(const SoundMacro::ICmd& op)
template <class Op, class O, class... _Args>
O SoundMacro::CmdDo(_Args&&... args)
{
switch (_ReadCmdOp(std::forward<_Args>(args)...))
SoundMacro::CmdOp op = _ReadCmdOp(std::forward<_Args>(args)...);
switch (op)
{
case CmdOp::End:
return Op::template Do<CmdEnd>(std::forward<_Args>(args)...);
@ -645,6 +649,10 @@ O SoundMacro::CmdDo(_Args&&... args)
return Op::template Do<CmdSetKeygroup>(std::forward<_Args>(args)...);
case CmdOp::SRCmodeSelect:
return Op::template Do<CmdSRCmodeSelect>(std::forward<_Args>(args)...);
case CmdOp::WiiUnknown:
return Op::template Do<CmdWiiUnknown>(std::forward<_Args>(args)...);
case CmdOp::WiiUnknown2:
return Op::template Do<CmdWiiUnknown2>(std::forward<_Args>(args)...);
case CmdOp::AddVars:
return Op::template Do<CmdAddVars>(std::forward<_Args>(args)...);
case CmdOp::SubVars:
@ -824,6 +832,10 @@ std::string_view SoundMacro::CmdOpToStr(CmdOp op)
return "SetKeygroup"sv;
case CmdOp::SRCmodeSelect:
return "SRCmodeSelect"sv;
case CmdOp::WiiUnknown:
return "WiiUnknown"sv;
case CmdOp::WiiUnknown2:
return "WiiUnknown2"sv;
case CmdOp::AddVars:
return "AddVars"sv;
case CmdOp::SubVars:
@ -987,6 +999,10 @@ SoundMacro::CmdOp SoundMacro::CmdStrToOp(std::string_view op)
return CmdOp::SetKeygroup;
else if (!CompareCaseInsensitive(op.data(), "SRCmodeSelect"))
return CmdOp::SRCmodeSelect;
else if (!CompareCaseInsensitive(op.data(), "WiiUnknown"))
return CmdOp::WiiUnknown;
else if (!CompareCaseInsensitive(op.data(), "WiiUnknown2"))
return CmdOp::WiiUnknown2;
else if (!CompareCaseInsensitive(op.data(), "AddVars"))
return CmdOp::AddVars;
else if (!CompareCaseInsensitive(op.data(), "SubVars"))
@ -1006,7 +1022,7 @@ SoundMacro::CmdOp SoundMacro::CmdStrToOp(std::string_view op)
return CmdOp::Invalid;
}
bool AudioGroupPool::toYAML(SystemStringView groupPath) const
std::vector<uint8_t> AudioGroupPool::toYAML() const
{
athena::io::YAMLDocWriter w("amuse::Pool");
@ -1081,20 +1097,15 @@ bool AudioGroupPool::toYAML(SystemStringView groupPath) const
}
}
SystemString poolPath(groupPath);
poolPath += _S("/!pool.yaml");
athena::io::FileWriter fo(poolPath);
return w.finish(&fo);
athena::io::VectorWriter fo;
w.finish(&fo);
return fo.data();
}
template <athena::Endian DNAE>
bool AudioGroupPool::toData(SystemStringView groupPath) const
std::vector<uint8_t> AudioGroupPool::toData() const
{
SystemString poolPath(groupPath);
poolPath += _S(".pool");
athena::io::FileWriter fo(poolPath);
if (fo.hasError())
return false;
athena::io::VectorWriter fo;
PoolHeader<DNAE> head = {};
head.write(fo);
@ -1202,10 +1213,10 @@ bool AudioGroupPool::toData(SystemStringView groupPath) const
fo.seek(0, athena::Begin);
head.write(fo);
return true;
return fo.data();
}
template bool AudioGroupPool::toData<athena::Big>(SystemStringView groupPath) const;
template bool AudioGroupPool::toData<athena::Little>(SystemStringView groupPath) const;
template std::vector<uint8_t> AudioGroupPool::toData<athena::Big>() const;
template std::vector<uint8_t> AudioGroupPool::toData<athena::Little>() const;
template <>
void amuse::Curve::Enumerate<LittleDNA::Read>(athena::io::IStreamReader& r)

View File

@ -1,3 +1,4 @@
#include <athena/VectorWriter.hpp>
#include "amuse/AudioGroupProject.hpp"
#include "amuse/AudioGroupPool.hpp"
#include "amuse/AudioGroupSampleDirectory.hpp"
@ -331,6 +332,8 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade
AudioGroupProject AudioGroupProject::CreateAudioGroupProject(const AudioGroupData& data)
{
if (data.getProjSize() < 4)
return {};
athena::io::MemoryReader r(data.getProj(), data.getProjSize());
switch (data.getDataFormat())
{
@ -754,7 +757,7 @@ void SFXGroupIndex::toYAML(athena::io::YAMLDocWriter& w) const
}
}
bool AudioGroupProject::toYAML(SystemStringView groupPath) const
std::vector<uint8_t> AudioGroupProject::toYAML() const
{
athena::io::YAMLDocWriter w("amuse::Project");
@ -790,10 +793,9 @@ bool AudioGroupProject::toYAML(SystemStringView groupPath) const
}
}
SystemString projPath(groupPath);
projPath += _S("/!project.yaml");
athena::io::FileWriter fo(projPath);
return w.finish(&fo);
athena::io::VectorWriter fo;
w.finish(&fo);
return fo.data();
}
#if 0
@ -906,16 +908,12 @@ struct ObjectIdPool
};
#endif
bool AudioGroupProject::toGCNData(SystemStringView groupPath, const AudioGroupPool& pool,
const AudioGroupSampleDirectory& sdir) const
std::vector<uint8_t> AudioGroupProject::toGCNData(const AudioGroupPool& pool,
const AudioGroupSampleDirectory& sdir) const
{
constexpr athena::Endian DNAE = athena::Big;
SystemString projPath(groupPath);
projPath += _S(".proj");
athena::io::FileWriter fo(projPath);
if (fo.hasError())
return false;
athena::io::VectorWriter fo;
std::vector<GroupId> groupIds;
groupIds.reserve(m_songGroups.size() + m_sfxGroups.size());
@ -1032,7 +1030,7 @@ bool AudioGroupProject::toGCNData(SystemStringView groupPath, const AudioGroupPo
const uint32_t finalTerm = 0xffffffff;
athena::io::Write<athena::io::PropType::None>::Do<decltype(finalTerm), DNAE>({}, finalTerm, fo);
return true;
return fo.data();
}
}

View File

@ -8,6 +8,7 @@
#include "athena/MemoryReader.hpp"
#include "athena/FileWriter.hpp"
#include "athena/FileReader.hpp"
#include "athena/VectorWriter.hpp"
#include <cstring>
#ifndef _WIN32
#include <fcntl.h>
@ -126,6 +127,8 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader&
AudioGroupSampleDirectory AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(const AudioGroupData& data)
{
if (data.getSdirSize() < 4)
return {};
athena::io::MemoryReader r(data.getSdir(), data.getSdirSize());
switch (data.getDataFormat())
{
@ -885,21 +888,14 @@ void AudioGroupSampleDirectory::reloadSampleData(SystemStringView groupPath)
}
}
bool AudioGroupSampleDirectory::toGCNData(SystemStringView groupPath, const AudioGroupDatabase& group) const
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
AudioGroupSampleDirectory::toGCNData(const AudioGroupDatabase& group) const
{
constexpr athena::Endian DNAE = athena::Big;
group.setIdDatabases();
SystemString sdirPath(groupPath);
SystemString sampPath(groupPath);
sdirPath += _S(".sdir");
sampPath += _S(".samp");
athena::io::FileWriter fo(sdirPath);
if (fo.hasError())
return false;
athena::io::FileWriter sfo(sampPath);
if (sfo.hasError())
return false;
athena::io::VectorWriter fo;
athena::io::VectorWriter sfo;
std::vector<std::pair<EntryDNA<DNAE>, ADPCMParms>> entries;
entries.reserve(m_entries.size());
@ -975,6 +971,6 @@ bool AudioGroupSampleDirectory::toGCNData(SystemStringView groupPath, const Audi
fo.writeUBytes((uint8_t*)&p.second, sizeof(ADPCMParms::DSPParms));
}
return true;
return {fo.data(), sfo.data()};
}
}

View File

@ -192,7 +192,7 @@ bool SoundMacro::CmdEnd::Do(SoundMacroState& st, Voice& vox) const
const SoundMacro::CmdIntrospection SoundMacro::CmdStop::Introspective =
{
CmdType::Structure,
"Stop"sv,
"Stop"sv,
"Stops the macro at any point."sv,
};
bool SoundMacro::CmdStop::Do(SoundMacroState& st, Voice& vox) const
@ -318,7 +318,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdWaitTicks::Introspective =
bool SoundMacro::CmdWaitTicks::Do(SoundMacroState& st, Voice& vox) const
{
/* Set wait state */
if (ticksOrMs >= 0)
if (ticksOrMs != 65535)
{
float q = msSwitch ? 1000.f : st.m_ticksPerSec;
float secTime = ticksOrMs / q;
@ -476,7 +476,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdWaitMs::Introspective =
bool SoundMacro::CmdWaitMs::Do(SoundMacroState& st, Voice& vox) const
{
/* Set wait state */
if (ms >= 0)
if (ms != 65535)
{
float secTime = ms / 1000.f;
/* Randomize at the proper resolution */
@ -2765,6 +2765,42 @@ bool SoundMacro::CmdSRCmodeSelect::Do(SoundMacroState& st, Voice& vox) const
return false;
}
const SoundMacro::CmdIntrospection SoundMacro::CmdWiiUnknown::Introspective =
{
CmdType::Setup,
"Wii Unknown"sv,
"????"sv,
{
{
FIELD_HEAD(SoundMacro::CmdWiiUnknown, flag),
"?"sv,
0, 1, 0
}
}
};
bool SoundMacro::CmdWiiUnknown::Do(SoundMacroState& st, Voice& vox) const
{
return false;
}
const SoundMacro::CmdIntrospection SoundMacro::CmdWiiUnknown2::Introspective =
{
CmdType::Setup,
"Wii Unknown 2"sv,
"????"sv,
{
{
FIELD_HEAD(SoundMacro::CmdWiiUnknown2, flag),
"?"sv,
0, 1, 0
}
}
};
bool SoundMacro::CmdWiiUnknown2::Do(SoundMacroState& st, Voice& vox) const
{
return false;
}
const SoundMacro::CmdIntrospection SoundMacro::CmdAddVars::Introspective =
{
CmdType::Special,

View File

@ -431,33 +431,35 @@ void Voice::preSupplyAudio(double dt)
/* Process active pan-sweep */
bool refresh = false;
if (m_panningTime >= 0.f)
if (!m_panningQueue.empty())
{
m_panningTime += dt;
float start = (m_panPos - 64) / 64.f;
float end = (m_panPos + m_panWidth - 64) / 64.f;
float t = clamp(0.f, m_panningTime / m_panningDur, 1.f);
Panning& p = m_panningQueue.front();
p.m_time += dt;
float start = (p.m_pos - 64) / 64.f;
float end = (p.m_pos + p.m_width - 64) / 64.f;
float t = clamp(0.f, p.m_time / p.m_dur, 1.f);
_setPan((start * (1.0f - t)) + (end * t));
refresh = true;
/* Done with panning */
if (m_panningTime > m_panningDur)
m_panningTime = -1.f;
if (p.m_time > p.m_dur)
m_panningQueue.pop();
}
/* Process active span-sweep */
if (m_spanningTime >= 0.f)
if (!m_spanningQueue.empty())
{
m_spanningTime += dt;
float start = (m_spanPos - 64) / 64.f;
float end = (m_spanPos + m_spanWidth - 64) / 64.f;
float t = clamp(0.f, m_spanningTime / m_spanningDur, 1.f);
Panning& s = m_spanningQueue.front();
s.m_time += dt;
float start = (s.m_pos - 64) / 64.f;
float end = (s.m_pos + s.m_width - 64) / 64.f;
float t = clamp(0.f, s.m_time / s.m_dur, 1.f);
_setSurroundPan((start * (1.0f - t)) + (end * t));
refresh = true;
/* Done with spanning */
if (m_spanningTime > m_spanningDur)
m_spanningTime = -1.f;
if (s.m_time > s.m_dur)
m_spanningQueue.pop();
}
/* Calculate total pitch */
@ -681,7 +683,10 @@ size_t Voice::supplyAudio(size_t samples, int16_t* data)
}
}
else
{
_macroSampleEnd();
memset(data, 0, sizeof(int16_t) * samples);
}
if (m_voxState == VoiceState::Dead)
m_curSample.reset();
@ -1018,6 +1023,8 @@ void Voice::startSample(SampleId sampId, int32_t offset)
m_lastSamplePos = m_curSample->m_loopLengthSamples
? (m_curSample->m_loopStartSample + m_curSample->m_loopLengthSamples)
: numSamples;
if (m_lastSamplePos)
--m_lastSamplePos;
bool looped;
_checkSamplePos(looped);
@ -1238,18 +1245,12 @@ void Voice::startFadeIn(double dur, float vol, const Curve* envCurve)
void Voice::startPanning(double dur, uint8_t panPos, int8_t panWidth)
{
m_panningTime = 0.f;
m_panningDur = dur;
m_panPos = panPos;
m_panWidth = panWidth;
m_panningQueue.push({0.f, dur, panPos, panWidth});
}
void Voice::startSpanning(double dur, uint8_t spanPos, int8_t spanWidth)
{
m_spanningTime = 0.f;
m_spanningDur = dur;
m_spanPos = spanPos;
m_spanWidth = spanWidth;
m_spanningQueue.push({0.f, dur, spanPos, spanWidth});
}
void Voice::setPitchKey(int32_t cents)