Skip to content

Commit

Permalink
Fix tests and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikNatanael committed Oct 7, 2024
1 parent f390772 commit 84416fe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 48 deletions.
46 changes: 1 addition & 45 deletions knyst/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! ```
//! # use knyst::prelude::*;
//! # use knyst::wavetable::*;
//! let graph_settings = GraphSettings {
//! block_size: 64,
//! sample_rate: 44100.,
Expand All @@ -29,14 +28,10 @@
use crate::gen::{Gen, GenContext, GenState};
#[allow(unused)]
use crate::trig;
use crate::{BlockSize, Sample, SampleRate};
use crate::{BlockSize, Sample};
use knyst_macro::impl_gen;
// For using impl_gen inside the knyst crate
use crate as knyst;
// #[cfg(loom)]
// use loom::cell::UnsafeCell;
#[cfg(loom)]
use loom::sync::atomic::Ordering;

#[macro_use]
pub mod connection;
Expand All @@ -58,7 +53,6 @@ use slotmap::{new_key_type, SecondaryMap, SlotMap};
use std::cell::UnsafeCell;
use std::collections::{HashMap, HashSet};
use std::mem;
#[cfg(not(loom))]
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicBool, AtomicU64};
use std::sync::{Arc, RwLock};
Expand Down Expand Up @@ -1040,7 +1034,6 @@ impl Drop for OwnedRawBuffer {
/// # Example
/// ```
/// use knyst::prelude::*;
/// use knyst::wavetable::*;
/// use knyst::graph::RunGraph;
/// let graph_settings = GraphSettings {
/// block_size: 64,
Expand Down Expand Up @@ -4230,42 +4223,5 @@ impl Mult {
}
}

struct NaiveSine {
phase: Sample,
phase_step: Sample,
amp: Sample,
}
impl NaiveSine {
pub fn update_freq(&mut self, freq: Sample, sample_rate: Sample) {
self.phase_step = freq / sample_rate;
}
}

#[impl_gen]
impl NaiveSine {
#[process]
fn process(
&mut self,
freq: &[Sample],
amp: &[Sample],
sig: &mut [Sample],
block_size: BlockSize,
sample_rate: SampleRate,
) -> GenState {
for i in 0..*block_size {
let freq = freq[i];
let amp = amp[i];
self.update_freq(freq, *sample_rate);
self.amp = amp;
sig[i] = self.phase.cos() * self.amp;
self.phase += self.phase_step;
if self.phase > 1.0 {
self.phase -= 1.0;
}
}
GenState::Continue
}
}

#[cfg(test)]
mod tests;
2 changes: 1 addition & 1 deletion knyst/src/modal_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::graph::{GraphSettings, NodeId, Time};
use crate::handles::{GraphHandle, Handle};
use crate::prelude::{CallbackHandle, MultiThreadedKnystCommands};
use crate::sphere::KnystSphere;
use crate::wavetable_aa::{self, Wavetable};
use crate::wavetable_aa::Wavetable;

/// A unique id for a KnystSphere.
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion knyst/src/scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl Default for MusicalTimeMap {
}

/// Exposes the shared MusicalTimeMap in a read only Sync container.
pub struct MusicalTimeMapRef(Arc<RwLock<MusicalTimeMap>>);
pub struct MusicalTimeMapRef(#[allow(unused)] Arc<RwLock<MusicalTimeMap>>);

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion knyst/src/wavetable_aa.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Wavetable synthesis

use crate::wavetable::{WavetablePhase, FRACTIONAL_PART, TABLE_HIGH_MASK, TABLE_POWER, TABLE_SIZE};
use crate::wavetable::{WavetablePhase, TABLE_SIZE};
use crate::Sample;

// use std::f64::consts::PI;
Expand Down

0 comments on commit 84416fe

Please sign in to comment.