mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Get it all compiling again
This commit is contained in:
parent
103dfd52db
commit
3be63230de
|
@ -63,16 +63,17 @@ pub fn parse_module(module: &Module) -> agb_tracker_interop::Track {
|
||||||
let volume = Num::from_f32(sample.volume);
|
let volume = Num::from_f32(sample.volume);
|
||||||
|
|
||||||
let sample = match &sample.data {
|
let sample = match &sample.data {
|
||||||
SampleDataType::Depth8(depth8) => depth8
|
SampleDataType::Mono8(depth8) => depth8
|
||||||
.iter()
|
.iter()
|
||||||
.map(|value| *value as u8)
|
.map(|value| *value as u8)
|
||||||
.take(sample_len)
|
.take(sample_len)
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
SampleDataType::Depth16(depth16) => depth16
|
SampleDataType::Mono16(depth16) => depth16
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sample| (sample >> 8) as i8 as u8)
|
.map(|sample| (sample >> 8) as i8 as u8)
|
||||||
.take(sample_len)
|
.take(sample_len)
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
|
_ => panic!("Stereo samples not supported"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let fadeout = Num::from_f32(instrument.volume_fadeout);
|
let fadeout = Num::from_f32(instrument.volume_fadeout);
|
||||||
|
@ -691,23 +692,23 @@ impl EnvelopeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sustain = if e.sustain_enabled {
|
let sustain = if e.sustain_enabled {
|
||||||
Some(
|
Some(Self::envelope_frame_to_gba_frame(
|
||||||
Self::envelope_frame_to_gba_frame(e.point[e.sustain_point as usize].frame, bpm)
|
e.point[e.sustain_point].frame,
|
||||||
as usize,
|
bpm,
|
||||||
)
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let (loop_start, loop_end) = if e.loop_enabled {
|
let (loop_start, loop_end) = if e.loop_enabled {
|
||||||
(
|
(
|
||||||
Some(Self::envelope_frame_to_gba_frame(
|
Some(Self::envelope_frame_to_gba_frame(
|
||||||
e.point[e.loop_start_point as usize].frame,
|
e.point[e.loop_start_point].frame,
|
||||||
bpm,
|
bpm,
|
||||||
) as usize),
|
)),
|
||||||
Some(Self::envelope_frame_to_gba_frame(
|
Some(Self::envelope_frame_to_gba_frame(
|
||||||
e.point[e.loop_end_point as usize].frame,
|
e.point[e.loop_end_point].frame,
|
||||||
bpm,
|
bpm,
|
||||||
) as usize),
|
)),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(None, None)
|
(None, None)
|
||||||
|
@ -748,13 +749,13 @@ impl EnvelopeData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn envelope_frame_to_gba_frame(envelope_frame: u16, bpm: u32) -> u16 {
|
fn envelope_frame_to_gba_frame(envelope_frame: usize, bpm: u32) -> usize {
|
||||||
// FT2 manual says number of ticks / second = BPM * 0.4
|
// FT2 manual says number of ticks / second = BPM * 0.4
|
||||||
// somehow this works as a good approximation :/
|
// somehow this works as a good approximation :/
|
||||||
(envelope_frame as u32 * 250 / bpm) as u16
|
(envelope_frame as u32 * 250 / bpm) as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gba_frame_to_envelope_frame(gba_frame: u16, bpm: u32) -> u16 {
|
fn gba_frame_to_envelope_frame(gba_frame: usize, bpm: u32) -> usize {
|
||||||
(gba_frame as u32 * bpm / 250) as u16
|
(gba_frame as u32 * bpm / 250) as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue