Multichannel rendering for amuserender

This commit is contained in:
Jack Andersen 2018-09-03 14:14:12 -10:00
parent 8fee7a282b
commit 25aacc9511
1 changed files with 23 additions and 2 deletions

View File

@ -100,6 +100,7 @@ int main(int argc, const boo::SystemChar** argv)
std::vector<boo::SystemString> m_args; std::vector<boo::SystemString> m_args;
m_args.reserve(argc); m_args.reserve(argc);
double rate = NativeSampleRate; double rate = NativeSampleRate;
int chCount = 2;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
#if _WIN32 #if _WIN32
@ -113,6 +114,16 @@ int main(int argc, const boo::SystemChar** argv)
++i; ++i;
} }
} }
else if (!wcsncmp(argv[i], L"-c", 2))
{
if (argv[i][2])
chCount = wcstoul(&argv[i][2], nullptr, 0);
else if (argc > (i + 1))
{
chCount = wcstoul(argv[i + 1], nullptr, 0);
++i;
}
}
else else
m_args.push_back(argv[i]); m_args.push_back(argv[i]);
#else #else
@ -126,6 +137,16 @@ int main(int argc, const boo::SystemChar** argv)
++i; ++i;
} }
} }
else if (!strncmp(argv[i], "-c", 2))
{
if (argv[i][2])
chCount = strtoul(&argv[i][2], nullptr, 0);
else if (argc > (i + 1))
{
chCount = strtoul(argv[i + 1], nullptr, 0);
++i;
}
}
else else
m_args.push_back(argv[i]); m_args.push_back(argv[i]);
#endif #endif
@ -134,7 +155,7 @@ int main(int argc, const boo::SystemChar** argv)
/* Load data */ /* Load data */
if (m_args.size() < 1) if (m_args.size() < 1)
{ {
Log.report(logvisor::Error, "Usage: amuserender <group-file> [<songs-file>] [-r <sample-rate>]"); Log.report(logvisor::Error, "Usage: amuserender <group-file> [<songs-file>] [-r <sample-rate>] [-c <channel-count>]");
return 1; return 1;
} }
@ -452,7 +473,7 @@ int main(int argc, const boo::SystemChar** argv)
Log.report(logvisor::Info, _S("Writing to %s"), pathOut); Log.report(logvisor::Info, _S("Writing to %s"), pathOut);
/* Build voice engine */ /* Build voice engine */
std::unique_ptr<boo::IAudioVoiceEngine> voxEngine = boo::NewWAVAudioVoiceEngine(pathOut, rate); std::unique_ptr<boo::IAudioVoiceEngine> voxEngine = boo::NewWAVAudioVoiceEngine(pathOut, rate, chCount);
amuse::BooBackendVoiceAllocator booBackend(*voxEngine); amuse::BooBackendVoiceAllocator booBackend(*voxEngine);
amuse::Engine engine(booBackend, amuse::AmplitudeMode::PerSample); amuse::Engine engine(booBackend, amuse::AmplitudeMode::PerSample);