From 93e38d49ef712aa466463ad6dfb3deb368039ee5 Mon Sep 17 00:00:00 2001 From: Kevin Hamacher Date: Fri, 14 Feb 2020 11:39:20 +0100 Subject: [PATCH] cargo fmt --- src/sound/envelope.rs | 4 ++-- src/sound/length.rs | 17 +++++++++++------ src/sound/square.rs | 15 +++++---------- src/sound/wave.rs | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/sound/envelope.rs b/src/sound/envelope.rs index d5d2f5a..3a5c4f6 100644 --- a/src/sound/envelope.rs +++ b/src/sound/envelope.rs @@ -4,7 +4,7 @@ use sound::{AudioComponent, AudioModule}; #[derive(Clone, Debug)] pub enum EnvelopeDirection { Increase, - Decrease + Decrease, } impl Default for EnvelopeDirection { @@ -15,7 +15,7 @@ impl Default for EnvelopeDirection { /// Represents a volume envelope for the sound channels #[derive(Default, Debug)] -pub struct VolumeEnvelope{ +pub struct VolumeEnvelope { /// Accessible via the corresponding memory location, used as template /// when the sound is enabled register_value: u8, diff --git a/src/sound/length.rs b/src/sound/length.rs index 884c9b2..defd224 100644 --- a/src/sound/length.rs +++ b/src/sound/length.rs @@ -1,15 +1,21 @@ // Implement the length counter -use std::fmt::Debug; use sound::{AudioComponent, AudioModule}; +use std::fmt::Debug; #[derive(Default, Debug)] -pub struct LengthCounter where T: Default + Debug { +pub struct LengthCounter +where + T: Default + Debug, +{ // Do we need an additional enabled flag? counter: T, enabled: bool, } -impl LengthCounter where T: Default + Debug { +impl LengthCounter +where + T: Default + Debug, +{ pub fn set_length(&mut self, value: T) { self.counter = value; } @@ -19,8 +25,7 @@ impl LengthCounter where T: Default + Debug { } } - -impl AudioModule for LengthCounter { +impl AudioModule for LengthCounter { fn transform(&self, sample: u8) -> u8 { if self.enabled { if self.counter > 0 { @@ -44,7 +49,7 @@ impl AudioComponent for LengthCounter { // TODO: Is the same as above, there is something we should be able to do about // this -impl AudioModule for LengthCounter { +impl AudioModule for LengthCounter { fn transform(&self, sample: u8) -> u8 { if self.enabled { if self.counter > 0 { diff --git a/src/sound/square.rs b/src/sound/square.rs index b514c0a..845e7ba 100644 --- a/src/sound/square.rs +++ b/src/sound/square.rs @@ -33,7 +33,6 @@ pub struct SquareWaveGenerator { // Current sweep clock cycle sweep_clock: u8, - // sweep_freq_shadow: f32, } @@ -73,17 +72,13 @@ impl SquareWaveGenerator { if self.sweep_clock >= self.sweep_change_period { self.sweep_clock = 0; let change = self.frequency / (2f32.powi(self.sweep_change as _)); - self.frequency += if self.sweep_dec { - change - } else { - -change - }; + self.frequency += if self.sweep_dec { change } else { -change }; } } } } - pub fn reset(&mut self) { + pub fn reset(&mut self) { self.time = 0f32; } @@ -99,21 +94,21 @@ impl SquareWaveGenerator { } else { 0 } - }, + } DutyCycle::Duty1 => { if temp < 0.25 { 255 } else { 0 } - }, + } DutyCycle::Duty2 => { if temp < 0.5 { 255 } else { 0 } - }, + } DutyCycle::Duty3 => { if temp < 0.75 { 255 diff --git a/src/sound/wave.rs b/src/sound/wave.rs index b40821d..596516d 100644 --- a/src/sound/wave.rs +++ b/src/sound/wave.rs @@ -50,7 +50,7 @@ impl WaveGenerator { self.update_frequency(); } - pub fn reset(&mut self) { + pub fn reset(&mut self) { self.time = 0f32; }