diff --git a/README.md b/README.md index d345758..4b54ff5 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ The [examples](https://github.com/ggerganov/ggwave/blob/master/examples/) folder | [ggwave-rx](https://github.com/ggerganov/ggwave/blob/master/examples/ggwave-rx) | Very basic receive-only program | SDL | | [ggwave-cli](https://github.com/ggerganov/ggwave/blob/master/examples/ggwave-cli) | Command line tool for sending/receiving data through sound | SDL | | [ggwave-wasm](https://github.com/ggerganov/ggwave/blob/master/examples/ggwave-wasm) | WebAssembly module for web applications | SDL | -| [ggwave-to-file](https://github.com/ggerganov/ggwave/blob/master/examples/ggwave-to-file) | Output generated audio to a file | - | +| [ggwave-to-file](https://github.com/ggerganov/ggwave/blob/master/examples/ggwave-to-file) | Output generated waveform to a file | - | | [waver](https://github.com/ggerganov/ggwave/blob/master/examples/waver) | GUI tool for sending/receiving data through sound | SDL | Other projects using **ggwave** or one of its prototypes: diff --git a/examples/ggwave-to-file/README.md b/examples/ggwave-to-file/README.md index c1b169e..1063122 100644 --- a/examples/ggwave-to-file/README.md +++ b/examples/ggwave-to-file/README.md @@ -1,7 +1,7 @@ ## ggwave-to-file -Output generated audio to a file. +Output generated waveform to a file. ```bash -./bin/ggwave-to-file "Hello World!" > example.wav +echo "Hello World!" | ./bin/ggwave-to-file > example.wav ``` diff --git a/examples/ggwave-to-file/main.cpp b/examples/ggwave-to-file/main.cpp index c407043..4c3d75b 100644 --- a/examples/ggwave-to-file/main.cpp +++ b/examples/ggwave-to-file/main.cpp @@ -7,9 +7,10 @@ #include #include +#include int main(int argc, char** argv) { - fprintf(stderr, "Usage: %s \"message\" output.wav [-pN]\n", argv[0]); + fprintf(stderr, "Usage: %s [-pN]\n", argv[0]); fprintf(stderr, " -pN - select the transmission protocol\n"); fprintf(stderr, "\n"); fprintf(stderr, " Available protocols:\n"); @@ -20,11 +21,14 @@ int main(int argc, char** argv) { } fprintf(stderr, "\n"); - if (argc < 2) { + if (argc < 1) { return -1; } - std::string message = argv[1]; + fprintf(stderr, "Enter a text message:\n"); + + std::string message; + std::getline(std::cin, message); if (message.size() == 0) { fprintf(stderr, "Invalid message: size = 0\n"); @@ -42,6 +46,8 @@ int main(int argc, char** argv) { auto sampleRateOut = GGWave::kBaseSampleRate; + fprintf(stderr, "Generating waveform for message '%s' ...\n", message.c_str()); + GGWave ggWave(GGWave::kBaseSampleRate, sampleRateOut, 1024, 4, 2); ggWave.init(message.size(), message.data(), ggWave.getTxProtocols()[protocolId], volume);