// // main.swift // WaterfallFile // // Created by Jacky Jack on 23/12/2024. // import Foundation import Accelerate import ArgumentParser //set the command line arguments struct CommandLineArgs: ParsableCommand { @Argument var inputFile:String = "" @Argument var outputFile:String = "" } let args = CommandLineArgs.parseOrExit() print("Read binary file") let input_filename=args.inputFile //get data from u8 file let fileReader = FileReader() do { try fileReader.open(filename: input_filename) } catch { print("Cant open file \(input_filename)") exit(0) } var i8_arr:[Int8]? = nil do { try i8_arr = fileReader.readAll() } catch { print("Got error \(error)") } fileReader.close() //all data in buffer lets process data //convert all u8 data to float's //is there other ways to do that? //will generate 512x512 image let sampleCount = 512 let img = SimpleImage(width: sampleCount, height: sampleCount) let number_of_lines = (i8_arr!.count/sampleCount) var frequencyDomain:[Float] = [] var transform_result:[Float] = .init(repeating: 0.0, count: sampleCount) let fft512 = NaiveFFT512() for i in 0..