summaryrefslogtreecommitdiff
path: root/Radio
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-02-03 22:31:45 +0000
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-02-03 22:31:45 +0000
commit972a6d3e4d3b684fbadeb5cd046a8634ec24eb8c (patch)
treee96c4ce2d649558cc0b7b452d7a64fbe980b65c0 /Radio
parent1e096e55ca30dc80c3faa8d1ea36de13bc90cc6a (diff)
downloadPrySDR-972a6d3e4d3b684fbadeb5cd046a8634ec24eb8c.tar.gz
PrySDR-972a6d3e4d3b684fbadeb5cd046a8634ec24eb8c.zip
iqconvert: converts from u8 to f32 without issuesmain
Diffstat (limited to 'Radio')
-rw-r--r--Radio/Utils/iqconvert/main.swift50
1 files changed, 48 insertions, 2 deletions
diff --git a/Radio/Utils/iqconvert/main.swift b/Radio/Utils/iqconvert/main.swift
index f619529..49db280 100644
--- a/Radio/Utils/iqconvert/main.swift
+++ b/Radio/Utils/iqconvert/main.swift
@@ -35,7 +35,7 @@ if args.listFormats {
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(" fc32: inspectrum, sdr++ ")
print(" wav: SDR# [not suppoprted]")
}
@@ -84,8 +84,54 @@ if let dotIndex = args.outputFile.lastIndex(of: ".") {
print("Input file format:\(inputFormat) output file format:\(outputFormat)")
+//read from file
+//if let data_u8:[UInt8] = fileReader.readAll() {
+var data_u8:[UInt8] = []
+do {
+ data_u8 = try fileReader.readAll()
+} catch {
+ print("Reading file: \(error)")
+ exit(1)
+}
-fileReader.close()
+//convert to output format
+var outdata_f32:[Float32] = []
+if data_u8.count > 0 {
+ outdata_f32 = cnvU8toFloat32(data_u8)
+} else {
+ print("No data in buffer")
+}
+// write to file
+let fileWrite = FileWriter()
+var file_ok = false
+if (checkIfFileExists(args.outputFile)) {
+ do {
+ print("try to delet file for write")
+ try fileWrite.deleteForWrite(filename: args.outputFile)
+ } catch {
+ print("cant delete file \(error)")
+ exit(1)
+ }
+} else {
+ do {
+ print("try to creating file")
+ try fileWrite.createForWrite(filename: args.outputFile)
+ } catch {
+ print("cant create file \(error)")
+ exit(1)
+ }
+}
+
+do {
+ try fileWrite.writeAll(outdata_f32)
+} catch {
+ print("Cant write to file \(error)")
+ exit(1)
+}
+
+
+fileReader.close()
+fileWrite.close()