Hi Kfrajer,
I test the SamplePlayer and it’s quite funny for setting speed and easy to use because you can select sample just by starting the program.
But, I can’t manage to use properly the demo in your last link.
I have tried to change the code but without success. the console says this:
AudioContext : no AudioIO specified, using default => beads.JavaSoundAudioIO.
java.io.IOException: Problem loading file (class=class beads.WavFileReaderWriter) /Users/macbookpro/Documents/Processing/Lireplusieurssamples2/130_ChillinBeat_SP_01.wav, Could not read audio file: /Users/macbookpro/Documents/Processing/Lireplusieurssamples2/130_ChillinBeat_SP_01.wav (No such file or directory)
at beads.Sample.loadAudioFile(Unknown Source)
at beads.Sample.<init>(Unknown Source)
at Lireplusieurssamples2.setup(Lireplusieurssamples2.java:88)
at processing.core.PApplet.handleDraw(PApplet.java:2425)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
NullPointerException
and the program that I tried to change
import beads.*;
import java.util.Arrays;
AudioContext ac;
PowerSpectrum ps;
Glide gainValue, gainValue2, gainValue3;
Frequency f;
SpectralCentroid sc;
SpectralPeaks sp;
int nPeaks;
float fColor = 0;
void setup() {
size(600, 600);
ac = new AudioContext();
//**** the original program
gainValue = new Glide(ac, 0.5, 20);
Gain g = new Gain(ac, 2, gainValue);
gainValue2 = new Glide(ac, 0.5, 20);
Gain g2 = new Gain(ac, 2, gainValue2);
gainValue3 = new Glide(ac, 0.5, 20);
Gain g3 = new Gain(ac, 2, gainValue3);
SamplePlayer player = null;
SamplePlayer player2 = null;
SamplePlayer player3 = null;
//**** a possibility to control gain value of each sample?
/*
Gain g = new Gain(ac, 2, gainValue);
Gain g2 = new Gain(ac, 2, gainValue);
Gain g3 = new Gain(ac, 2, gainValue);
SamplePlayer player = null;
SamplePlayer player2 = null;
SamplePlayer player3 = null;
g.addInput(player);
g2.addInput(player);
g3.addInput(player);
ac.out.addInput(g);
ac.out.addInput(g2); // player 2
ac.out.addInput(g3); // p^ayer 3
*/
//******** end of the possible program
try {
/*
player = new SamplePlayer(ac, new Sample(sketchPath("") + "../130bpm/130_ChillinBeat_SP_01.wav"));
g.addInput(player);
player2 = new SamplePlayer(ac, new Sample(sketchPath("") + "../130bpm/130_DelaySnareBeat_SP_01.wav"));
g2.addInput(player2);
player3 = new SamplePlayer(ac, new Sample(sketchPath("") + "../130bpm/130_Floor4Beat_SP_01.wav"));
*/
player = new SamplePlayer(ac, new Sample(sketchPath("") + "130_ChillinBeat_SP_01.wav"));
g.addInput(player);
player2 = new SamplePlayer(ac, new Sample(sketchPath("") + "130_DelaySnareBeat_SP_01.wav"));
g2.addInput(player2);
player3 = new SamplePlayer(ac, new Sample(sketchPath("") + "130_Floor4Beat_SP_01.wav"));
g3.addInput(player3);
}
catch (Exception e) {
e.printStackTrace();
}
player.setKillOnEnd(false);
player2.setKillOnEnd(false);
player3.setKillOnEnd(false);
player.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
player2.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
player3.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
ac.out.addInput(g);
ac.out.addInput(g2);
ac.out.addInput(g3);
/////////////////////
ShortFrameSegmenter sfs = new ShortFrameSegmenter(ac);
sfs.addInput(ac.out);
FFT fft = new FFT();
sfs.addListener(fft);
ps = new PowerSpectrum();
fft.addListener(ps);
ac.out.addDependent(sfs);
////////////////////
ac.start();
}
void draw() {
float[] features = ps.getFeatures();
if (features != null) {
float bass = 0;
for (int i = 5; i < 10; ++i) {
bass += features[i];
}
bass /= (float)(5);
float heights = 0;
for (int i = 40; i < 45; ++i) {
heights += features[i];
}
heights /= (float)(5);
ellipse(width / 2 - 100, height / 2, bass * 20, bass * 20);
ellipse(width / 2 + 100, height / 2, heights * 50, heights * 50);
}
}
Regards, Benjamin