From 18eb8a07ba39a8aad1c75521cee027b9c9c72e40 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 1 Feb 2026 00:58:20 +0100 Subject: clang-format --- tools/asset_packer.cc | 18 +++++++++++------- tools/seq_compiler.cc | 22 +++++++++++++--------- tools/spectool.cc | 20 +++++++++++--------- tools/specview.cc | 17 ++++++++++------- 4 files changed, 45 insertions(+), 32 deletions(-) (limited to 'tools') diff --git a/tools/asset_packer.cc b/tools/asset_packer.cc index 4a2e631..c803c02 100644 --- a/tools/asset_packer.cc +++ b/tools/asset_packer.cc @@ -8,7 +8,7 @@ #include #include -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { if (argc != 4) { std::cerr << "Usage: " << argv[0] << " " @@ -59,17 +59,20 @@ int main(int argc, char *argv[]) { std::vector asset_names; while (std::getline(assets_txt_file, line)) { - if (line.empty() || line[0] == '#') continue; + if (line.empty() || line[0] == '#') + continue; size_t first_comma = line.find(','); - if (first_comma == std::string::npos) continue; + if (first_comma == std::string::npos) + continue; std::string asset_name = line.substr(0, first_comma); asset_name.erase(0, asset_name.find_first_not_of(" \t\r\n")); asset_name.erase(asset_name.find_last_not_of(" \t\r\n") + 1); size_t second_comma = line.find(',', first_comma + 1); - if (second_comma == std::string::npos) continue; + if (second_comma == std::string::npos) + continue; std::string filename = line.substr(first_comma + 1, second_comma - first_comma - 1); @@ -99,13 +102,14 @@ int main(int argc, char *argv[]) { assets_data_cc_file << "static const uint8_t ASSET_DATA_" << asset_name << "[] = {"; for (size_t i = 0; i < buffer.size(); ++i) { - if (i % 12 == 0) assets_data_cc_file << "\n "; + if (i % 12 == 0) + assets_data_cc_file << "\n "; assets_data_cc_file << "0x" << std::hex << (int)buffer[i] << std::dec << (i == buffer.size() - 1 ? "" : ", "); } assets_data_cc_file << "\n};\n\n"; - asset_id_counter++; + ++asset_id_counter; } assets_h_file << "};\n\n"; @@ -114,7 +118,7 @@ int main(int argc, char *argv[]) { // Generate the lookup array in assets_data.cc assets_data_cc_file << "extern const AssetRecord g_assets[] = {\n"; - for (const std::string &name : asset_names) { + for (const std::string& name : asset_names) { assets_data_cc_file << " { ASSET_DATA_" << name << ", sizeof(ASSET_DATA_" << name << ") },\n"; } diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc index e84877b..a8a9795 100644 --- a/tools/seq_compiler.cc +++ b/tools/seq_compiler.cc @@ -22,14 +22,15 @@ struct SequenceEntry { std::vector effects; }; -std::string trim(const std::string &str) { +std::string trim(const std::string& str) { size_t first = str.find_first_not_of(" "); - if (std::string::npos == first) return str; + if (std::string::npos == first) + return str; size_t last = str.find_last_not_of(" "); return str.substr(first, (last - first + 1)); } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] << " \n"; std::cerr << "Example: " << argv[0] @@ -44,14 +45,15 @@ int main(int argc, char *argv[]) { } std::vector sequences; - SequenceEntry *current_seq = nullptr; + SequenceEntry* current_seq = nullptr; std::string line; int line_num = 0; while (std::getline(in_file, line)) { - line_num++; + ++line_num; std::string trimmed = trim(line); - if (trimmed.empty() || trimmed[0] == '#') continue; + if (trimmed.empty() || trimmed[0] == '#') + continue; std::stringstream ss(trimmed); std::string command; @@ -85,7 +87,9 @@ int main(int argc, char *argv[]) { // Remove leading whitespace from getline if any (getline reads the space // after priority) extra_args = trim(extra_args); - if (!extra_args.empty()) { extra_args = ", " + extra_args; } + if (!extra_args.empty()) { + extra_args = ", " + extra_args; + } current_seq->effects.push_back( {class_name, start, end, priority, extra_args}); @@ -108,10 +112,10 @@ int main(int argc, char *argv[]) { out_file << "void LoadTimeline(MainSequence& main_seq, WGPUDevice device, " "WGPUQueue queue, WGPUTextureFormat format) {\n"; - for (const auto &seq : sequences) { + for (const SequenceEntry& seq : sequences) { out_file << " {\n"; out_file << " auto seq = std::make_shared();\n"; - for (const auto &eff : seq.effects) { + for (const EffectEntry& eff : seq.effects) { out_file << " seq->add_effect(std::make_shared<" << eff.class_name << ">(device, queue, format" << eff.extra_args << "), " << eff.start << "f, " << eff.end << "f, " << eff.priority diff --git a/tools/spectool.cc b/tools/spectool.cc index 5c05a03..80a970e 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -31,7 +31,7 @@ struct SpecHeader { int32_t num_frames; }; -int analyze_audio(const char *in_path, const char *out_path) { +int analyze_audio(const char* in_path, const char* out_path) { printf("Analyzing %s -> %s\n", in_path, out_path); ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 1, 32000); @@ -57,7 +57,9 @@ int analyze_audio(const char *in_path, const char *out_path) { } // Apply window - for (int i = 0; i < DCT_SIZE; ++i) { pcm_chunk[i] *= window[i]; } + for (int i = 0; i < DCT_SIZE; ++i) { + pcm_chunk[i] *= window[i]; + } // Apply FDCT float dct_chunk[DCT_SIZE]; @@ -88,7 +90,7 @@ int analyze_audio(const char *in_path, const char *out_path) { spec_data.resize(last_frame * DCT_SIZE); // Write to .spec file - FILE *f_out = fopen(out_path, "wb"); + FILE* f_out = fopen(out_path, "wb"); if (!f_out) { printf("Error: Failed to open output file: %s\n", out_path); return 1; @@ -108,10 +110,10 @@ int analyze_audio(const char *in_path, const char *out_path) { return 0; } -int play_spec(const char *in_path) { +int play_spec(const char* in_path) { printf("Playing %s\n", in_path); - FILE *f_in = fopen(in_path, "rb"); + FILE* f_in = fopen(in_path, "rb"); if (!f_in) { printf("Error: Failed to open input file: %s\n", in_path); return 1; @@ -152,7 +154,7 @@ int play_spec(const char *in_path) { return 0; } -int test_gen(const char *out_path) { +int test_gen(const char* out_path) { printf("Generating test spectrogram -> %s\n", out_path); std::vector track_data; @@ -189,7 +191,7 @@ int test_gen(const char *out_path) { } // Write to file (Duplicate logic, but fine for now) - FILE *f_out = fopen(out_path, "wb"); + FILE* f_out = fopen(out_path, "wb"); if (!f_out) { printf("Error: Failed to open output file: %s\n", out_path); return 1; @@ -222,13 +224,13 @@ void print_usage() { "spectrogram.\n"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc < 2) { print_usage(); return 1; } - const char *command = argv[1]; + const char* command = argv[1]; if (strcmp(command, "analyze") == 0) { if (argc < 4) { diff --git a/tools/specview.cc b/tools/specview.cc index 59b6d70..3cbfdc9 100644 --- a/tools/specview.cc +++ b/tools/specview.cc @@ -21,15 +21,15 @@ void print_usage() { printf("Displays an ASCII representation of a spectrogram file.\n"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc < 2) { print_usage(); return 1; } - const char *input_path = argv[1]; + const char* input_path = argv[1]; - FILE *f_in = fopen(input_path, "rb"); + FILE* f_in = fopen(input_path, "rb"); if (!f_in) { printf("Error: Failed to open input file: %s\n", input_path); return 1; @@ -64,17 +64,20 @@ int main(int argc, char **argv) { // Find max magnitude for normalization float max_mag = 0.0f; - for (float val : spec_data) { max_mag = std::max(max_mag, fabsf(val)); } - if (max_mag == 0.0f) max_mag = 1.0f; // Avoid division by zero + for (float val : spec_data) { + max_mag = std::max(max_mag, fabsf(val)); + } + if (max_mag == 0.0f) + max_mag = 1.0f; // Avoid division by zero // ASCII visualization - const char *gradient = " .:-=+*#%@"; + const char* gradient = " .:-=+*#%@"; int gradient_len = strlen(gradient); printf("\nASCII Visualization:\n"); for (int frame = 0; frame < header.num_frames; ++frame) { printf("%4d: ", frame); - const float *current_frame_data = + const float* current_frame_data = spec_data.data() + frame * header.dct_size; // Average bins into fewer columns for better fit on console -- cgit v1.2.3