Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
2171c9b1
Commit
2171c9b1
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
refact(oo): encapsulate channel state handling
#65
parent
3e0db1f3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/aura_engine/core/channels.py
+2
-0
2 additions, 0 deletions
src/aura_engine/core/channels.py
src/aura_engine/core/mixer.py
+13
-19
13 additions, 19 deletions
src/aura_engine/core/mixer.py
src/aura_engine/engine.py
+1
-5
1 addition, 5 deletions
src/aura_engine/engine.py
with
16 additions
and
24 deletions
src/aura_engine/core/channels.py
+
2
−
0
View file @
2171c9b1
...
...
@@ -244,6 +244,7 @@ class GenericChannel:
self
.
logger
.
info
(
SU
.
pink
(
f
"
Fade in channel
{
self
}
"
))
faded
=
self
.
mixer
.
select_channel
(
self
,
True
)
selected
=
self
.
mixer
.
fade_in
(
self
,
volume
)
self
.
mixer
.
set_active_channel
(
self
)
return
faded
and
selected
def
fade_out
(
self
,
instant
=
False
):
...
...
@@ -264,6 +265,7 @@ class GenericChannel:
self
.
logger
.
info
(
SU
.
pink
(
f
"
Fade out channel
{
self
}
"
))
faded
=
self
.
mixer
.
fade_out
(
self
)
selected
=
self
.
mixer
.
select_channel
(
self
,
False
)
self
.
mixer
.
set_active_channel
(
None
)
return
faded
and
selected
def
roll
(
self
,
seconds_to_roll
):
...
...
This diff is collapsed.
Click to expand it.
src/aura_engine/core/mixer.py
+
13
−
19
View file @
2171c9b1
...
...
@@ -96,22 +96,6 @@ class Mixer:
outputs
=
LU
.
json_to_dict
(
outputs
)
return
outputs
def
set_active_channel_name
(
self
,
channel_name
:
ChannelName
):
"""
Set the currently active channel.
TODO active channel state should be handled internally.
"""
self
.
active_channel_name
=
channel_name
def
get_active_channel_name
(
self
)
->
ChannelName
:
"""
Retrieve the currently active channel.
TODO active channel state should be handled internally.
"""
return
self
.
active_channel_name
def
get_channel
(
self
,
channel_name
:
ChannelName
)
->
GenericChannel
:
"""
Retrieve a channel identified by name.
...
...
@@ -122,12 +106,22 @@ class Mixer:
def
get_active_channel
(
self
)
->
GenericChannel
:
"""
Retrieve
a channel identified by name
.
Retrieve
the currently active channel
.
"""
if
self
.
active_channel_name
:
return
self
.
channel
s
.
get
(
self
.
active_channel_name
)
return
self
.
get_
channel
(
self
.
active_channel_name
)
return
None
def
set_active_channel
(
self
,
channel
:
GenericChannel
):
"""
Set the currently active channel.
"""
if
channel
:
self
.
active_channel_name
=
channel
.
name
else
:
self
.
active_channel_name
=
None
self
.
logger
.
info
(
SU
.
pink
(
"
Reset active channel
"
))
def
get_free_channel
(
self
,
channel_type
:
ChannelType
)
->
GenericChannel
:
"""
Return any _free_ channel of the given type.
...
...
@@ -330,7 +324,7 @@ class Mixer:
except
ValueError
:
idx
=
create_channel
(
name
)
status
=
self
.
get_channel_status
(
idx
)
msg
=
f
"
Channel
#
{
idx
}
status:
{
status
}
"
msg
=
f
"
Channel
{
self
.
get_channel
(
name
)
}
status:
{
status
}
"
self
.
logger
.
info
(
SU
.
pink
(
msg
))
@private
...
...
This diff is collapsed.
Click to expand it.
src/aura_engine/engine.py
+
1
−
5
View file @
2171c9b1
...
...
@@ -389,9 +389,6 @@ class Player:
instant
=
not
(
transition
==
Player
.
TransitionType
.
FADE
)
entry
.
channel
.
fade_in
(
entry
.
volume
,
instant
=
instant
)
# Update active channel
self
.
mixer
.
set_active_channel_name
(
entry
.
channel
.
name
)
# Dispatch event
self
.
event_dispatcher
.
on_play
(
entry
)
...
...
@@ -403,8 +400,7 @@ class Player:
transition (Player.TransitionType): The type of transition to use e.g. fade-out
"""
with
suppress
(
CoreConnectionError
):
channel_name
=
self
.
mixer
.
get_active_channel_name
()
channel
=
self
.
mixer
.
get_channel
(
channel_name
)
channel
=
self
.
mixer
.
get_active_channel
()
if
not
channel
:
self
.
logger
.
info
(
SU
.
pink
(
"
Nothing to stop, no active channel
"
))
return
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment