Skip to content

Commit

Permalink
Added soundscape
Browse files Browse the repository at this point in the history
  • Loading branch information
theleadingzero committed May 10, 2012
1 parent b89e987 commit 829af82
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 45 deletions.
Binary file not shown.
Binary file not shown.
Binary file added Processing/gps_terrain/data/SATELLITE_BLEEP.mp3
Binary file not shown.
165 changes: 120 additions & 45 deletions Processing/gps_terrain/gps_terrain.pde
Expand Up @@ -9,6 +9,12 @@
import processing.dxf.*; import processing.dxf.*;
import processing.serial.*; import processing.serial.*;
import peasy.*; import peasy.*;
import ddf.minim.*;

Minim minim;
AudioPlayer bgSound;
AudioPlayer radioStatic;
AudioPlayer beep;


PeasyCam cam; PeasyCam cam;


Expand Down Expand Up @@ -58,6 +64,19 @@ int framesPassed = 0;
//-------------------------------------------------- //--------------------------------------------------
void setup() { void setup() {
size(1440, 900, OPENGL); size(1440, 900, OPENGL);
// set up audio
minim = new Minim(this);
bgSound = minim.loadFile("KOSMO_376_700%_FILM SCORE.mp3");
bgSound.loop();

// if satellites are 0, loop radio static
radioStatic = minim.loadFile("RADIO STATIC_GLITCH START_FOR FILM.mp3");

// volume controlled by fix age
beep = minim.loadFile("SATELLITE_BLEEP.mp3");
beep.setGain(-100.0);
println(beep.getControls());
//beep.loop();


// set up camera // set up camera
cam = new PeasyCam(this, 100); cam = new PeasyCam(this, 100);
Expand Down Expand Up @@ -96,7 +115,7 @@ void setup() {
days = 0; days = 0;
months = 0; months = 0;
years = 0; years = 0;

for ( int i=0; i<3; i++) { for ( int i=0; i<3; i++) {
sats[i] = 0; sats[i] = 0;
hdops[i] = 0; hdops[i] = 0;
Expand All @@ -122,7 +141,7 @@ void draw() {


fill(168, 168, 168); fill(168, 168, 168);
noStroke(); noStroke();

// setup lights // setup lights
updateLights(12, 0); updateLights(12, 0);


Expand All @@ -137,15 +156,17 @@ void draw() {
updateTerrain(); updateTerrain();
terrain.display(); terrain.display();




// HUD // HUD
cam.beginHUD(); cam.beginHUD();

// setup lights // setup lights
updateHUDLights(); updateHUDLights();

// raw data feeds // raw data feeds


// label boxes // label boxes
fill(255); fill(255);
int rh = 20; int rh = 20;
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
Expand Down Expand Up @@ -176,10 +197,10 @@ void draw() {
for (int i=0; i<3; i++) { for (int i=0; i<3; i++) {
text(sats[i], 50, 100 + i*30); text(sats[i], 50, 100 + i*30);
text(hdops[i], 220, 100 + i*30); text(hdops[i], 220, 100 + i*30);

String lt = nfs(lats[i], 2, 5); String lt = nfs(lats[i], 2, 5);
String ln = nfs(longs[i], 1, 5); String ln = nfs(longs[i], 1, 5);

text(lt, 371, 100 + i*30); text(lt, 371, 100 + i*30);
text(ln, 530, 100 + i*30); text(ln, 530, 100 + i*30);
text(altitudes[i], 750, 100 + i*30); text(altitudes[i], 750, 100 + i*30);
Expand All @@ -188,19 +209,22 @@ void draw() {


text("DATE //", 1200, 70); text("DATE //", 1200, 70);
String d = days + "/" + months + "/" + years; String d = days + "/" + months + "/" + years;
text(d, 1290, 70); text(d, 1282, 70);

String h, m, s; String h, m, s;
if( hours < 10) { if ( hours < 10) {
h = "0" + hours + ":"; h = "0" + hours + ":";
} else h = hours + ":"; }
if( mins < 10) { else h = hours + ":";
if ( mins < 10) {
m = "0" + mins + ":"; m = "0" + mins + ":";
} else m = mins + ":"; }
if( secs < 10) { else m = mins + ":";
if ( secs < 10) {
s = "0" + secs; s = "0" + secs;
} else s = secs + " "; }

else s = secs + " ";

String t = h + m + s; String t = h + m + s;
text(t, 1290, 100); text(t, 1290, 100);
text("TIME //", 1200, 100); text("TIME //", 1200, 100);
Expand Down Expand Up @@ -230,19 +254,24 @@ void updateGpsValues() {
longs[i] = longs[i-1]; longs[i] = longs[i-1];
altitudes[i] = altitudes[i-1]; altitudes[i] = altitudes[i-1];
} }

sats[0] = gpsParser.getSatellites(); sats[0] = gpsParser.getSatellites();
if( sats[0] < 1) {
startStatic();
} else {stopStatic();}

hdops[0] = gpsParser.getHDOP(); hdops[0] = gpsParser.getHDOP();
fixes[0] = gpsParser.getFixAge(); fixes[0] = gpsParser.getFixAge();

adjustBeep(fixes[0]);

lats[0] = gpsParser.getLatitude(); lats[0] = gpsParser.getLatitude();
longs[0] = gpsParser.getLongitude(); longs[0] = gpsParser.getLongitude();
altitudes[0] = gpsParser.getAltitude(); altitudes[0] = gpsParser.getAltitude();

hours = (gpsParser.getHour() + 1)%24; hours = (gpsParser.getHour() + 1)%24;
mins = gpsParser.getMinute(); mins = gpsParser.getMinute();
secs = gpsParser.getSeconds(); secs = gpsParser.getSeconds();

days = gpsParser.getDay(); days = gpsParser.getDay();
months = gpsParser.getMonth(); months = gpsParser.getMonth();
years = gpsParser.getYear(); years = gpsParser.getYear();
Expand All @@ -252,83 +281,113 @@ void updateTerrain() {
// jaggedness affected by HDOP // jaggedness affected by HDOP
// 100-150 almost flat terrain 0.01 // 100-150 almost flat terrain 0.01
j = map(hdops[0], 100, 5000, 0.01, 0.9); j = map(hdops[0], 100, 5000, 0.01, 0.9);
if(hdops[0] == 0) if (hdops[0] == 0)
j = 1.0; j = 1.0;
terrain.updateJaggedness(j); terrain.updateJaggedness(j);

// stability affected by satellites // stability affected by satellites
if( sats[0] > 0 ){ if ( sats[0] > 0 ) {
s = 50/sats[0]; s = 50/sats[0];
} }
else { else {
s = 100.0; s = 100.0;
} }
if( s != prev_s ) { if ( s != prev_s ) {
terrain.updateStability(s); terrain.updateStability(s);
} }
prev_s = s; prev_s = s;

// lat and long affect camera view // lat and long affect camera view
/* /*
moveLR = 0.0 - longs[0] - prev_moveLR; moveLR = 0.0 - longs[0] - prev_moveLR;
moveCameraLeft(moveLR*10000); moveCameraLeft(moveLR*10000);
println("------moveLR: " + moveLR*100000.0); println("------moveLR: " + moveLR*100000.0);
prev_moveLR = moveLR; prev_moveLR = moveLR;
moveFB = (51.0 - lats[0] - prev_moveFB)*100000.; moveFB = (51.0 - lats[0] - prev_moveFB)*100000.;
moveCameraForward( moveFB); moveCameraForward( moveFB);
println("------moveFB: " + moveFB); println("------moveFB: " + moveFB);
prev_moveFB = moveFB; prev_moveFB = moveFB;
*/ */
}

//--------------------------------------------------
// function for sounds
//--------------------------------------------------
void adjustBeep(int fixAge) {
// fix age of 0 is gain of -100.0
// fix age of >1000 is gain of 0.0
float g;
g = fixAge/-5 - 100.0; // adjust the volume
if(g > 0.0) {
g = 0.0;
}
println("---fa is: " + fixAge + " beep gain is: " + g);
beep.setGain(g);
}

void startStatic() {
if( !radioStatic.isPlaying())
println("----starting static");
radioStatic.loop();
}

void stopStatic() {
if( radioStatic.isPlaying()){
println("----stoping static");
radioStatic.pause();
radioStatic.rewind();
}
} }


//-------------------------------------------------- //--------------------------------------------------
// function for lighting // function for lighting
//-------------------------------------------------- //--------------------------------------------------
void updateHUDLights() { void updateHUDLights() {
//spotLight(20, 20, 20, 1000.0, 1000.0, 1000.0, 0, 1, 0, PI/2, 2); //spotLight(20, 20, 20, 1000.0, 1000.0, 1000.0, 0, 1, 0, PI/2, 2);
directionalLight(100, 100, 100, 0.5f, 500.19f, 0.5f); directionalLight(100, 100, 100, 0, 1, 1);
} }


void updateLights(int currHour, int currMin) { void updateLights(int currHour, int currMin) {
// June sunrise 5:00 // June sunrise 5:00
// June sunset 9:30 // June sunset 9:30
int ambLevel = 150; int ambLevel;
float spotX; float spotX;
if (currHour<14) { if (currHour<14) {
//ambLevel = 10 + currHour*10; ambLevel = 10 + currHour*10;
spotX = -100 + currHour*100.0; spotX = -100 + currHour*100.0;
} }
else { else {
//ambLevel = 10 + (23-currHour)*10; ambLevel = 10 + (23-currHour)*10;
spotX = -100 + (23-currHour)*100.0; spotX = -100 + (23-currHour)*100.0;
} }


//ambientLight(ambLevel, ambLevel/2, ambLevel); //ambientLight(ambLevel, ambLevel/2, ambLevel);
//spotLight(123, 0, 155, -spotX, 500.0, 1000.0, -1, 1, 0, PI/4, 2); ambientLight(200, 255, 255);
directionalLight(200, 200, 200, 0.5f, -0.1f, 0.5f); spotLight(123, 0, 155, -spotX, 5000.0, 1000.0, -1, 1, 0, PI/2, 2);
//directionalLight(200, 200, 200, 0.5f, -0.1f, 0.5f);
} }


//-------------------------------------------------- //--------------------------------------------------
// functions for moving the camera // functions for moving the camera
//-------------------------------------------------- //--------------------------------------------------
void moveCameraLeft(float amount) { void moveCameraLeft(float amount) {
if(abs(amount) < 10) if (abs(amount) < 10)
longT += amount; longT += amount;
} }
//-------------------------------------------------- //--------------------------------------------------
void moveCameraRight(float amount) { void moveCameraRight(float amount) {
if(abs(amount) < 10) if (abs(amount) < 10)
longT -= amount; longT -= amount;
} }
//-------------------------------------------------- //--------------------------------------------------
void moveCameraForward(float amount) { void moveCameraForward(float amount) {
if(abs(amount) < 10) if (abs(amount) < 10)
latT += amount; latT += amount;
} }
//-------------------------------------------------- //--------------------------------------------------
void moveCameraBackward(float amount) { void moveCameraBackward(float amount) {
if(abs(amount) < 10) if (abs(amount) < 10)
latT -= amount; latT -= amount;
} }


Expand Down Expand Up @@ -391,3 +450,19 @@ void mouseReleased() {
h = h%24; h = h%24;
} }


//--------------------------------------------------
// stop - clean up audio objects
//--------------------------------------------------
void stop()
{
// always close Minim audio classes when you are finished with them
bgSound.close();
radioStatic.close();
beep.close();

// always stop Minim before exiting
minim.stop();
// this closes the sketch
super.stop();
}

0 comments on commit 829af82

Please sign in to comment.