From 4078eacfbd9c05712169110c2dfeb6e1b253bd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maksymilian=20Wilczy=C5=84ski?= Date: Sun, 6 Apr 2025 20:06:29 +0200 Subject: [PATCH] allow to specify output --- synthetizer.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/synthetizer.cpp b/synthetizer.cpp index 6c951f1..df25861 100644 --- a/synthetizer.cpp +++ b/synthetizer.cpp @@ -358,7 +358,13 @@ void writeWav(const std::string& filename, const std::vector& samples) file.write(reinterpret_cast(samples.data()), samples.size() * sizeof(int16_t)); } -int main() { +int main(int argc, char* argv[]) { + std::string out_name; + if (argc == 2) + out_name = argv[1]; + else + out_name = "output.wav"; + std::vector waves; int totalDuration = 0; @@ -372,8 +378,8 @@ int main() { std::vector samples = generateAudio(waves, totalDuration); // Write the audio to a WAV file - writeWav("output.wav", samples); + writeWav(out_name, samples); - std::cout << "WAV file generated: output.wav" << std::endl; + std::cout << "WAV file generated: " << out_name << std::endl; return 0; }