-
Notifications
You must be signed in to change notification settings - Fork 45
/
OssiaServerExample.qml
94 lines (82 loc) · 2.92 KB
/
OssiaServerExample.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import com.github.jcelerier.CreativeControls 1.0
import Ossia 1.0 as Ossia
/**
* This file presents an example of usage of the controls
* provided by this library, with libossia.
* libossia is a library that provides multiple network and message
* protocols useful for creative coding: MIDI, OSC, OSCQuery, etc.
*
* More information is available on :
* https://github.com/OSSIA/libossia
*
* In the current example, the application we are writing acts as a server:
* nodes are declared through the OSCQuery protocol, and other applications
* can connect to this one. It is also possible to query the state through a
* web browser, by going to http://localhost:5678/
*/
Page {
id: root
header: Text { font.pointSize: 30 ; text: "Server example" }
width: 800
height: 500
// From this point, we enter the /test relative namespace level
// If no 'node' is given, the parent object's objectName will be used.
// If there is no objectName, the name of the parent class will be used.
// Nodes with an absolute address repsect their given address.
Ossia.Node { node: 'test' }
GridLayout
{
Text { Layout.row: 0; Layout.column: 0; width: 50; wrapMode: Text.Wrap;
text: "Graph" }
Rectangle {
Layout.row: 0
Layout.column: 1
width: 400
height: 200
border.width: 2
Graph {
width: parent.width - 2
height: parent.height - 4
y: 2
// A value we add for receiving the new message
property real nextVal
onNextValChanged: pushValue(nextVal)
// This creates a new node '/units/float'
// with the type of nextVal.
Ossia.Property on nextVal {
node: '/units/float'
}
}
}
Text { Layout.row: 1; Layout.column: 0; width: 50; wrapMode: Text.Wrap;
text: "Sliders (controlled by the Joystick in the client)" }
MultiSlider {
Layout.row: 1
Layout.column: 1
count: 2
height: 100
// Reads and writes from /test/values
Ossia.Property on values { }
}
Text { Layout.row: 2; Layout.column: 0; width: 50; wrapMode: Text.Wrap;
text: "Angle slider (changes the text in client)" }
AngleSlider {
Layout.row: 2
Layout.column: 1
// Reads and writes from /test/angle
Ossia.Property on angle {
// The value will be bounded between these:
min: -90
max: 0
bounding: Ossia.Context.Clip
}
}
}
Component.onCompleted: {
Ossia.SingleDevice.openOSCQueryServer(5678,1234)
Ossia.SingleDevice.recreate(root)
}
}