© 2010 Dr. M Grierson / Strangeloop

12. Sample player

#include "maximilian.h"

sample beats; //We give our sample a name. It's called beats this time.
//We could have loads of them, but they have to have different names.

extern int channels=2;//stereo-must be supported by hardware
extern int buffersize=256;//should be fine for most things
extern int samplerate=44100;//SR must be supported by card. It's always the default

void setup() {//some inits

beats.load("/Users/Michael/Desktop/beat.wav");
//load in your samples. Provide the full path to a wav file.
printf("Summary:\n%s", beats.getSummary());//get info on samples if you like.

}

void play(double *output) {//this is where the magic happens. Very slow magic.

*output=beats.play();//just play the file. Looping is default for all play functions.

//*output=beats.play(0.69);//play the file with a speed setting. 1. is normal speed.

//*output=beats.play(0.5,0,44100);
//play with a frequency input, start point and end point. Useful for syncing.


}

back