I dont really understand why this code is neccessary ; (i've looked at docs, but doesnt yet make sense to me);
i have tried just putting in;
sp = new SamplePlayer(ac, new Sample(sourceFile));
but it doesn't run. Can i run the sketch without the above code?
- import beads.*;
- AudioContext ac;
- WavePlayer wp;
- Gain g;
- Glide gainValue;
- SamplePlayer sp;
- String sourceFile;
- void setup()
- {
- size(400, 300);
- ac = new AudioContext();
- sourceFile = dataPath("Drum_Loop_01.wav");
- try {
- sp = new SamplePlayer(ac, new Sample(sourceFile));
- }
- catch(Exception e)
- {}
- sp.setKillOnEnd(false);
- gainValue = new Glide(ac, 0.0, 50);
- g = new Gain(ac, 1, gainValue);
- g.addInput(sp);
- ac.out.addInput(g);
- ac.start();
- }
- void draw()
- {
- gainValue.setValue(mouseY / (float)height);
- }
1