Controling slide changes with sound
in
Contributed Library Questions
•
6 months ago
I'm trying to make simple slideshow (with or without transition effects) for projection mapping.
I have in processing OutOfMemory problem because 250-300 images (1280x720) have been loaded in setup function.
Then I have found FileSequence example in toxiclibs library that works pretty well although framerate drops dramatically (5-10).
What I need is to control appearance of images using minim library and SoundEnergy ( beat.isOnset(), beat.isKick(), beat.isHat(), beat.isSnare() ).
The images would be changed when specific audio parameter exceeds a certain value ( in rhythm).
Welcome with good ideas...
first attempt:
I have in processing OutOfMemory problem because 250-300 images (1280x720) have been loaded in setup function.
Then I have found FileSequence example in toxiclibs library that works pretty well although framerate drops dramatically (5-10).
What I need is to control appearance of images using minim library and SoundEnergy ( beat.isOnset(), beat.isKick(), beat.isHat(), beat.isSnare() ).
The images would be changed when specific audio parameter exceeds a certain value ( in rhythm).
Welcome with good ideas...
first attempt:
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import toxi.util.*;
- import java.awt.FileDialog;
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- Minim minim;
- AudioPlayer song;
- BeatDetect beat;
- FileSequenceDescriptor fsd;
- Iterator images;
- String imgPath;
- PImage img;
- void setup() {
- size(1280, 720, GLConstants.GLGRAPHICS);
- minim = new Minim(this);
- song = minim.loadFile("marcus_kellis_
theme.mp3", 2048); - song.play();
- // a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
- beat = new BeatDetect();
- String path = FileUtils.showFileDialog(
frame, "Choose start frame...", dataPath(""), new String[] { - ".tga", ".png", ".jpg" }, FileDialog.LOAD);
- // the path variable will be null if the user has cancelled
- if (path != null) {
- // get an descriptor for this base path
- // this will analyse and identify the length of the sequence
- // see javadocs for further details
- fsd=FileUtils.
getFileSequenceDescriptorFor( path); - println("start: "+fsd.getStartIndex()+" end: "+fsd.getFinalIndex());
- // now ask descriptor for an iterator which will return
- // absolute file paths for all images in this sequence in succession
- images=fsd.iterator();
- }
- else {
- // quit if user cancelled dialog...
- exit();
- }
- }
- void draw() {
- background(0);
- beat.detect(song.mix);
- if (!images.hasNext()) {
- images=fsd.iterator();
- }
- if ( beat.isOnset() ) {
- imgPath=(String)images.next();
- img=loadImage(imgPath);
- image(img, 0, 0, width, height);
- }
- println(frameRate);
- }
- void stop()
- {
- // always close Minim audio classes when you are finished with them
- song.close();
- // always stop Minim before exiting
- minim.stop();
- super.stop();
- }
1