diff options
| author | San Jacobs | 2025-12-16 07:31:37 +0100 |
|---|---|---|
| committer | San Jacobs | 2025-12-16 07:31:37 +0100 |
| commit | 466bf5ec49bc6f99c827b6452e2b6d937ad115f5 (patch) | |
| tree | 2d488e4a6888ffb2a0a8454ff86367d1ff1da25b /src/wav | |
| parent | dae712ac1cbe9751c8da0e826b8111351cf9519d (diff) | |
| download | better-report-466bf5ec49bc6f99c827b6452e2b6d937ad115f5.tar.gz better-report-466bf5ec49bc6f99c827b6452e2b6d937ad115f5.tar.bz2 better-report-466bf5ec49bc6f99c827b6452e2b6d937ad115f5.zip | |
Tunings and todos
Diffstat (limited to 'src/wav')
| -rw-r--r-- | src/wav/wav.odin | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/wav/wav.odin b/src/wav/wav.odin index 14ed74a..bfd8a55 100644 --- a/src/wav/wav.odin +++ b/src/wav/wav.odin @@ -7,6 +7,11 @@ import "core:strconv" import "core:os" import "xml" +/* +TODO: Support RF64 +TODO: Support music metadata +*/ + Wav :: struct { // Basic data path : string, @@ -83,17 +88,23 @@ main :: proc() { when VERBOSE do fmt.printf("\n\nenok = %#v\n\n", enok) prins, prins_ok := read("test/WAVs/KRONPRINS01T01.wav", context.temp_allocator) when VERBOSE do fmt.printf("\n\nprins = %#v\n\n", prins) + */ f8, f8_ok := read("test/WAVs/F8-SL098-T001.WAV", context.temp_allocator) when VERBOSE do fmt.printf("\n\nf8 = %#v\n\n", f8) + load(&f8) + wave_print(f8.audio[0]) + + /* ski, ski_ok := read("test/WAVs/FOLEY, SKI, KLAEBO 01, LCR.wav", context.temp_allocator) when VERBOSE do fmt.printf("\n\nSKI = %#v\n\n", ski) load(&ski) wave_print(ski.audio[0]) - */ + t, t_ok := read("test/WAVs/test_data.wav", context.temp_allocator) when VERBOSE do fmt.printf("\n\nTEST = %#v\n\n", t) - load(&t) + load(&t, {1}, allocator=context.temp_allocator) wave_print(t.audio[1]) + */ } /* @@ -111,7 +122,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option defer os.close(file.handle) defer file.handle = 0 if load_err != os.General_Error.None { - fmt.eprintln("ERROR %v: Unable to load file \"%v\"", load_err, path) + fmt.eprintfln("ERROR %v: Unable to load file \"%v\"", load_err, path) return {}, false } @@ -236,7 +247,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option if file.format == .ADPCM { - // TODO: Support ADPCM + // TODO: Support ADPCM (Very low priority) when VERBOSE do fmt.println("Samples pr chunk (In bit-depth field because it's unsupported):", file.bit_depth) } else { if valid_bits_pr_sample < bits_pr_sample { @@ -667,16 +678,22 @@ wave_print :: proc(wave : []f32) { fmt.printf(" %+01.04f\n", sample) } } -bar_print :: proc(x : f32, one_side_width : int = 25) { +bar_print :: proc(x : f32, one_side_width : int = 64, sign := '#', square := true) { + x := x + positive := x>0 + if square { + x = math.sqrt(abs(x)) + if !positive do x *= -1 + } bar_length := int(math.round(abs(min(x, 1))*f32(one_side_width))) spaces := one_side_width-bar_length - if x>0 { + if positive { for _ in 0..<one_side_width { fmt.print(" ") } fmt.print("|") for _ in 0..<bar_length { - fmt.print("#") + fmt.print(sign) } for _ in 0..<spaces { fmt.print(" ") @@ -686,7 +703,7 @@ bar_print :: proc(x : f32, one_side_width : int = 25) { fmt.print(" ") } for _ in 0..<bar_length { - fmt.print("#") + fmt.print(sign) } fmt.print("|") for _ in 0..<one_side_width { |