Skip to content

Commit

Permalink
fix: pan right chan index error on hello example
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosprint committed Jan 22, 2025
1 parent 3dda62b commit bf8cfad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 65 deletions.
65 changes: 2 additions & 63 deletions rs/main/examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,69 +1,8 @@
use glicol::Engine;
// use glicol::{EngineError, get_error_info};

// use glicol::GlicolNodeInfo;
// use std::collections::HashMap;

fn main() {
let mut engine = Engine::<32>::new();
let mut engine = Engine::<8>::new();
engine
.update_with_code(r#"o: constsig 1.0 >> pan 0.9"#)
.update_with_code(r#"o: constsig 42 >> pan 0.9"#)
.unwrap();
// engine.update_with_code(r#"o: [0.1=>100, 1/2=> 1.0]"#);
// engine.update_with_code(r#"o: sin 440"#);
// engine.update_with_code(r#"// a sawtooth osc chained with a onepole filter
// // the first meta is to write a saw manually
// out: meta `
// f = 220.;
// output.pad(128, 0.0);
// for i in 0..128 {
// output[i] = p * 2. - 1.;
// p += f / sr;
// };
// if p > 1.0 { p -= 1.0 };
// output
// ` >> meta `
// r = 1./2000.;
// if phase == 0.0 {
// z = 0.0
// }
// output.pad(128, 0.0);
// b = (-2.0 * PI() * r).exp();
// a = 1.0 - b;
// for i in 0..128 {
// y = input[i] * a + b * z;
// output[i] = y;
// z = y;
// };
// output
// `
// // if the script has an input, you can use the "input" variable
// // the "input" is a 128-size array in web audio"#);
// match engine.update("o: imp 100 >> mul ~mod
// ~mo: sin 1 >> mul 0.5 >> add 0.5") {
// Ok(_) => {},
// Err(e) => {
// println!("{:?}", e);
// // match e {
// // EngineError::ParsingError(e) => {
// // println!("{:?}", get_error_info(e))
// // },
// // _ => unimplemented!()
// // }
// }
// };
// println!("refpairlist {:?}", engine.refpairlist);
// engine.update("o: saw 500 >> lpf 100.0 1.0;

// ~mod: sin 0.2 >> mul 200.0 >> add 500.0");
// engine.add_sample("\\bb", &[1.0], 1);
// engine.update(r#"o: imp 1 >> sp \808_0 >> delayms ~mod

// ~mod: sin 0.2 >> mul 100 >> add 200"#);
// for e in engine.context.graph.edges(engine.context.destination) {
// println!("destinations {:?}", e);
// }
println!("next block {:?}", engine.next_block(vec![]));
// engine.send_msg("o", 0, (0, "1."));
// engine.next_block();
}
3 changes: 1 addition & 2 deletions rs/synth/src/node/effect/pan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{Buffer, Input, Message, Node};
use hashbrown::HashMap;
// use std::f32::consts::PI;

#[derive(Debug, Clone)]
pub struct Pan {
Expand Down Expand Up @@ -31,7 +30,7 @@ impl<const N: usize> Node<N> for Pan {
let (left, right) = output.split_at_mut(1);
for ((left, right), sample) in left[0]
.iter_mut()
.zip(right[1].iter_mut())
.zip(right[0].iter_mut())
.zip(input_buffers[0].iter())
{
*left = left_gain * sample; // Left channel
Expand Down

0 comments on commit bf8cfad

Please sign in to comment.