mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Add sample offset command support
This commit is contained in:
parent
ea792f4768
commit
559367f607
|
@ -93,6 +93,7 @@ pub enum PatternEffect {
|
||||||
/// Increase / decrease the pitch by the specified amount immediately
|
/// Increase / decrease the pitch by the specified amount immediately
|
||||||
PitchBend(Num<u32, 8>),
|
PitchBend(Num<u32, 8>),
|
||||||
Jump(Jump),
|
Jump(Jump),
|
||||||
|
SampleOffset(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -401,6 +402,7 @@ impl quote::ToTokens for PatternEffect {
|
||||||
PatternEffect::Jump(jump) => {
|
PatternEffect::Jump(jump) => {
|
||||||
quote! { Jump(#jump) }
|
quote! { Jump(#jump) }
|
||||||
}
|
}
|
||||||
|
PatternEffect::SampleOffset(offset) => quote! { SampleOffset(#offset) },
|
||||||
};
|
};
|
||||||
|
|
||||||
tokens.append_all(quote! {
|
tokens.append_all(quote! {
|
||||||
|
|
|
@ -126,6 +126,9 @@ struct TrackerChannel {
|
||||||
current_speed: Num<u32, 16>,
|
current_speed: Num<u32, 16>,
|
||||||
current_panning: Num<i32, 8>,
|
current_panning: Num<i32, 8>,
|
||||||
is_playing: bool,
|
is_playing: bool,
|
||||||
|
|
||||||
|
// if some, should set the current position to this
|
||||||
|
current_pos: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -337,6 +340,10 @@ impl<'track, TChannelId> TrackerInner<'track, TChannelId> {
|
||||||
channel.volume(tracker_channel.current_volume.try_change_base().unwrap());
|
channel.volume(tracker_channel.current_volume.try_change_base().unwrap());
|
||||||
channel.panning(tracker_channel.current_panning.try_change_base().unwrap());
|
channel.panning(tracker_channel.current_panning.try_change_base().unwrap());
|
||||||
|
|
||||||
|
if let Some(offset) = tracker_channel.current_pos.take() {
|
||||||
|
channel.set_pos(offset as u32);
|
||||||
|
}
|
||||||
|
|
||||||
if tracker_channel.is_playing {
|
if tracker_channel.is_playing {
|
||||||
channel.resume();
|
channel.resume();
|
||||||
} else {
|
} else {
|
||||||
|
@ -601,6 +608,11 @@ impl TrackerChannel {
|
||||||
PatternEffect::Jump(jump) => {
|
PatternEffect::Jump(jump) => {
|
||||||
*current_jump = Some(jump.clone());
|
*current_jump = Some(jump.clone());
|
||||||
}
|
}
|
||||||
|
PatternEffect::SampleOffset(offset) => {
|
||||||
|
if tick == 0 {
|
||||||
|
self.current_pos = Some(*offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,6 +689,10 @@ impl SoundChannel for agb::sound::mixer::SoundChannel {
|
||||||
fn panning(&mut self, panning: impl Into<Num<i16, 8>>) -> &mut Self {
|
fn panning(&mut self, panning: impl Into<Num<i16, 8>>) -> &mut Self {
|
||||||
self.panning(panning)
|
self.panning(panning)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_pos(&mut self, pos: impl Into<Num<u32, 8>>) -> &mut Self {
|
||||||
|
self.set_pos(pos)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "agb")]
|
#[cfg(feature = "agb")]
|
||||||
|
|
|
@ -17,6 +17,8 @@ pub trait SoundChannel {
|
||||||
fn restart_point(&mut self, value: impl Into<Num<u32, 8>>) -> &mut Self;
|
fn restart_point(&mut self, value: impl Into<Num<u32, 8>>) -> &mut Self;
|
||||||
fn playback(&mut self, playback_speed: impl Into<Num<u32, 8>>) -> &mut Self;
|
fn playback(&mut self, playback_speed: impl Into<Num<u32, 8>>) -> &mut Self;
|
||||||
fn panning(&mut self, panning: impl Into<Num<i16, 8>>) -> &mut Self;
|
fn panning(&mut self, panning: impl Into<Num<i16, 8>>) -> &mut Self;
|
||||||
|
|
||||||
|
fn set_pos(&mut self, pos: impl Into<Num<u32, 8>>) -> &mut Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Mixer {
|
pub trait Mixer {
|
||||||
|
|
|
@ -324,6 +324,7 @@ pub fn parse_module(module: &Module) -> agb_tracker_interop::Track {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
0x9 => PatternEffect::SampleOffset(effect_parameter as u16 * 256),
|
||||||
0xB => {
|
0xB => {
|
||||||
let pattern_idx = slot.effect_parameter;
|
let pattern_idx = slot.effect_parameter;
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,11 @@ impl agb_tracker::SoundChannel for SoundChannel {
|
||||||
self.panning = panning.into();
|
self.panning = panning.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_pos(&mut self, pos: impl Into<Num<u32, 8>>) -> &mut Self {
|
||||||
|
self.pos = pos.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl agb_tracker::Mixer for Mixer {
|
impl agb_tracker::Mixer for Mixer {
|
||||||
|
|
BIN
tracker/desktop-player/tests/delay.xm
Normal file
BIN
tracker/desktop-player/tests/delay.xm
Normal file
Binary file not shown.
Loading…
Reference in a new issue