cuemsutils 0.1.0rc2__tar.gz → 0.1.0rc4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cuemsutils-0.1.0rc2 → cuemsutils-0.1.0rc4}/PKG-INFO +8 -1
- {cuemsutils-0.1.0rc2 → cuemsutils-0.1.0rc4}/README.md +5 -0
- cuemsutils-0.1.0rc4/cuemsutils/__init__.py +4 -0
- cuemsutils-0.1.0rc4/cuemsutils/create_script.py +171 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/ActionCue.py +76 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/AudioCue.py +176 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/Cue.py +401 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/CueList.py +165 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/CueOutput.py +50 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/CuemsScript.py +309 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/DmxCue.py +472 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/MediaCue.py +297 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/VideoCue.py +167 -0
- cuemsutils-0.1.0rc4/cuemsutils/cues/__init__.py +15 -0
- cuemsutils-0.1.0rc4/cuemsutils/daemon.py +35 -0
- cuemsutils-0.1.0rc4/cuemsutils/helpers.py +193 -0
- cuemsutils-0.1.0rc4/cuemsutils/log.py +165 -0
- cuemsutils-0.1.0rc4/cuemsutils/timeoutloop.py +19 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/CTimecode.py +162 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/CommunicatorServices.py +219 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/ConfigBase.py +136 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/ConfigManager.py +300 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/CopyMoveVersioned.py +39 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/HubServices.py +526 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/SignalEngine.py +100 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/StringSanitizer.py +43 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/Uuid.py +54 -0
- cuemsutils-0.1.0rc4/cuemsutils/tools/__init__.py +0 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/CMLCuemsConverter.py +183 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/Parsers.py +284 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/Settings.py +221 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/XmlBuilder.py +291 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/XmlReaderWriter.py +113 -0
- cuemsutils-0.1.0rc4/cuemsutils/xml/__init__.py +10 -0
- {cuemsutils-0.1.0rc2 → cuemsutils-0.1.0rc4}/pyproject.toml +14 -2
- {cuemsutils-0.1.0rc2 → cuemsutils-0.1.0rc4}/.gitignore +0 -0
- {cuemsutils-0.1.0rc2 → cuemsutils-0.1.0rc4}/LICENSE +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/network_map.xsd +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/outputs.xsd +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/project_mappings.xsd +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/project_settings.xsd +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/script.xsd +0 -0
- {cuemsutils-0.1.0rc2/src → cuemsutils-0.1.0rc4}/cuemsutils/xml/schemas/settings.xsd +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cuemsutils
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0rc4
|
|
4
4
|
Summary: Reusable classes and methods for CueMS system
|
|
5
5
|
Project-URL: Documentation, https://github.com/stagesoft/cuems-utils#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/stagesoft/cuems-utils/issues
|
|
@@ -12,6 +12,7 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
12
12
|
Classifier: Programming Language :: Python
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
16
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
17
18
|
Requires-Python: >=3.8
|
|
@@ -21,6 +22,7 @@ Requires-Dist: json-fix==1.0.0
|
|
|
21
22
|
Requires-Dist: lxml==5.3.0
|
|
22
23
|
Requires-Dist: peewee==3.17.8
|
|
23
24
|
Requires-Dist: pynng==0.8.1
|
|
25
|
+
Requires-Dist: systemd-python==235
|
|
24
26
|
Requires-Dist: timecode
|
|
25
27
|
Requires-Dist: websockets==14.1
|
|
26
28
|
Requires-Dist: xmlschema==3.4.3
|
|
@@ -51,11 +53,16 @@ pip install cuemsutils
|
|
|
51
53
|
## Release notes
|
|
52
54
|
### v0.1.0
|
|
53
55
|
- First stable version
|
|
56
|
+
- Compatibility for Python 3.13 with tests (`$> hatch test --show`)
|
|
57
|
+
- `localize_cue` method added to define `_local` cue attribute
|
|
58
|
+
- `check_mappings` method is been deprecated in favor of future mapping logic. Returns always `True` with a warning
|
|
59
|
+
- `ConfigManager.get_video_player_id` renamed to `get_video_output_id` for clarity
|
|
54
60
|
- `nng_hub_port` added to settings
|
|
55
61
|
- outputs and mappings checks added to `DmxCue`
|
|
56
62
|
- `AddressIpc` misspelling corrected. `AdressIpc` no longer exists
|
|
57
63
|
- `Nng_request_response` deprecated in favor of `NngRequestResponse` for naming coherence
|
|
58
64
|
- `Nng_bus_hub` deprecated in favor of `NngBusHub` for naming coherence
|
|
65
|
+
- `Logger` properly logs caller module and class name
|
|
59
66
|
|
|
60
67
|
### v0.0.9
|
|
61
68
|
- New `HubServices` for multiple dialers communication
|
|
@@ -21,11 +21,16 @@ pip install cuemsutils
|
|
|
21
21
|
## Release notes
|
|
22
22
|
### v0.1.0
|
|
23
23
|
- First stable version
|
|
24
|
+
- Compatibility for Python 3.13 with tests (`$> hatch test --show`)
|
|
25
|
+
- `localize_cue` method added to define `_local` cue attribute
|
|
26
|
+
- `check_mappings` method is been deprecated in favor of future mapping logic. Returns always `True` with a warning
|
|
27
|
+
- `ConfigManager.get_video_player_id` renamed to `get_video_output_id` for clarity
|
|
24
28
|
- `nng_hub_port` added to settings
|
|
25
29
|
- outputs and mappings checks added to `DmxCue`
|
|
26
30
|
- `AddressIpc` misspelling corrected. `AdressIpc` no longer exists
|
|
27
31
|
- `Nng_request_response` deprecated in favor of `NngRequestResponse` for naming coherence
|
|
28
32
|
- `Nng_bus_hub` deprecated in favor of `NngBusHub` for naming coherence
|
|
33
|
+
- `Logger` properly logs caller module and class name
|
|
29
34
|
|
|
30
35
|
### v0.0.9
|
|
31
36
|
- New `HubServices` for multiple dialers communication
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
from .cues import ActionCue, AudioCue, DmxCue, CuemsScript, CueList, VideoCue
|
|
2
|
+
from .cues.DmxCue import DmxScene, DmxUniverse, DmxChannel
|
|
3
|
+
from .cues.MediaCue import Media, Region
|
|
4
|
+
from .cues.CueOutput import AudioCueOutput, VideoCueOutput, DmxCueOutput
|
|
5
|
+
from .helpers import new_datetime, new_uuid
|
|
6
|
+
from .xml import XmlReaderWriter
|
|
7
|
+
from .log import Logger
|
|
8
|
+
import xmlschema.validators.exceptions as xmlschema_exceptions
|
|
9
|
+
|
|
10
|
+
now = new_datetime()
|
|
11
|
+
def create_script():
|
|
12
|
+
"""Create a minimal script with available cues.
|
|
13
|
+
|
|
14
|
+
This function creates a minimal script with available cues.
|
|
15
|
+
It includes an audio cue, a video cue and an action cue.
|
|
16
|
+
The script is returned as a CuemsScript object.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
CuemsScript: A minimal script with configured cues.
|
|
20
|
+
"""
|
|
21
|
+
target_uuid = '1f301cf8-dd03-4b40-ac17-ef0e5e7988be'
|
|
22
|
+
act = ActionCue({'action_target': target_uuid, 'action_type': 'play', 'ui_properties' : {'warning' : 0}})
|
|
23
|
+
ac = AudioCue({
|
|
24
|
+
'master_vol': 66,
|
|
25
|
+
'Media': Media({
|
|
26
|
+
'file_name': 'file.ext',
|
|
27
|
+
'id': '',
|
|
28
|
+
'duration': '00:00:00.000',
|
|
29
|
+
'regions': [
|
|
30
|
+
Region({
|
|
31
|
+
'id': 0,
|
|
32
|
+
'loop': 1,
|
|
33
|
+
'in_time': None,
|
|
34
|
+
'out_time': None
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
}),
|
|
38
|
+
'ui_properties' : {
|
|
39
|
+
'warning': None
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
vc = VideoCue({
|
|
43
|
+
'Media': Media({
|
|
44
|
+
'file_name': 'file_video.ext',
|
|
45
|
+
'id': '',
|
|
46
|
+
'duration': '00:00:00.000',
|
|
47
|
+
'regions' : [
|
|
48
|
+
Region({
|
|
49
|
+
'id': 0, 'loop': 1, 'in_time': None, 'out_time': None
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
'ui_properties' : {
|
|
54
|
+
'warning': None
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
dc = DmxCue({
|
|
58
|
+
'fadein_time':0.0,
|
|
59
|
+
'fadeout_time':0.0,
|
|
60
|
+
'DmxScene': DmxScene({
|
|
61
|
+
'id': 0,
|
|
62
|
+
'DmxUniverse': DmxUniverse({
|
|
63
|
+
'universe_num': 0,
|
|
64
|
+
'dmx_channels': [
|
|
65
|
+
DmxChannel({
|
|
66
|
+
'channel': 0,
|
|
67
|
+
'value': 0
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
}),
|
|
74
|
+
'time': 0,
|
|
75
|
+
'ui_properties' : {
|
|
76
|
+
'warning': None
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
ac.outputs = [AudioCueOutput({
|
|
80
|
+
"output_name": "0367f391-ebf4-48b2-9f26-000000000001_system:playback_1",
|
|
81
|
+
"output_vol": 80,
|
|
82
|
+
"channels": [
|
|
83
|
+
{
|
|
84
|
+
"channel": {
|
|
85
|
+
"channel_num": 0,
|
|
86
|
+
"channel_vol": 80
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
})]
|
|
91
|
+
|
|
92
|
+
vc.outputs = [VideoCueOutput({
|
|
93
|
+
"output_name": "0367f391-ebf4-48b2-9f26-000000000001_0",
|
|
94
|
+
"output_geometry": {
|
|
95
|
+
"x_scale": 1,
|
|
96
|
+
"y_scale": 1,
|
|
97
|
+
"corners": {
|
|
98
|
+
"top_left": {
|
|
99
|
+
"x": 0,
|
|
100
|
+
"y": 0
|
|
101
|
+
},
|
|
102
|
+
"top_right": {
|
|
103
|
+
"x": 0,
|
|
104
|
+
"y": 0
|
|
105
|
+
},
|
|
106
|
+
"bottom_left": {
|
|
107
|
+
"x": 0,
|
|
108
|
+
"y": 0
|
|
109
|
+
},
|
|
110
|
+
"bottom_right": {
|
|
111
|
+
"x": 0,
|
|
112
|
+
"y": 0
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})]
|
|
117
|
+
|
|
118
|
+
dc.outputs = [DmxCueOutput({
|
|
119
|
+
"output_name": "0367f391-ebf4-48b2-9f26-000000000001"
|
|
120
|
+
})]
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
custom_cue_list = CueList({'contents': [ac]})
|
|
124
|
+
custom_cue_list.append(vc)
|
|
125
|
+
custom_cue_list.append(dc)
|
|
126
|
+
custom_cue_list.append(act)
|
|
127
|
+
|
|
128
|
+
script = CuemsScript({'CueList': custom_cue_list})
|
|
129
|
+
script.name = "Test Script"
|
|
130
|
+
script.description = "This is a test script"
|
|
131
|
+
|
|
132
|
+
# set dates and ids so it can be validated
|
|
133
|
+
script.created = now
|
|
134
|
+
script.modified = now
|
|
135
|
+
script['id'] = new_uuid()
|
|
136
|
+
script['CueList']['id'] = new_uuid()
|
|
137
|
+
script.cuelist['contents'][0]['id'] = new_uuid()
|
|
138
|
+
script.cuelist['contents'][1]['id'] = new_uuid()
|
|
139
|
+
script.cuelist['contents'][2]['id'] = new_uuid()
|
|
140
|
+
script.cuelist['contents'][3]['id'] = new_uuid()
|
|
141
|
+
script['ui_properties'] = {
|
|
142
|
+
'warning': 0,
|
|
143
|
+
}
|
|
144
|
+
Logger.debug(f'Created test script: {script.cuelist}')
|
|
145
|
+
|
|
146
|
+
try:
|
|
147
|
+
validate_template(script)
|
|
148
|
+
except xmlschema_exceptions.XMLSchemaValidationError as e:
|
|
149
|
+
Logger.error("Script validation failed. Please check the template.")
|
|
150
|
+
Logger.error(f"Validation error: {e}")
|
|
151
|
+
finally:
|
|
152
|
+
# remove dates and ids so we send it empty
|
|
153
|
+
script.created = None
|
|
154
|
+
script.modified = None
|
|
155
|
+
script.id = None
|
|
156
|
+
script.cuelist.id = None
|
|
157
|
+
script.cuelist.contents[0]['id'] = None
|
|
158
|
+
script.cuelist.contents[1]['id'] = None
|
|
159
|
+
script.cuelist.contents[2]['id'] = None
|
|
160
|
+
script.cuelist.contents[3]['id'] = None
|
|
161
|
+
|
|
162
|
+
return script
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def validate_template(project_template):
|
|
166
|
+
writer = XmlReaderWriter(schema_name = "script", xmlfile = None)
|
|
167
|
+
result=writer.validate_object(project_template)
|
|
168
|
+
Logger.debug(f'initial template validation result: {result}')
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from .Cue import Cue
|
|
2
|
+
from ..helpers import ensure_items
|
|
3
|
+
|
|
4
|
+
REQ_ITEMS = {
|
|
5
|
+
'action_target': None,
|
|
6
|
+
'action_type': 'play'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class ActionCue(Cue):
|
|
10
|
+
"""A cue that represents an action to be performed on a target object.
|
|
11
|
+
|
|
12
|
+
This cue is used to trigger actions on other objects in the system, such as
|
|
13
|
+
playing, pausing, or stopping media cues.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, init_dict: dict = None):
|
|
17
|
+
"""Initialize an ActionCue.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
init_dict (dict, optional): Dictionary containing initialization values.
|
|
21
|
+
If not provided, default values from REQ_ITEMS will be used.
|
|
22
|
+
"""
|
|
23
|
+
if init_dict:
|
|
24
|
+
init_dict = ensure_items(init_dict, REQ_ITEMS)
|
|
25
|
+
else:
|
|
26
|
+
init_dict = REQ_ITEMS
|
|
27
|
+
super().__init__(init_dict)
|
|
28
|
+
|
|
29
|
+
self._action_target_object = None
|
|
30
|
+
|
|
31
|
+
def get_action_target(self):
|
|
32
|
+
"""Get the target object for the action.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The target object identifier.
|
|
36
|
+
"""
|
|
37
|
+
return super().__getitem__('action_target')
|
|
38
|
+
|
|
39
|
+
def set_action_target(self, action_target: str) -> None:
|
|
40
|
+
"""Set the target object for the action.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
action_target: The target object identifier.
|
|
44
|
+
"""
|
|
45
|
+
super().__setitem__('action_target', action_target)
|
|
46
|
+
|
|
47
|
+
action_target = property(get_action_target, set_action_target)
|
|
48
|
+
|
|
49
|
+
def get_action_type(self) -> str:
|
|
50
|
+
"""Get the type of action to perform.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
str: The action type (e.g., 'play', 'pause', 'stop').
|
|
54
|
+
"""
|
|
55
|
+
return super().__getitem__('action_type')
|
|
56
|
+
|
|
57
|
+
def set_action_type(self, action_type: str) -> None:
|
|
58
|
+
"""Set the type of action to perform.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
action_type (str): The action type (e.g., 'play', 'pause', 'stop').
|
|
62
|
+
"""
|
|
63
|
+
super().__setitem__('action_type', action_type)
|
|
64
|
+
|
|
65
|
+
action_type = property(get_action_type, set_action_type)
|
|
66
|
+
|
|
67
|
+
def items(self):
|
|
68
|
+
"""Get all items in the cue as a dictionary.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
dict_items: A view of the cue's items, with required items sorted first.
|
|
72
|
+
"""
|
|
73
|
+
x = dict(super().items())
|
|
74
|
+
for k in sorted(REQ_ITEMS.keys()):
|
|
75
|
+
x[k] = self[k]
|
|
76
|
+
return x.items()
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
from time import sleep
|
|
2
|
+
from deprecated import deprecated
|
|
3
|
+
|
|
4
|
+
from .MediaCue import MediaCue
|
|
5
|
+
from ..helpers import ensure_items
|
|
6
|
+
from ..log import logged, Logger
|
|
7
|
+
|
|
8
|
+
REQ_ITEMS = {
|
|
9
|
+
'master_vol': 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class AudioCue(MediaCue):
|
|
13
|
+
"""A cue for handling audio playback and control.
|
|
14
|
+
|
|
15
|
+
This class extends MediaCue to provide specific functionality for audio playback,
|
|
16
|
+
including volume control and OSC communication for audio routing.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, init_dict = None):
|
|
20
|
+
"""Initialize an AudioCue.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
init_dict (dict, optional): Dictionary containing initialization values.
|
|
24
|
+
If provided, will be used to set initial properties.
|
|
25
|
+
"""
|
|
26
|
+
if not init_dict:
|
|
27
|
+
init_dict = REQ_ITEMS
|
|
28
|
+
else:
|
|
29
|
+
init_dict = ensure_items(init_dict, REQ_ITEMS)
|
|
30
|
+
super().__init__(init_dict)
|
|
31
|
+
|
|
32
|
+
self._player = None
|
|
33
|
+
self._osc_route = None
|
|
34
|
+
|
|
35
|
+
def get_master_vol(self):
|
|
36
|
+
"""Get the master volume level.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
float: The master volume level.
|
|
40
|
+
"""
|
|
41
|
+
return super().__getitem__('master_vol')
|
|
42
|
+
|
|
43
|
+
def set_master_vol(self, master_vol):
|
|
44
|
+
"""Set the master volume level.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
master_vol (float): The new master volume level.
|
|
48
|
+
"""
|
|
49
|
+
super().__setitem__('master_vol', master_vol)
|
|
50
|
+
|
|
51
|
+
master_vol = property(get_master_vol, set_master_vol)
|
|
52
|
+
|
|
53
|
+
def items(self):
|
|
54
|
+
"""Get all items in the cue as a dictionary.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
dict_items: A view of the cue's items, with required items sorted first.
|
|
58
|
+
"""
|
|
59
|
+
x = dict(super().items())
|
|
60
|
+
for k in sorted(REQ_ITEMS.keys()):
|
|
61
|
+
x[k] = self[k]
|
|
62
|
+
return x.items()
|
|
63
|
+
|
|
64
|
+
def player(self, player):
|
|
65
|
+
"""Set the audio player instance.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
player: The audio player instance to use.
|
|
69
|
+
"""
|
|
70
|
+
self._player = player
|
|
71
|
+
|
|
72
|
+
def osc_route(self, osc_route):
|
|
73
|
+
"""Set the OSC route for audio control.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
osc_route (str): The OSC route to use for audio control.
|
|
77
|
+
"""
|
|
78
|
+
self._osc_route = osc_route
|
|
79
|
+
|
|
80
|
+
@deprecated(
|
|
81
|
+
reason="Use loop_cue from CueHandler instead",
|
|
82
|
+
version="0.0.9rc5"
|
|
83
|
+
)
|
|
84
|
+
@logged
|
|
85
|
+
def audio_media_loop(self, ossia, mtc):
|
|
86
|
+
"""Handle the audio media playback loop.
|
|
87
|
+
|
|
88
|
+
This method manages the playback loop for audio media, including handling
|
|
89
|
+
looping behavior and OSC communication for timing control.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
ossia: The OSC communication interface.
|
|
93
|
+
mtc: The MIDI Time Code interface.
|
|
94
|
+
"""
|
|
95
|
+
try:
|
|
96
|
+
loop_counter = 0
|
|
97
|
+
duration = self.media.regions[0].out_time - self.media.regions[0].in_time
|
|
98
|
+
|
|
99
|
+
while not self.media.regions[0].loop or loop_counter < self.media.regions[0].loop:
|
|
100
|
+
while self._player.is_alive() and (mtc.main_tc.milliseconds < self._end_mtc.milliseconds):
|
|
101
|
+
sleep(0.005)
|
|
102
|
+
|
|
103
|
+
if self._local:
|
|
104
|
+
# Recalculate offset and apply
|
|
105
|
+
self._end_mtc = self._start_mtc + (duration)
|
|
106
|
+
offset_to_go = float(-(self._start_mtc.milliseconds) + self.media.regions[0].in_time.milliseconds)
|
|
107
|
+
try:
|
|
108
|
+
key = f'{self._osc_route}/offset'
|
|
109
|
+
ossia.send_message(key, offset_to_go)
|
|
110
|
+
except KeyError:
|
|
111
|
+
Logger.debug(
|
|
112
|
+
f'Key error 3 in go_callback {key}',
|
|
113
|
+
extra = {"caller": self.__class__.__name__}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
loop_counter += 1
|
|
117
|
+
|
|
118
|
+
if self._local:
|
|
119
|
+
try:
|
|
120
|
+
key = f'{self._osc_route}/mtcfollow'
|
|
121
|
+
ossia.send_message(key, 0)
|
|
122
|
+
except KeyError:
|
|
123
|
+
Logger.debug(
|
|
124
|
+
f'Key error 4 in go_callback {key}',
|
|
125
|
+
extra = {"caller": self.__class__.__name__}
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
except AttributeError:
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
def stop(self):
|
|
132
|
+
"""Stop the audio playback.
|
|
133
|
+
|
|
134
|
+
This method stops the audio player and sets the stop request flag.
|
|
135
|
+
"""
|
|
136
|
+
self._stop_requested = True
|
|
137
|
+
if self._player and self._player.is_alive():
|
|
138
|
+
self._player.kill()
|
|
139
|
+
|
|
140
|
+
def check_mappings(self, settings):
|
|
141
|
+
"""Check if the audio output mappings are valid.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
settings: The settings containing project node mappings.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
bool: True if the mappings are valid, False otherwise.
|
|
148
|
+
"""
|
|
149
|
+
return super().check_mappings()
|
|
150
|
+
|
|
151
|
+
if not settings.project_node_mappings:
|
|
152
|
+
return True
|
|
153
|
+
|
|
154
|
+
found = True
|
|
155
|
+
map_list = ['default']
|
|
156
|
+
|
|
157
|
+
Logger.debug(f'AudioCue check_mappings: {settings.project_node_mappings}')
|
|
158
|
+
if settings.project_node_mappings['audio'][0]['outputs']:
|
|
159
|
+
for elem in settings.project_node_mappings['audio'][0]['outputs']:
|
|
160
|
+
Logger.debug(f'AudioCue elem: {elem}')
|
|
161
|
+
elem = elem['output']
|
|
162
|
+
for map in elem['mappings']:
|
|
163
|
+
Logger.debug(f'AudioCue map: {map}')
|
|
164
|
+
map_list.append(map['mapped_to'])
|
|
165
|
+
|
|
166
|
+
for output in self.outputs:
|
|
167
|
+
if output['output_name'][:36] == settings.node_conf['uuid']:
|
|
168
|
+
self._local = True
|
|
169
|
+
if output['output_name'][37:] not in map_list:
|
|
170
|
+
found = False
|
|
171
|
+
break
|
|
172
|
+
else:
|
|
173
|
+
self._local = False
|
|
174
|
+
found = True
|
|
175
|
+
|
|
176
|
+
return found
|