Commit 21a60a48 authored by Pierre Donat-Bouillud's avatar Pierre Donat-Bouillud
Browse files

Fix incoherent buffer sizes for source outputs and sink inputs if

resamplers after or before resp.
parent 915084cc
......@@ -536,6 +536,9 @@ impl AudioEffect for AudioGraph {
let mut edges = self.outputs_mut(self.input_node_index);
let mut i = 0;
while let Some(edge) = edges.next_edge(&self.graph) {
self.output_edges[i].resize(self.graph.edge_weight(edge).unwrap().buffer().len());
self.output_edges[i].samplerate = self.graph.edge_weight(edge).unwrap().samplerate;
debug_assert_eq!(self.graph.edge_weight(edge).unwrap().buffer().len(), self.output_edges[i].buffer().len());
self.graph.edge_weight_mut(edge).unwrap().buffer_mut().copy_from_slice(self.output_edges[i].buffer());
i += 1;
}
......@@ -595,11 +598,15 @@ impl AudioEffect for AudioGraph {
// Sink
//println!("Executing {}", self.graph.node_weight(self.output_node_index).unwrap().node_processor);
//Prepare inputs
//Quite inefficient, with allocating. Rather use a fixed vec with max number of inputs and outputs and a buffer pool
// Or just use &[&DspEdge]??
let mut edges = self.inputs_mut(self.output_node_index);
let mut i = 0;
while let Some(edge) = edges.next_edge(&self.graph) {
self.input_edges[i].resize(self.graph.edge_weight(edge).unwrap().buffer().len());
self.input_edges[i].samplerate = self.graph.edge_weight(edge).unwrap().samplerate;
debug_assert_eq!(self.graph.edge_weight(edge).unwrap().buffer().len(), self.input_edges[i].buffer().len());
self.input_edges[i].buffer_mut().copy_from_slice(self.graph.edge_weight(edge).unwrap().buffer());
i += 1;
}
......
......@@ -30,7 +30,7 @@ use audio_adaptive::sndfile;
const CHANNELS: i32 = 1;
const SAMPLE_RATE: u32 = 44_100;
const NB_CYCLES : u32 = 12000;
const FRAMES_PER_BUFFER : usize = 256;
const FRAMES_PER_BUFFER : usize = 512;
#[derive(Clone, Copy, Debug)]
pub struct TimeMonitor {
......@@ -227,6 +227,9 @@ fn main() {
.short("m")
.long("monitor")
.help("Monitor execution and save it as a csv file."))
.arg(Arg::with_name("silent")
.long("silent")
.help("No output at all on the terminal."))
.group(ArgGroup::with_name("execution-mode")
.args(&["real-time", "bounce"])
.required(true))
......@@ -238,13 +241,16 @@ fn main() {
let bounce = matches.is_present("bounce");
let nb_cycles : u32 = matches.value_of("cycles").map_or(NB_CYCLES, |v| v.parse().unwrap_or(NB_CYCLES));
let monitor = matches.is_present("monitor");
let silent = matches.is_present("silent");
let mut audiograph = parse_audiograph_from_file(filename, FRAMES_PER_BUFFER, 1, SAMPLE_RATE).unwrap();
audiograph.update_schedule().expect(&format!("Audio graph in {} is cyclic!!", filename));
let basename = Path::new(filename).file_stem().and_then(OsStr::to_str).unwrap();
println!("Starting processing");
if !silent {
println!("Starting processing")
};
let start = PreciseTime::now();
if real_time {
real_time_run(audiograph, basename.to_string(), nb_cycles, monitor).unwrap();
......@@ -254,5 +260,5 @@ fn main() {
bounce_run(audiograph, basename.to_string(), audio_input, nb_cycles, monitor).unwrap();
}
let execution_time = start.to(PreciseTime::now()).num_microseconds().unwrap();
println!("End processing in {}s", execution_time as f64 / 1_000_000.0);
if !silent {println!("End processing in {}s", execution_time as f64 / 1_000_000.0);}
}
......@@ -92,7 +92,6 @@ pub fn parse_audiograph(audiograph : &str, buffer_size: usize, nb_channels: usiz
port_ident = inner_rule.into_inner().next().unwrap().into_inner();
let dst_id = port_ident.next().unwrap().as_str().to_string();
let dst_port = port_ident.next().unwrap().as_str().parse().unwrap();
println!("dst_id = {}; dst_port = {}", dst_id, dst_port);
edges.push(Edge {src_id, src_port, dst_id : dst_id.clone(), dst_port});
src_id = dst_id;
src_port = dst_port;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment