From 5f3f01578087c4bd4d556f4e4c9c22c587487c6f Mon Sep 17 00:00:00 2001 From: IzaZed Date: Mon, 6 May 2024 20:56:25 +0200 Subject: [PATCH 1/5] add volume to EventInstance --- pyfmodex/studio/event_instance.py | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pyfmodex/studio/event_instance.py b/pyfmodex/studio/event_instance.py index a3b66e3..dee5124 100644 --- a/pyfmodex/studio/event_instance.py +++ b/pyfmodex/studio/event_instance.py @@ -34,6 +34,28 @@ 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 paused(self): """Tthe pause state. @@ -126,6 +148,17 @@ def _commit_3d(self): )) ) + def set_volume(self, vol): + """Sets the volume level. + + :param vol: float + """ + self.volume = vol + + def get_volume(self): + """Retrieves the volume level.""" + return self.volume + def get_parameter_by_name(self, name): """A parameter value. From 512ac77b165ed55dc15deb9e760fdd273581cd37 Mon Sep 17 00:00:00 2001 From: IzaZed Date: Fri, 19 Jul 2024 13:08:52 +0200 Subject: [PATCH 2/5] add Release --- pyfmodex/studio/event_instance.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyfmodex/studio/event_instance.py b/pyfmodex/studio/event_instance.py index dee5124..3ac96cd 100644 --- a/pyfmodex/studio/event_instance.py +++ b/pyfmodex/studio/event_instance.py @@ -219,6 +219,9 @@ def set_3d_attributes( self._up = VECTOR.from_list(up) self._commit_3d() + def release(self): + self._call('Release') + @property def channel_group(self): """The core channel group corresponding to the master track. From 028d0038de545d93a4b987711e2de3b8203a6470 Mon Sep 17 00:00:00 2001 From: IzaZed Date: Mon, 5 Aug 2024 18:08:37 +0200 Subject: [PATCH 3/5] add simple bindings --- pyfmodex/studio/event_instance.py | 63 ++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/pyfmodex/studio/event_instance.py b/pyfmodex/studio/event_instance.py index 3ac96cd..9473f45 100644 --- a/pyfmodex/studio/event_instance.py +++ b/pyfmodex/studio/event_instance.py @@ -56,9 +56,23 @@ def volume(self): 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. """ @@ -85,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. @@ -159,6 +194,28 @@ def get_volume(self): """Retrieves the volume level.""" return self.volume + def set_pitch(self, vol): + """Sets the pitch level. + + :param vol: float + """ + 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 vol: int + """ + 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. @@ -219,6 +276,10 @@ 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') From 483ea46766c468d70b10d5141e7f3b5031cc67ae Mon Sep 17 00:00:00 2001 From: IzaZed Date: Mon, 5 Aug 2024 18:20:15 +0200 Subject: [PATCH 4/5] add reverb_level --- pyfmodex/studio/event_instance.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pyfmodex/studio/event_instance.py b/pyfmodex/studio/event_instance.py index 9473f45..81886ab 100644 --- a/pyfmodex/studio/event_instance.py +++ b/pyfmodex/studio/event_instance.py @@ -295,11 +295,10 @@ def channel_group(self): self._call("GetChannelGroup", byref(ptr)) return ChannelGroup(ptr) - @property - def reverb_level(self): - """Not Implemented.""" - raise NotImplementedError + def set_reverb_level(self, index, level): + self._call('SetReverbLevel', c_int(index), c_float(level)) - @reverb_level.setter - def reverb_level(self, level): - raise NotImplementedError + def get_reverb_level(self, index): + level = c_float() + self._call('GetReverbLevel', c_int(index), byref(level)) + return level.value From 4bf2802625862f334a3284ab4a7c0901366c2e6b Mon Sep 17 00:00:00 2001 From: IzaZed Date: Mon, 5 Aug 2024 18:37:13 +0200 Subject: [PATCH 5/5] add isVirtual & correct docstrings --- pyfmodex/studio/event_instance.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pyfmodex/studio/event_instance.py b/pyfmodex/studio/event_instance.py index 81886ab..ba49aba 100644 --- a/pyfmodex/studio/event_instance.py +++ b/pyfmodex/studio/event_instance.py @@ -186,7 +186,7 @@ def _commit_3d(self): def set_volume(self, vol): """Sets the volume level. - :param vol: float + :param vol: Volume multiplier. """ self.volume = vol @@ -197,7 +197,7 @@ def get_volume(self): def set_pitch(self, vol): """Sets the pitch level. - :param vol: float + :param vol: Pitch multiplier. """ self.pitch = vol @@ -208,7 +208,7 @@ def get_pitch(self): def set_timeline_position(self, pos: int): """Sets the timeline cursor position. - :param vol: int + :param pos: Timeline position. """ self.timeline_position = pos @@ -296,9 +296,28 @@ def channel_group(self): 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 is_virtual(self): + """Retrieves the virtualization state. + + 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