Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pierre Donat-Bouillud
audio-adaptive-scheduling
Commits
9946f8af
Commit
9946f8af
authored
Mar 01, 2019
by
Pierre Donat-Bouillud
Browse files
Handle 0 input or output nodes from audiograph format and source not at
the beginning of the schedule.
parent
319ea2de
Pipeline
#724
passed with stage
in 2 minutes and 54 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/audiograph.rs
View file @
9946f8af
...
...
@@ -77,13 +77,16 @@ impl DspNode {
DspNode
{
node_infos
,
node_processor
}
}
pub
fn
new
(
node_infos
:
audiograph_parser
::
Node
)
->
DspNode
{
pub
fn
new
(
node_infos
:
audiograph_parser
::
Node
,
nb_channels
:
usize
)
->
DspNode
{
let
node_processor
:
Box
<
dyn
AudioEffect
>
=
match
node_infos
.class_name
.as_str
()
{
"osc"
=>
Box
::
new
(
Oscillator
::
from_node_infos
(
&
node_infos
)),
"mod"
=>
Box
::
new
(
Modulator
::
from_node_infos
(
&
node_infos
)),
"mix"
=>
Box
::
new
(
InputsOutputsAdaptor
::
from_node_infos
(
&
node_infos
)),
"resampler"
=>
Box
::
new
(
Resampler
::
from_node_infos
(
&
node_infos
)),
"source"
=>
Box
::
new
(
InputsOutputsAdaptor
::
new
(
nb_channels
,
node_infos
.nb_outlets
as
usize
)),
"sink"
=>
Box
::
new
(
InputsOutputsAdaptor
::
new
(
node_infos
.nb_inlets
as
usize
,
nb_channels
)),
_
=>
{
//We replace it by a default effect
println!
(
"Unkwown node {:?}. Replacing it by a known one."
,
node_infos
);
if
node_infos
.nb_inlets
==
0
&&
node_infos
.nb_outlets
==
1
{
Box
::
new
(
Oscillator
::
new
(
0.
,
440
,
1.
))
}
...
...
@@ -317,11 +320,22 @@ impl AudioGraph {
//self.print_schedule(&self.schedule);
self
.schedule
=
filtered_schedule
;
//self.schedule = self.schedule.iter().filter(|v| {dfs.discovered.is_visited(v)}).collect::<Vec<_>>();
if
self
.schedule
.contains
(
&
self
.input_node_index
)
{
let
mut
source_index
=
0
;
for
(
i
,
e
)
in
self
.schedule
.iter
()
.enumerate
()
{
if
*
e
==
self
.input_node_index
{
self
.has_source
=
true
;
source_index
=
i
;
break
;
}
}
if
self
.has_source
{
self
.schedule
.remove
(
source_index
);
}
/*if self.schedule.contains(&self.input_node_index) {
self.has_source = true;
assert!(self.schedule[0] == self.input_node_index);
self.schedule.remove(0);
}
}
*/
}
/// Adjust buffer sizes and samplerates for nodes between two resamplers
...
...
src/audiograph_exec.rs
View file @
9946f8af
...
...
@@ -179,7 +179,7 @@ fn bounce_run<'a>(mut audio_graph: AudioGraph, graph_name: String, audio_input:
let
mut
output_file
=
sndfile
::
SndFile
::
open_write
(
graph_name
+
".wav"
,
samplerate
,
nb_channels
as
u32
)
?
;
while
advance
(
buf_in
[
0
]
.buffer_mut
())
!=
0
{
while
advance
(
buf_in
[
0
]
.buffer_mut
())
!=
0
{
let
start
=
PreciseTime
::
now
();
audio_graph
.process
(
&
buf_in
,
&
mut
buf_out
);
output_file
.write_float
(
buf_out
[
0
]
.buffer
());
...
...
src/audiograph_parser.rs
View file @
9946f8af
...
...
@@ -8,8 +8,6 @@ use std::collections::HashMap;
use
petgraph
::
graph
::
NodeIndex
;
use
itertools
::
Itertools
;
use
pest
::
error
::
Error
as
ParseError
;
use
audiograph
::
*
;
...
...
@@ -116,7 +114,7 @@ pub fn parse_audiograph(audiograph : &str, buffer_size: usize, nb_channels: usiz
for
node_infos
in
nodes
.into_iter
()
{
let
id
=
node_infos
.id
.clone
();
let
node
=
DspNode
::
new
(
node_infos
);
let
node
=
DspNode
::
new
(
node_infos
,
nb_channels
);
let
node_index
=
audiograph
.add_node
(
node
);
node_indexes
.insert
(
id
,
node_index
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment