mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-03-17 16:06:00 +08:00
ggwave-to-file : get input from stdin
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user