summaryrefslogtreecommitdiff
path: root/Gen
diff options
context:
space:
mode:
authorArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-05-23 09:48:25 +0100
committerArturs Artamonovs <arturs.artamonovs@protonmail.com>2025-05-23 09:48:25 +0100
commit76869b1d3eac88cc6bdef2ef6f3a009b5c28c84d (patch)
tree61c1a3bdf7b691fd42336c8d66fd27c633392d56 /Gen
parent5aa1435739fa1cd150dd8cd8fb2fee5473d5ed3f (diff)
downloadPrySDR-76869b1d3eac88cc6bdef2ef6f3a009b5c28c84d.tar.gz
PrySDR-76869b1d3eac88cc6bdef2ef6f3a009b5c28c84d.zip
genearation of s8/u8/s16/u16/s16q11 works as expectedmain
Diffstat (limited to 'Gen')
-rw-r--r--Gen/GenAM.swift7
-rw-r--r--Gen/GenCW.swift7
-rw-r--r--Gen/GenFM.swift7
-rw-r--r--Gen/GenMFSK.swift7
-rw-r--r--Gen/GenTrig.swift31
5 files changed, 59 insertions, 0 deletions
diff --git a/Gen/GenAM.swift b/Gen/GenAM.swift
new file mode 100644
index 0000000..b194c83
--- /dev/null
+++ b/Gen/GenAM.swift
@@ -0,0 +1,7 @@
+//
+// GenAM.swift
+// PrySDR
+//
+// Created by Jacky Jack on 22/05/2025.
+//
+
diff --git a/Gen/GenCW.swift b/Gen/GenCW.swift
new file mode 100644
index 0000000..7699f9a
--- /dev/null
+++ b/Gen/GenCW.swift
@@ -0,0 +1,7 @@
+//
+// GenCW.swift
+// PrySDR
+//
+// Created by Jacky Jack on 22/05/2025.
+//
+
diff --git a/Gen/GenFM.swift b/Gen/GenFM.swift
new file mode 100644
index 0000000..6d8268e
--- /dev/null
+++ b/Gen/GenFM.swift
@@ -0,0 +1,7 @@
+//
+// GenFM.swift
+// PrySDR
+//
+// Created by Jacky Jack on 22/05/2025.
+//
+
diff --git a/Gen/GenMFSK.swift b/Gen/GenMFSK.swift
new file mode 100644
index 0000000..8b99c81
--- /dev/null
+++ b/Gen/GenMFSK.swift
@@ -0,0 +1,7 @@
+//
+// GenMFSK.swift
+// PrySDR
+//
+// Created by Jacky Jack on 22/05/2025.
+//
+
diff --git a/Gen/GenTrig.swift b/Gen/GenTrig.swift
index cc4abb5..fa0cd57 100644
--- a/Gen/GenTrig.swift
+++ b/Gen/GenTrig.swift
@@ -6,6 +6,7 @@
//
import Foundation
+import ComplexModule
/// Generate sin function as float array
/// - Parameters:
@@ -31,6 +32,22 @@ func genSin(_ sample_rate: Int,_ freq: Int,_ ampl: Float,_ phase: Float,_ sample
return out_signal
}
+func genSin(_ sample_rate: Int,_ freq: Int,_ ampl: Float,_ phase: Float,_ sample_num: Int) -> Array<Complex<Float32>> {
+
+ //let one_sec = sample_num/sample_rate
+ let sample_per_hz:Float32 = Float32(sample_rate)/Float32(freq)
+ let hz_step: Float32 = 2*Float32.pi/sample_per_hz
+ var out_signal:[Complex<Float32>] = Array(repeating: Complex<Float32>(Float(0.0)), count: sample_num)
+ var start = phase
+ for i in 0..<sample_num {
+ out_signal[i].real = ampl * sin(start)
+ out_signal[i].imaginary = 0.0
+ start += hz_step
+ }
+
+ return out_signal
+}
+
/// Generate Cos function as float array
/// - Parameters:
/// - sample_rate: sample rate, how many samples per second
@@ -54,3 +71,17 @@ func genCos(_ sample_rate: Int,_ freq: Float,_ ampl: Float,_ phase: Float,_ samp
return out_signal
}
+func genCos(_ sample_rate: Int,_ freq: Float,_ ampl: Float,_ phase: Float,_ sample_num: Int) -> Array<Complex<Float32>> {
+ //let one_sec = sample_num/sample_rate
+ let sample_per_hz:Float32 = Float32(sample_rate)/Float32(freq)
+ let hz_step: Float32 = 2*Float32.pi/sample_per_hz
+ var out_signal:[Complex<Float32>] = Array(repeating: Complex<Float32>(Float32(0.0)), count: sample_num)
+ var start = phase
+ for i in 0...sample_num {
+ out_signal[i].real = ampl * cos(start)
+ out_signal[i].imaginary = 0.0
+ start += hz_step
+ }
+
+ return out_signal
+}