pub struct Audact { /* private fields */ }
Expand description
Struct for the main audact system
Implementations§
Source§impl Audact
implementation for the audact struct
impl Audact
implementation for the audact struct
Sourcepub fn new(steps: i32, bpm: i32, per_bar: f32) -> Audact
pub fn new(steps: i32, bpm: i32, per_bar: f32) -> Audact
Creates a new instance of audact
Examples found in repository?
examples/tone.rs (line 7)
6fn main() {
7 let mut audact = Audact::new(16, 100, 4f32);
8
9 let c = std_note_freq(0);
10
11 // single test tone
12 audact.channel(
13 Wave::Sine,
14 0.7f32,
15 Processing::default(),
16 vec![c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c],
17 );
18
19 audact.start(1);
20}
More examples
examples/proc.rs (line 13)
10fn main() {
11 let seq_len = 16;
12
13 let mut audact = Audact::new(seq_len, 100, 4f32);
14
15 let mut rng = rand::thread_rng();
16
17 let seq: Vec<f32> = (0..(seq_len as f32 / 4f32) as usize)
18 .map(|_| iter::repeat(std_note_freq(rng.gen_range(-12, 12))).take(4))
19 .flat_map(|x| x)
20 .collect();
21
22 let processing = ProcessingBuilder::default()
23 .attack(Duration::from_millis(300u64))
24 .reverb((Duration::from_millis(200), 0.8f32))
25 .build()
26 .unwrap();
27
28 // single test tone
29 audact.channel(Wave::Sine, 0.3f32, processing, seq);
30
31 audact.start(4);
32}
examples/docs.rs (line 7)
6fn main() {
7 let mut audact = Audact::new(16, 120, 4f32);
8
9 let default_processing = Processing::default();
10 let n_1 = std_note_freq(0);
11 let n_2 = std_note_freq(2);
12
13 audact.channel(
14 Wave::Sine,
15 1f32,
16 default_processing,
17 vec![
18 n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32,
19 0f32,
20 ],
21 );
22 audact.channel(
23 Wave::Square,
24 1f32,
25 default_processing,
26 vec![
27 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2,
28 0f32,
29 ],
30 );
31
32 audact.start(1);
33}
examples/patterns.rs (line 7)
6fn main() {
7 let mut pattern_1 = Audact::new(16, 100, 4f32);
8 let n_1 = std_note_freq(0);
9 pattern_1.channel(
10 Wave::Sine,
11 0.7f32,
12 Processing::default(),
13 vec![
14 n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, 0f32, 0f32, 0f32,
15 ],
16 );
17
18 let mut pattern_2 = Audact::new(16, 100, 4f32);
19 let n_2 = std_note_freq(4);
20 pattern_2.channel(
21 Wave::Sine,
22 0.7f32,
23 Processing::default(),
24 vec![
25 n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2,
26 ],
27 );
28
29 // play the patterns one after another
30 pattern_1.start(1);
31 pattern_2.start(1);
32}
examples/main.rs (line 9)
8fn main() {
9 let mut audact = Audact::new(16, 100, 4f32);
10
11 let lead_processing = ProcessingBuilder::default()
12 .attack(Duration::from_millis(100u64))
13 .reverb((Duration::from_millis(200), 0.8f32))
14 .build()
15 .unwrap();
16
17 let default_processing = Processing::default();
18
19 //lead
20 let l_1 = std_note_freq(0);
21 let l_2 = std_note_freq(-2);
22 let l_3 = std_note_freq(-4);
23 audact.channel(
24 Wave::Saw,
25 0.1f32,
26 lead_processing,
27 vec![
28 l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3,
29 ],
30 );
31
32 //pad
33 let p_1 = std_note_freq(-12);
34 let p_2 = std_note_freq(-14);
35 let p_3 = std_note_freq(-16);
36 audact.channel(
37 Wave::Square,
38 0.1f32,
39 default_processing,
40 vec![
41 p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_2, p_2, p_2, p_2, p_3, p_3, p_3, p_3,
42 ],
43 );
44
45 let b_1 = std_note_freq(-24);
46 let b_2 = std_note_freq(-26);
47 //bass
48 audact.channel(
49 Wave::Sine,
50 0.1f32,
51 default_processing,
52 vec![
53 b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_2, b_2, b_2, b_2, b_2, b_2, b_2, b_2,
54 ],
55 );
56
57 // percussion
58 audact.channel(
59 Wave::Noise,
60 0.2f32,
61 default_processing,
62 vec![
63 b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32,
64 ],
65 );
66
67 audact.start(1);
68}
Sourcepub fn channel(
&mut self,
wave: Wave,
volume: f32,
processing: Processing,
seq: Vec<f32>,
)
pub fn channel( &mut self, wave: Wave, volume: f32, processing: Processing, seq: Vec<f32>, )
Add a voice channel to audact for synth playback
Examples found in repository?
examples/tone.rs (lines 12-17)
6fn main() {
7 let mut audact = Audact::new(16, 100, 4f32);
8
9 let c = std_note_freq(0);
10
11 // single test tone
12 audact.channel(
13 Wave::Sine,
14 0.7f32,
15 Processing::default(),
16 vec![c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c],
17 );
18
19 audact.start(1);
20}
More examples
examples/proc.rs (line 29)
10fn main() {
11 let seq_len = 16;
12
13 let mut audact = Audact::new(seq_len, 100, 4f32);
14
15 let mut rng = rand::thread_rng();
16
17 let seq: Vec<f32> = (0..(seq_len as f32 / 4f32) as usize)
18 .map(|_| iter::repeat(std_note_freq(rng.gen_range(-12, 12))).take(4))
19 .flat_map(|x| x)
20 .collect();
21
22 let processing = ProcessingBuilder::default()
23 .attack(Duration::from_millis(300u64))
24 .reverb((Duration::from_millis(200), 0.8f32))
25 .build()
26 .unwrap();
27
28 // single test tone
29 audact.channel(Wave::Sine, 0.3f32, processing, seq);
30
31 audact.start(4);
32}
examples/docs.rs (lines 13-21)
6fn main() {
7 let mut audact = Audact::new(16, 120, 4f32);
8
9 let default_processing = Processing::default();
10 let n_1 = std_note_freq(0);
11 let n_2 = std_note_freq(2);
12
13 audact.channel(
14 Wave::Sine,
15 1f32,
16 default_processing,
17 vec![
18 n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32,
19 0f32,
20 ],
21 );
22 audact.channel(
23 Wave::Square,
24 1f32,
25 default_processing,
26 vec![
27 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2,
28 0f32,
29 ],
30 );
31
32 audact.start(1);
33}
examples/patterns.rs (lines 9-16)
6fn main() {
7 let mut pattern_1 = Audact::new(16, 100, 4f32);
8 let n_1 = std_note_freq(0);
9 pattern_1.channel(
10 Wave::Sine,
11 0.7f32,
12 Processing::default(),
13 vec![
14 n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, 0f32, 0f32, 0f32,
15 ],
16 );
17
18 let mut pattern_2 = Audact::new(16, 100, 4f32);
19 let n_2 = std_note_freq(4);
20 pattern_2.channel(
21 Wave::Sine,
22 0.7f32,
23 Processing::default(),
24 vec![
25 n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2,
26 ],
27 );
28
29 // play the patterns one after another
30 pattern_1.start(1);
31 pattern_2.start(1);
32}
examples/main.rs (lines 23-30)
8fn main() {
9 let mut audact = Audact::new(16, 100, 4f32);
10
11 let lead_processing = ProcessingBuilder::default()
12 .attack(Duration::from_millis(100u64))
13 .reverb((Duration::from_millis(200), 0.8f32))
14 .build()
15 .unwrap();
16
17 let default_processing = Processing::default();
18
19 //lead
20 let l_1 = std_note_freq(0);
21 let l_2 = std_note_freq(-2);
22 let l_3 = std_note_freq(-4);
23 audact.channel(
24 Wave::Saw,
25 0.1f32,
26 lead_processing,
27 vec![
28 l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3,
29 ],
30 );
31
32 //pad
33 let p_1 = std_note_freq(-12);
34 let p_2 = std_note_freq(-14);
35 let p_3 = std_note_freq(-16);
36 audact.channel(
37 Wave::Square,
38 0.1f32,
39 default_processing,
40 vec![
41 p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_2, p_2, p_2, p_2, p_3, p_3, p_3, p_3,
42 ],
43 );
44
45 let b_1 = std_note_freq(-24);
46 let b_2 = std_note_freq(-26);
47 //bass
48 audact.channel(
49 Wave::Sine,
50 0.1f32,
51 default_processing,
52 vec![
53 b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_2, b_2, b_2, b_2, b_2, b_2, b_2, b_2,
54 ],
55 );
56
57 // percussion
58 audact.channel(
59 Wave::Noise,
60 0.2f32,
61 default_processing,
62 vec![
63 b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32,
64 ],
65 );
66
67 audact.start(1);
68}
Sourcepub fn start(&mut self, bars: i32)
pub fn start(&mut self, bars: i32)
Kick off audact to start and loop ‘bars’ times
Examples found in repository?
examples/tone.rs (line 19)
6fn main() {
7 let mut audact = Audact::new(16, 100, 4f32);
8
9 let c = std_note_freq(0);
10
11 // single test tone
12 audact.channel(
13 Wave::Sine,
14 0.7f32,
15 Processing::default(),
16 vec![c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c],
17 );
18
19 audact.start(1);
20}
More examples
examples/proc.rs (line 31)
10fn main() {
11 let seq_len = 16;
12
13 let mut audact = Audact::new(seq_len, 100, 4f32);
14
15 let mut rng = rand::thread_rng();
16
17 let seq: Vec<f32> = (0..(seq_len as f32 / 4f32) as usize)
18 .map(|_| iter::repeat(std_note_freq(rng.gen_range(-12, 12))).take(4))
19 .flat_map(|x| x)
20 .collect();
21
22 let processing = ProcessingBuilder::default()
23 .attack(Duration::from_millis(300u64))
24 .reverb((Duration::from_millis(200), 0.8f32))
25 .build()
26 .unwrap();
27
28 // single test tone
29 audact.channel(Wave::Sine, 0.3f32, processing, seq);
30
31 audact.start(4);
32}
examples/docs.rs (line 32)
6fn main() {
7 let mut audact = Audact::new(16, 120, 4f32);
8
9 let default_processing = Processing::default();
10 let n_1 = std_note_freq(0);
11 let n_2 = std_note_freq(2);
12
13 audact.channel(
14 Wave::Sine,
15 1f32,
16 default_processing,
17 vec![
18 n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32, 0f32, n_1, 0f32, 0f32,
19 0f32,
20 ],
21 );
22 audact.channel(
23 Wave::Square,
24 1f32,
25 default_processing,
26 vec![
27 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2, 0f32, 0f32, 0f32, n_2,
28 0f32,
29 ],
30 );
31
32 audact.start(1);
33}
examples/patterns.rs (line 30)
6fn main() {
7 let mut pattern_1 = Audact::new(16, 100, 4f32);
8 let n_1 = std_note_freq(0);
9 pattern_1.channel(
10 Wave::Sine,
11 0.7f32,
12 Processing::default(),
13 vec![
14 n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, n_1, 0f32, 0f32, n_1, 0f32, 0f32, 0f32,
15 ],
16 );
17
18 let mut pattern_2 = Audact::new(16, 100, 4f32);
19 let n_2 = std_note_freq(4);
20 pattern_2.channel(
21 Wave::Sine,
22 0.7f32,
23 Processing::default(),
24 vec![
25 n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2, n_2,
26 ],
27 );
28
29 // play the patterns one after another
30 pattern_1.start(1);
31 pattern_2.start(1);
32}
examples/main.rs (line 67)
8fn main() {
9 let mut audact = Audact::new(16, 100, 4f32);
10
11 let lead_processing = ProcessingBuilder::default()
12 .attack(Duration::from_millis(100u64))
13 .reverb((Duration::from_millis(200), 0.8f32))
14 .build()
15 .unwrap();
16
17 let default_processing = Processing::default();
18
19 //lead
20 let l_1 = std_note_freq(0);
21 let l_2 = std_note_freq(-2);
22 let l_3 = std_note_freq(-4);
23 audact.channel(
24 Wave::Saw,
25 0.1f32,
26 lead_processing,
27 vec![
28 l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3, l_1, l_2, l_3, l_3,
29 ],
30 );
31
32 //pad
33 let p_1 = std_note_freq(-12);
34 let p_2 = std_note_freq(-14);
35 let p_3 = std_note_freq(-16);
36 audact.channel(
37 Wave::Square,
38 0.1f32,
39 default_processing,
40 vec![
41 p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_1, p_2, p_2, p_2, p_2, p_3, p_3, p_3, p_3,
42 ],
43 );
44
45 let b_1 = std_note_freq(-24);
46 let b_2 = std_note_freq(-26);
47 //bass
48 audact.channel(
49 Wave::Sine,
50 0.1f32,
51 default_processing,
52 vec![
53 b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_1, b_2, b_2, b_2, b_2, b_2, b_2, b_2, b_2,
54 ],
55 );
56
57 // percussion
58 audact.channel(
59 Wave::Noise,
60 0.2f32,
61 default_processing,
62 vec![
63 b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32, b_1, 0f32, l_1, 0f32,
64 ],
65 );
66
67 audact.start(1);
68}
Auto Trait Implementations§
impl Freeze for Audact
impl !RefUnwindSafe for Audact
impl !Send for Audact
impl !Sync for Audact
impl Unpin for Audact
impl !UnwindSafe for Audact
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more