// // main.swift // GenSin // // Created by Jacky Jack on 21/02/2025. // import Foundation import ArgumentParser /* Takes as input */ enum OutputFormat { case FMT_NONE case FMT_U8 case FMT_S8 case FMT_U16 case FMT_S16 case FMT_SC16Q11 case FMT_F32 case FMT_WAV_INT16 case FMT_WAV_F32 } print("gen sin") //set the command line arguments struct CommandLineArgs: ParsableCommand { @Argument var outputFile:String = "" @Flag(help:"Version \(software_version)") var version: Bool = false @Flag(name: .shortAndLong) var verbose: Bool = false @Option(name:.shortAndLong) var samplerate: Int = 1000 @Option(name:.shortAndLong) var amplitude: Float = 1.0 @Option(name:.shortAndLong) var freq: Int = 10 @Option(name:.shortAndLong) var num: Int = 100000 //@Option(name:.shortAndLong) var type: String = "sine" @Flag(name: .shortAndLong) var listFormats: Bool = false } let args = CommandLineArgs.parseOrExit() if args.listFormats { print("Supported output:") print(" s8,u8: [DONE]") print(" s16,u16: not") print(" s16q11: not") print(" f32: not ") print(" wav i16, fc32: not") } //outputfile Format var outputFormat = OutputFormat.FMT_NONE if let dotIndex = args.outputFile.lastIndex(of: ".") { let index = args.outputFile.index(dotIndex, offsetBy: 1) let fileExtension = String(args.outputFile[index..