Processing Sound - Windows 7 Support

edited April 2018 in Library Questions

I wrote this really simple sketch on my macbook after installing the processing.sound library. it works exactly as it should ( moving the mouse along the horizontal axis I can control the speed of reproduction of the audio file )

When I tried to run this very same example on my windows 7 pro machine I got no audio and the following error in the console : "cannot free root node 0".

Help please?

    import processing.sound.*;
    SoundFile file;
    
    void setup() {
      size(640, 360);
      background(255);
        
      // Load a soundfile from the data folder of the sketch and play it
      file = new SoundFile(this, "sample_m.mp3");
      file.loop();
      file.rate(1);
    }      
    
    void draw() {
    }
    
    void mouseMoved() {
      float value = (float)mouseX/width * 2;
      println(value);
      file.rate(value);
      
    }

Answers

  • edited March 2018

    here is a royalty free mp3 file that i tested and works on mac:

  • Not sure - I am on macOS - but saw this message once before:

  • yes I have seen it in a couple of places ( I usually google before I ask ) but they were all dead ends, anyone out there willing to give it a shot? Is there a Github page for the library where I can ask?

  • Ok I got it to ( sorta ) work, it was a stupid 3rd party audio driver thing, basically it had the digital out port as the default audio device. I went in and set the speaker as the Default audio device and it worked( sorta ).

    Now I have a new problem: It does not loop on my windows machine, it's a mono mp3 file. it loops just fine on mac.

    When I run the sketch if I quit before it reaches the end of the first playback i get nothing. if i wait for the file to fully play and then quit i get two error messages:

    Error: /node/free: Node 1 not found
    Error: /node/free: Node 2 not found
    

    Which now leads me to believe loop tries to free the memory from the two channels it allocates for the stereo out when it reaches the EOF and reinitialiaze the file.

    I could not find documentation about sound on the javadoc page.

    Could someone please help? is it because i'm trying to play a mono file on a stereo system? Seems like a big problem. I know the sound library is less than robust and the error messages hard to divine but this is just broken....

  • edited April 2018

    Have you tried the minim library? Unfortunately I don't think processing.sound is getting proper support these days. Most of sounds posts seems to be dealing with minim instead.

    Kf

    Keywords: kf_keyword playback speed rate beads library sound kf_keyword_sound kf_keyword_audio

  • minim is great but it's lacking the one thing I need, setting the playback speed for my sound file.

  • @jacopom I ran your sketch on my laptop with Windows 7 Pro (64-bit) using Processing 3.3.6 and a Mac Book Pro with El Capitan using Processing 3.3.7 -- I did cut the sample MP3 down from 10 minutes to 9 seconds.

    On both machines the music stopped after the 9 seconds -- so it did not loop -- and I started to see the error message "ERROR: /node/set: Synth 1 not found" (same error on both machines).

    Sorry, I have no idea why the Sound library will not play the music in a continuous loop.

    BTW: If you haven't found it yet the documentation for the library is here: https://processing.org/reference/libraries/sound/index.html

  • edited April 2018

    Curse my curiosity! :))

    Take a look at the Beads library (part of the Contributed libraries for Processing). It can change the playback rate and a lot more. Here is the equivalent of your original sketch, but using Beads. I've modified the playback rate to go from -2.0 (rewind at double speed) to +2.0 (fast-forward at double speed).

    // Looping Sample using Beads Library
    //
    // Processing forum post:
    //  forum.processing.org/two/discussion/comment/123003/
    //
    // Reference:
    //  - Beads home page: www.beadsproject.net/
    //  - Javadocs: www.beadsproject.net/doc/
    
    import beads.*;
    import org.jaudiolibs.beads.*;
    
    SamplePlayer player;
    AudioContext ac;
    Glide glide;
    
    String sampleName = "dream_center_9secs.wav";
    
    void setup() {
      size(400, 400);
    
      ac = new AudioContext();
      glide = new Glide(ac, 1);
    
      // WARNING: Beads needs the absolute pathname to sample files! (so use dataPath())
      Sample sound = SampleManager.sample(dataPath(sampleName));
      if (sound == null) println("Failed to load sample!");
    
      player = new SamplePlayer(ac, sound);
    
      player.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
      player.setRate(glide);
    
      Gain g = new Gain(ac, 2, 0.2);
      g.addInput(player);
      ac.out.addInput(g);
    
      ac.start();
    }
    
    
    void draw() {
    }
    
    void mouseMoved() {
      // Scale playback rate to be from -2.0 to +2.0
      float value = ((float)mouseX - (width / 2)) / (width / 4);
    
      println(value);
    
      // Set playback rate (it's a multiplier),
      // 0.0 = pause, 1.0 = normal rate, -1.0 = rewind.
      glide.setValue(value);
    }
    
Sign In or Register to comment.