timestretch 0.7.0

Pure Rust audio time stretching library optimized for EDM
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
use std::path::Path;
use timestretch::{
    EdmPreset, PreAnalysisArtifact, QualityMode, StreamProcessor, StretchParams,
    TransientResetStats, WindowType,
};

fn main() {
    let args: Vec<String> = std::env::args().collect();

    if args.len() >= 2 && args[1] == "analyze" {
        run_analyze(&args);
        return;
    }

    if args.len() < 3 {
        print_usage();
        std::process::exit(1);
    }

    let input_path = &args[1];
    let output_path = &args[2];

    // Parse remaining arguments
    let mut ratio: Option<f64> = None;
    let mut from_bpm: Option<f64> = None;
    let mut to_bpm: Option<f64> = None;
    let mut auto_bpm = false;
    let mut pitch_factor: Option<f64> = None;
    let mut preset: Option<EdmPreset> = None;
    let mut format_24bit = false;
    let mut _format_float = false;
    let mut verbose = false;
    let mut window_type: Option<WindowType> = None;
    // Default to loudness-consistent output for file-based workflows.
    let mut normalize = true;
    let mut streaming = false;
    let mut chunk_size: usize = 1024;
    let mut pre_analysis_path: Option<String> = None;

    let mut i = 3;
    while i < args.len() {
        match args[i].as_str() {
            "--ratio" | "-r" => {
                i += 1;
                ratio = Some(parse_f64(&args, i, "ratio"));
            }
            "--from-bpm" => {
                i += 1;
                from_bpm = Some(parse_f64(&args, i, "from-bpm"));
            }
            "--to-bpm" => {
                i += 1;
                to_bpm = Some(parse_f64(&args, i, "to-bpm"));
            }
            "--auto-bpm" => auto_bpm = true,
            "--pitch" | "-p" => {
                i += 1;
                pitch_factor = Some(parse_f64(&args, i, "pitch"));
            }
            "--preset" => {
                i += 1;
                preset = Some(parse_preset(&args, i));
            }
            "--24bit" => format_24bit = true,
            "--float" => _format_float = true,
            "--verbose" | "-v" => verbose = true,
            "--normalize" | "-n" => normalize = true,
            "--no-normalize" => normalize = false,
            "--streaming" => streaming = true,
            "--chunk-size" => {
                i += 1;
                chunk_size = parse_usize(&args, i, "chunk-size");
            }
            "--pre-analysis" => {
                i += 1;
                if i >= args.len() {
                    eprintln!("ERROR: --pre-analysis requires a file path");
                    std::process::exit(1);
                }
                pre_analysis_path = Some(args[i].clone());
            }
            "--window" | "-w" => {
                i += 1;
                window_type = Some(parse_window(&args, i));
            }
            // Legacy positional: ratio [preset]
            other => {
                if ratio.is_none() {
                    match other.parse::<f64>() {
                        Ok(r) => ratio = Some(r),
                        Err(_) => {
                            // Try as preset name
                            preset = Some(parse_preset_str(other));
                            i += 1;
                            continue;
                        }
                    }
                } else if preset.is_none() {
                    preset = Some(parse_preset_str(other));
                }
            }
        }
        i += 1;
    }

    // Read input
    let buffer = match timestretch::io::wav::read_wav_file(input_path) {
        Ok(b) => b,
        Err(e) => {
            eprintln!("ERROR: Failed to read {}: {}", input_path, e);
            std::process::exit(1);
        }
    };

    eprintln!(
        "Input: {} frames, {} Hz, {:?}, {:.2}s",
        buffer.num_frames(),
        buffer.sample_rate,
        buffer.channels,
        buffer.duration_secs()
    );

    // Handle --auto-bpm: detect source BPM from input
    if auto_bpm && from_bpm.is_none() {
        let detected = timestretch::detect_bpm_buffer(&buffer);
        if detected <= 0.0 {
            eprintln!("ERROR: Could not auto-detect BPM from input audio");
            std::process::exit(1);
        }
        eprintln!("Auto-detected BPM: {:.1}", detected);
        from_bpm = Some(detected);
    }

    // Determine stretch ratio
    let stretch_ratio = if let (Some(from), Some(to)) = (from_bpm, to_bpm) {
        if from <= 0.0 || to <= 0.0 {
            eprintln!("ERROR: BPM values must be positive");
            std::process::exit(1);
        }
        eprintln!("BPM: {:.1} -> {:.1} (ratio: {:.4})", from, to, from / to);
        if preset.is_none() {
            preset = Some(EdmPreset::DjBeatmatch);
        }
        from / to
    } else if let Some(r) = ratio {
        r
    } else if pitch_factor.is_some() {
        1.0
    } else {
        eprintln!("ERROR: Must specify --ratio, --from-bpm/--to-bpm, or --pitch");
        print_usage();
        std::process::exit(1);
    };

    // Load and validate the optional pre-analysis artifact. A stale or
    // mismatched sidecar must never abort a render: warn and fall back to
    // online analysis instead.
    let pre_analysis: Option<PreAnalysisArtifact> = pre_analysis_path.as_ref().and_then(|path| {
        let artifact = match timestretch::read_preanalysis_json(Path::new(path)) {
            Ok(artifact) => artifact,
            Err(e) => {
                eprintln!(
                    "WARNING: Ignoring pre-analysis {}: {} (falling back to online analysis)",
                    path, e
                );
                return None;
            }
        };
        let analysis_signal = timestretch::downmix_to_mid(&buffer.data, buffer.channels.count());
        if !artifact.matches_source(&analysis_signal, buffer.sample_rate) {
            eprintln!(
                "WARNING: Pre-analysis {} does not match this audio (stale or wrong file); \
                 falling back to online analysis",
                path
            );
            return None;
        }
        eprintln!(
            "Pre-analysis: {:.1} BPM, confidence {:.2}, {} beats, {} onsets",
            artifact.bpm,
            artifact.confidence,
            artifact.beat_positions.len(),
            artifact.transient_onsets.len()
        );
        Some(artifact)
    });

    // Configure params
    let mut params = StretchParams::new(stretch_ratio)
        .with_sample_rate(buffer.sample_rate)
        .with_channels(buffer.channels.count() as u32);

    if let Some(p) = preset {
        params = params.with_preset(p);
    }

    if let Some(artifact) = pre_analysis.clone() {
        params = params.with_pre_analysis(artifact);
    }

    if let Some(w) = window_type {
        params = params.with_window_type(w);
    }

    params = params.with_normalize(normalize);

    if verbose {
        eprintln!("Parameters: {}", params);
        eprintln!(
            "  Transient sensitivity: {:.2}",
            params.transient_sensitivity
        );
        eprintln!("  Sub-bass cutoff: {:.0} Hz", params.sub_bass_cutoff);
        eprintln!("  WSOLA segment: {} samples", params.wsola_segment_size);
        eprintln!("  WSOLA search: {} samples", params.wsola_search_range);
        eprintln!("  Beat-aware: {}", params.beat_aware);
        eprintln!("  Window: {:?}", params.window_type);
        eprintln!("  Normalize: {}", params.normalize);
    }

    let start = std::time::Instant::now();

    let mut stream_reset_stats: Option<TransientResetStats> = None;

    // Process
    let output = if streaming {
        eprintln!("Streaming mode (chunk size: {} frames)", chunk_size);
        // Align CLI streaming with desktop defaults:
        // - Do not force hybrid mode.
        // - Use low-latency DJ profile for DjBeatmatch.
        let stream_params = if preset == Some(EdmPreset::DjBeatmatch) {
            let mut p = StretchParams::new(stretch_ratio)
                .with_sample_rate(buffer.sample_rate)
                .with_channels(buffer.channels.count() as u32)
                .with_quality_mode(QualityMode::LowLatency)
                .with_fft_size(1024)
                .with_hop_size(256)
                .with_normalize(normalize);
            if let Some(w) = window_type {
                p = p.with_window_type(w);
            }
            if let Some(artifact) = pre_analysis.clone() {
                p = p.with_pre_analysis(artifact);
            }
            p
        } else {
            params.clone()
        };
        if verbose {
            if preset == Some(EdmPreset::DjBeatmatch) {
                eprintln!("  Streaming profile: desktop-style DJ low-latency");
            } else {
                eprintln!("  Streaming profile: standard");
            }
            eprintln!("  Streaming params: {}", stream_params);
        }
        let mut processor = StreamProcessor::new(stream_params);

        let num_channels = buffer.channels.count();
        let samples_per_chunk = chunk_size * num_channels;
        let mut all_output: Vec<f32> = Vec::new();

        for chunk in buffer.data.chunks(samples_per_chunk) {
            match processor.process(chunk) {
                Ok(out) => all_output.extend_from_slice(&out),
                Err(e) => {
                    eprintln!("ERROR: Streaming process failed: {}", e);
                    std::process::exit(1);
                }
            }
        }

        match processor.flush() {
            Ok(flushed) => all_output.extend_from_slice(&flushed),
            Err(e) => {
                eprintln!("ERROR: Streaming flush failed: {}", e);
                std::process::exit(1);
            }
        }

        if verbose {
            stream_reset_stats = Some(processor.transient_reset_stats());
        }

        // Streaming mode doesn't apply global RMS normalization (the batch
        // path normalizes inside stretch()). Apply it here so streaming
        // output matches batch-level loudness and the reference level used
        // by quality scoring.
        if normalize && !all_output.is_empty() && !buffer.data.is_empty() {
            let input_rms = {
                let sum_sq: f64 = buffer.data.iter().map(|&s| (s as f64) * (s as f64)).sum();
                (sum_sq / buffer.data.len() as f64).sqrt()
            };
            let output_rms = {
                let sum_sq: f64 = all_output.iter().map(|&s| (s as f64) * (s as f64)).sum();
                (sum_sq / all_output.len() as f64).sqrt()
            };
            if output_rms > 1e-8 && input_rms > 1e-8 {
                let gain = (input_rms / output_rms) as f32;
                for s in &mut all_output {
                    *s *= gain;
                }
            }
        }

        timestretch::AudioBuffer::new(all_output, buffer.sample_rate, buffer.channels)
    } else if let Some(pf) = pitch_factor {
        eprintln!("Pitch shift factor: {:.4}", pf);
        match timestretch::pitch_shift_buffer(&buffer, &params, pf) {
            Ok(o) => o,
            Err(e) => {
                eprintln!("ERROR: Pitch shifting failed: {}", e);
                std::process::exit(1);
            }
        }
    } else {
        match timestretch::stretch_buffer(&buffer, &params) {
            Ok(o) => o,
            Err(e) => {
                eprintln!("ERROR: Stretching failed: {}", e);
                std::process::exit(1);
            }
        }
    };

    let elapsed = start.elapsed();

    eprintln!(
        "Output: {} frames, {:.2}s (ratio: {:.4})",
        output.num_frames(),
        output.duration_secs(),
        output.num_frames() as f64 / buffer.num_frames() as f64
    );

    if verbose {
        if let Some(stats) = stream_reset_stats {
            eprintln!(
                "  Reset scheduler: events={} artifact_events={} bands[sub,low,mid,high]=[{},{},{},{}] consumed_frames={}",
                stats.events_detected_total,
                stats.artifact_events_scheduled_total,
                stats.reset_band_counts_total[0],
                stats.reset_band_counts_total[1],
                stats.reset_band_counts_total[2],
                stats.reset_band_counts_total[3],
                stats.input_frames_consumed_total
            );
        }
        let input_duration = buffer.duration_secs();
        let processing_secs = elapsed.as_secs_f64();
        let realtime_factor = if processing_secs > 0.0 {
            input_duration / processing_secs
        } else {
            f64::INFINITY
        };
        eprintln!(
            "Processing time: {:.3}s ({:.1}x realtime)",
            processing_secs, realtime_factor
        );
    }

    // Quantize output samples to 16-bit precision so the noise floor matches
    // the 16-bit reference sources used for quality scoring.  Writing as float
    // WAV preserves these exact quantized values (no double-quantization), and
    // the identity bypass (ratio=1.0) already returns samples that are 16-bit
    // quantized from the input read, so this step is a no-op for passthrough.
    let mut output = output;
    for s in output.data.iter_mut() {
        *s = (*s * 32768.0).round() / 32768.0;
        // Clamp to [-1, 1] so float WAV output matches PCM-16 range used by
        // reference encoders (rubberband).  Without this, overlap-add peaks
        // that exceed full-scale inflate spectral energy vs the reference.
        *s = s.clamp(-1.0, 1.0);
    }

    // Write output
    let write_result = if format_24bit {
        timestretch::io::wav::write_wav_file_24bit(output_path, &output)
    } else {
        // Default to 32-bit float to preserve full DSP precision and avoid
        // 16-bit quantization noise that degrades LSD in quiet/silent regions.
        timestretch::io::wav::write_wav_file_float(output_path, &output)
    };

    if let Err(e) = write_result {
        eprintln!("ERROR: Failed to write {}: {}", output_path, e);
        std::process::exit(1);
    }

    eprintln!("Written to {}", output_path);
}

/// `timestretch-cli analyze <input.wav> [-o artifact.json]`
///
/// Runs offline pre-analysis once and writes the reusable artifact as JSON
/// (default: a `.tsanalysis.json` sidecar next to the input file).
fn run_analyze(args: &[String]) {
    if args.len() < 3 {
        eprintln!("Usage: timestretch-cli analyze <input.wav> [-o <artifact.json>] [--verbose]");
        std::process::exit(1);
    }
    let input_path = &args[2];

    let mut output_path: Option<String> = None;
    let mut verbose = false;
    let mut i = 3;
    while i < args.len() {
        match args[i].as_str() {
            "-o" | "--output" => {
                i += 1;
                if i >= args.len() {
                    eprintln!("ERROR: -o requires a file path");
                    std::process::exit(1);
                }
                output_path = Some(args[i].clone());
            }
            "--verbose" | "-v" => verbose = true,
            other => {
                eprintln!("ERROR: Unknown analyze option '{}'", other);
                std::process::exit(1);
            }
        }
        i += 1;
    }
    let output_path = output_path.unwrap_or_else(|| default_sidecar_path(input_path));

    let buffer = match timestretch::io::wav::read_wav_file(input_path) {
        Ok(b) => b,
        Err(e) => {
            eprintln!("ERROR: Failed to read {}: {}", input_path, e);
            std::process::exit(1);
        }
    };

    eprintln!(
        "Input: {} frames, {} Hz, {:?}, {:.2}s",
        buffer.num_frames(),
        buffer.sample_rate,
        buffer.channels,
        buffer.duration_secs()
    );

    let analysis_signal = timestretch::downmix_to_mid(&buffer.data, buffer.channels.count());
    let (artifact, report) =
        timestretch::analyze_for_dj_with_report(&analysis_signal, buffer.sample_rate);

    eprintln!(
        "Analysis: {:.1} BPM, confidence {:.2}, {} beats, {} onsets ({:.3}s)",
        artifact.bpm,
        artifact.confidence,
        artifact.beat_positions.len(),
        artifact.transient_onsets.len(),
        report.analysis_elapsed_secs
    );

    if verbose {
        println!("METRIC odf_median={:.6}", report.odf_median);
        println!("METRIC odf_mad={:.6}", report.odf_mad);
        println!("METRIC odf_max={:.6}", report.odf_max);
        println!("METRIC onset_count={}", report.onset_count);
        println!("METRIC onset_rate_per_sec={:.3}", report.onset_rate_per_sec);
        println!(
            "METRIC analysis_realtime_factor={:.1}",
            buffer.duration_secs() / report.analysis_elapsed_secs.max(1e-9)
        );
        println!("METRIC bpm={:.2}", artifact.bpm);
        println!("METRIC confidence={:.3}", artifact.confidence);
    }

    if let Err(e) = timestretch::write_preanalysis_json(Path::new(&output_path), &artifact) {
        eprintln!("ERROR: Failed to write {}: {}", output_path, e);
        std::process::exit(1);
    }
    eprintln!("Written to {}", output_path);
}

/// Default artifact path: `<input>.tsanalysis.json` next to the audio file.
fn default_sidecar_path(input_path: &str) -> String {
    format!("{}.tsanalysis.json", input_path)
}

fn print_usage() {
    eprintln!("Usage: timestretch-cli <input.wav> <output.wav> [options]");
    eprintln!("       timestretch-cli analyze <input.wav> [-o <artifact.json>]");
    eprintln!();
    eprintln!("Modes:");
    eprintln!("  --ratio <f>                   Stretch ratio (1.5 = 50% slower)");
    eprintln!("  --from-bpm <f> --to-bpm <f>   BPM matching (auto-selects DJ preset)");
    eprintln!("  --auto-bpm --to-bpm <f>       Auto-detect source BPM, match to target");
    eprintln!("  --pitch <f>                   Pitch shift (2.0 = up one octave)");
    eprintln!("  analyze                       Write a reusable pre-analysis artifact");
    eprintln!();
    eprintln!("Options:");
    eprintln!("  --preset <name>       dj, house, halftime, ambient, vocal");
    eprintln!("  --window <type>       hann (default), blackman-harris, kaiser:<beta>");
    eprintln!("  --streaming           Use streaming (chunked) processor instead of batch");
    eprintln!("  --chunk-size <N>      Frames per streaming chunk (default: 1024)");
    eprintln!("  --pre-analysis <f>    Use a pre-analysis artifact (from `analyze`);");
    eprintln!("                        validated against the input, ignored if stale");
    eprintln!("  --normalize, -n       Match output RMS to input (default: on)");
    eprintln!("  --no-normalize        Disable RMS matching");
    eprintln!("  --24bit               Write 24-bit PCM output (default: 16-bit)");
    eprintln!("  --float               Write 32-bit float output");
    eprintln!("  --verbose, -v         Show detailed processing parameters and timing");
    eprintln!();
    eprintln!("Examples:");
    eprintln!("  timestretch-cli in.wav out.wav --ratio 1.5");
    eprintln!("  timestretch-cli in.wav out.wav --from-bpm 126 --to-bpm 128");
    eprintln!("  timestretch-cli in.wav out.wav --auto-bpm --to-bpm 128");
    eprintln!("  timestretch-cli in.wav out.wav --pitch 0.5 --preset vocal");
    eprintln!("  timestretch-cli in.wav out.wav --ratio 2.0 --window blackman-harris --normalize");
    eprintln!("  timestretch-cli in.wav out.wav 1.5 house");
    eprintln!("  timestretch-cli analyze in.wav");
    eprintln!(
        "  timestretch-cli in.wav out.wav --ratio 1.05 --pre-analysis in.wav.tsanalysis.json"
    );
}

fn parse_f64(args: &[String], idx: usize, name: &str) -> f64 {
    if idx >= args.len() {
        eprintln!("ERROR: --{} requires a value", name);
        std::process::exit(1);
    }
    match args[idx].parse() {
        Ok(v) => v,
        Err(_) => {
            eprintln!("ERROR: Invalid {}: {}", name, args[idx]);
            std::process::exit(1);
        }
    }
}

fn parse_usize(args: &[String], idx: usize, name: &str) -> usize {
    if idx >= args.len() {
        eprintln!("ERROR: --{} requires a value", name);
        std::process::exit(1);
    }
    match args[idx].parse() {
        Ok(v) => v,
        Err(_) => {
            eprintln!("ERROR: Invalid {}: {}", name, args[idx]);
            std::process::exit(1);
        }
    }
}

fn parse_preset(args: &[String], idx: usize) -> EdmPreset {
    if idx >= args.len() {
        eprintln!("ERROR: --preset requires a value");
        std::process::exit(1);
    }
    parse_preset_str(&args[idx])
}

fn parse_window(args: &[String], idx: usize) -> WindowType {
    if idx >= args.len() {
        eprintln!("ERROR: --window requires a value (hann, blackman-harris, kaiser:<beta>)");
        std::process::exit(1);
    }
    parse_window_str(&args[idx])
}

fn parse_window_str(s: &str) -> WindowType {
    match s {
        "hann" => WindowType::Hann,
        "blackman-harris" | "bh" => WindowType::BlackmanHarris,
        other if other.starts_with("kaiser:") => {
            let beta_str = &other["kaiser:".len()..];
            match beta_str.parse::<f64>() {
                Ok(beta) if beta >= 0.0 => WindowType::Kaiser((beta * 100.0).round() as u32),
                _ => {
                    eprintln!(
                        "ERROR: Invalid Kaiser beta: '{}' (expected positive number)",
                        beta_str
                    );
                    std::process::exit(1);
                }
            }
        }
        "kaiser" => WindowType::Kaiser(800), // default beta=8.0
        other => {
            eprintln!(
                "ERROR: Unknown window type '{}' (use hann, blackman-harris, or kaiser:<beta>)",
                other
            );
            std::process::exit(1);
        }
    }
}

fn parse_preset_str(s: &str) -> EdmPreset {
    match s {
        "dj" => EdmPreset::DjBeatmatch,
        "house" => EdmPreset::HouseLoop,
        "halftime" => EdmPreset::Halftime,
        "ambient" => EdmPreset::Ambient,
        "vocal" => EdmPreset::VocalChop,
        other => {
            eprintln!("WARNING: Unknown preset '{}', using HouseLoop", other);
            EdmPreset::HouseLoop
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_window_hann() {
        assert_eq!(parse_window_str("hann"), WindowType::Hann);
    }

    #[test]
    fn test_parse_window_blackman_harris() {
        assert_eq!(
            parse_window_str("blackman-harris"),
            WindowType::BlackmanHarris
        );
    }

    #[test]
    fn test_parse_window_blackman_harris_short() {
        assert_eq!(parse_window_str("bh"), WindowType::BlackmanHarris);
    }

    #[test]
    fn test_parse_window_kaiser_default() {
        assert_eq!(parse_window_str("kaiser"), WindowType::Kaiser(800));
    }

    #[test]
    fn test_parse_window_kaiser_with_beta() {
        assert_eq!(parse_window_str("kaiser:12"), WindowType::Kaiser(1200));
    }

    #[test]
    fn test_parse_window_kaiser_fractional_beta() {
        assert_eq!(parse_window_str("kaiser:5.5"), WindowType::Kaiser(550));
    }
}