-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab0dc28
commit 6cb6418
Showing
13 changed files
with
90 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
from .bytematch import ByteMatch, fromNibbles | ||
from .ieventpattern import IEventPattern | ||
from .basicpattern import BasicEventPattern | ||
from .forwardedpattern import ForwardedEventPattern | ||
from .basicpattern import BasicPattern | ||
from .forwardedpattern import ForwardedPattern | ||
from .unionpattern import UnionPattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
common > eventpattern > unionpattern | ||
Contains the definition for the union type event pattern, which allows events | ||
to be detected if they match any of a number of patterns. | ||
Authors: | ||
* Miguel Guthridge [[email protected], HDSQ#2154] | ||
""" | ||
|
||
from common.types import eventData | ||
from .ieventpattern import IEventPattern | ||
|
||
class UnionPattern(IEventPattern): | ||
""" | ||
Represents the union of multiple event patterns. A match with any of those | ||
patterns is considered a match overall. | ||
""" | ||
|
||
def __init__(self, *patterns: IEventPattern) -> None: | ||
""" | ||
Create a UnionPattern | ||
Args: | ||
* `*patterns` (`IEventPattern`): event patterns to match, each as | ||
separate arguments | ||
""" | ||
if len(patterns) < 2: | ||
raise ValueError("Expected at least two event patterns to union") | ||
self._patterns = patterns | ||
|
||
def matchEvent(self, event: 'eventData') -> bool: | ||
return any(p.matchEvent(event) for p in self._patterns) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Miguel Guthridge [[email protected], HDSQ#2154] | ||
""" | ||
|
||
from common.eventpattern import BasicEventPattern, fromNibbles, IEventPattern | ||
from common.eventpattern import BasicPattern, fromNibbles, IEventPattern | ||
from . import ControlSurface, IValueStrategy, Data2Strategy, Data1Strategy | ||
|
||
class AfterTouch(ControlSurface): | ||
|
@@ -39,7 +39,7 @@ class ChannelAfterTouch(AfterTouch): | |
""" | ||
def __init__(self, channel: 'int|ellipsis' = ...) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles(0xD,channel), ..., ...), | ||
BasicPattern(fromNibbles(0xD,channel), ..., ...), | ||
Data1Strategy() | ||
) | ||
|
||
|
@@ -50,6 +50,6 @@ class NoteAfterTouch(AfterTouch): | |
""" | ||
def __init__(self, note: int, channel: 'int|ellipsis' = ...) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles(0xA,channel), note, ...), | ||
BasicPattern(fromNibbles(0xA,channel), note, ...), | ||
Data2Strategy() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Miguel Guthridge [[email protected], HDSQ#2154] | ||
""" | ||
from common.types import eventData | ||
from common.eventpattern import BasicEventPattern, fromNibbles | ||
from common.eventpattern import BasicPattern, fromNibbles | ||
from . import ControlSurface, IValueStrategy | ||
|
||
class NoteValueStrategy(IValueStrategy): | ||
|
@@ -32,7 +32,7 @@ class Note(ControlSurface): | |
""" | ||
def __init__(self, note_num: int, channel:int = 0) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles((8, 9), channel), note_num, ...), | ||
BasicPattern(fromNibbles((8, 9), channel), note_num, ...), | ||
NoteValueStrategy(), | ||
"notes", | ||
(channel, note_num) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Miguel Guthridge [[email protected], HDSQ#2154] | ||
""" | ||
|
||
from common.eventpattern import IEventPattern, BasicEventPattern, fromNibbles | ||
from common.eventpattern import IEventPattern, BasicPattern, fromNibbles | ||
from common.types import eventData | ||
from . import ControlSurface | ||
from . import Data2Strategy, IValueStrategy | ||
|
@@ -34,7 +34,7 @@ class StandardModWheel(ModWheel): | |
""" | ||
def __init__(self) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles(0xB, ...), 0x1, ...), | ||
BasicPattern(fromNibbles(0xB, ...), 0x1, ...), | ||
Data2Strategy(), | ||
"wheels" | ||
) | ||
|
@@ -73,7 +73,7 @@ class StandardPitchWheel(PitchWheel): | |
""" | ||
def __init__(self) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles(0xE, ...), ..., ...), | ||
BasicPattern(fromNibbles(0xE, ...), ..., ...), | ||
PitchValueStrategy() | ||
) | ||
|
||
|
@@ -84,6 +84,6 @@ class Data2PitchWheel(PitchWheel): | |
""" | ||
def __init__(self) -> None: | ||
super().__init__( | ||
BasicEventPattern(fromNibbles(0xE, ...), 0x0, ...), | ||
BasicPattern(fromNibbles(0xE, ...), 0x0, ...), | ||
Data2Strategy() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.