Browse Source

fmt

pull/83/head
Andrea Ciliberti 2 years ago
parent
commit
429e60c878
  1. 10
      ctru-rs/examples/audio_filters.rs
  2. 2
      ctru-rs/src/services/ndsp/mod.rs
  3. 8
      ctru-rs/src/services/ndsp/wave.rs

10
ctru-rs/examples/audio_filters.rs

@ -80,12 +80,14 @@ fn main() {
// We set up two wave buffers and alternate between the two, // We set up two wave buffers and alternate between the two,
// effectively streaming an infinitely long sine wave. // effectively streaming an infinitely long sine wave.
let mut audio_data1 = Box::new_in([0u8; AUDIO_WAVE_LENGTH], LinearAllocator); let mut audio_data1 = Box::new_in([0u8; AUDIO_WAVE_LENGTH], LinearAllocator);
fill_buffer(&mut audio_data1[..], NOTEFREQ[4]); fill_buffer(&mut audio_data1[..], NOTEFREQ[4]);
let mut audio_data2 = audio_data1.clone(); let mut audio_data2 = audio_data1.clone();
let mut audio_buffer1 = WaveBuffer::new(audio_data1, AudioFormat::PCM16Stereo).expect("Couldn't sync DSP cache"); let mut audio_buffer1 =
let mut audio_buffer2 = WaveBuffer::new(audio_data2, AudioFormat::PCM16Stereo).expect("Couldn't sync DSP cache"); WaveBuffer::new(audio_data1, AudioFormat::PCM16Stereo).expect("Couldn't sync DSP cache");
let mut audio_buffer2 =
WaveBuffer::new(audio_data2, AudioFormat::PCM16Stereo).expect("Couldn't sync DSP cache");
let mut wave_info1 = WaveInfo::new(&mut audio_buffer1, false); let mut wave_info1 = WaveInfo::new(&mut audio_buffer1, false);
let mut wave_info2 = WaveInfo::new(&mut audio_buffer2, false); let mut wave_info2 = WaveInfo::new(&mut audio_buffer2, false);

2
ctru-rs/src/services/ndsp/mod.rs

@ -151,7 +151,7 @@ impl Channel {
unsafe { ctru_sys::ndspChnWaveBufClear(self.id) }; unsafe { ctru_sys::ndspChnWaveBufClear(self.id) };
} }
/// Add a wave buffer to the channel's queue. /// Add a wave buffer to the channel's queue.
/// If there are no other buffers in queue, playback for this buffer will start. /// If there are no other buffers in queue, playback for this buffer will start.
/// ///
/// # Warning /// # Warning

8
ctru-rs/src/services/ndsp/wave.rs

@ -93,7 +93,11 @@ impl<'b> WaveInfo<'b> {
next: std::ptr::null_mut(), next: std::ptr::null_mut(),
}; };
Self { buffer, raw_data, played_on_channel: None,} Self {
buffer,
raw_data,
played_on_channel: None,
}
} }
pub fn get_mut_wavebuffer(&mut self) -> &mut WaveBuffer { pub fn get_mut_wavebuffer(&mut self) -> &mut WaveBuffer {
@ -144,7 +148,7 @@ impl<'b> Drop for WaveInfo<'b> {
// If the status flag is "unfinished" // If the status flag is "unfinished"
_ => { _ => {
// The unwrap is safe, since it must have a value in the case the status is "unfinished". // The unwrap is safe, since it must have a value in the case the status is "unfinished".
unsafe { ndspChnWaveBufClear(self.played_on_channel.unwrap().into() )}; unsafe { ndspChnWaveBufClear(self.played_on_channel.unwrap().into()) };
} }
} }
} }

Loading…
Cancel
Save