We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Change playback speed/sample rate with minim
Page Index Toggle Pages: 1
Change playback speed/sample rate with minim (Read 2285 times)
Change playback speed/sample rate with minim
Jan 13th, 2010, 11:45am
 
Hi there,


i am desperately trying to figure out, how to change the playback speed of a sample with minim.

I would like to use minim as it supports mp3s and works well with metadata.

The function setSampleRate() does not exist (as it does for Gain, Pan, etc...)

So i'm trying to directly control sampling rate like shown in the minim references (http://code.compartmental.net/tools/minim/manual-controller/).

I get the error "Cannot invoke setValue(float) on the primitive type float".

This is my Code:
import ddf.minim.*;

AudioPlayer player;
Minim minim;

void setup()
{
 size(512, 200, P2D);

 minim = new Minim(this);
 
 // load a file, give the AudioPlayer buffers that are 1024 samples long
 // player = minim.loadFile("groove.mp3");
 
 // load a file, give the AudioPlayer buffers that are 2048 samples long
 player = minim.loadFile("groove.mp3", 2048);
 // play the file

 player.play();
}

void draw()
{

  if (player.hasControl(Controller.SAMPLE_RATE) )
 {
   // map the mouse position to the range of the sampling rate
   float val = map(mouseX, 0, width, 0, 48000);
   player.sampleRate().setValue(val);
 }
 else
 {
   text("There is no sampling rate control for this output.", 5, 15);
 }
}
 


void stop()
{
 // always close Minim audio classes when you are done with them
 player.close();
 minim.stop();
 
 super.stop();
}



I'm starting to believe changing playback speed is not possible with minim...

Any help would be very much appreciated!

thx, * jns  

Re: Change playback speed/sample rate with minim
Reply #1 - Jan 15th, 2010, 1:17pm
 
You're doing everything right, and nothing is working.  Sad

When I tried running your code to play my own .mp3, I got the same error.

With this updated draw function:

Quote:
void draw()
{
 
   if (player.hasControl(Controller.SAMPLE_RATE) )
  {
    // map the mouse position to the range of the sampling rate
    float val = map(mouseX, 0, width, 0, 48000);
   // player.sampleRate().setValue(val);
  }
  else
  {
    println("There is no sampling rate control for this output.");
  }
}



I got the error message "There is no sampling rate control for this output." showing up.

I'm going to have to agree with you - it doesn't seem possible.  Cry
Re: Change playback speed/sample rate with minim
Reply #2 - Apr 13th, 2010, 2:09am
 
i checked minims source code and it looks like they didn't implement sample rate control. if i have some time i might look into it, maybe it's easy enough for me to fix...

anyways, changing playback rate of a sample using sonia http://sonia.pitaru.com/ works, but there is no reverse (values below zero don't work). beads http://www.beadsproject.net/ does a great job changing sample rates and even playing samples backwards.

cheers,
jns
Page Index Toggle Pages: 1