Minim: preloading songs for FilePlayer

edited October 2016 in Library Questions

Cobbled together a Minim script, and a bit unsure if reusing minim.loadFileStream() for every song change is the correct move or not as I'm only rotating between 3-4 song files and I'm going to be importing this functionality in to a much more heavy script. Is there a way to preload all 3-4 songs and just switch between them with FilePlayer? Just started using minim ytd and still a bit overwhelmed by the whole UGens concept >_>

Also: the tickRate seems to be reacting strangely.. while switching around the songs, I noticed the range of speed was different for the same song at different times.. even though its supposed to be mapped between 0-3..

EDIT: found out that tickRate UGen dislikes being patched alongside other UGen (such as gain) which was causing the weird output

Thanks in advance for any help you can punt my way :)

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim minim;
TickRate rateControl;
Gain gain;
AudioOutput out;
FilePlayer filePlayer;
String[] fileName = {"again_loop.aif", "groove.mp3", "jingle.mp3"};

void setup(){
  size(640, 200);
  minim = new Minim(this); 
  out = minim.getLineOut();
  rateControl = new TickRate(1.f);
  gain = new Gain(dB);
  rateControl.setInterpolation( true );

void draw(){
  float rate = map(mouseX, 0, width, 0.0f, 3.f);

void keyPressed() {
  if ( key == '0' ) {
    filePlayer = new FilePlayer(minim.loadFileStream(fileName[0]));
  if ( key == '1' ) {
    filePlayer = new FilePlayer(minim.loadFileStream(fileName[1]));
  if ( key == '2' ) {
    filePlayer = new FilePlayer(minim.loadFileStream(fileName[2]));
Sign In or Register to comment.