Why won't minim work in this code?

edited April 2014 in Library Questions

Hi,

I'm using processing to retrieve earthquake data from USGS.

I've got the magnitude and the place printing in Processing. When the magnitude is a certain value, I want a sound to play. I've tried basic my if statement off the PlayAFile example in the Minim library but it doesn't seem to work. However when i tried triggering a sample it did work. I need the sound file to play sound for about 20secs at least when the magnitude is a certain value. Can anyone see below why the playafile won't work in this sketch? Or is there a way to make trigger a sample last longer? Also, is there anyway to make processing constantly check if new mag and place appear in the json as I want to work with live data. I'm also getting an error which you can see below the code when I go to play a sound. Thanks in advance for any help!

JSONObject earthJSON;
JSONArray earth;

import ddf.minim.*;

Minim minim;
AudioPlayer sound;

void setup() {
  earthJSON = loadJSONObject("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson");

  earth = earthJSON.getJSONArray("features");
  //println(earth.size());

  for (int i = 0; i < earth.size(); i++) {
    int mag = earth.getJSONObject(i).getJSONObject("properties").getInt("mag");
    String place = earth.getJSONObject(i).getJSONObject("properties").getString("place");

    println("_________________________");
    println("mag: " + mag);   
    println("place: " + place);

  minim = new Minim(this);
  sound = minim.loadFile( "sound.mp3");



if (mag == 0){

  sound.play();

}

  }

}


==== JavaSound Minim Error ====
==== Don't know the ID3 code TXXX

==== JavaSound Minim Error ====
==== Don't know the ID3 code TDEN

==== JavaSound Minim Error ====
==== Don't know the ID3 code TSSE

java.lang.NullPointerException
    at processing.mode.java.runner.Runner.findException(Runner.java:947)
    at processing.mode.java.runner.Runner.reportException(Runner.java:892)
    at processing.mode.java.runner.Runner.exceptionEvent(Runner.java:818)
    at processing.mode.java.runner.Runner$2.run(Runner.java:707)
Sign In or Register to comment.