simplify
This commit is contained in:
parent
28c964e37e
commit
17e30fdec4
|
@ -100,7 +100,7 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if system.keyboard.is_key_pressed(Scancode::Num6) {
|
if system.keyboard.is_key_pressed(Scancode::Num6) {
|
||||||
audio_device.play_generator(Box::new(SineWaveGenerator::new()), false);
|
audio_device.play_generator(SineWaveGenerator::new(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
for index in 0..NUM_CHANNELS {
|
for index in 0..NUM_CHANNELS {
|
||||||
|
|
|
@ -152,9 +152,9 @@ impl AudioChannel {
|
||||||
self.loops = loops;
|
self.loops = loops;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn play_generator(&mut self, generator: Box<dyn AudioGenerator>, loops: bool) {
|
pub fn play_generator(&mut self, generator: impl AudioGenerator + 'static, loops: bool) {
|
||||||
self.data.clear();
|
self.data.clear();
|
||||||
self.generator = Some(generator);
|
self.generator = Some(Box::new(generator));
|
||||||
self.position = 0;
|
self.position = 0;
|
||||||
self.playing = true;
|
self.playing = true;
|
||||||
self.loops = loops;
|
self.loops = loops;
|
||||||
|
@ -250,7 +250,7 @@ impl AudioDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn play_generator(&mut self, generator: Box<dyn AudioGenerator>, loops: bool) -> Result<Option<&mut AudioChannel>, AudioDeviceError> {
|
pub fn play_generator(&mut self, generator: impl AudioGenerator + 'static, loops: bool) -> Result<Option<&mut AudioChannel>, AudioDeviceError> {
|
||||||
if let Some(channel) = self.stopped_channels_iter_mut().next() {
|
if let Some(channel) = self.stopped_channels_iter_mut().next() {
|
||||||
channel.play_generator(generator, loops);
|
channel.play_generator(generator, loops);
|
||||||
Ok(Some(channel))
|
Ok(Some(channel))
|
||||||
|
|
Loading…
Reference in a new issue