summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Northup <grissess@nexusg.org>2017-09-18 23:53:16 -0400
committerGraham Northup <grissess@nexusg.org>2017-09-18 23:53:16 -0400
commit26e95364ad9073dd7cb571454cd52ae66f320a73 (patch)
tree96b94123569588515d79428fe6c940db75dc2813
parent85925d69e08455bd91d32a27cd3690c9cb634a6b (diff)
it builds and does a thing
-rw-r--r--src/main.rs7
-rw-r--r--src/synth/math.rs8
-rw-r--r--src/synth/param.rs6
-rw-r--r--src/synth/sine.rs6
4 files changed, 15 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index 6db2bcf..711463b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,15 +7,18 @@ use synfone::synth::*;
const FRAMES: usize = 44100 * 2;
fn main() {
- let mut params = Default::default();
+ let mut params = Parameters::default();
let mut freq: GenBox = Box::new(Param { name: "freq".to_string(), default: 440.0, buf: SampleBuffer::new(1) });
let mut sg: GenBox = Box::new(Sine { freq: freq, phase: 0.0, buf: SampleBuffer::new(params.env.default_buffer_size) });
let mut counter = 0;
- let mut out = io::stderr();
+ let mut out = io::stdout();
+
+ params.vars.insert("freq".to_string(), 440.0);
while counter < FRAMES {
+ *params.vars.get_mut("freq").unwrap() = 440.0 + 440.0 * ((counter as f32) / (FRAMES as f32));
let buf = sg.eval(&params);
out.write_all(buf.bytes());
counter += buf.len();
diff --git a/src/synth/math.rs b/src/synth/math.rs
index b016103..66a86a0 100644
--- a/src/synth/math.rs
+++ b/src/synth/math.rs
@@ -1,8 +1,8 @@
use super::*;
pub struct Add {
- terms: Vec<GenBox>,
- buf: SampleBuffer,
+ pub terms: Vec<GenBox>,
+ pub buf: SampleBuffer,
}
impl Generator for Add {
@@ -21,8 +21,8 @@ impl Generator for Add {
}
pub struct Mul {
- factors: Vec<GenBox>,
- buf: SampleBuffer,
+ pub factors: Vec<GenBox>,
+ pub buf: SampleBuffer,
}
impl Generator for Mul {
diff --git a/src/synth/param.rs b/src/synth/param.rs
index 3177ffd..ced5900 100644
--- a/src/synth/param.rs
+++ b/src/synth/param.rs
@@ -1,9 +1,9 @@
use super::*;
pub struct Param {
- name: String,
- default: Sample,
- buf: SampleBuffer,
+ pub name: String,
+ pub default: Sample,
+ pub buf: SampleBuffer,
}
impl Generator for Param {
diff --git a/src/synth/sine.rs b/src/synth/sine.rs
index 3ee4857..212ab21 100644
--- a/src/synth/sine.rs
+++ b/src/synth/sine.rs
@@ -4,9 +4,9 @@ use super::*;
const TAU: f32 = 2f32 * PI;
pub struct Sine {
- freq: GenBox,
- phase: f32,
- buf: SampleBuffer,
+ pub freq: GenBox,
+ pub phase: f32,
+ pub buf: SampleBuffer,
}
impl Generator for Sine {