diff python/src/lib.rs @ 783:ec1e06402a97

Replace SDL2_mixer with the kira crate
author Link Mauve <linkmauve@linkmauve.fr>
date Fri, 21 Nov 2025 10:21:59 +0100
parents a30ce01b9154
children 1f152ca95658
line wrap: on
line diff
--- a/python/src/lib.rs
+++ b/python/src/lib.rs
@@ -1,6 +1,7 @@
 use pyo3::exceptions::{PyIOError, PyKeyError};
 use pyo3::prelude::*;
 use pyo3::types::{PyBytes, PyTuple};
+use touhou_formats::th06::pos::LoopPoints;
 use touhou_formats::th06::pbg3;
 use touhou_formats::th06::std as stage;
 use touhou_formats::th06::msg;
@@ -13,6 +14,8 @@
 #[cfg(feature = "glide")]
 mod glide;
 
+mod audio;
+
 #[pyclass(module = "libtouhou")]
 struct PyModel {
     inner: stage::Model,
@@ -96,7 +99,7 @@
                 msg::Instruction::SpawnEnemySprite() => (6, ().into_pyobject(py)?),
                 msg::Instruction::ChangeMusic(track) => (7, (track,).into_pyobject(py)?),
                 msg::Instruction::DisplayDescription(side, index, text) => (8, (side, index, text).into_pyobject(py)?),
-                msg::Instruction::ShowScores(unk1) => (8, (unk1,).into_pyobject(py)?),
+                msg::Instruction::ShowScores(unk1) => (9, (unk1,).into_pyobject(py)?),
                 msg::Instruction::Freeze() => (10, ().into_pyobject(py)?),
                 msg::Instruction::NextStage() => (11, ().into_pyobject(py)?),
                 msg::Instruction::Unk2() => (12, ().into_pyobject(py)?),
@@ -205,11 +208,22 @@
     }
 }
 
+impl Loader {
+    fn get_loop_points(&self, name: &str) -> Result<LoopPoints, ()> {
+        let vec = self.get_file_internal(name).unwrap();
+        let (_, inner) = LoopPoints::from_slice(&vec).unwrap();
+        Ok(inner)
+    }
+}
+
 #[pymodule]
 mod libtouhou {
     #[pymodule_export]
     use super::Loader;
 
+    #[pymodule_export]
+    use crate::audio::Audio;
+
     #[cfg(feature = "glide")]
     #[pymodule_export]
     use super::glide::module;