diff options
author | Graham Northup <grissess@nexusg.org> | 2017-10-03 14:50:18 -0400 |
---|---|---|
committer | Graham Northup <grissess@nexusg.org> | 2017-10-03 14:50:18 -0400 |
commit | 22dd5bc5862e91330c8da0d5f141998cdbe546fb (patch) | |
tree | 253cb9f6b080caaad18b2df9f63004266bf73c27 /src/main.rs | |
parent | 145e2771c0d1ad30748da6e6ef1fabbd4cc2478c (diff) |
Finished clientside parsing, starting graphics
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 9b78146..fb98dfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ -use std::io; +use std::{io, env}; use std::io::*; +use std::fs::*; use std::net::*; use std::sync::*; use std::collections::VecDeque; @@ -13,18 +14,18 @@ use synfone::lang::*; use synfone::proto::*; use synfone::client::*; -const GEN: &'static str = "mul(saw(param('v_freq', 500)), ifelse(rel(param('v_frame'), '<', param('v_deadline')), param('v_amp'), 0.0))"; - fn main() { let env = Environment::default(); - let mut gens = Vec::new(); - for _i in 0..25 { - let gen = Parser::new(Tokenizer::new(GEN.chars())).expect("Failed to get first token").parse().expect("Failed to compile generator"); - gens.push(gen); - } + let mut genfile = File::open(env::args_os().nth(1).expect("Need first argument to be a file with a generator vector")).expect("Failed to open file"); + let mut genstr = String::new(); + genfile.read_to_string(&mut genstr); + + let gens = Parser::new(Tokenizer::new(genstr.chars()), env.clone()).expect("Failed to get first token").parse_gen_vec().expect("Failed to compile generators"); let sock = UdpSocket::bind("0.0.0.0:13676").expect("Failed to bind socket"); + eprintln!("Parsed {} generator definitions", gens.len()); + let mut client = Arc::new(Mutex::new(Client::new(sock.try_clone().expect("Failed to clone socket"), gens, env.clone()).expect("Failed to create client"))); let pa_inst = pa::PortAudio::new().expect("Failed to create PortAudio interface"); |