Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nenikitov committed Oct 9, 2024
1 parent 6a5e62f commit b1182dd
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 26 deletions.
1 change: 0 additions & 1 deletion engine/src/asset/sound/dat/mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ impl<'a> Player<'a> {
}
}
E::SampleOffset(Some(offset)) => {
// TODO(nenikitov): Remove this hardcoded value
channel.pos_sample = offset as f64 / TSample::SAMPLE_RATE as f64;
}
E::NoteDelay(delay) => {
Expand Down
3 changes: 1 addition & 2 deletions engine/src/asset/sound/dat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ fn uncompress(bytes: &[u8]) -> Vec<i16> {
}

fn convert_volume(volume: u8) -> f32 {
// TODO(nenikitov): Check if the volume should be limited to `1` max
volume as f32 / 64.0
volume as f32 / 64.
}
2 changes: 1 addition & 1 deletion engine/src/asset/sound/dat/pattern_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl PatternEffect {
PatternEffect::Volume(Volume::Bump { up: true, .. }) => {
Some(PatternEffectMemoryKey::VolumeBumpUp)
}
PatternEffect::Volume(Volume::Bump { up: down, .. }) => {
PatternEffect::Volume(Volume::Bump { up: false, .. }) => {
Some(PatternEffectMemoryKey::VolumeBumpDown)
}
PatternEffect::SampleOffset(..) => Some(PatternEffectMemoryKey::SampleOffset),
Expand Down
5 changes: 2 additions & 3 deletions engine/src/asset/sound/dat/pattern_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl AssetParser<Wildcard> for Option<PatternEventInstrument> {
input,
should_parse.then(|| match instruments.get(instrument as usize) {
Some(instrument) => PatternEventInstrument::Instrument(instrument.clone()),
None => PatternEventInstrument::Ghost,
None => PatternEventInstrument::Previous,
}),
))
}
Expand Down Expand Up @@ -131,14 +131,13 @@ impl AssetParser<Wildcard> for Option<PatternEventVolume> {
#[derive(Default, Debug, Clone)]
pub enum PatternEventInstrument {
#[default]
Ghost,
Previous,
Instrument(Rc<TInstrument>),
}

#[derive(Default, Debug)]
pub struct PatternEvent {
pub note: Option<PatternEventNote>,
// Option<Rc<TInstrument>>
pub instrument: Option<PatternEventInstrument>,
pub volume: Option<PatternEventVolume>,
pub effects: [Option<PatternEffect>; 2],
Expand Down
4 changes: 1 addition & 3 deletions engine/src/asset/sound/dat/t_instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use crate::{
utils::{iterator::CollectArray, nom::*},
};

// TODO(nenikitov): Double check these flags
bitflags! {
#[derive(Debug, Clone, Copy)]
pub struct TInstrumentFlags: u8 {
const HasVolumeEnvelope = 1 << 0;
const HasPanEnvelope = 1 << 1;
const HasPanEnvelope = 1 << 1;
}
}

Expand Down Expand Up @@ -190,7 +189,6 @@ impl AssetParser<Wildcard> for TInstrument {
}
}

// TODO(nenikitov): I'm not sure about this flag
bitflags! {
#[derive(Debug, Clone, Copy)]
pub struct TSampleFlags: u8 {
Expand Down
4 changes: 3 additions & 1 deletion engine/src/asset/sound/dat/t_song.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ impl std::fmt::Debug for TSong {
}
if let Some(instrument) = &event.instrument {
d.field_with("instrument", |f| match instrument {
PatternEventInstrument::Ghost => write!(f, "Ghost"),
PatternEventInstrument::Previous => {
write!(f, "Previous")
}
PatternEventInstrument::Instrument(instrument) => {
write!(
f,
Expand Down
14 changes: 0 additions & 14 deletions engine/src/asset/sound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@ mod tests {

let output_dir = PathBuf::from(parsed_file_path!("sounds/songs/"));

// TODO(nenikitov): Remove this debug code
{
let i = 0x3;
let song = sounds
.iter()
.filter_map(|s| match s {
Sound::Song(s) => Some(s),
Sound::Effect(_) => None,
})
.collect::<Vec<_>>()[i];

//dbg!(song);
}

sounds
.iter()
.filter_map(|s| {
Expand Down
1 change: 0 additions & 1 deletion engine/src/asset/sound/sample.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO(nenikitov): Remove this test code
use std::{fmt::Debug, mem::size_of, ops::Index};

pub enum AudioSamplePointFormat {
Expand Down

0 comments on commit b1182dd

Please sign in to comment.