Skip to content

Commit

Permalink
inline some small fns
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 22, 2024
1 parent f67ce02 commit d951f5d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,16 +1214,19 @@ impl Del2 {
});
}

#[inline]
fn lerp(a: f32, b: f32, x: f32) -> f32 {
(b - a).mul_add(x, a)
}
#[inline]
fn log_interpolate(a: f32, b: f32, x: f32) -> f32 {
a * (b / a).powf(x)
}

// Takes a pan value and gives a delay offset, in samples
// instead of adding delay, it subtracts delay from the other channel,
// so we stay under the maximum delay value
#[inline]
fn pan_to_haas_samples(pan: f32, sample_rate: f32) -> (isize, isize) {
let delay_samples = (pan.abs() * (MAX_HAAS_MS / 1000.0) * sample_rate) as isize;
if pan > 0.0 {
Expand All @@ -1234,6 +1237,7 @@ impl Del2 {
}

// for fn initialize():
#[inline]
fn calculate_buffer_size(buffer_size: u32) -> u32 {
((TOTAL_DELAY_SAMPLES as f64 / f64::from(buffer_size)).ceil() as u32 * buffer_size)
.next_power_of_two()
Expand Down Expand Up @@ -1288,6 +1292,7 @@ impl Del2 {
}
}

#[inline]
fn is_playing_action(&self, index: usize) -> bool {
self.last_played_notes
.is_playing(self.learned_notes.load(index))
Expand Down

0 comments on commit d951f5d

Please sign in to comment.