Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
university
music_proj
Commits
831c426f
Commit
831c426f
authored
Aug 13, 2019
by
Kamal Nasser
Browse files
changes
parent
17350c52
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
+29
-17
config.py
config.py
+3
-3
server/server.py
server/server.py
+19
-8
utils.py
utils.py
+7
-6
No files found.
config.py
View file @
831c426f
...
...
@@ -11,8 +11,8 @@ abletonMaxConfig = {
}
AXIS_RANGES
=
{
'x'
:
(
-
0.
941
,
0.
972
),
'y'
:
(
-
1.
312
,
0.768
),
'z'
:
(
-
1.356
,
0.
779
),
'x'
:
(
-
0.
889
,
-
0.
565
),
'y'
:
(
-
1.
814
,
1.330
),
'z'
:
(
0.040
,
0.
350
),
'roll'
:
(
-
180
,
180
)
}
server/server.py
View file @
831c426f
...
...
@@ -3,7 +3,7 @@ import optirx_utils
import
eventlet
import
math
from
oscpy.client
import
OSCClient
from
utils
import
clip_value
,
remap_range
,
make_motive_sock
,
read_motive_packet
from
utils
import
clip_value
,
remap_range
,
make_motive_sock
,
read_motive_packet
,
three_dim_dist
from
config
import
motiveConfig
,
abletonMaxConfig
,
AXIS_RANGES
import
json
...
...
@@ -98,8 +98,12 @@ def get_rtscs_params_body(rh):
udp_msg_to_send
=
None
xAxisLength
=
axis_length
(
"x"
)
zAxisMidpoint
=
axis_midpoint
(
"z"
)
+
axis_length
(
"z"
)
/
4
xAxisLength
=
axis_length
(
"x"
)
/
2
zAxisMidpoint
=
axis_midpoint
(
"z"
)
distMax
=
three_dim_dist
(
AXIS_RANGES
[
'x'
][
0
],
AXIS_RANGES
[
'y'
][
0
],
AXIS_RANGES
[
'z'
][
0
],
AXIS_RANGES
[
'x'
][
1
],
AXIS_RANGES
[
'y'
][
1
],
AXIS_RANGES
[
'z'
][
1
]
)
def
get_optirx_data
():
...
...
@@ -117,13 +121,20 @@ def get_optirx_data():
params2
=
get_rtscs_params_body
(
b2
)
if
params1
!=
(
0
,
0
,
0
,
0
)
and
params2
!=
(
0
,
0
,
0
,
0
):
xDistance
=
params1
[
0
]
-
params2
[
0
]
body_dist
=
three_dim_dist
(
params1
[
0
],
params1
[
1
],
params1
[
2
],
params2
[
0
],
params2
[
1
],
params2
[
2
]
)
berlinPos
=
params1
[
2
]
if
params1
[
0
]
>
params2
[
0
]:
body_dist
=
-
body_dist
msg
=
[
json
.
dumps
({
'drumVolume'
:
remap_value_of_axis_range
(
"y"
,
0.0
,
1.0
,
params1
[
1
]),
'groupCVolume'
:
remap_value_of_axis_range
(
"y"
,
0.0
,
1.0
,
params2
[
1
]),
'tempo'
:
int
(
remap_and_clip
(
-
xAxisLength
,
xAxisLength
,
60
,
132
,
xDistance
)),
'berlin'
:
0
if
berlinPos
<
zAxisMidpoint
else
int
(
remap_and_clip
(
zAxisMidpoint
,
AXIS_RANGES
[
'z'
][
1
],
0
,
50
,
params1
[
2
])
)
'drumVolume'
:
remap_value_of_axis_range
(
"y"
,
0.
1
0
,
0.8
,
params1
[
1
]),
'groupCVolume'
:
remap_value_of_axis_range
(
"y"
,
0.
1
0
,
0.8
,
params2
[
1
]),
'tempo'
:
int
(
remap_and_clip
(
-
distMax
,
distMax
,
60
,
132
,
body_dist
)),
'berlin'
:
remap_and_clip
(
zAxisMidpoint
,
AXIS_RANGES
[
'z'
][
1
]
*
2
,
0
,
0.5
,
berlinPos
)
})]
global
udp_msg_to_send
...
...
utils.py
View file @
831c426f
from
config
import
motiveConfig
import
optirx
as
rx
import
math
def
make_motive_sock
():
...
...
@@ -41,9 +42,9 @@ def dicts_have_same_keys(dict1, dict2):
return
(
set
(
dict1
.
keys
())
-
set
(
dict2
.
keys
()))
==
set
([])
def
display_shutdown_prompt
(
shutdown_token
=
'q'
):
shutdown_msg
=
'Enter "{}" to shutdown the system and end the session:'
.
forma
t
(
shutdown_token
)
print
shutdown_msg
while
raw_input
().
lower
()
!=
shutdown_token
:
print
'Invalid input. '
+
shutdown_msg
def
three_dim_dist
(
x1
,
y1
,
z1
,
x2
,
y2
,
z2
):
return
math
.
sqr
t
(
(
x2
-
x1
)
**
2
+
(
y2
-
y1
)
**
2
+
(
z2
-
z1
)
**
2
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment