Sound in processing program

edited May 2016 in Library Questions

Hello,
I am trying to generate a sound as part of a processing program.
I have tried the code below but it does not work.
I tried to store my sound file (Surf.wav) in a 'data' folder but still does not work.
I use 'filezilla' to load my sketch, so I have created the data folder below the 'public' folder.
I don't get any error message, just sound does not play.
Thanks for your help.

Vincent

code:

import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup() {
    minim = new Minim(this);
    player = minim.loadFile("data/Surf.wav");
    player.play();

Answers

  • edited May 2016 Answer ✓

    Try loadFile("Surf.wav"); Without the word "data" --- make sure file name is correct!!!

    File name is case sensitive

    Try make all vars global (they are already) and use play in draw()

  • Why is this posted under the p5js category? Sounds like you're trying to run Java Processing online (note for others: filezilla is an FTP client used to move files to a server); in which case you're out of luck... Online Java is dead 8-X

    If you're trying to use the minim library with p5js you're also out of luck. You could instead use the p5js sound library...

  • Did not answer my question at all.

  • minim comes with a lot of examples, see processing, menu file, then examples (in your language), then minim | Basics

    here the file is not in the data folder but just in the sketch folder

    import ddf.minim.*;
    Minim minim = null;
    AudioPlayer groove = null;
    
    void setup() {
      size(512, 200, P3D);
      minim = new Minim(this);
      groove = minim.loadFile("groove.mp3", 2048);
      if (groove==null) {
        println ("failed to load file (mp3) or something else went wrong"); 
        exit();
      } else {
        groove.loop();
      } // else
    }
    
    void draw() {
    
      background(0);
      stroke(255);
    
      if (groove!=null) {
        for (int i = 0; i < groove.bufferSize () - 1; i++) {
          line(i, 50  + groove.left.get(i)*50, i+1, 50  + groove.left.get(i+1)*50);
          line(i, 150 + groove.right.get(i)*50, i+1, 150 + groove.right.get(i+1)*50);
        } // for
      } // if
    }
    //
    
  • edited May 2016

    Thanks for this code Chrisir. Unfortunatly I copied it in a '.pde' file and then 'dragged' it on my internet site but it did not work. I don't understand why it does not work because I do the same thing with a game (written in processing language) and it works perfectly well (without any sound). In fact, my pde programme is integrated inside an html file with the following code:

    <canvas data-processing-sources="Prog1.pde"></canvas>.
    

    Vincent

  • edited May 2016

    I don't know if a library (!) works in a website

    ask gotoloop

Sign In or Register to comment.