Get a simple audio signal of my computer sound card threw Processing

edited November 2014 in How To...

Hello there, I'm a newscomer in the Processing world. I'm embarrassed, i've got a little question :

I would like to get simply the audio signal of my computer directly transmitted in a Processing Sketch. Example : supposing that i've a video playing (with audio indeed) in VLC or Quicktime. I would like to get (to retrieve) the sound that i hear directly into Processing. How can i achieve that ?

Best E'

Answers

  • edited November 2014

    did you look at the library minim?

    see libraries on the processing main page.

    you can play a mp3, I don't know if it can listen to the other programs though.

    ;-)

  • Hello Chrisir, Yes, thanks for your help and for the tricks ! Best

  • Processing's default audio library is called minim, the best you can do is have a look at the examples that come with it. You can't select which audio device it uses, it always uses the OS default audio device which means you need to change your default audio recording device to the one which is the sum of all sounds played rather than for example the microphone. On my system (windows 7) I right click the speaker icon, click select input devices and change default recording device to Stereo Mix. This device's name can be different for your system, it's also sometimes called along the lines of WhatYouHear.

  • Hi colouredmirrorball, I found a way by installing soundflower on mac OSX which let me route the audio signal flawlessly threw any of the input. So it's Ok now.

    But, got now another problem : I would like to create conditions to display several PGraphics forms with Minim when for example, I use the Midibus library or when i hit some letters on my keyboard. How can i code that ?

    Here's a sample of my sketch :

    void draw()
    {
      pg.beginDraw();
      pg.strokeWeight(1);
      pg.stroke(255);
      pg.background(0);
    
      for(int i = 0; i < in.bufferSize() - 1; i++)
      {    
        // Generated Form 01
        pg.line(i, 100, i, 100 + in.left.get(1)*300);
    
        // Generated Form 02
        pg.point(i, 400  + in.left.get(i)*400);
      }
    
    
      // A third and simple animated form 03 without PGraphics
      pg.rect(x+in.left.get(1) , 200 , in.left.get(1) , 100);
    
       // A fourth and simple animated form 04  without PGraphics
      pg.rect(x, 594 , 100 , 6);
    
      // Call of the move function to animated these simple form 03 and  04 
      move();
    
    
      pg.endDraw();
      image(pg, 0, 0);
      server.sendImage(pg); 
    }
    
    void move() {
      x = x + speed;
      if (x > width) {
        x = 0;
      }
    }
    
    
    void stop()
    {
      in.close();
      minim.stop();
      super.stop();
    }
    

    Let's say for example : when i play a C3 note, i would like to hide the Generated Form 01 and reveal the Generated Form 02, or when i play C4, i would like to play both of them, or when i play A2 i would like to hide Generated Form 01 and 02 and reveal the simple animated Form 03).

    Or, hit key "S", "C", and so on. A way to create various display of the PGraphics.

    Do you know how can I achieve that ? Ideas welcome… Best Crem'

  • Can you, for example, do a println() when you receive a MIDI note? MidiBus has an example that does this. Try to incorporate that in your project and work from there.

Sign In or Register to comment.