1#![allow(dead_code)]
2#![allow(non_camel_case_types)] mod envelopes;
5pub(crate) use envelopes::*;
6
7mod simd;
8pub(crate) use simd::*;
9
10mod simdvoice;
11pub(crate) use simdvoice::*;
12
13mod base;
14pub(crate) use base::*;
15
16mod squarewave;
17#[allow(unused_imports)]
18pub(crate) use squarewave::*;
19
20mod channels;
21#[allow(unused_imports)]
22pub(crate) use channels::*;
23
24mod constant;
25pub(crate) use constant::*;
26
27mod sampler;
28pub(crate) use sampler::*;
29
30mod control;
31pub(crate) use control::*;
32
33mod cutoff;
34pub(crate) use cutoff::*;
35
36#[derive(Copy, Clone)]
38pub struct EnvelopeControlData {
39 pub attack: Option<u8>,
42
43 pub release: Option<u8>,
46}
47
48#[derive(Copy, Clone, PartialEq)]
50pub enum ReleaseType {
51 Standard,
53
54 Kill,
56}
57
58#[derive(Copy, Clone)]
60pub struct VoiceControlData {
61 pub voice_pitch_multiplier: f32,
63
64 pub envelope: EnvelopeControlData,
66}
67
68impl VoiceControlData {
69 pub fn new_defaults() -> Self {
70 VoiceControlData {
71 voice_pitch_multiplier: 1.0,
72 envelope: EnvelopeControlData {
73 attack: None,
74 release: None,
75 },
76 }
77 }
78}
79
80pub trait VoiceGeneratorBase: Sync + Send {
81 fn ended(&self) -> bool;
82 fn signal_release(&mut self, rel_type: ReleaseType);
83 fn process_controls(&mut self, control: &VoiceControlData);
84}
85
86pub trait VoiceSampleGenerator: VoiceGeneratorBase {
87 fn render_to(&mut self, buffer: &mut [f32]);
88}
89
90pub trait Voice: VoiceSampleGenerator + Send + Sync {
91 fn is_releasing(&self) -> bool;
92 fn is_killed(&self) -> bool;
93
94 fn velocity(&self) -> u8;
95 fn exclusive_class(&self) -> Option<u8>;
96}