Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
fthofhuis
fthofhuis's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Looping over URLs, stupid problem...
[0 Replies]
24-Mar-2011 06:44 AM
Forum:
Core Library Questions
Hi,
i am working with processing for not so long now, and i am kinda stuck with this...
I have 2 urls, where i want to loop through.
Putting them in an array is something i do not quite understand..
The urls are about stock data, and with Minim i convert them to Hertz.
Now i have put the 2 urls in the void draw() function, but now it will only put out the last url as sound.
I want to have the first url for 2 seconds and then the second url for 2 seconds.
Quite ugly how it looks now, but i was just trying..
CAN ANYBODY HELP ME??
thanks in advance!!
Code:
"
import ddf.minim.*;
import ddf.minim.signals.*;
ArrayList tags;
AudioOutput outSine;
AudioOutput outSaw;
AudioOutput outSine2;
AudioOutput outSaw2;
SineWave sine;
SineWave saw;
SineWave sine2;
SineWave saw2;
float koers = 0;
void setup() {
size(512, 200);
frameRate(0.5);
tags = new ArrayList();
}
void draw() {
background(0);
stroke(255);
// draw the waveforms
String lines[] = loadStrings("http://finance.yahoo.com/d/quotes.csv?s=RDSA.AS&f=c6snd1l1c1b2b6yr");
println(lines);
String[] bedrijf = split(lines[0],',');
float bedrijfsKoers = float(bedrijf[6]);
println(bedrijfsKoers);
Minim minim = new Minim(this);
// get a line out from Minim,
// default sample rate is 44100, default bit depth is 16
outSine = minim.getLineOut(Minim.STEREO, 512);
outSaw = minim.getLineOut(Minim.STEREO, 512);
// create a sine wave Oscillator,
// set to 440 Hz, at 0.5 amplitude,
// using the sample rate of the output
println("koers="+koers);
sine = new SineWave(bedrijfsKoers, 0.5, outSine.sampleRate());
saw = new SineWave(bedrijfsKoers, 0.5, outSaw.sampleRate());
for(int i = 0; i < outSine.left.size()-1; i++) {
line(i, 50 + outSine.left.get(i)*50, i+1, 50 + outSine.left.get(i+1)*50);
line(i, 150 + outSine.right.get(i)*50, i+1, 150 + outSine.right.get(i+1)*50);
}
for(int i = 0; i < outSaw.left.size()-1; i++) {
line(i, 50 + outSaw.left.get(i)*50, i+1, 50 + outSaw.left.get(i+1)*50);
line(i, 150 + outSaw.right.get(i)*50, i+1, 150 + outSaw.right.get(i+1)*50);
}
String lines2[] = loadStrings("http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=c6snd1l1c1b2b6yr");
println(lines2);
String[] bedrijf2 = split(lines2[0],',');
float bedrijfsKoers2 = float(bedrijf2[6]);
println(bedrijfsKoers2);
Minim minim2 = new Minim(this);
// get a line out from Minim,
// default sample rate is 44100, default bit depth is 16
outSine2 = minim2.getLineOut(Minim.STEREO, 512);
outSaw2 = minim2.getLineOut(Minim.STEREO, 512);
// create a sine wave Oscillator,
// set to 440 Hz, at 0.5 amplitude,
// using the sample rate of the output
println("koers="+koers);
sine2 = new SineWave(bedrijfsKoers2, 0.5, outSine2.sampleRate());
saw2 = new SineWave(bedrijfsKoers2, 0.5, outSaw2.sampleRate());
// add the oscillator to the line out
outSine2.addSignal(sine);
outSaw2.addSignal(saw);
for(int i = 0; i < outSine2.left.size()-1; i++) {
line(i, 50 + outSine2.left.get(i)*50, i+1, 50 + outSine2.left.get(i+1)*50);
line(i, 150 + outSine2.right.get(i)*50, i+1, 150 + outSine2.right.get(i+1)*50);
}
for(int i = 0; i < outSaw2.left.size()-1; i++) {
line(i, 50 + outSaw2.left.get(i)*50, i+1, 50 + outSaw2.left.get(i+1)*50);
line(i, 150 + outSaw2.right.get(i)*50, i+1, 150 + outSaw2.right.get(i+1)*50);
}
}
"
«Prev
Next »
Moderate user : fthofhuis
Forum