Skip to content

Commit e964f0b

Browse files
uklotzdeorottier
authored andcommitted
Rename function for accessing the precomputed sine table
1 parent 7e9c18c commit e964f0b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/node/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ pub(crate) const TABLE_LENGTH_BY_4_USIZE: usize = TABLE_LENGTH_USIZE / 4;
5656
pub(crate) const TABLE_LENGTH_F32: f32 = TABLE_LENGTH_USIZE as f32;
5757
pub(crate) const TABLE_LENGTH_BY_4_F32: f32 = TABLE_LENGTH_BY_4_USIZE as f32;
5858

59-
pub(crate) fn sine_table() -> &'static [f32] {
59+
/// Precomputed sine table
60+
pub(crate) fn precomputed_sine_table() -> &'static [f32] {
6061
static INSTANCE: OnceLock<Vec<f32>> = OnceLock::new();
6162
INSTANCE.get_or_init(|| {
6263
// Compute one period sine wavetable of size TABLE_LENGTH

src/node/oscillator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crate::render::{AudioParamValues, AudioProcessor, AudioRenderQuantum, Render
99
use crate::RENDER_QUANTUM_SIZE;
1010

1111
use super::{
12-
sine_table, AudioNode, AudioScheduledSourceNode, ChannelConfig, ChannelConfigOptions,
13-
TABLE_LENGTH_USIZE,
12+
precomputed_sine_table, AudioNode, AudioScheduledSourceNode, ChannelConfig,
13+
ChannelConfigOptions, TABLE_LENGTH_USIZE,
1414
};
1515

1616
/// Options for constructing an [`OscillatorNode`]
@@ -222,7 +222,7 @@ impl OscillatorNode {
222222
started: false,
223223
periodic_wave: None,
224224
ended_triggered: false,
225-
sine_table: sine_table(),
225+
sine_table: precomputed_sine_table(),
226226
};
227227

228228
let node = Self {

src/node/stereo_panner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::param::{AudioParam, AudioParamDescriptor};
44
use crate::render::{AudioParamValues, AudioProcessor, AudioRenderQuantum, RenderScope};
55

66
use super::{
7-
sine_table, AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode,
7+
precomputed_sine_table, AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode,
88
ChannelInterpretation, TABLE_LENGTH_BY_4_F32, TABLE_LENGTH_BY_4_USIZE,
99
};
1010

@@ -215,7 +215,7 @@ impl StereoPannerRenderer {
215215
fn new(pan: AudioParamId) -> Self {
216216
Self {
217217
pan,
218-
sine_table: sine_table(),
218+
sine_table: precomputed_sine_table(),
219219
}
220220
}
221221
}
@@ -356,7 +356,7 @@ mod tests {
356356

357357
#[test]
358358
fn test_get_stereo_gains() {
359-
let sine_table = sine_table();
359+
let sine_table = precomputed_sine_table();
360360

361361
// check correctness of wavetable lookup
362362
for i in 0..1001 {

0 commit comments

Comments
 (0)