Can't get audio mixer to work #405
-
as title says: I have been trying to get the audio mixer to work. I have followed the documentation and tried just using the example code #![no_std]
#![no_main]
#![cfg_attr(test, feature(custom_test_frameworks))]
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
extern crate alloc;
mod sfx;
use agb::{
println,
sound::mixer::{SoundChannel, Frequency}
};
pub const PURPLE_NIGHT: &[u8] = agb::include_wav!("sfx/01 - The Purple Night (Main Loop).wav");
#[agb::entry]
fn main(mut gba: agb::Gba) -> ! {
let vblank = agb::interrupt::VBlank::get();
vblank.wait_for_vblank();
let mut mixer = gba.mixer.mixer(Frequency::Hz18157);
mixer.enable();
let mut song_pos: agb::fixnum::Num<usize, 8> = 0.into();
let mut channel = SoundChannel::new_high_priority(PURPLE_NIGHT);
channel.stereo().should_loop();
let bgm = mixer.play_sound(channel);
println!("init");
println!("purple night len: {}", sfx::PURPLE_NIGHT.len());
loop {
if let Some(ref bgm) = bgm {
song_pos = mixer.channel(bgm).expect("expected music to be playing").pos();
println!("pos: {}", song_pos.to_raw());
}
mixer.frame();
vblank.wait_for_vblank();
}
} update: it seems like it gets a little bit into the audio file and just pauses |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
the problem was I was using 0.12.2 instead of 0.13, no idea what that was causing but that fixed it |
Beta Was this translation helpful? Give feedback.
the problem was I was using 0.12.2 instead of 0.13, no idea what that was causing but that fixed it