aboutsummaryrefslogtreecommitdiff
path: root/src/wav
diff options
context:
space:
mode:
authorSan Jacobs2025-12-21 06:50:16 +0100
committerSan Jacobs2025-12-21 06:50:16 +0100
commit7c5a4bd34e286608d61735bd77f5635dc6bc227e (patch)
tree41378b766ecec3a758f1dcb7c26165d174352f06 /src/wav
parenteeb72b021c5c8d6ccafbcdbce398d848f49b053e (diff)
downloadbetter-report-7c5a4bd34e286608d61735bd77f5635dc6bc227e.tar.gz
better-report-7c5a4bd34e286608d61735bd77f5635dc6bc227e.tar.bz2
better-report-7c5a4bd34e286608d61735bd77f5635dc6bc227e.zip
Major restructuring, GUI, icons, MacOS compatibility, fixes
Diffstat (limited to 'src/wav')
-rw-r--r--src/wav/wav.odin15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/wav/wav.odin b/src/wav/wav.odin
index bfa11b1..89dd5eb 100644
--- a/src/wav/wav.odin
+++ b/src/wav/wav.odin
@@ -110,7 +110,7 @@ main :: proc() {
/*
Reads in the wav file metadata, without loading the sound data into ram.
*/
-read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #optional_ok {
+read :: proc(path : string, allocator := context.allocator) -> (Wav, bool) #optional_ok {
file : Wav
file.path = path
file.take = -1
@@ -126,11 +126,10 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option
return {}, false
}
-
- temp_buf := new([BUFFER_SIZE]u8)[:]
+ temp_buf := make([]u8, BUFFER_SIZE)
+ defer delete(temp_buf)
temp_bext : []u8
temp_ixml : string
- defer delete(temp_buf)
os.read(file.handle, temp_buf)
@@ -318,7 +317,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option
*/
interleave_set := false
- xml_recurse :: proc(doc: ^xml.Document, element_id: xml.Element_ID, file: ^Wav, naming_channel: ^int, interleave_set: ^bool, allocator:=context.allocator, indent := 0) {
+ xml_recurse :: proc(doc: ^xml.Document, element_id: xml.Element_ID, file: ^Wav, naming_channel: ^int, interleave_set: ^bool, allocator:type_of(context.allocator), indent := 0) {
naming_channel := naming_channel
interleave_set := interleave_set
@@ -448,6 +447,9 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option
parsed_ixml : ^xml.Document
+ prev_alloc := context.allocator
+ defer context.allocator = prev_alloc
+ context.allocator = context.temp_allocator
parsed_ixml, _ = xml.parse(temp_ixml, xml.Options{
flags={.Ignore_Unsupported},
expected_doctype = "",
@@ -469,7 +471,7 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option
description := string(temp_bext[:256])
for line in strings.split_lines(description) {
-
+ if len(line)<1 do continue
if file.channel_names[naming_channel] == "" &&
(strings.starts_with(line, "sTRK") || strings.starts_with(line, "zTRK")) {
eq_index := strings.index(line, "=")
@@ -545,7 +547,6 @@ read :: proc(path : string, allocator:=context.allocator) -> (Wav, bool) #option
// just here to make some printing prettier
temp_bext = nil
- temp_buf = nil
return file, true
}