Fix floating-point literal used in pattern in example (#705)

This commit is contained in:
Joshua Erney
2017-09-21 18:33:06 +02:00
committed by Cobrand
parent b52bd54463
commit 0f44d43595
+1 -4
View File
@@ -15,10 +15,7 @@ impl AudioCallback for SquareWave {
fn callback(&mut self, out: &mut [f32]) {
// Generate a square wave
for x in out.iter_mut() {
*x = match self.phase {
0.0...0.5 => self.volume,
_ => -self.volume
};
*x = if self.phase < 0.5 { self.volume } else { -self.volume };
self.phase = (self.phase + self.phase_inc) % 1.0;
}
}