Skip to content

Commit

Permalink
Update Rust crate xmrs to v0.8.5 (#786)
Browse files Browse the repository at this point in the history
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [xmrs](https://codeberg.org/sbechet/xmrs) | dependencies | patch |
`=0.8.1` -> `=0.8.5` |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/agbrs/agb).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMjAuMSIsInVwZGF0ZWRJblZlciI6IjM4LjEyMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
  • Loading branch information
gwilymk authored Nov 6, 2024
2 parents 8e885a8 + 0333a63 commit 16c1fad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tracker/agb-xm-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ syn = "2"
agb_tracker_interop = { version = "0.21.1", path = "../agb-tracker-interop", default-features = false }
agb_fixnum = { version = "0.21.1", path = "../../agb-fixnum" }

xmrs = { version = "=0.8.1", features = ["std", "import"] }
xmrs = { version = "=0.8.5", features = ["std", "import"] }
33 changes: 17 additions & 16 deletions tracker/agb-xm-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ pub fn parse_module(module: &Module) -> agb_tracker_interop::Track {
let volume = Num::from_f32(sample.volume);

let sample = match &sample.data {
SampleDataType::Depth8(depth8) => depth8
SampleDataType::Mono8(depth8) => depth8
.iter()
.map(|value| *value as u8)
.take(sample_len)
.collect::<Vec<_>>(),
SampleDataType::Depth16(depth16) => depth16
SampleDataType::Mono16(depth16) => depth16
.iter()
.map(|sample| (sample >> 8) as i8 as u8)
.take(sample_len)
.collect::<Vec<_>>(),
_ => panic!("Stereo samples not supported"),
};

let fadeout = Num::from_f32(instrument.volume_fadeout);
Expand Down Expand Up @@ -652,7 +653,7 @@ static AMIGA_FREQUENCIES: &[u32] = &[
457,
];

#[derive(PartialEq, Eq, Hash, Clone)]
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
struct EnvelopeData {
amounts: Vec<Num<i16, 8>>,
sustain: Option<usize>,
Expand Down Expand Up @@ -684,30 +685,30 @@ impl EnvelopeData {
let first_point = &e.point[index];
let second_point = &e.point[index + 1];

let amount = EnvelopePoint::lerp(first_point, second_point, xm_frame) / 64.0;
let amount = EnvelopePoint::lerp(first_point, second_point, xm_frame);
let amount = Num::from_f32(amount);

amounts.push(amount);
}

let sustain = if e.sustain_enabled {
Some(
Self::envelope_frame_to_gba_frame(e.point[e.sustain_point as usize].frame, bpm)
as usize,
)
Some(Self::envelope_frame_to_gba_frame(
e.point[e.sustain_point].frame,
bpm,
))
} else {
None
};
let (loop_start, loop_end) = if e.loop_enabled {
(
Some(Self::envelope_frame_to_gba_frame(
e.point[e.loop_start_point as usize].frame,
e.point[e.loop_start_point].frame,
bpm,
) as usize),
)),
Some(Self::envelope_frame_to_gba_frame(
e.point[e.loop_end_point as usize].frame,
e.point[e.loop_end_point].frame,
bpm,
) as usize),
)),
)
} else {
(None, None)
Expand Down Expand Up @@ -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
// 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 {
(gba_frame as u32 * bpm / 250) as u16
fn gba_frame_to_envelope_frame(gba_frame: usize, bpm: u32) -> usize {
(gba_frame as u32 * bpm / 250) as usize
}
}
2 changes: 1 addition & 1 deletion tracker/agb-xm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ proc-macro2 = "1"
quote = "1"
syn = "2"

xmrs = "=0.8.1"
xmrs = "=0.8.5"
2 changes: 1 addition & 1 deletion tracker/desktop-player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ agb_tracker = { version = "0.21.1", path = "../agb-tracker", default-features =
agb_fixnum = { version = "0.21.1", path = "../../agb-fixnum" }

anyhow = "1"
xmrs = "=0.8.1"
xmrs = "=0.8.5"

cpal = "0.15"

0 comments on commit 16c1fad

Please sign in to comment.