diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/spectool.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/spectool.cc b/tools/spectool.cc index 7733b98..663e89e 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -155,13 +155,14 @@ int play_spec(const char *in_path) { int test_gen(const char *out_path) { printf("Generating test spectrogram -> %s\n", out_path); - + std::vector<float> track_data; int track_frames = 0; - + // Generate a simple C Major scale - float freqs[] = {261.63f, 293.66f, 329.63f, 349.23f, 392.00f, 440.00f, 493.88f, 523.25f}; - + float freqs[] = {261.63f, 293.66f, 329.63f, 349.23f, + 392.00f, 440.00f, 493.88f, 523.25f}; + srand(time(NULL)); for (int i = 0; i < 8; ++i) { @@ -177,15 +178,17 @@ int test_gen(const char *out_path) { params.harmonic_decay = 0.5f; params.pitch_randomness = 1.0f; params.amp_randomness = 0.05f; - + int note_frames = 0; - std::vector<float> note_data = generate_note_spectrogram(params, ¬e_frames); - + std::vector<float> note_data = + generate_note_spectrogram(params, ¬e_frames); + // Paste at 0.4s intervals (overlap) int offset = (int)(i * 0.4f * 32000.0f / DCT_SIZE); - paste_spectrogram(track_data, &track_frames, note_data, note_frames, offset); + paste_spectrogram(track_data, &track_frames, note_data, note_frames, + offset); } - + // Write to file (Duplicate logic, but fine for now) FILE *f_out = fopen(out_path, "wb"); if (!f_out) { @@ -202,7 +205,7 @@ int test_gen(const char *out_path) { fwrite(&header, sizeof(SpecHeader), 1, f_out); fwrite(track_data.data(), sizeof(float), track_data.size(), f_out); fclose(f_out); - + printf("Generated %d frames.\n", track_frames); return 0; } @@ -214,7 +217,8 @@ void print_usage() { "save as a spectrogram.\n"); printf( " play <input.spec> Play a spectrogram file.\n"); - printf(" test_gen <output.spec> Generate a test spectrogram.\n"); + printf(" test_gen <output.spec> Generate a test " + "spectrogram.\n"); } int main(int argc, char **argv) { @@ -233,7 +237,7 @@ int main(int argc, char **argv) { } return analyze_audio(argv[2], argv[3]); } else if (strcmp(command, "play") == 0) { - if (argc < 3) { + if (argc < 3) { printf("Error: 'play' command requires an input file.\n"); print_usage(); return 1; |
