User Tools

Site Tools


sonifying_gps_data

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sonifying_gps_data [2013/09/29 19:35]
eteboul created
sonifying_gps_data [2013/09/29 19:42] (current)
eteboul
Line 1: Line 1:
-Original file looked like this:  +{{:gps_sonification_doc.pdf|}}
- +
-====== <​when>​2013-06-06T21:​00:​43.481-07:​00</​when>​ +
-<​gx:​coord>​-72.634041 42.323624 0</​gx:​coord>​ +
-<​when>​2013-06-06T21:​01:​33.350-07:​00</​when>​ +
-<​gx:​coord>​-72.634041 42.323624 0</​gx:​coord>​ +
-<​when>​2013-06-07T07:​51:​11.789-07:​00</​when>​ +
-<​gx:​coord>​-72.623965 42.329313 0</​gx:​coord>​ +
-<​when>​2013-06-07T07:​54:​09.306-07:​00</​when>​ +
-<​gx:​coord>​-72.607879 42.338003 39</​gx:​coord>​ +
-<​when>​2013-06-07T07:​59:​07.184-07:​00</​when>​ +
-<​gx:​coord>​-72.553444 42.322957 126</​gx:​coord>​ +
-<​when>​2013-06-07T08:​01:​01.519-07:​00</​when>​ +
-<​gx:​coord>​-72.553444 42.322957 0</​gx:​coord>​ ====== +
- +
-using the following processing sketch:  +
- +
-//Sonifying GPS data project +
-//​http://​digitalmusics.dartmouth.edu/​~hamr/​ +
-//code written mostly by Andy Sarroff based on an idea by Ezra Teboul +
- +
-import java.util.*;​ +
-import java.text.*;​ +
-PrintWriter output; +
-void setup() ​{ +
- +
-  SimpleDateFormat sdf = new SimpleDateFormat("​yyyy-MM-dd'​T'​HH:​mm:​ss.SSS"​);​ +
-  Date d1 = null; +
-  String inFile = "​*********HAMR/​Geo data/​geodata- original.kml";​ +
-  String outFile = "​**********HAMR/​Geo data/​geoDataParsed2.csv";​ +
-  XML xml = loadXML(inFile);​ +
-  XML doc = xml.getChild("​Document"​);​ +
-  XML pm = doc.getChild("​Placemark"​);​ +
-  XML track = pm.getChild("​gx:​Track"​);​ +
-  XML[] when = track.getChildren("​when"​);​ +
-  XML[] coord = track.getChildren("​gx:​coord"​);​ +
- +
-  output = createWriter(outFile);​ +
- +
-  if (when.length != coord.length) ​{ +
-    println("​ERROR! data length mismatch"​);​ +
-  } +
-  //  Table table = new Table(); +
-  //  table.addColumn("​when"​);​ +
-  //  table.addColumn("​coord"​);​ +
-  for (int i = 0; i < when.length;​ i++) { +
-    try { +
-      d1 = sdf.parse(when[i].getContent());​ +
-    }  +
-    catch  (ParseException e) { +
-      e.printStackTrace();​ +
-    } +
- +
-    //TableRow newRow = table.addRow();​ +
-    String[] tmp = split(coord[i].getContent(),​ ' '); +
-    String tmp2 = String.valueOf(d1.getTime());​ +
-    //​println(tmp2);​ +
- +
-    //​newRow.setInt("​when",​ tmp2); +
-    //​newRow.setString("​coord",​ tmp[0]+'​ '​+tmp[1]); ​    +
-    output.println(tmp2+';'​+tmp[0]+'​ '​+tmp[1]);​ +
-  } +
-  //​saveTable(table,​ outFile); +
-  output.flush();​ +
-  output.close();​ +
-  exit(); +
-+
- +
-we can get it to look more like this +
- +
-===== 1370566843481;​-72.634041 42.323624 +
-1370566893350;​-72.634041 42.323624 +
-1370605871789;​-72.623965 42.329313 +
-1370606049306;​-72.607879 42.338003 +
-1370606347184;​-72.553444 42.322957 +
-1370606461519;​-72.553444 42.322957 +
-1370633101246;​-72.524324 42.327243 +
-1370633280743;​-72.519241 42.340368 ===== +
- +
-i.e. time difference from a reference date and coordinates separated by a space +
- +
-then using this second sketch:  +
- +
-//Sonifying GPS data project +
-//​http://​digitalmusics.dartmouth.edu/​~hamr/​ +
-//code written mostly by Andy Sarroff based on an idea by Ezra Teboul +
- +
-BufferedReader reader; +
-String line1; +
-String line2; +
-int BUF = 816; +
-float[][] data; +
-String inFile = "​*******HAMR/​Geo data/​geoDataParsed2.csv";​ +
-String outFile = "​*******HAMR/​Geo data/​geojustDistance.csv";​ +
-PrintWriter output; +
-void setup() { +
-  // Open the file from the createWriter() example +
-  reader = createReader(inFile);​ +
-  output = createWriter(outFile);​ +
-  data = new float[BUF][3];​ +
-  int i = 0; +
-  try { +
-    line1 = reader.readLine();​ +
-  }  +
-  catch (IOException e) { +
-    e.printStackTrace();​ +
-    line1 = null; +
-  } +
-  line2 = "​a";​ +
-  while (true) {  +
-    try { +
-      line2 = reader.readLine();​ +
-    }  +
-    catch (IOException e) { +
-      e.printStackTrace();​ +
-    } +
-    if (line2 == null) { +
-      break; +
-    } +
-    distance(line1,​ line2, i); +
-    i++; +
-    line1 = line2; +
-    line2 = "​a";​ +
-  } +
-  output.flush();​ +
-  output.close();​ +
-  exit(); +
-+
- +
-void distance(String line1, String line2, int i) { +
-  long ts1 = Long.valueOf(split(line1,​ ';'​)[0]);​ +
-  long ts2 = Long.valueOf(split(line2,​ ';'​)[0]);​ +
-  int dif1 = int(ts2-ts1);​ +
-  float coord1a = float(split(split(line1,​ ';'​)[1],​ ' '​)[0]);​ +
-  float coord1b = float(split(split(line1,​ ';'​)[1],​ ' '​)[1]);​ +
-  float coord2a = float(split(split(line2,​ ';'​)[1],​ ' '​)[0]);​ +
-  float coord2b = float(split(split(line2,​ ';'​)[1],​ ' '​)[1]);​ +
-  float dif2 = sqrt(sq(coord1a-coord2a)+sq(coord1b-coord2b));​ +
-  //​data[i][0] = dif1; +
-  //​data[i][1] = dif2; +
-  //​data[i][2] = dif2 / dif1; +
-  float dif3 = dif1 / 1000. /60. /60.; +
-  String out = ""​+i+";"​+dif3+";"​+dif2+";"​+dif2/​dif3;​ +
-  //prints only speed values - uncomment line above and comment line below for complete table:  +
- // String out = dif2/​dif3;​ +
-  output.println(out);​ +
-  if (i == 1) { +
-    //​println((ts2-ts1)/​1000/​60./​60.);​ +
-    //​println(ts2/​1000);​ +
-    //​println(dif1/​1000./​60./​60.);​ +
-    //​println(dif2);​ +
-    //​println(dif2/​(dif1/​1000./​60./​60.));​ +
-  } +
-+
- +
-we can do some more parsing that allows us to do some math to calculate the speed at each step, as is detailed in the resulting file:  +
- +
-==== 0;​0.0138525;​0.0;​0.0 +
-1;​10.827345;​0.01157259;​0.0010688299 +
-2;​0.04931028;​0.018280298;​0.37071982 +
-3;​0.08274388;​0.056476593;​0.68254703 +
-4;​0.03175972;​0.0;​0.0 +
-5;​7.3999248;​0.02943536;​0.003977792 +
-6;​0.049860276;​0.014071954;​0.28222775 +
-7;​0.05006667;​8.0036855E-4;​0.015986055 ==== +
- +
-you can then import the right column (speeds) into max/MSP as a list. The patch looks a bit like this:  +
- +
-{{:​capture_d_e_cran_2013-09-29_a_19.32.05.png?​200|}} +
- +
-I'll work on making a standalone available here soon  +
- +
-... that's pretty much it. Load your wav, load the list, and let it make some really weird noises... Works really interestingly with speech, music, test tones, etc...  +
- +
-Possible improvements:​  +
- +
-get the smartphone from which the datalog was taken to take a picture and add it to every entry. Use Jitter to scroll through the picture along with the bits of chopped audio for ultimate cheesiness and an odd, creepy, really not ok security wise automated way to keep track of yourself/ your friends/ your kids /the people who don't realize their feeds are public.  +
- +
-feel free to email noise dot gr at dartmouth dot com if you have any question. I'd love to hear about any use you have for this code!  +
- +
-et+
sonifying_gps_data.txt · Last modified: 2013/09/29 19:42 by eteboul