1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
// Copyright (c) 2024 Lily Lyons
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use std::ffi::{c_float, c_int};
use fmod_sys::*;
use crate::Sound;
impl Sound {
/// Gets the number of music channels inside a MOD/S3M/XM/IT/MIDI file.
pub fn get_music_channel_count(&self) -> Result<i32> {
let mut num_channels = 0;
unsafe {
FMOD_Sound_GetMusicNumChannels(self.inner, &mut num_channels).to_result()?;
}
Ok(num_channels)
}
/// Sets the volume of a MOD/S3M/XM/IT/MIDI music channel volume.
pub fn set_music_channel_volume(&self, channel: c_int, volume: c_float) -> Result<()> {
unsafe {
FMOD_Sound_SetMusicChannelVolume(self.inner, channel, volume).to_result()?;
}
Ok(())
}
/// Retrieves the volume of a MOD/S3M/XM/IT/MIDI music channel volume.
pub fn get_music_channel_volume(&self, channel: c_int) -> Result<c_float> {
let mut volume = 0.0;
unsafe {
FMOD_Sound_GetMusicChannelVolume(self.inner, channel, &mut volume).to_result()?;
}
Ok(volume)
}
/// Sets the relative speed of MOD/S3M/XM/IT/MIDI music.
pub fn set_music_speed(&self, speed: c_float) -> Result<()> {
unsafe {
FMOD_Sound_SetMusicSpeed(self.inner, speed).to_result()?;
}
Ok(())
}
/// Gets the relative speed of MOD/S3M/XM/IT/MIDI music.
pub fn get_music_speed(&self) -> Result<c_float> {
let mut speed = 0.0;
unsafe {
FMOD_Sound_GetMusicSpeed(self.inner, &mut speed).to_result()?;
}
Ok(speed)
}
}