Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit 1601aaf

Browse files
committed
bela pd examples
1 parent db76221 commit 1601aaf

File tree

4 files changed

+81
-5
lines changed

4 files changed

+81
-5
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,18 @@
99
To run this example, open the Bela OSC example at:
1010
https://github.com/BelaPlatform/Bela/blob/master/examples/Communication/OSC/render.cpp
1111
12-
And replace the ports and IP with the following:
12+
And change the IP address to the following:
1313
```
14-
int localPort = 8888;
15-
int remotePort = 9999;
1614
const char* remoteIp = "192.168.7.1";
1715
```
1816
"""
1917

2018
from iipyper import OSC, run, repeat
2119

22-
def main(host="192.168.7.1", port=9999):
20+
def main(host="192.168.7.1", port=7563):
2321

2422
osc = OSC(host, port)
25-
osc.create_client("bela", host="192.168.7.2", port=8888)
23+
osc.create_client("bela", host="192.168.7.2", port=7562)
2624

2725
connected = False
2826
count = 0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Authors:
3+
Victor Shepardson
4+
Jack Armitage
5+
Intelligent Instruments Lab 2022
6+
"""
7+
8+
"""
9+
Run this example alongside the Bela Pure Data osc-receive example at:
10+
https://github.com/BelaPlatform/Bela/tree/master/examples/PureData/osc-receive
11+
"""
12+
13+
import random
14+
15+
from iipyper import OSC, run, repeat
16+
17+
def main():
18+
19+
osc = OSC()
20+
osc.create_client("bela", host="192.168.7.2", port=7562)
21+
22+
count = 0
23+
countMax = 6
24+
25+
@repeat(0.5)
26+
def _():
27+
nonlocal count
28+
nonlocal countMax
29+
osc("bela", "/slider", random.random())
30+
osc("bela", "/counter", count)
31+
count = count + 1
32+
if count==countMax:
33+
count = 0
34+
35+
if __name__=='__main__':
36+
run(main)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Authors:
3+
Victor Shepardson
4+
Jack Armitage
5+
Intelligent Instruments Lab 2022
6+
"""
7+
8+
"""
9+
Run this example alongside the Bela Pure Data osc-send example at:
10+
https://github.com/BelaPlatform/Bela/tree/master/examples/PureData/osc-send
11+
"""
12+
13+
from iipyper import OSC, run, repeat
14+
15+
def main(host="192.168.7.1", port=7562):
16+
17+
osc = OSC(host, port)
18+
19+
@osc.args("/slider")
20+
def _(address, *args):
21+
"""
22+
Handle OSC messages from Bela
23+
"""
24+
print(f"{address} {args}")
25+
26+
if address=="/slider":
27+
print("slider", args)
28+
29+
elif address=="/counter":
30+
print("slider", args)
31+
32+
else:
33+
print(f"Unrecognised OSC {address} with {args}")
34+
35+
if __name__=='__main__':
36+
run(main)

examples/bela/pd/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# `iipyper` Pure Data examples
2+
3+
Bela comes with a tutorial and example code for communicating with OSC:
4+
https://learn.bela.io/tutorials/pure-data/communication/open-sound-control/
5+
6+
The examples `osc-send` and `osc-receive` in this folder correspond directly to the Bela examples.

0 commit comments

Comments
 (0)