Skip to content

Commit

Permalink
some midi clean up before split into Jovi_MIDI
Browse files Browse the repository at this point in the history
  • Loading branch information
Amorano committed Feb 1, 2025
1 parent 7a880d5 commit b81505a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ Please consider sponsoring me if you enjoy the results of my work, code or docum
* `STREAM READER` node to capture monitor, webcam or url media
* `STREAM WRITER` node to export media to a HTTP/HTTPS server for OBS or other 3rd party streaming software
* `SPOUT` streaming support *WINDOWS ONLY*
* MIDI device read support with `MIDI FILTER` and `MIDI FILTER EZ` nodes to drive other node parameters
* `MIDI READER` Captures MIDI messages from an external MIDI device or controller
* `MIDI MESSAGE` Processes MIDI messages received from an external MIDI controller or device
* `MIDI FILTER` (advanced filter) to select messages from MIDI streams and devices
* `MIDI FILTER EZ` simpler interface to filter single messages from MIDI streams and devices
* Full Text generation support using installed system fonts
* Basic parametric shape (Circle, Square, Polygon) generator
* `COLOR BLIND` check support
Expand Down Expand Up @@ -96,6 +99,16 @@ You can colorize nodes via their `title` or `body`. This can be done to the node

## UPDATES

**2024/02/01** @1.2.63:
* Fixed `MIDI FILTER` to parse all filters for trigger
* Better `MIDI FILTER` ranges:
* * Single numbers: "1, 2" (equals)
* * Closed ranges: "5-10" (between inclusive)
* * Open ranges: "-100" (less than or equal to 100)
* * Open ranges: "50-" (greater than or equal to 50)
* * 1, 5-10, 2
* * * would check == 1, == 2 and 5 <= x <= 10

**2024/01/30** @1.2.62:
* `QUEUE` nodes can do URL loading of images

Expand Down
51 changes: 35 additions & 16 deletions core/device_midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,32 +158,51 @@ def INPUT_TYPES(cls) -> dict:

def __filter(self, data:int, value:str) -> bool:
"""Parse strings with number ranges into number ranges.
Supports:
- Single numbers: "1, 2" (equals)
- Closed ranges: "5-10" (between inclusive)
- Open ranges: "-100" (less than or equal to 100)
- Open ranges: "50-" (greater than or equal to 50)
1, 5-10, 2
Would check == 1, == 2 and 5 <= x <= 10
Would check == 1, == 2 and 5 <= x <= 10
"""
value = value.strip()
if value == "" or len(value) == 0 or value is None:
if not value:
return True

ranges = value.split(',')
for item in ranges:
item = item.strip()
if '-' in item:

if item.startswith('-'):
try:
bound = float(item[1:])
if data <= bound:
return True
except ValueError:
continue
elif item.endswith('-'):
try:
bound = float(item[:-1])
if data >= bound:
return True
except ValueError:
continue
elif '-' in item:
try:
a, b = map(float, item.split('-'))
if a <= data <= b:
return True
except ValueError:
pass
except Exception as e:
logger.error(e)
continue
# Handle single number
else:
try:
if isclose(data, float(item)):
return True
except ValueError:
pass
except Exception as e:
logger.error(e)
continue
return False

def run(self, **kw) -> Tuple[bool]:
Expand All @@ -196,19 +215,19 @@ def run(self, **kw) -> Tuple[bool]:
normal: str = parse_param(kw, Lexicon.NORMALIZE, EnumConvertType.STRING, "")[0]

if note_on != MIDINoteOnFilter.IGNORE:
if note_on == MIDINoteOnFilter.NOTE_ON and message.note_on != True:
if note_on == MIDINoteOnFilter.NOTE_ON and not message.note_on:
return message, False,
if note_on == MIDINoteOnFilter.NOTE_OFF and message.note_on != False:
if note_on == MIDINoteOnFilter.NOTE_OFF and message.note_on:
return message, False,
elif self.__filter(message.channel, chan) == False:
if self.__filter(message.channel, chan) == False:
return message, False,
elif self.__filter(message.control, ctrl) == False:
if self.__filter(message.control, ctrl) == False:
return message, False,
elif self.__filter(message.note, note) == False:
if self.__filter(message.note, note) == False:
return message, False,
elif self.__filter(message.value, value) == False:
if self.__filter(message.value, value) == False:
return message, False,
elif self.__filter(message.normal, normal) == False:
if self.__filter(message.normal, normal) == False:
return message, False,
return message, True,

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "jovimetrix"
description = "Integrates Webcam, MIDI, Spout and GLSL shader support. Animation via tick. Parameter manipulation with wave generator. Math operations with Unary and Binary support. Value conversion for all major types (int, string, list, dict, Image, Mask). Shape mask generation, image stacking and channel ops, batch splitting, merging and randomizing, load images and video from anywhere, dynamic bus routing with a single node, export support for GIPHY, save output anywhere! flatten, crop, transform; check colorblindness, make stereogram or stereoscopic images, or liner interpolate values and more."
version = "1.2.62"
version = "1.2.63"
license = { file = "LICENSE" }
dependencies = [
"aenum",
Expand Down

0 comments on commit b81505a

Please sign in to comment.