-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use phase modulation for continous curves
- Loading branch information
1 parent
6f58a83
commit 4f77a99
Showing
26 changed files
with
424 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"fract" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
|
||
[workspace] | ||
members = [ | ||
"audio-engine-common", | ||
"audio-engine-notes", | ||
"audio-engine-fm" | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "audio-engine-common" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
name="audio_engine_common" | ||
path="src/lib.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod phase_time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::ops::AddAssign; | ||
|
||
#[derive(Default)] | ||
pub struct PhaseTime { | ||
pub time: f32, | ||
} | ||
|
||
impl PhaseTime { | ||
pub fn delta_phase_time(frequency: f32, sample_rate: f32) -> PhaseTime { | ||
PhaseTime { | ||
time: (frequency / sample_rate).fract(), | ||
} | ||
} | ||
} | ||
|
||
impl AddAssign for PhaseTime { | ||
fn add_assign(&mut self, other: Self) { | ||
self.time = (self.time + 1.0 + other.time).fract() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
use crate::{ | ||
algorithm::Algorithm, | ||
operator::Operators, | ||
sample::{NoUserData, SampleGenerator}, | ||
operator::{Operators, OperatorsNoteState}, | ||
}; | ||
|
||
pub struct Instrument { | ||
pub operators: Operators, | ||
pub algorithm: Algorithm, | ||
} | ||
|
||
impl SampleGenerator for Instrument { | ||
type U = NoUserData; | ||
fn sample( | ||
impl Instrument { | ||
pub fn sample( | ||
&self, | ||
note_time: crate::Time, | ||
note_off: Option<crate::Time>, | ||
frequency: f32, | ||
_user_data: &Self::U, | ||
state: &mut InstrumentNoteState, | ||
) -> f32 { | ||
self.algorithm | ||
.sample(note_time, note_off, frequency, &self.operators) | ||
self.algorithm.sample( | ||
note_time, | ||
note_off, | ||
frequency, | ||
&self.operators, | ||
&mut state.operators, | ||
) | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct InstrumentNoteState { | ||
pub operators: OperatorsNoteState, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.