aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-01-01 18:05:48 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-01-01 18:05:48 +0100
commite4746f6fb598decb3c66e90d72b1c15dfd4b613f (patch)
tree78e4eef62ba802b97e0514c4cc54a2b29c42272b /src
parent049b7964ab83e9dd1a008bd3bcb38d7bb351a140 (diff)
downloadfl2k_ampliphase-e4746f6fb598decb3c66e90d72b1c15dfd4b613f.tar.gz
fl2k_ampliphase-e4746f6fb598decb3c66e90d72b1c15dfd4b613f.tar.bz2
fl2k_ampliphase-e4746f6fb598decb3c66e90d72b1c15dfd4b613f.zip
Fix parse of modulation index
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index fceb37f..8aec593 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -114,16 +114,16 @@ impl DDS {
self.phase = phase as u32 + self.phase_step;
- let amp = (self.amplitude * 32767.0) as i32; // 0..15
+ let amp = (self.amplitude * 32767.0) as i32; // 0..15
let amp_i = amp * self.trig_table_inphase[phase_idx_i as usize] as i32; // 0..31
let amp_q = amp * self.trig_table_quadrature[phase_idx_q as usize] as i32; // 0..31
- //
+
let i = (amp_i >> 24) as i8; // 0..31 >> 24 => 0..8
let q = (amp_q >> 24) as i8; // 0..31 >> 24 => 0..8
out_i.push(i);
out_q.push(q);
- self.phase_delta += self.phase_slope;
+ self.phase_delta += self.phase_slope;
}
(out_i, out_q)
}
@@ -190,7 +190,7 @@ fn main() {
None => 48_000,
};
- let modulation_index = match cli_args.opt_str("i") {
+ let modulation_index = match cli_args.opt_str("m") {
Some(s) => s.parse().expect("floating point value"),
None => 0.25,
};
@@ -283,7 +283,7 @@ fn main() {
for sample in buf {
let slope = sample - lastamp;
- let slope = slope * 1.0 / rf_to_baseband_sample_ratio as f32;
+ let slope = slope / rf_to_baseband_sample_ratio as f32;
let pd = lastamp * modulation_index * INT32_MAX_AS_FLOAT;
@@ -295,6 +295,7 @@ fn main() {
}
let pdslope = slope * modulation_index * INT32_MAX_AS_FLOAT;
+ println!("Samp = {}, Slope {} = {} * {} * {}", sample, pdslope, slope, modulation_index, INT32_MAX_AS_FLOAT);
if pdslope < MIN_VAL || pdslope > MAX_VAL {
panic!("pdslope out of bounds {}", pdslope);
}
@@ -315,9 +316,9 @@ fn main() {
thread::spawn(move || {
let mut dds = DDS::init(samp_rate as f32, base_freq, 0.0, 1.0, waveform);
loop {
- let Ok(buf) = pd_rx.recv() else { break };
+ let Ok(pd_buf) = pd_rx.recv() else { break };
- for (pd, pdslope) in buf {
+ for (pd, pdslope) in pd_buf {
dds.set_phase(pd, pdslope);
let iq_bufs = dds.generate_iq(rf_to_baseband_sample_ratio as usize);