mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Use relative notes to make it sound almost correct
This commit is contained in:
parent
4d699e9000
commit
07b00f11e1
|
@ -170,13 +170,10 @@ impl TrackerChannel {
|
||||||
channel.stop();
|
channel.stop();
|
||||||
}
|
}
|
||||||
PatternEffect::Arpeggio(first, second) => {
|
PatternEffect::Arpeggio(first, second) => {
|
||||||
let first: Num<u32, 8> = first.change_base();
|
|
||||||
let second: Num<u32, 8> = second.change_base();
|
|
||||||
|
|
||||||
match tick % 3 {
|
match tick % 3 {
|
||||||
0 => channel.playback(self.base_speed),
|
0 => channel.playback(self.base_speed),
|
||||||
1 => channel.playback(self.base_speed + first),
|
1 => channel.playback(self.base_speed + first.change_base()),
|
||||||
2 => channel.playback(self.base_speed + second),
|
2 => channel.playback(self.base_speed + second.change_base()),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
let start_pos = pattern_data.len();
|
let start_pos = pattern_data.len();
|
||||||
|
|
||||||
for row in pattern.iter() {
|
for row in pattern.iter() {
|
||||||
let mut notes = vec![None; module.get_num_channels()];
|
let mut note_and_sample = vec![None; module.get_num_channels()];
|
||||||
|
|
||||||
for (i, slot) in row.iter().enumerate() {
|
for (i, slot) in row.iter().enumerate() {
|
||||||
let channel_number = i % module.get_num_channels();
|
let channel_number = i % module.get_num_channels();
|
||||||
|
@ -139,33 +139,42 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
|
|
||||||
if matches!(slot.note, Note::KeyOff) {
|
if matches!(slot.note, Note::KeyOff) {
|
||||||
effect1 = PatternEffect::Stop;
|
effect1 = PatternEffect::Stop;
|
||||||
notes[channel_number] = None;
|
note_and_sample[channel_number] = None;
|
||||||
} else {
|
} else if !matches!(slot.note, Note::None) {
|
||||||
notes[channel_number] = Some(slot.note);
|
if sample != 0 {
|
||||||
|
note_and_sample[channel_number] = Some((slot.note, &samples[sample - 1]));
|
||||||
|
} else if let Some((note, _)) = &mut note_and_sample[channel_number] {
|
||||||
|
*note = slot.note;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let effect2 = match slot.effect_type {
|
let effect2 = match slot.effect_type {
|
||||||
0x0 => {
|
0x0 => {
|
||||||
if slot.effect_parameter == 0 {
|
if slot.effect_parameter == 0 {
|
||||||
PatternEffect::None
|
PatternEffect::None
|
||||||
} else if let Some(note) = notes[channel_number] {
|
} else if let Some((note, sample)) = note_and_sample[channel_number] {
|
||||||
let first_arpeggio = slot.effect_parameter >> 4;
|
let first_arpeggio = slot.effect_parameter >> 4;
|
||||||
let second_arpeggio = slot.effect_parameter & 0xF;
|
let second_arpeggio = slot.effect_parameter & 0xF;
|
||||||
|
|
||||||
let note_speed = note_to_speed(note, 0.0, 0, module.frequency_type);
|
let note_speed = note_to_speed(
|
||||||
|
note,
|
||||||
|
sample.fine_tune,
|
||||||
|
sample.relative_note,
|
||||||
|
module.frequency_type,
|
||||||
|
);
|
||||||
|
|
||||||
let note = note as u8;
|
let first_arpeggio_speed = note_to_speed(
|
||||||
let first_arpeggio: Note = (note + first_arpeggio)
|
note,
|
||||||
.try_into()
|
sample.fine_tune,
|
||||||
.expect("Note out of bounds");
|
sample.relative_note + first_arpeggio as i8,
|
||||||
let second_arpeggio: Note = (note + second_arpeggio)
|
module.frequency_type,
|
||||||
.try_into()
|
);
|
||||||
.expect("Note out of bounds");
|
let second_arpeggio_speed = note_to_speed(
|
||||||
|
note,
|
||||||
let first_arpeggio_speed =
|
sample.fine_tune,
|
||||||
note_to_speed(first_arpeggio, 0.0, 0, module.frequency_type);
|
sample.relative_note + second_arpeggio as i8,
|
||||||
let second_arpeggio_speed =
|
module.frequency_type,
|
||||||
note_to_speed(second_arpeggio, 0.0, 0, module.frequency_type);
|
);
|
||||||
|
|
||||||
let first_arpeggio_difference = first_arpeggio_speed - note_speed;
|
let first_arpeggio_difference = first_arpeggio_speed - note_speed;
|
||||||
let second_arpeggio_difference = second_arpeggio_speed - note_speed;
|
let second_arpeggio_difference = second_arpeggio_speed - note_speed;
|
||||||
|
|
Loading…
Reference in a new issue