Audio and frame delay timing using fft and screen position.

Hi all, I'm using the spectrum data from an FFT i'm performing to control the speed of the audio file as well as the delay between frames being drawn. This is what creates the avg. The issue is that i'm not sure how to make this work for a range of different files. Sometimes there'll be 1440 frames to play, othertimes there's 1700 and the audio is similarly varied.

How can a build this so that it'll always playback in the right amount of time, which is currently 1 minute but could be 2 or 3.

Thanks.

code snippet that i'm using to control the playback and delay:

if (tConnectSound) { if (avg > height/6+height/6*4 && avg < height) { //rateControl.value.setLastValue(frameSkipLoad/32); cp5.getController("sDelay").setValue(frameSkipLoad/32); }// else if (avg > height/6+height/6*3 && avg < height/6+height/6*4) { //rateControl.value.setLastValue(frameSkipLoad/16); cp5.getController("sDelay").setValue(frameSkipLoad/16); }// else if (avg > height/6+height/6*2 && avg < height/6+height/6*3) { //rateControl.value.setLastValue(frameSkipLoad/8); cp5.getController("sDelay").setValue(frameSkipLoad/8); }// else if (avg > height/6+height/6 && avg < height/6+height/6*2) { //rateControl.value.setLastValue(frameSkipLoad/4); cp5.getController("sDelay").setValue(frameSkipLoad/4); }// else if (avg > height/6 && avg < height/6+height/6) { //rateControl.value.setLastValue(frameSkipLoad/2); cp5.getController("sDelay").setValue(frameSkipLoad/2); }// else if (avg > 0 && avg < height/6) { //rateControl.value.setLastValue(frameSkipLoad); cp5.getController("sDelay").setValue(frameSkipLoad); } delay = cp5.getController("sDelay").getValue(); } 
submitted by /u/OlympicGurn
[link] [comments]

A loop that increases framerate?

Would really want a loop or something a like that increase framerate as it goes (pref 2 or 3 more frames per second) but I haven't found any example of doing this and the examples I have found about increasing numbers has been in Void Draw() and not in Void Setup()

Edit: Maybe you can't change anything in Void Setup() as you go?

Edit edit: fixed it....just moved frameRate() down to draw and the solution was simply

Void Draw(){

frameRate(x=x+1);}

submitted by /u/Erikbam
[link] [comments]

Claims

Most companies we represent have 24 hour service. You can use the following phone numbers to report your claim directly to your company, speeding up the claim process. These same phone numbers can be used for follow-up questions you may have concerning your claim. If possible, have either your policy number or claim number when calling.

submitted by /u/bobjohnsonins
[link] [comments]

I need help with using "parents" to create plants.

Confusing name? Basically, I have this program which currently generates a few plants with a random amount of stems. Each stem has height, angle, blah blah blah. Anyway, the way it works is each plant's "starting x&y" and "ending x&y" is connected. So, Stem0's End X&Y is equal to Stem1's Start X&Y. So, Stem1 is the parent of Stem0. In my code, I can easily make a straight line of a Stem Array, but I cannot so easily make random Stem's go off randomly from different Stems, so it branches out. So, each Stem excluding the base Stem has a random parent assigned, while still keeping a plant shape. Any advice, help?

Code:

 Creature[] crt = new Creature[2]; float groundHeight = 0; void setup() { size(1500,600); smooth(); groundHeight = height - 20; for (int i=0; i<crt.length; i++) { crt[i] = new Creature((((width*0.8)/crt.length)*i)+width*0.1,groundHeight); for (int w=0; w<crt[i].line.length; w++) { if(w == 0) { crt[i].line[w] = new Stem(crt[i],i); } else { crt[i].line[w] = new Stem(crt[i].line[w-1],i); } } } } void draw() { background(100,100,255); groundIt(); displayCrt(); } void displayCrt() { for(int i=0; i<crt.length; i++) { crt[i].displayPlant(); } } void groundIt() { stroke(0,240,0); strokeWeight(0); fill(0,255,0); rectMode(CORNERS); rect(0,groundHeight,width,height); } class Creature { Stem[] line = new Stem[(int)random(2,10)]; float x,y; float colour; float thickness; Creature(float x, float y) { this.x = x; this.y = y; colour = color(255,0,0); } void displayPlant() { for(int i=0; i<line.length; i++) { line[i].mathIt(); line[i].display(); } stroke(0); strokeWeight(0); fill(colour); ellipse(x,y,10,10); } } class Stem { float jointStartX; float jointStartY; float jointEndX; float jointEndY; float angle; float leng; int crtSyntax; Stem parent; Creature root; Stem(Creature root_,int crtSyntax_) { parent = null; root = root_; angle = -radians(random(0,180)); leng = 50; } Stem(Stem parent_,int crtSyntax_) { parent = parent_; parent = crt[1].line[1]; root = null; angle = -radians(random(0,180)); leng = random(20,100); } void mathIt() { if (parent != null) { jointStartX = parent.jointEndX; jointStartY = parent.jointEndY; } else if (root != null) { jointStartX = root.x; jointStartY = root.y; } jointEndX = leng * cos(angle) + jointStartX; jointEndY = leng * sin(angle) + jointStartY; } void display() { stroke(255); strokeWeight(4); line(jointStartX,jointStartY,jointEndX,jointEndY); stroke(0); ellipse(jointStartX,jointStartY,4,4); stroke(255,0,0); ellipse(jointEndX,jointEndY,4,4); } } 
submitted by /u/GameKwng
[link] [comments]

Need help with sound on project

I am working on a social project which is a clock that every x amount of seconds plays a sound file in order to bring discussion about something. Think of it as one of those "every 10 seconds [something] takes place in the world". I already have the clock working but I'm fairly new to Processing and I'm lost in regards to sound. I don't know if if there's a way to loop sound to every 7 seconds for example. Anyway heres my code: final float SecondHand = 250.0;

final int ClockWidth = int(2 * SecondHand + 30.0); final float ClockCenter = ClockWidth / 2.0; final float Diameter = ClockWidth - 5.0; final float MinuteHand = 7.0 / 8.0 * SecondHand; final float HourHand = 3.0 / 4.0 * MinuteHand; void setup() { size(530, 530); stroke(#3d3c3d); smooth(); noFill(); } PVector convertAndTranslate(float theta, float r) { theta -= HALF_PI; return new PVector(r * cos(theta) + ClockCenter, r * sin(theta) + ClockCenter); } void draw() { background(#d6d3d5); strokeWeight(6); ellipse(ClockCenter, ClockCenter, Diameter, Diameter); float theta = TWO_PI * second() / 60.0; PVector endpoint = convertAndTranslate(theta, SecondHand); line(ClockCenter, ClockCenter, endpoint.x, endpoint.y); strokeWeight(8); theta = TWO_PI * minute() / 60; endpoint = convertAndTranslate(theta, MinuteHand); line(ClockCenter, ClockCenter, endpoint.x, endpoint.y); strokeWeight(12); theta = TWO_PI * ((hour() % 12 + minute() / 60.0) / 12.0); endpoint = convertAndTranslate(theta, HourHand); line(ClockCenter, ClockCenter, endpoint.x, endpoint.y); } 
submitted by /u/Ejotei
[link] [comments]

Specific Simon game

Hey everyone !

I'm currently trying to make a simon like game, so basically I've already tried things (basic code, which contains everything I need). Except my goal is to play with a Position motor in the center of the room (with a magnet), and in the four corners of the place, there would be four different media (image, video, sound...) that would have to be reproduced by the player when the engine points those in the correct order, by pressing their buttons.

At the moment, this is what I wrote :

import processing.video.*; import ddf.minim.analysis.*; import ddf.minim.*; import themidibus.*; MidiBus myBus; Minim minim; Movie myMovie; AudioPlayer son; int etat; int lampe = 0; PImage img; int[]valeur = new int[1]; int phase = 0; void setup(){ size(1024,200); minim = new Minim(this); MidiBus.list(); myBus = new MidiBus(this, 0, 4); img = loadImage("canard.jpg"); son = minim.loadFile("coin.mp3", 2048); myMovie = new Movie(this, "Danse.mp4"); } void controllerChange(int channel, int number, int value){ valeur[number] = value; println("Capteur : " + number + " " + valeur[number]); } void keyPressed() { if (key == 'a') { etat = 1; } if (key == 'z') { etat = 2; } if (key == 'e') { etat = 3; } if (key == 'r') { etat = 4; } if (key == 'y') { etat = 5; } } void draw(){ //image(myMovie,0,0); switch(phase){ case 0 : phase = 1; break; case 1 : phase = 2; break; } void stop(){ minim.stop(); super.stop(); } 

My question is, is a switchcase the right solution? I'm kinda lost, because I don't know how to start. I don't really know how to make a position motor work in my code, since it has to sense each corner (with filters I guess ?).

Someone told me to do something like that :

final int kUnknown=-1; final int kSpicyPattern=0; final int kMusicCorner=90; final int kImageCorner=180; final int kMovieCorner=270;

int whatCorner =kUnknown;

void setup() { ..... }

void draw() {

switch(whatCorner) { case kSpicyPattern: execSpicyPattern(); break; case kMusicCorner: execMusic(); break; case kImageCorner: execShowImage(); break; case kMovieCorner: execShowMovie(); break; default: break; } }

void execSpicyPattern() { } void execMusic() { } void execShowImage() { } void execShowMovie() { }

I want to make it with sensors, using MIDI interface. Thank you in advance.

submitted by /u/Maelyia
[link] [comments]

Programming for Artists