-
Notifications
You must be signed in to change notification settings - Fork 1
/
AudioDisplay.pde
183 lines (152 loc) · 4.53 KB
/
AudioDisplay.pde
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/**
* ---------------------------------------------
* AudioDisplay.pde
* Description: CAVE2 Master Situation Display (MSD)
*
* Class:
* System: Processing 2.2, SUSE 12.1, Windows 7 x64
* Author: Arthur Nishimoto
* Copyright (C) 2012-2014
* Electronic Visualization Laboratory, University of Illinois at Chicago
*
* Version Notes:
* ---------------------------------------------
*/
ArrayList soundList = new ArrayList();
boolean playingStereo = false;
int stereoSounds = 0;
class Sound
{
int bufferNo;
int nodeID;
float amplitude;
float maxDistance, minDistance;
PVector position;
boolean isStereo = false;
float triggerTime;
float maxLifetime = 1.0;
float lifetime = maxLifetime;
Sound( float xPos, float zPos )
{
position = new PVector(xPos, 0, zPos);
triggerTime = programTimer;
}
void draw()
{
pushMatrix();
translate( position.x * CAVE2_Scale, position.z * CAVE2_Scale, 0 );
lifetime -= deltaTime;
noStroke();
fill(255, 255, 255, 255 * lifetime);
ellipse( 0, 0, 20, 20 );
popMatrix();
}
}// class Sound
/* incoming osc message are forwarded to the oscEvent method. */
String lastOSCMessage = "";
void oscEvent(OscMessage theOscMessage) {
/* print the address pattern and the typetag of the received OscMessage */
//print("### received an osc message.");
//print(" addrpattern: "+theOscMessage.addrPattern());
//println(" typetag: "+theOscMessage.typetag());
lastOSCMessage = theOscMessage.toString() + "\n Arguments: ";
for( int i = 0; i < theOscMessage.arguments().length; i++ )
{
lastOSCMessage += "'"+theOscMessage.arguments()[i] + "' ";
}
// newMonoSound nodeID, bufNum, amp, xPos, zPos
// newStereoSound nodeID, bufNum, amp
if( theOscMessage.checkAddrPattern("newMonoSound") ) {
/* check if the typetag is the right one. */
if( theOscMessage.checkTypetag("iifff") ) {
float xPos = theOscMessage.get(3).floatValue();
float zPos = theOscMessage.get(4).floatValue();
Sound s = new Sound( xPos, zPos );
s.nodeID = theOscMessage.get(0).intValue();
s.bufferNo = theOscMessage.get(1).intValue();
s.amplitude = theOscMessage.get(2).floatValue();
soundList.add(s);
return;
}
}
if( theOscMessage.checkAddrPattern("newStereoSound") ) {
/* check if the typetag is the right one. */
if( theOscMessage.checkTypetag("iif") ) {
println("stereoSound");
playingStereo = true;
return;
}
}
if( theOscMessage.checkAddrPattern("bootCluster") ) {
/* check if the typetag is the right one. */
if( theOscMessage.checkTypetag("iii") ) {
onBootCluster( theOscMessage.get(0).intValue(), theOscMessage.get(1).intValue(), theOscMessage.get(2).intValue() );
return;
}
}
if( theOscMessage.checkAddrPattern("fixedMountPoints") ) {
mountPointsFixed = 1;
}
if( theOscMessage.checkAddrPattern("audioReceiver") ) {
/* check if the typetag is the right one. */
if( theOscMessage.checkTypetag("i") ) {
audioReceiverMode = theOscMessage.get(0).intValue();
return;
}
}
if( theOscMessage.checkAddrPattern("soundServerStarted") ) {
soundServerRunning = 1;
stereoEnabled = 0;
surroundEnabled = 0;
audioMuted = 0;
}
if( theOscMessage.checkAddrPattern("soundServerStopped") ) {
soundServerRunning = 0;
stereoEnabled = 0;
surroundEnabled = 0;
audioMuted = 0;
}
if( theOscMessage.checkAddrPattern("audioMuted") ) {
if( theOscMessage.checkTypetag("i") ) {
audioMuted = theOscMessage.get(0).intValue();
return;
}
}
if( theOscMessage.checkAddrPattern("serverVol") ) {
if( theOscMessage.checkTypetag("i") ) {
serverVol = theOscMessage.get(0).intValue();
return;
}
}
if( theOscMessage.checkAddrPattern("audioStereoEnabled") ) {
stereoEnabled = 1;
}
if( theOscMessage.checkAddrPattern("audioSurroundEnabled") ) {
surroundEnabled = 1;
}
if( theOscMessage.checkAddrPattern("oscDebugWindowEnabled") ) {
enablePopUpWindow = true;
messageType = -1;
}
if( theOscMessage.checkAddrPattern("oscDebugWindowDisabled") ) {
enablePopUpWindow = false;
messageType = -1;
}
}
void drawSounds()
{
ArrayList activeSounds = new ArrayList();
for( int i = 0; i < soundList.size(); i++ )
{
Sound s = (Sound)soundList.get(i);
s.draw();
if( s.lifetime > 0 )
activeSounds.add(s);
}
soundList = activeSounds;
}
void drawAudioStatus()
{
background(0);
systemText = "AUDIO SYSTEM";
}