mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-24 11:50:48 +00:00
fix bug in midi example.
now check for full velocity (button pressed) disable updates other than midi, in midi example. add docstring
This commit is contained in:
parent
b5fc37a362
commit
7b42837e32
@ -11,6 +11,11 @@ class Observer:
|
|||||||
self.vm.subject.add(self)
|
self.vm.subject.add(self)
|
||||||
|
|
||||||
def on_update(self, subject):
|
def on_update(self, subject):
|
||||||
|
"""
|
||||||
|
We expect to only receive midi updates.
|
||||||
|
|
||||||
|
We could skip subject check but check anyway, in case an event is added later.
|
||||||
|
"""
|
||||||
if subject == "midi":
|
if subject == "midi":
|
||||||
self.get_info()
|
self.get_info()
|
||||||
self.on_midi_press()
|
self.on_midi_press()
|
||||||
@ -20,9 +25,14 @@ class Observer:
|
|||||||
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
||||||
|
|
||||||
def on_midi_press(self):
|
def on_midi_press(self):
|
||||||
|
"""
|
||||||
|
checks if strip 3 level prefader mode is greater than -40
|
||||||
|
|
||||||
|
checks if midi button 48 velcity is 127 (full velocity for button press).
|
||||||
|
"""
|
||||||
if (
|
if (
|
||||||
max(self.vm.strip[3].levels.postfader) > -40
|
max(self.vm.strip[3].levels.postfader) > -40
|
||||||
and self.vm.midi.get(self.midi_btn) != 0
|
and self.vm.midi.get(self.midi_btn) == 127
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
f"Strip 3 level is greater than -40 and midi button {self.midi_btn} is pressed"
|
f"Strip 3 level is greater than -40 and midi button {self.midi_btn} is pressed"
|
||||||
@ -34,7 +44,9 @@ class Observer:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
# we only care about midi events here.
|
||||||
|
subs = {ev: False for ev in ["pdirty", "mdirty", "ldirty"]}
|
||||||
|
with voicemeeterlib.api(kind_id, subs=subs) as vm:
|
||||||
obs = Observer(vm, midi_btn, macrobutton)
|
obs = Observer(vm, midi_btn, macrobutton)
|
||||||
obs.register()
|
obs.register()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user