fmod/studio/event_instance/
core.rs

1// Copyright (c) 2024 Melody Madeline Lyons
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
7use std::ffi::{c_float, c_int};
8
9use fmod_sys::*;
10
11use crate::ChannelGroup;
12use crate::studio::EventInstance;
13use crate::{FmodResultExt, Result};
14
15impl EventInstance {
16    /// Retrieves the core [`ChannelGroup`].
17    ///
18    /// Until the event instance has been fully created this function will return [`FMOD_RESULT::FMOD_ERR_STUDIO_NOT_LOADED`].
19    pub fn get_channel_group(&self) -> Result<ChannelGroup> {
20        let mut channel_group = std::ptr::null_mut();
21        unsafe {
22            FMOD_Studio_EventInstance_GetChannelGroup(self.inner.as_ptr(), &raw mut channel_group)
23                .to_result()?;
24            Ok(ChannelGroup::from_ffi(channel_group))
25        }
26    }
27
28    /// Sets the core reverb send level.
29    ///          
30    /// This function controls the send level for the signal from the event instance to a core reverb instance.
31    pub fn set_reverb_level(&self, index: c_int, level: c_float) -> Result<()> {
32        unsafe {
33            FMOD_Studio_EventInstance_SetReverbLevel(self.inner.as_ptr(), index, level).to_result()
34        }
35    }
36
37    /// Retrieves the core reverb send level.
38    pub fn get_reverb_level(&self, index: c_int) -> Result<c_float> {
39        let mut level = 0.0;
40        unsafe {
41            FMOD_Studio_EventInstance_GetReverbLevel(self.inner.as_ptr(), index, &raw mut level)
42                .to_result()?;
43        }
44        Ok(level)
45    }
46}