expo-processing

This commit is contained in:
gbrochar 2020-11-22 19:27:22 +01:00
parent 5577300dd0
commit 9ea4c0bc7a
25 changed files with 1234 additions and 0 deletions

12
Bezier.pde Executable file
View File

@ -0,0 +1,12 @@
int []quadraticBezier(int p0_x, int p0_y, int p1_x, int p1_y, int p2_x, int p2_y, float t)
{
int []pf = { int(pow(1 - t, 2) * p0_x + (1 - t) * 2 * t * p1_x + t * t * p2_x),
int(pow(1 - t, 2) * p0_y + (1 - t) * 2 * t * p1_y + t * t * p2_y) };
return (pf);
}
C_point cubicBezier(C_point p0, C_point p1, C_point p2, C_point p3, float t)
{
return(new C_point(pow(1 - t, 3) * p0.x + pow(1 - t, 2) * 3 * t * p1.x + (1 - t) * 3 * t * t * p2.x + t * t * t * p3.x,
pow(1 - t, 3) * p0.y + pow(1 - t, 2) * 3 * t * p1.y + (1 - t) * 3 * t * t * p2.y + t * t * t * p3.y));
}

20
C_point.pde Executable file
View File

@ -0,0 +1,20 @@
class C_point
{
public float x;
public float y;
public float z;
public C_point(float px, float py)
{
x = px;
y = py;
}
public C_point(float px, float py, float pz)
{
x = px;
y = py;
z = pz;
}
}

93
Star.pde Executable file
View File

@ -0,0 +1,93 @@
class Star {
float x;
float y;
float z;
float pz;
int c;
Star()
{
x = random(-width, width);
y = random(-height, height * 2);
z = random(width);
pz = z;
c = int(random(20));
}
void update()
{
z -= tg_starfield_speed;
if (z < 1)
{
z = width;
x = random(-width / 2, width / 2);
y = random(-height / 2, height / 2);
pz = z;
}
}
void render()
{
if (c == 0)
fill(255,210,125);
if (c == 1)
fill(255,163,113);
if (c == 2)
fill(166,168,255);
if (c == 3)
fill(255,250,134);
if (c == 4)
fill(168,123,255);
if (c > 4)
fill(255, 255, 255);
noStroke();
pushMatrix();
translate(width / 2, height / 2, -1000);
float sx = map(x / z, 0, 1, 0, width);
float sy = map(y / z, 0, 1, 0, height);
float r = map(z, 0, width, 16, 0);
float px = map(x / pz, 0, 1, 0, width);
float py = map(y / pz, 0, 1, 0, height);
ellipse(sx, sy, r, r);
if (c == 0)
stroke(255,210,125);
if (c == 1)
stroke(255,163,113);
if (c == 2)
stroke(166,168,255);
if (c == 3)
stroke(255,250,134);
if (c == 4)
stroke(168,123,255);
if (c > 4)
stroke(255, 255, 255);
strokeWeight(1);
beginShape();
vertex(sx, sy - r / 4);
vertex(sx + r * 1.5, sy);
vertex(sx, sy + r / 4);
endShape();
beginShape();
vertex(sx, sy - r / 4);
vertex(sx - r * 1.5, sy);
vertex(sx, sy + r / 4);
endShape();
beginShape();
vertex(sx - r / 4, sy);
vertex(sx, sy + r * 1.5);
vertex(sx + r / 4, sy);
endShape();
beginShape();
vertex(sx - r / 4, sy);
vertex(sx, sy - r * 1.5);
vertex(sx + r / 4, sy);
endShape();
strokeWeight(r / 2);
line(px, py, sx, sy);
popMatrix();
pz = z;
}
}

BIN
accueil.mp3 Executable file

Binary file not shown.

BIN
data/carte.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
data/carte_size.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

124
data/defaultShader.cpp Executable file
View File

@ -0,0 +1,124 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// From Processing 2.1 and up, this line is optional
#define PROCESSING_COLOR_SHADER
// if you are using the filter() function, replace the above with
// #define PROCESSING_TEXTURE_SHADER
// ----------------------
// SHADERTOY UNIFORMS -
// ----------------------
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds) (replaces iGlobalTime which is now obsolete)
uniform float iTimeDelta; // render time (in seconds)
uniform int iFrame; // shader playback frame
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform vec4 iDate; // (year, month, day, time in seconds)
//uniform float iChannelTime[2];
//uniform vec3 iChannelResolution[2];
// Channels can be either 2D maps or Cubemaps.
// Pick the ones you need and uncomment them.
// uniform float iChannelTime[1..4]; // channel playback time (in seconds)
// uniform vec3 iChannelResolution[1..4]; // channel resolution (in pixels)
/*
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;
uniform samplerCube iChannel0;
uniform samplerCube iChannel1;
uniform samplerCube iChannel2;
uniform samplerCube iChannel3;
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform float iChannelTime[4]; // Channel playback time (in seconds)
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord );
void main() {
mainImage(gl_FragColor,gl_FragCoord.xy);
}
// ------------------------------
// SHADERTOY CODE BEGINS HERE -
// ------------------------------
vec2 cinv(in vec2 z)
{
return (vec2(z.x, -z.y) / dot(z, z));
}
vec2 cmul(in vec2 z1, in vec2 z2)
{
return(vec2(z1.x * z2.x - z1.y * z2.y, z1.x * z2.y + z1.y * z2.x));
}
vec2 cdiv(in vec2 z1, in vec2 z2)
{
return (cmul(z1, cinv(z2)));
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float myTime = iTime * 0.03;
vec2 a0 = vec2(sin(16 * myTime) * 1.0 + 5, 0);
vec2 a1 = vec2(sin(17 * myTime) * 2.0, 0);
vec2 a2 = vec2(sin(18 * myTime) * 3.0, 0);
vec2 a3 = vec2(sin(19 * myTime) * 4.0, 0);
vec2 a4 = vec2(sin(1.1 * myTime) * 5.0, 0);
vec2 a5 = vec2(sin(1.2 * myTime) * 6.0, 0);
vec2 a6 = vec2(sin(1.3 * myTime) * 7.0, 0);
vec2 a7 = vec2(sin(1.4 * myTime) * 8.0, 0);
vec2 a8 = vec2(sin(15 * myTime) * 9.0, 0);
vec2 a9 = vec2(sin(16 * myTime) * 10.0, sin(iTime));
vec2 a10 = vec2(sin(17 * myTime) * 11.0,1 + sin(myTime) * 0.2);
vec2 a = vec2(1.0, 1 + sin(0.16 * myTime) * 0.002);
vec2 c = vec2(0.01, sin(iTime) / 10);
// Normalized pixel coordinates (from 0 to 1)
vec2 z = cmul((fragCoord/iResolution.xy - 0.5), vec2(4,0));
vec2 init_z = z;
z.x = abs(z.x);
z.y = abs(z.y);
vec2 old_z = z;
float i_backup;
for (float i = 0.0; i < 16.0; i++)
{
z = z - cmul(a, cdiv(a0 + cmul(z, a1 + cmul(z, a2 + cmul(z, a3 + cmul(z, a4 + cmul(z, a5
+ cmul(z, a6 + cmul(z, a7 + cmul(z, a8 + cmul(z, a9 + cmul(a10, z)))))))))),
a1 + cmul(z, cmul(a2, vec2(2, 0)) + cmul(z, cmul(a3, vec2(3, 0))
+ cmul(z, cmul(a4, vec2(4, 0)) + cmul(z, cmul(a5, vec2(5, 0))
+ cmul(z, cmul(a6, vec2(6, 0)) + cmul(z, cmul(a7, vec2(7, 0))
+ cmul(z, cmul(a8, vec2(8, 0)) + cmul(z, cmul(a9, vec2(9, 0))
+ cmul(cmul(a10, vec2(10, 0)), z))))))))))) + c;
if (old_z.x * old_z.x + old_z.y * old_z.y < z.x * z.x + z.y * z.y + 0.001
&& old_z.x * old_z.x + old_z.y * old_z.y > z.x * z.x + z.y * z.y - 0.001)
{
i_backup = i / 16.0;
break;
}
old_z = z;
}
if (dot(init_z, init_z) > log(10) - log(10 - iTime) && iTime < 10)
fragColor = vec4(0,0,0,1);
else
fragColor = vec4(z.x, z.y, i_backup, 1.0);
}
// ----------------------------
// SHADERTOY CODE ENDS HERE -
// ----------------------------

BIN
data/video_terre.m4v Executable file

Binary file not shown.

BIN
decollage.mp3 Executable file

Binary file not shown.

BIN
decollage_bruitage.mp3 Executable file

Binary file not shown.

BIN
dimension_warp.mp3 Executable file

Binary file not shown.

5
end.pde Executable file
View File

@ -0,0 +1,5 @@
void draw_end()
{
background(0);
image(movie, 0, 0);
}

BIN
hypervitesse_bruitage.mp3 Executable file

Binary file not shown.

200
intro_atelier_2.pde Executable file
View File

@ -0,0 +1,200 @@
// minim is required to generate audio
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
import processing.video.*;
// import XYscope
import xyscope.*;
import themidibus.*;
MidiBus bus;
int master_control = 0;
boolean accueil_loaded = false;
boolean decollage_loaded = false;
boolean dimension_warp_loaded = false;
boolean pause_loaded = false;
boolean radar_loaded = false;
boolean fin_loaded = false;
float myTime;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
int bruitage_count = 0;
boolean intro = true;
Movie movie;
void setup()
{
size(1280, 720, P3D);
bus.list();
bus = new MidiBus(this, 1, 0);
minim = new Minim(this);
player = minim.loadFile("accueil.mp3");
player.loop();
player2 = minim.loadFile("decollage_bruitage.mp3");
setup_terrain_generation();
setup_polyphonic_synth();
setup_monophonic_synth();
setup_newton_fractal();
setup_radar();
movie = new Movie(this, "video_terre.m4v");
}
void movieEvent(Movie m) {
m.read();
}
void draw()
{
background(0);
if (intro)
{
if (master_control == 0)
{
if (!accueil_loaded)
{
player.pause();
player = minim.loadFile("accueil.mp3");
player.loop();
player.setGain(-3);
accueil_loaded = true;
decollage_loaded = false;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = false;
fin_loaded = false;
}
draw_terrain_generation();
}
if (master_control == 1)
{
if (!decollage_loaded)
{
player.pause();
player = minim.loadFile("decollage.mp3");
player.loop();
accueil_loaded = false;
decollage_loaded = true;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = false;
fin_loaded = false;
}
draw_terrain_generation();
}
if (master_control == 2)
{
if (!decollage_loaded)
{
player.pause();
player = minim.loadFile("decollage.mp3");
player.loop();
accueil_loaded = false;
decollage_loaded = true;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = false;
fin_loaded = false;
}
draw_polyphonic_synth();
}
if (master_control == 3)
{
if (!pause_loaded)
{
player.pause();
accueil_loaded = false;
decollage_loaded = false;
dimension_warp_loaded = false;
pause_loaded = true;
radar_loaded = false;
fin_loaded = false;
}
draw_monophonic_synth();
}
if (master_control == 4)
{
if (!dimension_warp_loaded)
{
player.pause();
player = minim.loadFile("dimension_warp.mp3");
player.play();
player.setGain(-9);
accueil_loaded = false;
decollage_loaded = false;
dimension_warp_loaded = true;
pause_loaded = false;
radar_loaded = false;
fin_loaded = false;
myTime = millis() / float(1000);
}
draw_newton_fractal();
}
if (master_control == 5)
{
if (!radar_loaded)
{
player.pause();
player = minim.loadFile("radar_bruitage.mp3");
player.play();
accueil_loaded = false;
decollage_loaded = false;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = true;
fin_loaded = false;
myTime = millis();
}
draw_radar();
}
}
else
{
if (master_control == 0)
{
if (!decollage_loaded)
{
player.pause();
player = minim.loadFile("decollage.mp3");
player.loop();
accueil_loaded = false;
decollage_loaded = true;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = false;
fin_loaded = false;
}
draw_terrain_generation();
}
if (master_control == 1)
{
if (!fin_loaded)
{
player.pause();
player = minim.loadFile("video_terre.mp3");
movie.play();
player.play();
player.setGain(0);
accueil_loaded = false;
decollage_loaded = false;
dimension_warp_loaded = false;
pause_loaded = false;
radar_loaded = false;
fin_loaded = true;
}
draw_end();
}
}
}

44
manage_star.pde Executable file
View File

@ -0,0 +1,44 @@
void tg_setup_star()
{
for (int i = 0; i < tg_stars.length; i++)
tg_stars[i] = new Star();
}
void tg_manage_star()
{
for (int i = 0; i < tg_stars.length; i++)
{
tg_stars[i].update();
tg_stars[i].render();
}
}
void setup_star()
{
for (int i = 0; i < stars.length; i++)
stars[i] = new Star();
}
void manage_star()
{
for (int i = 0; i < stars.length; i++)
{
stars[i].update();
stars[i].render();
}
}
void ms_setup_star()
{
for (int i = 0; i < ms_stars.length; i++)
ms_stars[i] = new Star();
}
void ms_manage_star()
{
for (int i = 0; i < ms_stars.length; i++)
{
ms_stars[i].update();
ms_stars[i].render();
}
}

144
monophonic_synth.pde Executable file
View File

@ -0,0 +1,144 @@
/*
basic_drawing
You can draw by simply adding points directly or converted
cc teddavis.org 2017/18
*/
// import and create instance of XYscope
XYscope ms_xy;
int ms_n_point = 30;
float ms_t;
float ms_x[] = new float[2000];
float ms_y[] = new float[2000];
float ms_rx[] = new float[2000];
float ms_ry[] = new float[2000];
float []ms_channel = new float[128];
float []ms_channel_amp = new float[128];
int []ms_chan_index = new int [121];
int ms_period = 0;
int ms_activated_channels = 0;
int ms_rect_circle = 0;
Star[] ms_stars = new Star[500];
void midi_monophonic_synth(int status, int chan, int value)
{
boolean swapped = false;
if (status == -112)
{
//channel = (12f*(log((pow(2, (chan - 69f)/12))/440f)/log(2)) + 69f);
for (int i = 0; i < 121; i++)
{
if (ms_channel[i] < 1)
{
ms_channel[i] = pow(2, (chan - 69f) / 12) * 440;
ms_channel_amp[i] = map(value, 0, 127, 0, 1);
ms_chan_index[i] = chan;
break;
}
}
ms_activated_channels++;
}
if (status == -128)
{
for (int i = 0; i < 121; i++)
{
if(ms_chan_index[i] == chan && swapped == false)
{
ms_channel[i] = 0;
ms_channel_amp[i] = 0;
ms_chan_index[i] = 0;
swapped = true;
}
if (swapped == true)
{
ms_channel[i] = ms_channel[i + 1];
ms_channel_amp[i] = ms_channel_amp[i + 1];
ms_chan_index[i] = ms_chan_index[i+1];
if (ms_channel[i] < 1)
break;
}
}
ms_activated_channels--;
}
if (chan == 7 && status == -80)
ms_n_point = value * 2;
if (chan == 7 && status == -79)
ms_rect_circle = value;
}
void setup_monophonic_synth() {
for (int i = 0; i < 2000; i++)
{
ms_rx[i] = random(-2000, 1000) / 1000.0;
ms_ry[i] = random(-1000, 1000) / 1000.0;
}
for (int i = 0; i < 128; i++)
{
ms_channel[i] = 0;
ms_channel_amp[i] = 0;
}
background(0);
// initialize XYscope with default sound out
ms_xy = new XYscope(this);
//xy.getMixerInfo();
ms_setup_star();
}
void draw_monophonic_synth() {
strokeWeight(2);
background(0);
ms_xy.clearWaves();
ms_t = millis() / 1000.0;
ms_t = 1;
//loadPixels();
if (ms_activated_channels > 0)
{
ms_xy.freq(ms_channel[ms_period % ms_activated_channels]);
ms_xy.amp(ms_channel_amp[ms_period % ms_activated_channels]);
} else
ms_xy.freq(0);
for (int i = 0; i < ms_n_point; i++)
{
ms_x[i] = (-ms_rx[i] * ms_rx[i] + ms_rx[i] + ms_ry[i]) * (cos(ms_t) * 500) + width/2;
ms_y[i] = (ms_rx[i] * (ms_rx[i] - ms_ry[i]) * ms_ry[i] - ms_rx[i] * ms_ry[i] + ms_ry[i]) * (sin(ms_t) * 500) * (cos(ms_rx[i]) * ms_rx[i]) + ms_ry[i] + height/2;
}
for (int i = 0; i < ms_activated_channels; i++)
{
for (int j = 127; j > 127 - ms_n_point; j--)
{
ms_xy.ellipse(map(ms_chan_index[i], 0, 120, 0, width), height / 2, j, j);
ms_xy.ellipse(map(ms_chan_index[i], 0, 120, 0, width), map(ms_chan_index[i], 0, 120, 0, height), j, j);
if (ms_rect_circle > 84)
{
ms_xy.rect(map(ms_chan_index[i], 0, 120, 0, width), 0, j / 2, j / 2);
ms_xy.ellipse(map(ms_chan_index[i], 0, 120, 0, width), 0.66f * height, j / 2, j / 2);
}
else if (ms_rect_circle > 42)
ms_xy.rect(map(ms_chan_index[i], 0, 120, 0, width), height/ 2, j / 2, j / 2);
else
ms_xy.ellipse(map(ms_chan_index[i], 0, 120, 0, width), height /2, j / 2, j / 2);
}
}
//updatePixels();
// build audio from shapes
ms_xy.buildWaves();
// draw all analytics
ms_xy.drawAll();
ms_period++;
ms_manage_star();
}
void keyPressed() {
if (keyCode == DOWN) { // DELETE
ms_xy.clearWaves();
}
}

BIN
moteur_shutdown_bruitage.mp3 Executable file

Binary file not shown.

64
newton_fractal.pde Executable file
View File

@ -0,0 +1,64 @@
// newton fractal globals
PShader nf_myShader;
float nf_previousTime = 0.0;
boolean nf_mouseDragged = false;
PVector nf_lastMousePosition;
float nf_mouseClickState = 0.0;
void setup_newton_fractal()
{
// Load the shader file from the "data" folder
nf_myShader = loadShader("defaultShader.cpp");
// We assume the dimension of the window will not change over time,
// therefore we can pass its values in the setup() function
nf_myShader.set("iResolution", float(width), float(height), 0.0);
nf_lastMousePosition = new PVector(float(mouseX),float(mouseY));
// needed cuz noFill means no shader
fill(255);
noStroke();
}
void draw_newton_fractal()
{
// shader playback time (in seconds)
float currentTime = millis()/1000.0 - myTime;
nf_myShader.set("iTime", currentTime);
// render time (in seconds)
float timeDelta = currentTime - nf_previousTime;
nf_previousTime = currentTime;
nf_myShader.set("iDeltaTime", timeDelta);
// shader playback frame
nf_myShader.set("iFrame", frameCount);
// mouse pixel coords. xy: current (if MLB down), zw: click
if(mousePressed) {
nf_lastMousePosition.set(float(mouseX),float(mouseY));
nf_mouseClickState = 1.0;
} else {
nf_mouseClickState = 0.0;
}
nf_myShader.set( "iMouse", nf_lastMousePosition.x, nf_lastMousePosition.y, nf_mouseClickState, nf_mouseClickState);
// Set the date
// Note that iDate.y and iDate.z contain month-1 and day-1 respectively,
// while x does contain the year (see: https://www.shadertoy.com/view/ldKGRR)
float timeInSeconds = hour()*3600 + minute()*60 + second();
nf_myShader.set("iDate", year(), month()-1, day()-1, timeInSeconds );
// This uniform is undocumented so I have no idea what the range is
nf_myShader.set("iFrameRate", frameRate);
// Apply the specified shader to any geometry drawn from this point
shader(nf_myShader);
// Draw the output of the shader onto a rectangle that covers the whole viewport.
fill(255);
rect(0, 0, width, height);
resetShader();
}

189
polyphonic_synth.pde Executable file
View File

@ -0,0 +1,189 @@
XYscope []xy = new XYscope[49];
float []channel = new float[49];
float []channel_amp = new float[49];
int []chan_index = new int [49];
int []adsr_t = new int[49];
int []t = new int[49];
float attack;
float decay;
float sustain;
float release;
int activated_channels = 0;
int timbre = 0;
int filling = 0;
Star[] stars = new Star[500];
// noise related
float[] yWave;
float[] xWave;
C c = new C();
C_sharp c_sharp = new C_sharp();
D d = new D();
D_sharp d_sharp = new D_sharp();
E e = new E();
F f = new F();
F_sharp f_sharp = new F_sharp();
G g = new G();
G_sharp g_sharp = new G_sharp();
A a = new A();
A_sharp a_sharp = new A_sharp();
B b = new B();
Draw_notes[] draw_notes_array = new Draw_notes[] {
new Draw_notes() { public void draw_(XYscope xy, int i) { c.draw_C(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { c_sharp.draw_C_sharp(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { d.draw_D(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { d_sharp.draw_D_sharp(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { e.draw_E(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { f.draw_F(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { f_sharp.draw_F_sharp(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { g.draw_G(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { g_sharp.draw_G_sharp(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { a.draw_A(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { a_sharp.draw_A_sharp(xy, i); } },
new Draw_notes() { public void draw_(XYscope xy, int i) { b.draw_B(xy, i); } },
};
int n_point = 30;
float x[] = new float[n_point];
float y[] = new float[n_point];
float rx[] = new float[n_point];
float ry[] = new float[n_point];
void midi_polyphonic_synth(int status, int chan, int value)
{
boolean swapped = false;
if (status == -112)
{
for (int i = 0; i < 49; i++)
{
if (channel[i] < 10)
{
channel[i] = pow(2, (chan - 69f) / 12) * 440;
channel_amp[i] = map(value, 0, 127, 0, 1);
channel_amp[i] = 1;
adsr_t[i] = 0;
t[i] = 0;
chan_index[i] = chan;
break;
}
}
activated_channels++;
}
if (status == -128)
{
for (int i = 0; i < 49; i++)
{
if(chan_index[i] == chan && swapped == false)
{
channel[i] = 0;
channel_amp[i] = 0;
chan_index[i] = 0;
swapped = true;
}
if (swapped == true)
{
channel[i] = channel[i + 1];
channel_amp[i] = channel_amp[i + 1];
chan_index[i] = chan_index[i+1];
adsr_t[i] = adsr_t[i + 1];
t[i] = t[i + 1];
if (channel[i] < 1)
break;
}
} activated_channels--;
}
if (status == -80 && chan == 7)
{
timbre = round(map(value, 1, 128, 0, 4));
}
if (status == -79 && chan == 7)
{
filling = int(value * 1.5f);
}
if (status == -76 && chan == 7)
{
attack = value;
}
if (status == -75 && chan == 7)
{
decay = value;
}
if (status == -74 && chan == 7)
{
sustain = log(map(value, 0 , 127, 1, 2.718));
}
if (status == -73 && chan == 7)
{
release = value;
}
}
void setup_polyphonic_synth() {
for (int i = 0; i < 49; i++)
{
channel[i] = 0;
channel_amp[i] = 0;
chan_index[i] = 0;
adsr_t[i] = 0;
t[i] = 0;
// initialize XYscope with default sound out
xy[i] = new XYscope(this);
xy[i].freq(0);
xy[i].amp(0);
xy[i].ellipseDetail(300);
genNoiseWave(xy[i]);
}
for (int i = 0; i < n_point; i++)
{
rx[i] = random(-200, 100) / 100.0;
ry[i] = random(-100, 100) / 100.0;
}
background(0);
setup_star();
}
void draw_polyphonic_synth() {
background(0);
strokeWeight(2);
for (int i = 0; i < activated_channels; i++)
{
xy[i].clearWaves();
xy[i].freq(channel[i]);
if(adsr_t[i] < attack)
{
xy[i].amp(adsr_t[i] / attack);
adsr_t[i]++;
}
else
{
channel_amp[i] = 1f - min((float(adsr_t[i]) - attack) / decay, 1) * (1f - sustain);
xy[i].amp(channel_amp[i]);
if (min((float(adsr_t[i]) - attack) / decay, 1) < 1)
adsr_t[i]++;
}
t[i]++;
draw_notes_array[chan_index[i] % 12].draw_(xy[i], i);
xy[i].buildWaves();
xy[i].drawAll();
}
for (int i = activated_channels; i < 49; i++)
{
adsr_t[i] = 0;
xy[i].clearWaves();
xy[i].amp(0);
xy[i].freq(0);
}
manage_star();
}

150
ps_draw_notes.pde Executable file
View File

@ -0,0 +1,150 @@
void genNoiseWave(XYscope xy) {
// set new noiseSeed
noiseSeed(frameCount);
// get bufferSize() of output
// initialize array for storing values
yWave = new float[xy.waveSize()];
xWave = new float[xy.waveSize()];
float nx = random(1);
float ny = random(1);
// add noise walker to waveform
for (int i=0; i<yWave.length; i++) {
xWave[i] = noise(nx)*1;
yWave[i] = noise(ny)*1;
nx+=.01;
ny+=.01;
}
}
void draw_shape(XYscope xy, int note, int i)
{
if (timbre == 0)
{
xy.ellipse(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2, height/5, height/5);
for (int j = height / 5; j > filling; j--)
{
xy.ellipse(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2, j, j);
}
}
if (timbre == 1)
{
C_point p0 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2);
C_point p1 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + cos(t[i] / 1f) + 150 + noise(t[i] / 100f) * 100f, + sin(t[i] / 1f) + height / 2 + noise(t[i] / 10f) * 100f );
C_point p2 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15) - cos(t[i] / 1f) + 150 * 2, - sin(t[i] / 10f) + 200 + height / 2 + noise(t[i] / 1f) * 100f);
C_point p3 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2);
C_point p4 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2);
C_point p5 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15) - cos(t[i] / 1f) - 150 - noise(t[i] / 100f) * 100f, - sin(t[i] / 1f) + height / 2 - noise(t[i] / 10f) * 100f );
C_point p6 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + cos(t[i] / 1f) - 150 * 2, + sin(t[i] / 10f) - 200 + height / 2 - noise(t[i] / 1f) * 100f);
C_point p7 = new C_point(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2);
xy.beginShape();
for (float tt = 0; tt < 1; tt+= 0.01)
{
C_point pFinal = cubicBezier(p0, p1, p2, p3, tt);
C_point pFinal2 = cubicBezier(p4, p5, p6, p7, tt);
xy.vertex(pFinal.x, pFinal.y);
}
xy.endShape();
xy.beginShape();
for (float tt = 0; tt < 1; tt+= 0.01)
{
C_point pFinal = cubicBezier(p4, p5, p6, p7, tt);
xy.vertex(pFinal.x, pFinal.y);
}
xy.endShape();
for (int j = -3; j < 4; j++)
{
xy.line(map(note, 0, 11, 2 * width / 15, 13 * width / 15)- 200 +j, height / 2 + 200+j, map(note, 0, 11, 2 * width / 15, 13 * width / 15) + 50+j, height / 2 - 50+j);
}
}
if (timbre == 2)
{
xy.beginShape();
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2 - height / 4);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2 + height / 4);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + height / 2, height / 2 - height / 4);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15), height / 2 - height / 4);
xy.endShape();;
}
if (timbre == 3)
{
xy.ellipse(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4, height/10, height/10);
xy.beginShape();
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + height/10);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + 2 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i] + height / 6, height / 4 + height / 2);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + 2 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i] - height / 6, height / 4 + height / 2);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + 2 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + 1 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i] + height / 6, height / 4 + 1 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i], height / 4 + 1 * height / 6);
xy.vertex(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + t[i] - height / 6, height / 4 + 1 * height / 6);
xy.endShape();
}
if (timbre == 4)
{
xy.rect(map(note, 0, 11, 2 * width / 15, 13 * width / 15) - height / 10, height / 2 - height / 10, height/5, height/5);
for (int j = height / 5; j > filling; j--)
{
xy.rect(map(note, 0, 11, 2 * width / 15, 13 * width / 15) + filling - j, height / 2 + filling - j, j, j);
}
}
}
public interface Draw_notes {
void draw_(XYscope xy, int i);
}
class C {
void draw_C(XYscope xy, int i) { draw_shape(xy, 0, i); }
}
class C_sharp {
void draw_C_sharp(XYscope xy, int i) { draw_shape(xy, 1, i); }
}
class D {
void draw_D(XYscope xy, int i) { draw_shape(xy, 2, i); }
}
class D_sharp {
void draw_D_sharp(XYscope xy, int i) { draw_shape(xy, 3, i); }
}
class E {
void draw_E(XYscope xy, int i) { draw_shape(xy, 4, i); }
}
class F {
void draw_F(XYscope xy, int i) { draw_shape(xy, 5, i); }
}
class F_sharp {
void draw_F_sharp(XYscope xy, int i) { draw_shape(xy, 6, i); }
}
class G {
void draw_G(XYscope xy, int i) { draw_shape(xy, 7, i); }
}
class G_sharp {
void draw_G_sharp(XYscope xy, int i) { draw_shape(xy, 8, i); }
}
class A {
void draw_A(XYscope xy, int i) { draw_shape(xy, 9, i); }
}
class A_sharp {
void draw_A_sharp(XYscope xy, int i) { draw_shape(xy, 10, i); }
}
class B {
void draw_B(XYscope xy, int i) { draw_shape(xy, 11, i); }
}

49
radar.pde Executable file
View File

@ -0,0 +1,49 @@
PImage carte;
void setup_radar()
{
carte = loadImage("carte_size.png");
}
void draw_radar()
{
int deltaTime = millis() - int(myTime);
if (deltaTime < 24000)
{
strokeWeight(1);
noFill();
pushMatrix();
translate(width / 2, height / 2);
float angle = (deltaTime % 62831) / 1000.0;
for (int i = 0; i < 600; i++)
{
stroke(0, 255 * (600 - i) / 600.0, 0);
line(0, 0, cos(angle - i / 1000.0) * 300.0, sin(angle - i / 1000.0) * 300.0);
}
stroke(0, 255, 0);
line(0, 0, cos(0) * 300.0, sin(0) * 300.0);
line(0, 0, cos(PI / 6) * 300.0, sin(PI / 6) * 300.0);
line(0, 0, cos(PI / 3) * 300.0, sin(PI / 3) * 300.0);
line(0, 0, cos(PI / 2) * 300.0, sin(PI / 2) * 300.0);
line(0, 0, cos(2 * PI / 3) * 300.0, sin(2 * PI / 3) * 300.0);
line(0, 0, cos(5 * PI / 6) * 300.0, sin(5 * PI / 6) * 300.0);
line(0, 0, cos(PI + 0) * 300.0, sin(PI + 0) * 300.0);
line(0, 0, cos(PI + PI / 6) * 300.0, sin(PI + PI / 6) * 300.0);
line(0, 0, cos(PI + PI / 3) * 300.0, sin(PI + PI / 3) * 300.0);
line(0, 0, cos(PI + PI / 2) * 300.0, sin(PI + PI / 2) * 300.0);
line(0, 0, cos(PI + 2 * PI / 3) * 300.0, sin(PI + 2 * PI / 3) * 300.0);
line(0, 0, cos(PI + 5 * PI / 6) * 300.0, sin(PI + 5 * PI / 6) * 300.0);
circle(0, 0, 600);
circle(0, 0, 500);
circle(0, 0, 400);
circle(0, 0, 300);
circle(0, 0, 200);
circle(0, 0, 100);
popMatrix();
}
else
{
background(255);
image(carte, 130, 0);
}
}

BIN
radar_bruitage.mp3 Executable file

Binary file not shown.

59
rawMidi.pde Executable file
View File

@ -0,0 +1,59 @@
// You can also use rawMidi(byte[] data, String bus_name)
void rawMidi(byte[] data)
{
int status, chan, value;
println(data.length + " ");
if (data.length == 3)
{
status = data[0];
chan = data[1];
value = data[2];
if (status == -80 && chan == 64)
master_control = 0;
if (status == -79 && chan == 64)
master_control = 1;
if (status == -78 && chan == 64)
master_control = 2;
if (status == -77 && chan == 64)
master_control = 3;
if (status == -76 && chan == 64)
master_control = 4;
if (status == -75 && chan == 64)
master_control = 5;
if (status == -74 && chan == 64)
intro = !intro;
if (status == -73 && chan == 64)
{
player2.play();
bruitage_count++;
if (bruitage_count % 3 == 0)
{
player2 = minim.loadFile("decollage_bruitage.mp3");
player2.setGain(0);
}
if (bruitage_count % 3 == 1)
{
player2 = minim.loadFile("hypervitesse_bruitage.mp3");
player2.setGain(-6);
}
if (bruitage_count % 3 == 2)
{
player2 = minim.loadFile("moteur_shutdown_bruitage.mp3");
player2.setGain(0);
}
}
//if (master_control == 0 || master_control == 1)
midi_terrain_generation(status, chan, value);
//if (master_control == 2)
midi_polyphonic_synth(status, chan, value);
//if (master_control == 3)
midi_monophonic_synth(status, chan, value);
//if (master_control == 3)
// midi_newton_fractal(status, chan, value);
println("status " + status + " chan " + chan + " value " + value);
}
}

81
terrain_generation.pde Executable file
View File

@ -0,0 +1,81 @@
// terrain generation globals
int tg_cols, tg_rows;
int tg_scale = 40;
float tg_t = 0;
float[][] tg_grid;
float tg_speed;
float tg_height;
Star[] tg_stars = new Star[500];
int tg_starfield_speed = 1;
void midi_terrain_generation(int status, int chan, int value)
{
if (status == -80 && chan == 7)
tg_speed = float(value) / float(10);
if (status == -79 && chan == 7)
tg_height = (log(128) - log(128 - value)) * float(1000);
if (status == -78 && chan == 7)
tg_starfield_speed = 1 + value;
}
void setup_terrain_generation()
{
tg_cols = width / tg_scale;
tg_rows = height / tg_scale;
tg_grid = new float[tg_cols + 200][tg_rows + 100];
for (int y = -100; y < tg_rows; y++)
for (int x = -100; x < tg_cols + 100; x++)
{
if (x < width/2 - 100 || x > width / 2 + 100)
tg_grid[x + 100][y + 100] = noise(float(x) / 5, float(y) / 5) * 1000;
else
tg_grid[x + 100][y + 100] = 0;
}
tg_setup_star();
}
void draw_terrain_generation()
{
background(0);
stroke(255, 0, 128);
fill(255, 0, 128);
noFill();
pushMatrix();
translate(0, height /2 + tg_height);
if (tg_height < 4000)
{
pushMatrix();
rotateX(PI / 3);
for (int y = -100; y < tg_rows - 1; y++)
{
beginShape(TRIANGLE_STRIP);
for (int x = -100; x < tg_cols + 100; x++)
{
strokeWeight(1);
if ((x < tg_cols/2 - 4 || x > tg_cols / 2 + 4))
{
stroke(100 * 255 / tg_grid[x + 100][y + 100], 0, 100 * 128 / tg_grid[x + 100][y + 100] + abs(tg_t % 512 - 255));
vertex(x * tg_scale, y * tg_scale, tg_grid[x + 100][y + 100]);
stroke(100 * 255 / tg_grid[x + 100][y + 100], 0, 100 * 128 / tg_grid[x + 100][y + 1 + 100] + abs(tg_t % 512 - 255));
vertex(x * tg_scale,(y + 1) * tg_scale, tg_grid[x + 100][y + 1 + 100]);
}
else
{
stroke(0, 100 * 255 / tg_grid[x + 100][y + 100], 100 * 128 / tg_grid[x + 100][y + 100] + abs(tg_t % 512 - 255));
vertex(x * tg_scale, y * tg_scale, 0);
stroke(0, 100 * 255 / tg_grid[x + 100][y + 100], 100 * 128 / tg_grid[x + 100][y + 1 + 100] + abs(tg_t % 512 - 255));
vertex(x * tg_scale,(y + 1) * tg_scale, 0);
}
tg_grid[x + 100][y + 100] = noise((float(x)) / 5, (y + tg_t) / 5) * 300;
}
endShape();
}
popMatrix();
}
translate(0, -height * 7.5);
tg_manage_star();
popMatrix();
tg_t -= tg_speed;
}

BIN
video_terre.mp3 Executable file

Binary file not shown.