mirror of
https://github.com/AxioDL/amuse.git
synced 2025-12-08 13:14:58 +00:00
Massive fmtlib refactor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user