mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Fix clippy lints
This commit is contained in:
parent
85561de1ca
commit
352658f23f
|
@ -504,7 +504,7 @@ impl MixerBuffer {
|
|||
for j in i..self.frequency.buffer_size() {
|
||||
// SAFETY: working buffer length = self.frequency.buffer_size()
|
||||
unsafe {
|
||||
*working_buffer_i32.get_unchecked_mut(j) = 0.into();
|
||||
*working_buffer_i32.get_unchecked_mut(j) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,7 @@ impl<'a> quote::ToTokens for Sample<'a> {
|
|||
volume,
|
||||
} = self;
|
||||
|
||||
let self_as_u8s: Vec<_> = data.iter().map(|i| *i as u8).collect();
|
||||
let samples = ByteString(&self_as_u8s);
|
||||
let samples = ByteString(data);
|
||||
let volume = volume.to_raw();
|
||||
|
||||
tokens.append_all(quote! {
|
||||
|
|
|
@ -135,10 +135,13 @@ impl Tracker {
|
|||
|
||||
impl TrackerChannel {
|
||||
fn play_sound(&mut self, mixer: &mut Mixer<'_>, sample: &Sample<'static>) {
|
||||
self.channel_id
|
||||
if let Some(channel) = self
|
||||
.channel_id
|
||||
.take()
|
||||
.and_then(|channel_id| mixer.channel(&channel_id))
|
||||
.map(|channel| channel.stop());
|
||||
{
|
||||
channel.stop();
|
||||
}
|
||||
|
||||
let mut new_channel = SoundChannel::new(sample.data);
|
||||
|
||||
|
@ -158,7 +161,7 @@ impl TrackerChannel {
|
|||
if let Some(channel) = self
|
||||
.channel_id
|
||||
.as_ref()
|
||||
.and_then(|channel_id| mixer.channel(&channel_id))
|
||||
.and_then(|channel_id| mixer.channel(channel_id))
|
||||
{
|
||||
if speed != 0.into() {
|
||||
self.base_speed = speed;
|
||||
|
@ -172,7 +175,7 @@ impl TrackerChannel {
|
|||
if let Some(channel) = self
|
||||
.channel_id
|
||||
.as_ref()
|
||||
.and_then(|channel_id| mixer.channel(&channel_id))
|
||||
.and_then(|channel_id| mixer.channel(channel_id))
|
||||
{
|
||||
match effect {
|
||||
PatternEffect::None => {}
|
||||
|
|
|
@ -14,7 +14,7 @@ use xmrs::{prelude::*, xm::xmmodule::XmModule};
|
|||
pub fn agb_xm_core(args: TokenStream) -> TokenStream {
|
||||
let input = match syn::parse::<LitStr>(args.into()) {
|
||||
Ok(input) => input,
|
||||
Err(err) => return proc_macro2::TokenStream::from(err.to_compile_error()),
|
||||
Err(err) => return err.to_compile_error(),
|
||||
};
|
||||
|
||||
let filename = input.value();
|
||||
|
@ -61,7 +61,9 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
|||
let mut samples = vec![];
|
||||
|
||||
for (instrument_index, instrument) in instruments.iter().enumerate() {
|
||||
let InstrumentType::Default(ref instrument) = instrument.instr_type else { continue; };
|
||||
let InstrumentType::Default(ref instrument) = instrument.instr_type else {
|
||||
continue;
|
||||
};
|
||||
|
||||
for (sample_index, sample) in instrument.sample.iter().enumerate() {
|
||||
let should_loop = !matches!(sample.flags, LoopType::No);
|
||||
|
@ -340,7 +342,7 @@ fn note_to_speed(
|
|||
|
||||
fn note_to_frequency_linear(note: Note, fine_tune: f64, relative_note: i8) -> f64 {
|
||||
let real_note = (note as usize as f64) + (relative_note as f64);
|
||||
let period = 10.0 * 12.0 * 16.0 * 4.0 - (real_note as f64) * 16.0 * 4.0 - fine_tune / 2.0;
|
||||
let period = 10.0 * 12.0 * 16.0 * 4.0 - real_note * 16.0 * 4.0 - fine_tune / 2.0;
|
||||
8363.0 * 2.0f64.powf((6.0 * 12.0 * 16.0 * 4.0 - period) / (12.0 * 16.0 * 4.0))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let module = agb_xm_core::load_module_from_file(&std::path::Path::new(
|
||||
"../agb-tracker/examples/final_countdown.xm",
|
||||
))?;
|
||||
let output = agb_xm_core::parse_module(&module);
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in a new issue