summaryrefslogtreecommitdiff
path: root/Radio/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'Radio/Utils')
-rw-r--r--Radio/Utils/WaterfallFile/NaiveFFT512.swift24
-rw-r--r--Radio/Utils/WaterfallFile/main.swift2
-rw-r--r--Radio/Utils/iqconvert/main.swift91
3 files changed, 94 insertions, 23 deletions
diff --git a/Radio/Utils/WaterfallFile/NaiveFFT512.swift b/Radio/Utils/WaterfallFile/NaiveFFT512.swift
index 0e6373a..510d784 100644
--- a/Radio/Utils/WaterfallFile/NaiveFFT512.swift
+++ b/Radio/Utils/WaterfallFile/NaiveFFT512.swift
@@ -46,28 +46,6 @@ class NaiveFFT512 {
return transform_result
}
- func computeLine1024(_ processingArray: [Int8]) -> [Float] {
-
- var dataFloat = [Float](repeating: 0.0, count: NaiveFFT512.sampleCount*2)
-
- if processingArray.count != NaiveFFT512.sampleCount*2 {
- print("Not supporting arrays not equail to \(NaiveFFT512.sampleCount)")
- return []
- }
-
- vDSP.convertElements(of: processingArray, to: &dataFloat)
- //dataFloat = vDSP.add(127.0, dataFloat)
- //print(dataFloat)
-
- //move from -127.0 to 128.0 range -1.0...1.0
- //var adjusted = vDSP.divide(dataFloat, Float(sampleCount))
- var adjusted = dataFloat
- //print(adjusted)
-
- var transform_result = forwardDCT.transform(adjusted)
- transform_result = vDSP.absolute(transform_result)
-
- return transform_result
- }
+
}
diff --git a/Radio/Utils/WaterfallFile/main.swift b/Radio/Utils/WaterfallFile/main.swift
index 039be72..7717f1c 100644
--- a/Radio/Utils/WaterfallFile/main.swift
+++ b/Radio/Utils/WaterfallFile/main.swift
@@ -11,7 +11,9 @@ import ArgumentParser
//set the command line arguments
struct CommandLineArgs: ParsableCommand {
+ //input file format detected from file extension
@Argument var inputFile:String = ""
+ //output file format detected from file extension
@Argument var outputFile:String = ""
}
diff --git a/Radio/Utils/iqconvert/main.swift b/Radio/Utils/iqconvert/main.swift
new file mode 100644
index 0000000..f619529
--- /dev/null
+++ b/Radio/Utils/iqconvert/main.swift
@@ -0,0 +1,91 @@
+//
+// main.swift
+// iqconvert
+//
+// Created by Jacky Jack on 17/01/2025.
+//
+
+import Foundation
+import ArgumentParser
+
+enum SDRInputFormat {
+ case FMT_NONE
+ case FMT_U8
+ case FMT_F32
+}
+
+//set the command line arguments
+struct CommandLineArgs: ParsableCommand {
+ @Argument var inputFile:String = ""
+ @Argument var outputFile:String = ""
+ @Flag(help:"Version \(software_version)") var version: Bool = false
+ @Flag(name: .shortAndLong) var verbose: Bool = false
+ @Flag(name: .shortAndLong) var listFormats: Bool = false
+}
+
+let args = CommandLineArgs.parseOrExit()
+
+if args.listFormats {
+ print("Supported input:")
+ print(" u8: RTLSDR [not supported]")
+ print(" u16: AirSpyHF [not supported]")
+ print(" u16r: AirSpy [not supported]")
+ print(" i16: AirSpy [not supported]")
+ print(" i16r: AirSpy [not supported]") //int16 real 1 * 16bit per sample
+ print(" sc16q11: BladeRF [not supported]")
+ print(" fc32r: AirSpy [not supported]") //float32 real 1 * 32bit per sampl
+ print("Supported output:")
+ print(" fc32: inspectrum, sdr++ [not supported]")
+ print(" wav: SDR# [not suppoprted]")
+}
+
+//var inputFilePath:String
+//check if input file exists as parameter is given
+if !checkIfFileExists(args.inputFile) {
+ print("Error: Input file \(args.inputFile) does not exist")
+ exit(1)
+}
+
+let fileReader = FileReader()
+do {
+ try fileReader.open(filename: args.inputFile)
+} catch {
+ print("ERROR: \(error) - Cant open file \(args.inputFile)")
+ exit(1)
+}
+
+var inputFormat = SDRInputFormat.FMT_NONE
+//file is open lets detect extension
+if let dotIndex = args.inputFile.lastIndex(of: ".") {
+ let index = args.inputFile.index(dotIndex, offsetBy: 1)
+ let fileExtension = String(args.inputFile[index..<args.inputFile.endIndex])
+ print("\(args.inputFile) extension \(fileExtension)")
+ let supportedExtensionList = ["u8","cu8"]
+ if supportedExtensionList.contains(fileExtension) {
+ if ["u8","cu8"].contains(fileExtension) {
+ inputFormat = SDRInputFormat.FMT_U8
+ }
+ }
+}
+
+//outputfile Format
+var outputFormat = SDRInputFormat.FMT_NONE
+if let dotIndex = args.outputFile.lastIndex(of: ".") {
+ let index = args.outputFile.index(dotIndex, offsetBy: 1)
+ let fileExtension = String(args.outputFile[index..<args.outputFile.endIndex])
+ print("\(args.outputFile) extension \(fileExtension)")
+ let supportedExtensionList = ["f32","fc32"]
+ if supportedExtensionList.contains(fileExtension) {
+ if ["f32","fc32"].contains(fileExtension) {
+ outputFormat = SDRInputFormat.FMT_F32
+ }
+ }
+}
+
+print("Input file format:\(inputFormat) output file format:\(outputFormat)")
+
+
+
+fileReader.close()
+
+