You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
5 years ago
|
class NullCalfbox(str): #iterable
|
||
|
"""A drop-in replacement for calfboxs python module.
|
||
|
Use this for testing and development.
|
||
|
|
||
|
At the start of your program, first file, insert:
|
||
3 years ago
|
import nullbox
|
||
|
or
|
||
|
from SOMETHING import nullbox
|
||
5 years ago
|
|
||
|
All further
|
||
|
from calfbox import cbox
|
||
|
will use the null module.
|
||
|
|
||
|
Even additional
|
||
|
import calfbox
|
||
|
will use the nullbox module.
|
||
|
"""
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
self.client_name = ""
|
||
|
self.pos_ppqn = 0
|
||
|
self.ignore_program_changes = False
|
||
|
self.patch = {i:(0, "nullbox") for i in range(1,17)} #catches status().patch
|
||
|
self.frame_rate = 48000
|
||
|
self.frame = 0
|
||
|
|
||
3 years ago
|
def __getattr__(self, *args, **kwargs):
|
||
5 years ago
|
return __class__()
|
||
|
|
||
|
def __call__(self, *args, **kwargs):
|
||
|
return __class__()
|
||
|
|
||
3 years ago
|
def __getitem__(self, key):
|
||
5 years ago
|
return __class__()
|
||
|
|
||
|
def serialize_event(self, *args, **kwargs):
|
||
|
return b''
|
||
|
|
||
|
def get_patches(self, *args):
|
||
|
"""sf2 compatibility"""
|
||
|
return {
|
||
|
0 : "nullbox",
|
||
|
}
|
||
3 years ago
|
|
||
5 years ago
|
def set_ignore_program_changes(self, state):
|
||
|
self.ignore_program_changes = state
|
||
|
|
||
3 years ago
|
|
||
|
#Operators
|
||
|
|
||
|
def __and__(self, *args):
|
||
|
return 1
|
||
|
|
||
|
__add__ = __sub__ = __mul__ = __floordiv__ = __div__ = __truediv__ = __mod__ = __divmod__ = __pow__ = __lshift__ = __rshift__ = __or__ = __xor__ = __ror__ = __ior__ = __rand__ = __iand__ = __rxor__ = __ixor__ = __invert__ = __and__
|
||
|
|
||
5 years ago
|
|
||
|
import sys
|
||
3 years ago
|
import nullbox
|
||
|
#Hack 'from calfbox import cbox'
|
||
|
sys.modules["calfbox"] = sys.modules["nullbox"]
|
||
5 years ago
|
import calfbox
|
||
|
|
||
|
cbox = NullCalfbox("fake cbox null client")
|
||
3 years ago
|
|
||
|
#Hack direct call 'import cbox'
|
||
|
sys.modules["cbox"] = cbox
|
||
|
import cbox
|