diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/spectool.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/spectool.cc b/tools/spectool.cc index c3aebb2..70bcae2 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -110,15 +110,18 @@ int analyze_audio(const char* in_path, const char* out_path, bool normalize, } } - // Second pass: Windowing + DCT + // Second pass: Windowing + DCT (OLA v2: Hann window, 50% overlap) std::vector<float> spec_data; float window[WINDOW_SIZE]; - hamming_window_512(window); + hann_window_512(window); - // Process PCM data in DCT_SIZE chunks - const size_t num_chunks = (pcm_data.size() + DCT_SIZE - 1) / DCT_SIZE; + // Process PCM data with OLA_HOP_SIZE stride (50% overlap) + const size_t hop = OLA_HOP_SIZE; + const size_t num_chunks = (pcm_data.size() > DCT_SIZE) + ? (pcm_data.size() - DCT_SIZE) / hop + 1 + : 1; for (size_t chunk_idx = 0; chunk_idx < num_chunks; ++chunk_idx) { - const size_t chunk_start = chunk_idx * DCT_SIZE; + const size_t chunk_start = chunk_idx * hop; const size_t chunk_end = (chunk_start + DCT_SIZE < pcm_data.size()) ? chunk_start + DCT_SIZE : pcm_data.size(); @@ -202,7 +205,7 @@ int analyze_audio(const char* in_path, const char* out_path, bool normalize, SpecHeader header; memcpy(header.magic, "SPEC", 4); - header.version = 1; + header.version = SPEC_VERSION_V2_OLA; header.dct_size = DCT_SIZE; header.num_frames = trimmed_data.size() / DCT_SIZE; |
