Skip to content

Commit

Permalink
syscalls progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikNatanael committed Dec 22, 2023
1 parent b302761 commit 6f1c541
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 51 deletions.
4 changes: 2 additions & 2 deletions code/syscalls/syscalls_sonifier/src/direct_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl SyscallWaveguide {
let feedback = 0.999
+ (self.average_iterations_since_trigger as f32 * 0.00001).clamp(0.0, 0.1);
i.wg.feedback(feedback);
i.wg_amp.set(1, 0.05);
i.wg_amp.set(0, 0.05);
self.iterations_since_trigger = 0;
} else {
i.exciter_sender.push(0.0).unwrap();
Expand All @@ -526,7 +526,7 @@ impl SyscallWaveguide {
if self.iterations_since_trigger == 1500 {
let feedback = 0.99;
i.wg.feedback(feedback);
i.wg_amp.set(1, 0.10);
i.wg_amp.set(0, 0.10);
}
}
}
Expand Down
50 changes: 9 additions & 41 deletions code/syscalls/syscalls_sonifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use crate::quantised_categories::QuantisedCategories;
mod direct_categories;
mod direct_functions;
mod harmony;
pub mod note;
mod peak_binaries;
pub mod phrase;
mod program_themes;
mod quantised_categories;
pub mod phrase;
pub mod note;

const RUMBLE_RESTART: i32 = 1;
const RUMBLE_STOP: i32 = 2;
Expand All @@ -44,7 +44,7 @@ fn main() -> Result<()> {
&mut backend,
SphereSettings {
num_inputs: 1,
num_outputs: 2,
num_outputs: 24,
..Default::default()
},
|e| {
Expand Down Expand Up @@ -131,7 +131,7 @@ fn main() -> Result<()> {
// let mut current_chord = 0;
let mut rng = thread_rng();

// app.change_movement(0, None, false, 30.);
app.change_movement(113, None, false, 30.);
// main loop
loop {
// Receive OSC messages
Expand Down Expand Up @@ -524,7 +524,7 @@ impl App {
lpf_high: 500.0..1000.0,
});
*chord_change_interval = None;
let mut qc = QuantisedCategories::new(1.0, sample_rate);
let mut qc = QuantisedCategories::new(1.0, sample_rate);
qc.patch_to_fx_chain(2);
*current_sonifiers = vec![Box::new(qc), Box::new(PeakBinaries::new())];
rumble_change = Some(RUMBLE_STOP);
Expand Down Expand Up @@ -552,8 +552,7 @@ impl App {
let mut pb = PeakBinaries::new();
pb.threshold = 3.0;
// pb.sound_kind = SoundKind::FilteredNoise(3);
*current_sonifiers =
vec![Box::new(ProgramThemes::new(0.1)), Box::new(pb)];
*current_sonifiers = vec![Box::new(ProgramThemes::new(0.1)), Box::new(pb)];
current_sonifiers
.iter_mut()
.for_each(|s| s.patch_to_fx_chain(1));
Expand Down Expand Up @@ -762,9 +761,9 @@ impl PanMonoToQuad {
let signal = input[i];
// The equation needs pan to be in the range [0, 1]
let pan_x = pan_x[i].clamp(-1., 1.0) * 0.5 + 0.5;
let pan_y =pan_y[i].clamp(-1.0, 1.0) * 0.5 + 0.5;
let pan_x_radians = pan_x * std::f32::consts::FRAC_PI_2;
let pan_y_radians = pan_y * std::f32::consts::FRAC_PI_2;
let pan_y = pan_y[i].clamp(-1.0, 1.0) * 0.5 + 0.5;
// let pan_x_radians = pan_x * std::f32::consts::FRAC_PI_2;
// let pan_y_radians = pan_y * std::f32::consts::FRAC_PI_2;
// let left_gain = fastapprox::fast::cos(pan_x_radians);
// let right_gain = fastapprox::fast::sin(pan_x_radians);
// let front_gain = fastapprox::fast::cos(pan_y_radians);
Expand All @@ -781,35 +780,4 @@ impl PanMonoToQuad {
}
GenState::Continue
}

fn num_inputs(&self) -> usize {
3
}

fn num_outputs(&self) -> usize {
4
}

fn input_desc(&self, input: usize) -> &'static str {
match input {
0 => "signal",
1 => "pan_x",
2 => "pan_y",
_ => "",
}
}

fn output_desc(&self, output: usize) -> &'static str {
match output {
0 => "left_front",
1 => "right_front",
2 => "left_rear",
3 => "right_rear",
_ => "",
}
}

fn name(&self) -> &'static str {
"PanMonoToStereo"
}
}
13 changes: 8 additions & 5 deletions code/syscalls/syscalls_sonifier/src/program_themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,14 @@ impl ProgramThemes {
main_bus.set(0, mul.channels(4));
// k.connect(mul.to(&bus).channels(4).to_channel(0));
// k.connect(bus.to_graph_out().channels(4).to_channel(0));
let mut wg_thunderbird = plucked_waveguide();
let mut wg_konqueror = plucked_waveguide();
let mut wg_htop = plucked_waveguide();
let mut wg_gedit = plucked_waveguide();
inner_graph.activate();
let wg_thunderbird = plucked_waveguide();
inner_graph.activate();
let wg_konqueror = plucked_waveguide();
inner_graph.activate();
let wg_htop = plucked_waveguide();
inner_graph.activate();
let wg_gedit = plucked_waveguide();
lpf.sig(wg_gedit);
lpf.sig(wg_konqueror);
lpf.sig(wg_thunderbird);
Expand All @@ -177,7 +181,6 @@ impl ProgramThemes {

let root = Arc::new(AtomicF32::new(25.));
let chord = Arc::new(AtomicU32::new(0));
let phrases = thunderbird_theme();

let callback_root = root.clone();
let callback_chord = chord.clone();
Expand Down
6 changes: 3 additions & 3 deletions code/syscalls/syscalls_sonifier/src/quantised_categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use knyst::controller::{schedule_bundle, KnystCommands};
use knyst::envelope::{Envelope, SustainMode};
use knyst::gen::delay::{sample_delay, SampleDelayHandle};
use knyst::gen::filter::one_pole::{one_pole_lpf, OnePoleLpfHandle};
use knyst::graph::{SimultaneousChanges, Time};
use knyst::graph::Time;
use knyst::handles::{GenericHandle, HandleData};
use knyst::prelude::*;
use knyst::time::Superseconds;
Expand All @@ -27,7 +27,7 @@ use rand::{thread_rng, Rng};
use rtrb::Producer;
use syscalls_shared::SyscallKind;

use crate::{to_freq53, PanMonoToQuad, Sonifier, pan_mono_to_quad, PanMonoToQuadHandle};
use crate::{pan_mono_to_quad, to_freq53, PanMonoToQuad, PanMonoToQuadHandle, Sonifier};
const SCALE: [i32; 7] = [0 + 5, 17 + 5, 31 + 5, 44 + 5, 53 + 5, 62 + 5, 53 + 17 + 5];

pub struct QuantisedCategories {
Expand Down Expand Up @@ -378,7 +378,7 @@ impl SyscallKindQuantisedWaveguide {
}
}
}
fn set_new_timing(&mut self, interval: f32, changes: &mut SimultaneousChanges) {
fn set_new_timing(&mut self, interval: f32) {
let delay_time = interval * self.delay_position;
self.trig_delay.delay_time(delay_time);
self.impulse.interval(interval);
Expand Down

0 comments on commit 6f1c541

Please sign in to comment.