Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 122 additions & 7 deletions pyfmodex/studio/event_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,45 @@ def stop(self):
"""Stops playback."""
self._call("Stop")

@property
def volume(self):
"""The volume level.

- 0: silent
- 1: full
- Negative level: inverts the signal
- Value larger than 1: amplifies the signal

Setting volume at a level higher than 1 can lead to
distortion/clipping.

:type: float
"""
vol = c_float()
self._call("GetVolume", byref(vol))
return vol.value

@volume.setter
def volume(self, vol):
self._call("SetVolume", c_float(vol))

@property
def pitch(self):
"""Pitch multiplier.

:type: float
"""
pitch = c_float()
self._call("GetPitch", byref(pitch))
return pitch.value

@pitch.setter
def pitch(self, pitch):
self._call("SetPitch", c_float(pitch))

@property
def paused(self):
"""Tthe pause state.
"""The pause state.

True if the event instance is paused.
"""
Expand All @@ -63,6 +99,27 @@ def playback_state(self):
self._call("GetPlaybackState", byref(state))
return PLAYBACK_STATE(state.value)

@property
def cpu_usage(self):
"""Retrieves the event CPU usage data."""
usage = c_int()
self._call('Release', byref(usage))
return usage.value

@property
def timeline_position(self):
"""Timeline cursor position

:type: int
"""
pos = c_int()
self._call("GetTimelinePosition", byref(pos))
return pos.value

@timeline_position.setter
def timeline_position(self, pos):
self._call("SetTimelinePosition", c_int(pos))

@property
def position(self):
"""Position in 3D space used for panning and attenuation.
Expand Down Expand Up @@ -126,6 +183,39 @@ def _commit_3d(self):
))
)

def set_volume(self, vol):
"""Sets the volume level.

:param vol: Volume multiplier.
"""
self.volume = vol

def get_volume(self):
"""Retrieves the volume level."""
return self.volume

def set_pitch(self, vol):
"""Sets the pitch level.

:param vol: Pitch multiplier.
"""
self.pitch = vol

def get_pitch(self):
"""Retrieves the pitch level."""
return self.pitch

def set_timeline_position(self, pos: int):
"""Sets the timeline cursor position.

:param pos: Timeline position.
"""
self.timeline_position = pos

def get_timeline_position(self):
"""Retrieves the timeline cursor position."""
return self.timeline_position

def get_parameter_by_name(self, name):
"""A parameter value.

Expand Down Expand Up @@ -186,6 +276,13 @@ def set_3d_attributes(
self._up = VECTOR.from_list(up)
self._commit_3d()

def get_cpu_usage(self):
'''Retrieves the event CPU usage data.'''
return self.cpu_usage

def release(self):
self._call('Release')

@property
def channel_group(self):
"""The core channel group corresponding to the master track.
Expand All @@ -198,11 +295,29 @@ def channel_group(self):
self._call("GetChannelGroup", byref(ptr))
return ChannelGroup(ptr)

def set_reverb_level(self, index, level):
"""Sets the core reverb send level.

:param index: Core reverb instance index.
:param level: Reverb send level.
"""
self._call('SetReverbLevel', c_int(index), c_float(level))

def get_reverb_level(self, index):
"""Retrieves the core reverb send level.

:param index: Core reverb instance index.
"""
level = c_float()
self._call('GetReverbLevel', c_int(index), byref(level))
return level.value

@property
def reverb_level(self):
"""Not Implemented."""
raise NotImplementedError
def is_virtual(self):
"""Retrieves the virtualization state.

@reverb_level.setter
def reverb_level(self, level):
raise NotImplementedError
True if the event instance has been virtualized due to the polyphony limit being exceeded.
"""
virtual = c_bool()
self._call('IsVirtual', byref(virtual))
return virtual.value