Skip to content

Commit

Permalink
Fix CI, clippy warnings & cargo description
Browse files Browse the repository at this point in the history
  • Loading branch information
tversteeg committed Apr 3, 2020
1 parent b4277db commit 65f3e14
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libsdl2-dev libasound2-dev
- uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -71,7 +70,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libsdl2-dev libasound2-dev
- uses: actions-rs/toolchain@v1
with:
Expand All @@ -83,7 +81,7 @@ jobs:
command: check
args: --all

# Run tests on Linux, macOS, and Windows
# Run tests on Linux
# On both Rust stable and Rust nightly
test:
name: Test Suite
Expand All @@ -92,7 +90,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest]
rust: [stable, nightly]
steps:
# Checkout the branch being tested
Expand Down Expand Up @@ -126,7 +124,6 @@ jobs:
dotnet-version: "2.2.402"

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libsdl2-dev libasound2-dev

# Run the ignored tests that expect the above setup
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ authors = ["Thomas Versteeg <thomasversteeg@gmx.com>"]
license = "AGPL-3.0-or-later"
edition = "2018"
readme = "README.md"
repository = "https://github.com/tversteeg/replace_me"
documentation = "https://docs.rs/replace_me"
description = ""
keywords = []
categories = []
repository = "https://github.com/tversteeg/usfx"
documentation = "https://docs.rs/usfx"
description = "Realtime procedurally generated sound effects"
keywords = ["sfx", "audio", "gamedev", "sound", "procedural"]
categories = ["game-development", "multimedia", "multimedia::audio", "simulation"]

[dev-dependencies]
cpal = "0.11.0"
Expand Down
1 change: 0 additions & 1 deletion examples/music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ fn generate_lead_frequencies(mut rng: &mut ThreadRng) -> Vec<usize> {

// Choose 8 random notes
(0..8)
.into_iter()
.map(
|_| match scale_notes.iter().choose(&mut rng).unwrap().pitch_class {
// Convert the pitch class of the note to a frequency
Expand Down
37 changes: 19 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub struct Sample {
env_decay: f32,
env_release: f32,
env_sustain: f32,
dis_crunch: f32,
dis_drive: f32,
dis_crunch: Option<f32>,
dis_drive: Option<f32>,
}

impl Default for Sample {
Expand All @@ -67,15 +67,15 @@ impl Default for Sample {
env_decay: 0.1,
env_sustain: 0.5,
env_release: 0.5,
dis_crunch: 0.0,
dis_drive: 1.0,
dis_crunch: None,
dis_drive: None,
}
}
}

impl Sample {
/// Set the frequency of the oscillator in hertz.
pub fn osc_frequency<'a>(&'a mut self, frequency: usize) -> &'a mut Self {
pub fn osc_frequency(&mut self, frequency: usize) -> &mut Self {
self.osc_frequency = frequency;

self
Expand All @@ -86,50 +86,50 @@ impl Sample {
/// See the [`OscillatorType`] enum for supported wave types.
///
/// [`OscillatorType`]: enum.OscillatorType.html
pub fn osc_type<'a>(&'a mut self, oscillator: OscillatorType) -> &'a mut Self {
pub fn osc_type(&mut self, oscillator: OscillatorType) -> &mut Self {
self.osc_type = oscillator;

self
}

/// Set the time until the first envelope slope reaches it's maximum height.
pub fn env_attack<'a>(&'a mut self, attack: f32) -> &'a mut Self {
pub fn env_attack(&mut self, attack: f32) -> &mut Self {
self.env_attack = attack;

self
}

/// Set the time it takes from the maximum height to go into the main plateau.
pub fn env_decay<'a>(&'a mut self, decay: f32) -> &'a mut Self {
pub fn env_decay(&mut self, decay: f32) -> &mut Self {
self.env_decay = decay;

self
}

/// Set the height of the main plateau.
pub fn env_sustain<'a>(&'a mut self, sustain: f32) -> &'a mut Self {
pub fn env_sustain(&mut self, sustain: f32) -> &mut Self {
self.env_sustain = sustain;

self
}

/// Set the time it takes to go from the end of the plateau to zero.
pub fn env_release<'a>(&'a mut self, release: f32) -> &'a mut Self {
pub fn env_release(&mut self, release: f32) -> &mut Self {
self.env_release = release;

self
}

/// Overdrive that adds hard clipping.
pub fn dis_crunch<'a>(&'a mut self, crunch: f32) -> &'a mut Self {
self.dis_crunch = crunch;
pub fn dis_crunch(&mut self, crunch: f32) -> &mut Self {
self.dis_crunch = Some(crunch);

self
}

/// Overdrive with soft clipping.
pub fn dis_drive<'a>(&'a mut self, drive: f32) -> &'a mut Self {
self.dis_drive = drive;
pub fn dis_drive(&mut self, drive: f32) -> &mut Self {
self.dis_drive = Some(drive);

self
}
Expand Down Expand Up @@ -236,10 +236,11 @@ impl Mixer {
let oscillator = Oscillator::new(buffer, self.sample_rate);

// Create the distortion if applicable
let distortion = if sample.dis_crunch == 0.0 && sample.dis_drive == 1.0 {
None
} else {
Some(Distortion::new(sample.dis_crunch, sample.dis_drive))
let distortion = match (sample.dis_crunch, sample.dis_drive) {
(Some(crunch), Some(drive)) => Some(Distortion::new(crunch, drive)),
(Some(crunch), None) => Some(Distortion::new(crunch, 1.0)),
(None, Some(drive)) => Some(Distortion::new(0.0, drive)),
(None, None) => None,
};

// Combine them in a generator
Expand Down

0 comments on commit 65f3e14

Please sign in to comment.