-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisualorgan.pde
179 lines (133 loc) · 3.93 KB
/
Visualorgan.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
import themidibus.*; //Import the library //<>//
import controlP5.*;
import spout.*;
MidiBus myBus; // The MidiBus
//ControlFrame cf;
//ControlP5 cp5;
//SPOUT
Spout spout;
String sendername;
String[] controlName;
int[] controlType;
float[] controlValue;
String[] controlText;
String UserText = "";
boolean BGrefresh = true, allKeys = false, PosRandom = false;
int amount = 10, polygonedges = 5;
float size = 150, topSpeed = 5, aceleracion = 1, rdm = 30, border = 1, sat = 150, bri = 150, life = 5;
int channel, pitch, velocity;
float RndX, RdmY;
float ang, angspeed;
int sliderValue = 100;
ArrayList<Particle> particles;
void settings() {
//fullScreen();
size(1200, 600, P3D);
}
void setup() {
colorMode(HSB);
// size(1200, 800);
background(0);
particles = new ArrayList<Particle>();
MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name.
myBus = new MidiBus(this, 0, 3); // Create a new MidiBus with no input device and the default Java Sound Synthesizer as the output device.
angspeed = 2;
//spout = new Spout(this);
iniciarspout();
hint(DISABLE_OPTIMIZED_STROKE);
}
void draw() {
ControlesSpout();
ang+=angspeed;
if (BGrefresh) {
background(0);
}
/*
text("CHANNEL"+channel,10,10);
text("Pitch"+pitch,10,100);
text("velocity"+velocity,10,150);*/
for (int i =particles.size()-1; i>=0; i--) {
Particle p = particles.get(i);
p.run();
if (p.isDead()) {
particles.remove(i);
}
}
spout.sendTexture();
fill(255);
textSize(15);
text("frameRate "+frameRate, 10, 50);
}
void mousePressed() {
}
void noteOn(int _channel, int _pitch, int _velocity) {
// Receive a noteOn
println();
println("Note On:");
println("--------");
//showMidivalues(_channel,_pitch,_velocity);
channel = _channel;
pitch = _pitch;
velocity = _velocity;
Addparticles(amount);
println("pitch", _pitch);
println("pitch-35", _pitch-35);
println("NOTA ", (pitch - 36) % 12);
}
void noteOff(int _channel, int _pitch, int _velocity) {
// Receive a noteOff
/*println();
println("Note Off:");
println("--------");
showMidivalues(_channel,_pitch,_velocity);*/
channel = _channel;
pitch = _pitch;
// velocity = _velocity;
}
void controllerChange(int channel, int number, int value) {
// Receive a controllerChange
println();
println("Controller Change:");
println("--------");
showMidivalues(channel, number, value);
}
void delay(int time) {
int current = millis();
while (millis () < current+time) Thread.yield();
}
void showMidivalues(int _channel, int _pitch, int _velocity) {
println("Channel:"+_channel);
println("Pitch:"+_pitch);
println("Velocity:"+_velocity);
}
void slider(float var) {
//myColor = color(theColor);
println("A slider event");
}
void Addparticles(int cantp) {
float rdmx, rdmy;
float Psize = map(velocity, 1, 127, 3, size) ;
for (int x=0; x<cantp; x++) {
if (allKeys) {
rdmx = sin(map(x, 0, cantp, 0, TWO_PI)+ang) * map((pitch - 36), 0, 60, 0, 200);
rdmy = cos(map(x, 0, cantp, 0, TWO_PI)+ang) * map((pitch - 36), 0, 60, 0, 200);
} else {
rdmx = sin(map(x, 0, cantp, 0, TWO_PI)+ang) * map((pitch - 36) % 12, 0, 12, 0, 200);
rdmy = cos(map(x, 0, cantp, 0, TWO_PI)+ang) * map((pitch - 36) % 12, 0, 12, 0, 200);
}
PVector pos;
if (PosRandom) {
pos = new PVector(random(width), random(height));
} else {
pos = new PVector(width/2 + rdmx, height/2 + rdmy);
}
particles.add(new Particle(pos,
topSpeed,
new PVector(random(-aceleracion, aceleracion), random(-aceleracion, aceleracion)),
rdm, rdm,
0,
Psize, border,
map((pitch - 36) % 12, 0, 12, 0, 255), sat, bri,
polygonedges, life));
}
}