From 4f4416ff213b8287778868a4b18e332b1c012d4f Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Fri, 13 Sep 2024 10:44:57 +0200 Subject: Init --- .gitignore | 3 + README.md | 13 + build.bat | 2 + build.sh | 4 + end.html | 33 ++ main.odin | 209 ++++++++++ sketch.html | 1289 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ start.html | 9 + start2.html | 103 +++++ 9 files changed, 1665 insertions(+) create mode 100644 .gitignore create mode 100755 README.md create mode 100755 build.bat create mode 100755 build.sh create mode 100755 end.html create mode 100755 main.odin create mode 100755 sketch.html create mode 100755 start.html create mode 100755 start2.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2dfbc9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pdb +*.exe +*.csv \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..ebe7f61 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# better-report + +Makes your sound reports better. +Only tested with reports from 688 at the moment. +Turns the awkward Sound Devices-generated CSV into a beautiful self-contained HTML file. + +Enbettermentifications: +- [X] Actually correctly sorted reports +- [X] Will let you change the sorting while looking at it +- [X] Removes empty tracks, so everything lines up with the actual wav files +- [X] Less ugly than most software for viewing CSV-files +- [X] Place a nice little logo in a top corner for branding +- [X] HTML is a format basically everyone can open anywhere \ No newline at end of file diff --git a/build.bat b/build.bat new file mode 100755 index 0000000..0890ae1 --- /dev/null +++ b/build.bat @@ -0,0 +1,2 @@ +odin build main.odin -file -debug -pdb-name:better-report.pdb -out:better-report.exe +odin build main.odin -file -o:speed -out:C:/tools/better-report.exe diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c40b73b --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +odin build main.odin -file -debug -out:better-report +odin build main.odin -file -o:speed -out:/home/san/scripts/better-report +chmod +x better-report +chmod +x /home/san/scripts/better-report diff --git a/end.html b/end.html new file mode 100755 index 0000000..f964978 --- /dev/null +++ b/end.html @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/main.odin b/main.odin new file mode 100755 index 0000000..03f1655 --- /dev/null +++ b/main.odin @@ -0,0 +1,209 @@ +package main + +import "core:fmt" +import "core:os" +import "core:path/filepath" +import "core:strings" + +PART_ONE :: #load("start.html", string) +PART_TWO :: #load("start2.html", string) +PART_END :: #load("end.html", string) + +main :: proc() { + + input_file_name : string + if len(os.args) < 2 { + // Attempt to auto-detect CSVs, but filepath.glob is broken. + // It doesn't return anything if you run the exe from a PATH folder. + + /* fmt.println("No file submitted. Using first CSV found.") + glob_pattern := fmt.aprintf("{}\\*.*", os.get_current_directory()) + fmt.println(glob_pattern) + csvs, _ := filepath.glob(glob_pattern) + fmt.println(csvs) + input_file_name = csvs[0] */ + fmt.println("ERROR: No file submitted.") + return + } else { + fmt.printf("Input CSV: {}\n", os.args[1]) + input_file_name = os.args[1] + } + + + // Reading CSV file + + data, ok := os.read_entire_file(input_file_name, context.allocator) + if !ok { + fmt.printf("ERROR: Could not read file: {}\n", os.args[1]) + return + } + defer delete(data, context.allocator) + + total_output: string = PART_ONE // Page title + total_output = append(total_output, fmt.aprintf("{} - Lydrapport", input_file_name[len(input_file_name)-17:len(input_file_name)-11])) + total_output = append(total_output, PART_TWO) + it := string(data) + + // First we do a pass to find out at what column the channels start and end, + // and to find out how many channels we actually use at maximum. + // This will let us compress the channel columns to only what is needed. + + tracks_start := 0 + tracks_end := 0 + max_tracks := 0 + line_index := 0 + for line in strings.split_lines_iterator(&it) { + tracks_seen_this_line := 0 + for element, e in strings.split(line, ",") { + if element == "Trk 1" { + tracks_start = e + fmt.printf("Tracks start at: {}\n", tracks_start) + } + if element == "Notes" { + tracks_end = e-1 + fmt.printf("Tracks end at: {}\n", tracks_end) + } + if e >= tracks_start && tracks_end >= e { // If there's anything in the range of where tracks are, count it + if element != "" do tracks_seen_this_line += 1 + } + } + // Update the max + if tracks_seen_this_line > max_tracks { + max_tracks = tracks_seen_this_line + fmt.printf("Highest track count so far found on line {}, with {} tracks.\n", line_index, max_tracks) + } + line_index += 1 + } + potensial_tracks := tracks_end+1 - tracks_start + unused_tracks := potensial_tracks - max_tracks + + // Now we output the HTML. + + it = string(data) + line_index = 0 + blank_lines := 0 + state : states = .TITLE + time_in_state := 0 + info_reading_to_field := true + for line in strings.split_lines_iterator(&it) { + //fmt.printf("state.{} line_index:{} t:{} blank_lines:{} : \t", state, line_index, time_in_state, blank_lines) + there_was_content_in_line := false + + // Writing the headers and section stuff. + #partial switch state { + case .HEADER: + if time_in_state == 1 do total_output = append(total_output, " \n \n \n") + + case .BODY: + total_output = append(total_output, " \n") + } + + columns_skipped := 0 + for element, e in strings.split(line, ",") { + if len(element)> 0 do there_was_content_in_line = true + if len(element)> 0 do blank_lines = 0 + // Filling the row of data + switch state { + case .TITLE: + //fmt.printf("{} T ", element) + case .INFO: + //fmt.printf("{} I ", element) + + if len(element)>0 { + if info_reading_to_field { + total_output = append(total_output, fmt.aprintf("

{}", element)) + } else { + total_output = append(total_output, fmt.aprintf(" {}

\n", element[1:len(element)-1])) + } + info_reading_to_field = !info_reading_to_field + } + + case .HEADER: + //fmt.printf("{} H ", element) + if time_in_state == 1 { + if e == 4 { // Magic number to select the default sorting column + total_output = append(total_output, fmt.aprintf(" \n", element)) + } else if e <= tracks_start+max_tracks-1 || e > tracks_end { + total_output = append(total_output, fmt.aprintf(" \n", element)) + } + } + + case .BODY: + //fmt.printf("{} B ", element) + if e == tracks_end+1 { + for _ in 0..<(columns_skipped - unused_tracks) { // Add padding so note at end ligns up + total_output = append(total_output, " \n") + } + } + if element != "" { + + if e >= tracks_start { + total_output = append(total_output, fmt.aprintf(" \n", element[1:len(element)-1])) + /*} else if e == 0 { // Making filename a link to the file + total_output = append(total_output, fmt.aprintf(" \n", element, element))*/ + } else { + total_output = append(total_output, fmt.aprintf(" \n", element)) + } + + } else { + columns_skipped += 1 + } + } + } + // Advancing state machine and finishing off divs n stuff + switch state { + case .TITLE: + if line_index==1 { + state = .INFO + time_in_state = 0 + } + case .INFO: + if blank_lines > 1 { + total_output = append(total_output, " \n \n") + state = .HEADER + time_in_state = 0 + } + case .HEADER: + if blank_lines > 0 { + state = .BODY + time_in_state = 0 + total_output = append(total_output, " \n \n \n") + } + case .BODY: + total_output = append(total_output, " \n") + } + if there_was_content_in_line { + blank_lines = 0 + } else { + blank_lines += 1 + } + //fmt.printf("\n") + line_index += 1 + time_in_state += 1 + } + total_output = append(total_output, PART_END) + + output_file_name := fmt.aprintf("{}_Knekt.html", os.args[1][:len(os.args[1])-4]) + os.remove(output_file_name) + output_file_handle, _ := os.open(output_file_name, os.O_CREATE, 0o777) + os.write_string(output_file_handle, "") // TODO: Figure out how to write this to a file + os.write_string(output_file_handle, total_output) // TODO: Figure out how to write this to a file + os.close(output_file_handle) + fmt.printf("Wrote file: {}", output_file_name) + //fmt.printf("\n\n\nTOTAL OUTPUT:\n\n\n") + //fmt.println(total_output) +} + +append :: proc(input, to_add: string) -> string { + output := strings.concatenate({input, to_add}) + //delete(to_add) + //delete(input) + return output +} + +states :: enum { + TITLE, + INFO, + HEADER, + BODY, +} \ No newline at end of file diff --git a/sketch.html b/sketch.html new file mode 100755 index 0000000..16db49f --- /dev/null +++ b/sketch.html @@ -0,0 +1,1289 @@ + + + + + + + + + Better Report Test + + + + + + + + + + + + + + +
+
+

Project: Heim

+

Producer: Bente Maalen

+

Production Sound Mixer: Sander Jacobsson Skjegstad

+

Tlf: +47 908 71 217

+

Boom Operator: Lars Jakob Hesby

+
+
{}{}{}{}{}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
File NameSceneTakeLengthStart TCTrk 1Trk 2Trk 3Trk 4Trk 5Trk 6Trk 7Trk 8Trk 9Trk 10Trk 11Trk 12Trk 13Trk 14Trk 15Trk 16Notes
SL150T01.WAVSL1500100:03:3915:48:06:00MixLMixRBOOMANNIODD BJORNPLANT
SL150T02.WAVSL1500200:03:4416:01:58:00MixLMixRBOOMANNIODD BJORNPLANT
SL150T03.WAVSL1500300:01:2916:08:48:00MixLMixRBOOMANNIODD BJORNPLANT
SL151T01.WAVSL1510100:01:0416:25:24:00MixLMixRBOOMANNIODD BJORNPLANT
SL151T03.WAVSL1510300:01:1916:33:49:00MixLMixRBOOMANNIODD BJORN
SL152T02.WAVSL1520200:01:0816:46:31:00MixLMixRBOOMANNIODD BJORN
SL152T01.WAVSL1520100:01:2116:42:13:00MixLMixRBOOMANNIODD BJORN
SL152T03.WAVSL1520300:01:1116:49:24:00MixLMixRBOOMANNIODD BJORN
SL153T01.WAVSL1530100:04:4816:59:01:00MixLMixRBOOMANNIODD BJORN
SL153T02.WAVSL1530200:03:0417:04:36:00MixLMixRBOOMANNIODD BJORNPLANT
SL154T01.WAVSL1540100:02:0617:12:37:00MixLMixRBOOMANNIODD BJORNPLANT
SL155T02.WAVSL1550200:02:1817:26:40:00MixLMixRBOOMANNIODD BJORNPLANT
SL155T01.WAVSL1550100:02:3717:20:51:00MixLMixRBOOMANNIODD BJORNPLANT
SL156T02.WAVSL1560200:01:1117:44:02:00MixLMixRBOOMANNIODD BJORNPLANT
SL156T01.WAVSL1560100:01:3617:38:20:00MixLMixRBOOMANNIODD BJORNPLANT
SL157T01.WAVSL1570100:01:3717:55:31:00MixLMixRBOOMANNIODD BJORNPLANT
SL158T02.WAVSL1580200:01:1318:35:14:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL158T01.WAVSL1580100:01:0918:29:09:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL158T03.WAVSL1580300:01:1818:39:45:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL158T04.WAVSL1580400:01:2318:43:34:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL158T05.WAVSL1580500:01:2318:45:24:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL159T01.WAVSL1590100:00:5818:56:00:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL159T02.WAVSL1590200:01:3019:00:16:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL160T01.WAVSL1600100:00:4119:14:57:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL160T02.WAVSL1600200:00:3419:18:07:00MixLMixRBOOMANNIERIKPLANTLED NOISE AT 6 KHZ 11.8 KHZ 17.75 KHZ
SL161T01.WAVSL1610100:01:4920:18:40:00MixLMixRBOOMANNIERIKPLANT PRINTER
SL161T02.WAVSL1610200:01:5420:28:18:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL162T01.WAVSL1620100:01:5420:38:31:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL163T01.WAVSL1630100:02:1320:44:45:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL163T02.WAVSL1630200:02:0220:48:55:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL164T01.WAVSL1640100:02:2420:54:38:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL165T01.WAVSL1650100:01:4521:14:07:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL165T02.WAVSL1650200:01:5421:19:25:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL168T01.WAVSL1680100:02:2921:54:29:00MixLMixRBOOMANNIELLA
SL166T01.WAVSL1660100:03:4321:26:16:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREENBEATBOX LEGEND
SL167T01.WAVSL1670100:00:5321:37:23:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREENWILD OF ERIK SAYING ANNI
SL166T02.WAVSL1660200:02:5121:31:50:00MixLMixRBOOMANNIERIKPLANT PRINTERPLANT SCREEN
SL168T02.WAVSL1680200:03:0722:01:12:00MixLMixRBOOMANNIELLA
SL170T01.WAVSL1700100:01:3922:23:20:00MixLMixRBOOMANNIELLA
SL169T02.WAVSL1690200:00:3822:13:49:00MixLMixRBOOMANNIELLA
SL169T01.WAVSL1690100:03:4722:10:02:00MixLMixRBOOMANNIELLA
SL171T01.WAVSL1710100:01:1622:44:02:00MixLMixRBOOMANNIELLA
SL171T02.WAVSL1710200:01:0422:46:57:00MixLMixRBOOMANNIELLA
SL171T03.WAVSL1710300:00:5922:49:45:00MixLMixRBOOMANNIELLA
SL171T04.WAVSL1710400:01:1422:50:49:00MixLMixRBOOMANNIELLA
SL172T01.WAVSL1720100:00:4822:53:19:00MixLMixRBOOMANNIELLA
+ + + + + + + \ No newline at end of file diff --git a/start.html b/start.html new file mode 100755 index 0000000..a1e9809 --- /dev/null +++ b/start.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/start2.html b/start2.html new file mode 100755 index 0000000..bd0021e --- /dev/null +++ b/start2.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + +

Lydrapport

+
Version 0.2
+
+
\ No newline at end of file -- cgit v1.2.1