-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
26 changed files
with
592 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
// use superdsp::gui::time_chart_complex::TimeChartComplex; | ||
// //use superdsp::gui::waterfall::Waterfall; | ||
// use superdsp::objects::object::DSPObject; | ||
// use superdsp::radios; | ||
// | ||
// | ||
// | ||
// fn main() { | ||
// let mut src = radios::bladerf::src::BladeRfSrc::new(915000000, 1_000_000, 1_000_000, 1_000_000, 1024); | ||
// let mut chart = TimeChartComplex::new(); | ||
// //let mut waterfall = Waterfall::new(1024); | ||
// | ||
// let s = src.get_bus(); | ||
// | ||
// waterfall.set_bus(s); | ||
// chart.set_bus(s); | ||
// | ||
// superdsp::objects::GUIExecutor::run(vec![Box::new(waterfall), Box::new(chart)], Box::new(src)); | ||
// } | ||
use superdsp::gui::time_chart_complex::TimeChartComplex; | ||
use superdsp::gui::waterfall::Waterfall; | ||
use superdsp::objects::object::DSPObject; | ||
use superdsp::radios; | ||
|
||
fn main() { | ||
let mut src = radios::bladerf::src::BladeRfSrc::new(915000000, 1_000_000, 1_000_000, 1_000_000, 1024); | ||
let mut chart = TimeChartComplex::new(); | ||
let mut waterfall = Waterfall::new(); | ||
|
||
let s = src.get_bus(); | ||
|
||
waterfall.set_bus(s); | ||
chart.set_bus(s); | ||
|
||
superdsp::objects::GUIExecutor::run(vec![Box::new(waterfall), Box::new(chart)], Box::new(src)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
use superdsp::gui::slider::Slider; | ||
use superdsp::gui::time_chart::TimeChart; | ||
use superdsp::objects::GUIExecutor; | ||
use superdsp::objects::object::DSPObject; | ||
use superdsp::objects::object::{Bus, DSPObject}; | ||
use superdsp::objects::wave_gen_time::WaveStepGenTime; | ||
|
||
fn main() { | ||
let mut wave_step_gen = WaveStepGenTime::new(440.0, 1.0, 0.0, 44100.0); | ||
let mut chart = TimeChart::new(); | ||
let mut frequency = Bus::from_f32(200.0); | ||
let amplitude = Bus::from_f32(1.0); | ||
let phase = Bus::from_f32(0.0); | ||
let sample_rate = Bus::from_f32(441.0); | ||
|
||
let mut slider = Slider::new(0.0, 100.0); | ||
slider.set_bus(&mut frequency); | ||
|
||
let mut wave_step_gen = WaveStepGenTime::new(frequency, amplitude, phase, sample_rate); | ||
let mut chart = TimeChart::new(); | ||
|
||
let s = wave_step_gen.get_bus(); | ||
chart.set_bus(s); | ||
|
||
GUIExecutor::run(vec![Box::new(chart)], Box::new(wave_step_gen)); | ||
GUIExecutor::run(vec![Box::new(chart), Box::new(slider)], Box::new(wave_step_gen)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
#![feature(generic_const_exprs)] | ||
|
||
use superdsp::gui::slider::Slider; | ||
use superdsp::gui::waterfall::Waterfall; | ||
use superdsp::objects::GUIExecutor; | ||
use superdsp::objects::object::DSPObject; | ||
use superdsp::objects::object::{Bus, DSPObject}; | ||
use superdsp::objects::wave_gen_time_complex::WaveStepGenTimeComplex; | ||
use std::thread; | ||
|
||
fn main() { | ||
let mut waterfall:Waterfall<256> = Waterfall::new(); | ||
let mut gen = WaveStepGenTimeComplex::new(8.0, 1.0, 0.0, 16.0); | ||
let mut frequency = Bus::from_f32(1.0); | ||
let amplitude = Bus::from_f32(1.0); | ||
let phase = Bus::from_f32(0.0); | ||
let sample_rate = Bus::from_f32(441.0); | ||
|
||
let mut waterfall: Waterfall<256> = Waterfall::new(); | ||
let mut slider = Slider::new(0.0,100.0); | ||
|
||
slider.set_bus(&mut frequency); | ||
|
||
let mut gen = WaveStepGenTimeComplex::new(frequency, amplitude, phase, sample_rate); | ||
|
||
waterfall.set_bus(gen.get_bus()); | ||
GUIExecutor::run(vec![Box::new(waterfall)], Box::new(gen)) | ||
GUIExecutor::run(vec![Box::new(waterfall), Box::new(slider)], Box::new(gen)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod blackman_nuttall; | |
pub mod gaussian_window; | ||
pub mod hamming; | ||
pub mod triangle; | ||
pub mod sin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// This function is based on the sin filter function from wikipedia found here: https://en.wikipedia.org/wiki/Window_function | ||
/// Creates a triangle filter of size N | ||
/// Formula: f(x) = sinf(pi*(n-o)/N) for n in 0..N | ||
/// | ||
/// Where: | ||
/// o is the bin offset | ||
/// | ||
/// # Arguments | ||
/// N: usize - Size of the filter | ||
/// offset: usize - Bin offset | ||
/// | ||
/// # Returns | ||
/// [f32; N] - Sin window | ||
/// | ||
use std::f32::consts::PI; | ||
|
||
pub fn sin_window<const N: usize>(offset: usize) -> [f32; N] { | ||
let mut filter = [0.0; N]; | ||
|
||
for n in 0..N { | ||
filter[n] = (PI*(n-offset) as f32 /N as f32).sin(); | ||
} | ||
|
||
filter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
// This function is based on the triangle filter function from wikipedia found here: https://en.wikipedia.org/wiki/Window_function | ||
|
||
use core::f32::consts::PI; | ||
|
||
/// Creates a triangle filter of size N | ||
/// Formula: f(x) = 1 - |((n - o) - (N / 2)) / (L / 2)| for n in 0..N | ||
/// | ||
/// | ||
/// Where: | ||
/// L can be N, N+1, or N+2 | ||
/// o is the bin offset | ||
/// | ||
/// | ||
/// # Arguments | ||
/// N: usize - Size of the filter | ||
/// l: usize - Filter setting (N, N+1, or N+2) | ||
/// offset: usize - Bin offset | ||
/// | ||
/// | ||
/// # Returns | ||
/// [f32; N] - Triangle window | ||
pub fn triangle_window<const N: usize>(l: usize, offset: usize) -> [f32; N] { | ||
let mut filter = [0.0; N]; | ||
|
||
for n in 0..N { | ||
filter[n] = 1.0 - (((n - offset) as f32 - (N as f32 / 2.0)) / (l as f32 / 2.0)).abs(); | ||
} | ||
|
||
filter | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use iced::Command; | ||
use plotters_iced::{Chart, ChartBuilder, DrawingBackend}; | ||
|
||
use crate::gui::{DSPChart, Message}; | ||
use crate::objects::object::{Bus, DSPObject, Type}; | ||
|
||
#[derive(Clone)] | ||
pub struct Slider { | ||
bus: Bus<'static>, | ||
min: f32, | ||
max: f32, | ||
} | ||
|
||
impl Slider { | ||
pub fn new(min: f32, max: f32) -> Slider { | ||
Slider { | ||
bus: Bus::new_complex(), | ||
min, | ||
max, | ||
} | ||
} | ||
} | ||
|
||
impl Default for Slider { | ||
fn default() -> Self { | ||
Self::new(0.0, 10.0) | ||
} | ||
} | ||
|
||
impl Chart<Message> for Slider { | ||
type State = (); | ||
|
||
fn build_chart<DB: DrawingBackend>(&self, state: &Self::State, mut builder: ChartBuilder<DB>) {} | ||
} | ||
|
||
impl DSPObject for Slider { | ||
fn return_type(&self) -> Type { | ||
Type::Complex | ||
} | ||
|
||
fn input_type(&self) -> Type { | ||
Type::Complex | ||
} | ||
|
||
fn get_bus(&mut self) -> &mut Bus<'static> { | ||
&mut self.bus | ||
} | ||
|
||
fn set_bus(&mut self, bus: &mut Bus<'static>) { | ||
self.bus = *bus; | ||
bus.subscribe(self); | ||
} | ||
|
||
fn start(&mut self) { | ||
panic!("Charts can not be root object"); | ||
} | ||
|
||
fn process(&mut self) {} | ||
} | ||
|
||
impl DSPChart for Slider { | ||
type Message = Message; | ||
type State = (); | ||
|
||
fn view(&self) -> iced::Element<Self::Message> { | ||
iced::widget::Slider::new(self.min..=self.max,*self.bus.buffer_f32.unwrap().read(), |value| { | ||
self.bus.trigger_f32(value); | ||
Message::SliderChanged | ||
}).into() | ||
} | ||
|
||
fn update(&mut self, message: Self::Message) -> Command<Self::Message> { | ||
Command::none() | ||
} | ||
} | ||
|
Oops, something went wrong.