Trying to set a text chain to midi music with an associated visual.
Well I've gotten this code to this stage it is not elegent but it is doing what I want it to do. My problem is that I want a visual going along with the notes and code. I wanted to map the value of "note" to between 0 and the width and display a rectangle at the coordinate that corresponds with the value of the note that is being played.
The problem is this: I guess when it goes through the for loop in the printStringToInts function draw doesn't run until the loop is completed and then only for one frame. I can get the rectangles to draw all at once inside the for loop but I want them to go off individually as a animation where they are ping ponging around the screen. Please help if you can I'd really appreciate I can't figure it out...
Here is the code:
import themidibus.*;
MidiBus myBus;
String[] headlines = {
"Communication: 07.06.2011",
"Jesse (1:25 AM): Made it home fine. Still pissed at the douche tho. Hope when your the bartender you don’t get butt hurt when I flip you off.",
"Tierna (9:05 AM): Can you meet @ 330?",
"Jason (9:37 AM): Don’t live like it’s your last day. That’s dumb. You’d be like, crying. Make today awesome and live like it’s today.",
"@Jesse (10:00 AM): Hey just got yr text glad you made it safe and don’t worry about my coworker he’s sensitive",
"@Tierna (10:01 AM): Yeah that should be fine I just have to be at work by five in rio rancho.",
"@Jason (10:03 AM): Sage words",
"Tierna (10:05 AM): K it will take about 20 min" ,
"@Tierna(10:06 AM): Sounds good flying star at three thirty see you then" ,
"Unknown(10:09 AM): Boo!",
"@Unknown(10:12 AM): You scared me. Who are you?" ,
"Unknown(10:13 AM): The Plumber" ,
"@Unknown(10:14 AM): Jake Plumber? What’s up man!" ,
"Unknown(10:16 AM): No…the plumber…I’ve come to fix your sink" ,
"@Unknown(10:18 AM): Oh OK well the key is under the door mat and I put a check on the table for you. Seriously who is this though?" ,
"Unknown(10:21 AM): It’s Chrissy goof!" ,
"@Unknown(10:23 AM): Haha. Oh hey what is up? I’m in summer school class right now" ,
"Unknown(10:25 AM): LOL summer school?" ,
"Sonya(10:26 AM): Have a good day in class!" ,
"@Sonya(10:28 AM): K call you when I get out xoxo" ,
"Unknown(1:45 PM): OMG I’m so sorry I was texting the wrong number lol" ,
"@Unknown(1:50 PM): Haha no worries. Thanks for fixing the sink" ,
"Unknown(1:53 PM): LOL sorry!" ,
"Taylor(2:09 PM): So I heard a band called Agent Ribbons. It was a pretty good girl band. Also check out Aerial M. They have a good 2 track ep." ,
"@Taylor(2:11 PM): Cool will do. I’ve been listening to this guy named Bob Dylan. It’s just him with an acoustic and a harmonica. It’s so awesome but his voice is a little different. You have to listen to the words man the words." ,
"Taylor(2:13 PM): Nice. I will give it a go. Is he that “everybody must get stoned guy”?" ,
"@Taylor(2:14 PM): Yeah I think that’s him. He does like a jimi Hendrix cover of All Along the Watchtower too." ,
"Taylor(2:15 PM): Oh I know that guy. I might try it. Not really my thing. U know im n2 hardcore ganster rap right?" ,
"Taylor(2:16 PM): Wanna play a quick name game? Patterson, hunter, maybin, Gomez, smoak. I really need sb’s but smoak may have a power comeback which I’ll also take." ,
"@Taylor(2:18 PM): Hmm I think I like smoak or hunter out of that group but not a lot of sbs. Not too sure what’s on the wire for speed. Hunter steals some like two a month or he used to anyways." ,
"Taylor(2:20 PM): How bout maybins gr8 walk against the mariners? Nice." ,
"@Taylor(2:22 PM): Ya that’s awesome. Intentionally walk a padre hitting .230 and choke throw it into the stands haha." ,
"Taylor(2:23 PM): Baseball is hard." ,
"@Taylor(2:24 PM): It really is. I’m so frustrated with that league." ,
"Taylor(2:26 PM): I know man. U r in an intense grind man. Circumstances will shift 2 ur favor at some point. Reading extra 2% right now I’ll loan it to you when I’m done." ,
"@Taylor(2:27 PM): Oh cool how is it? I’ll trade you Moneyball for that book and Bautista." ,
"Taylor(2:28 PM): That’s probably fair. Deal. It’s actually really good. Feel like I should have read Moneyball first but it was a dad’s day gift. Didn’t know your Sox were almost the Tampa Bay White Sox.",
"@Taylor(2:30 PM): What the fuck is that true? That would have fucking sucked",
"Taylor(2:31 PM): Apparently so ok will hit you up later bro.",
"@Sonya(3:07 PM): Hi baby. Killing time at fstar how are you?",
"Sonya(3:09 PM): I’m fine. I wish I could meet you at Flying Star :) how’s the project coming?",
"@Sonya(3:11 PM): So far so good just collecting data. I had a random person hit me up and had a little wrong number chain with them. I kept being like who is this? And they thought I was their friend so they kept texting me thinking I was joking.",
"Sonya(3:12 PM): LOL",
"Sonya(3:14 PM): Walkmen in Phoenix on Sept 15 with Fleet Foxes and Bon iver. Road Trip?",
"@Sonya(3:15 PM): Oh man. K I’m down!",
"Taylor(3:14 PM): And dude, u totally had Ogando pegged. I doubted u for dropping him, but now…",
"@Taylor(3:16 PM): Got that one right. His FIP was all fucked up.",
"Taylor(3:18 PM): Gr8 job dork!",
"Sonya(4:17 PM): What size shoe do you wear?",
"@Sonya(4:18 PM): Thirteen. Twelve in Converse.",
"Sonya(4:20 PM): That soccer players name is Hope Solo.",
"@Sonya(4:22 PM): That’s a stage name",
"@August(5:59 PM): Yr grandyman smack haha",
"August(6:01 PM): Thanks bro :) Glad someone got it…",
"Matthew(6:04 PM): I watched “White Fang” today. Did you?",
"@Matthew(6:10 PM): No but I watched a different Ethan Hawke joint. “Explorers”. River Phoenix is in it.",
"@August(6:30 PM): We might go see Walkmen and Fleet Foxes in Phoenix.",
"August(6:31 PM): Oh cool. Same show?",
"@August(6:33 PM): Yeah. Bon Iver is opening I think too.",
"August(6:35 PM): No way. He has the number one record. He’s not an opening act.",
"@August(6:36 PM): Hmm well the other two are fairly big acts so I don’t know then.",
"August(6:37 PM): Maybe. That sounds killer dude. I’m jealous.",
"@August(6:38 PM): Pixies in Santa Fe though! Hells Bells Tour.",
"August(6:39 PM): I just got a little wet.",
"@August(6:40 PM): lmfao",
"Edward(7:24 PM): Hey Vinnie! Matt saw White Fang today!",
"August(7:25 PM): Freakin lame. Sanchez blew me up again…",
"@August(7:27 PM): Romero epic digger. Bad week for me again. :(",
"@August(7:30 PM): Adam throws Masterson against the Yanks and he is freaking dealing. This season has been mentally exhausting dude.",
"Taylor(7:34 PM): You get my enviromentalist poster text?",
"@Taylor(7:36 PM): Oh yeah I did good shit. Meant to hit you up on that.",
"August(8:06 PM): Staci just told me that I’m ruining her life because I don’t want to take her on a vacation that costs $2500. She’s worried about her future…",
"@August(8:08 PM): ? What is that shit about?",
"August(8:09 PM): She says she needs to get out and experience life. And I don’t have those desires so it makes her scared about our future. And that her friends make way less than we do and they all go on vacations…",
"@August(8:11 PM): Well maybe if she got a job that would get her out of the house and experiencing life and understanding the value of money a bit better",
"August(8:12 PM): I agree. We live paycheck to paycheck. Sorry that stresses me out… That 07 VW isn’t paying for iself and neither will the house I’m trying to buy for us. And I’m ruining her existence.",
"@August(8:14 PM): That’s a bunch of horseshit",
"August(8:16 PM): I sort of get why people don’t like to come home from work now…",
"@August(8:17 PM): That’s so unfair to you it really makes me mad",
"August(8:20 PM): I thinks she’s stressed about the kids which is fine but don’t take that out on me like I don’t try and give you what you want and need.",
"Taylor(8:56 PM): My granddad just died.",
"@Taylor(8:57 PM): Oh t I am so truly sorry to hear that man.",
"@August(9:00 PM): Taylor’s grandpa passed away…RIP",
"August(9:01 PM): …Oh bummer…",
"August(9:02 PM): RIP indeed.",
"Brandon(10:13 PM): We found flights to St. Thomas next year for our wedding @ $700 round trip. Pretty cheap, may also get another discount due to group rate depending on how many people can commit now.",
"Brandon(10:15 PM): I know moneys tight, if you guys want to come let me know and I’ll include info in an email…",
};
// input a string, to be printed as ints to the console
void printStringToInts(String s) {
//declare variables
int note;
int totalChar;
int t=0;
// for the length of the String
for (int i=0; i<s.length(); i++) {
// convert each character in the string to an int
// and print it to the console
note=(int)s.charAt(i);
totalChar=(int)s.length();
println((note)+","+(t)+","+(totalChar)+","+(index));
int channel = 12;
int pitch = note;
int velocity = 127;
myBus.sendNoteOn(channel, note, velocity);
int number = 0;
int value = 90;
myBus.sendControllerChange(channel, number, value);
delay(totalChar/2);
t=t+1;
if (t >= s.length()) {
t=0;
index = (index + 1) % (headlines.length);
Hey I'm a noob with Processing and programming in gen., I have done some OK stuff but I need some help please! What I'm trying to do is to get the letters from this string array converted in numbers so I can turn them into MIDI notes. As is all I can get is the length of the array (6), but I am wanting the numbers representing the individual character in each array entry. I was able to do this using the tweetstream library and the length() function in a different sketch but i get the error that:
cannot convert string type [] to string when using "length" without the parenthesis works. Please help me out here is the code:
String[] headlines = {
"Jesse (1:25 AM): Made it home fine. Still pissed at the douche tho. Hope when your the bartender you don’t get butt hurt when I flip you off." ,
"Tierna (9:05 AM): Can you meet @ 330?" ,
"Jason (9:37 AM): Don’t live like it’s your last day. That’s dumb. You’d be like, crying. Make today awesome and live like it’s today." ,
"@Jesse (10:00 AM): Hey just got yr text glad you made it safe and don’t worry about my coworker he’s sensitive" ,
"@Tierna (10:01 AM): Yeah that should be fine I just have to be at work by five in rio rancho." ,
"@Jason (10:03 AM): Sage words" ,
};
PFont f; // Global font variable
float x; // Horizontal location
float t;
int index = 0;
void setup() {
size(screen.width,screen.height);
rectMode(CENTER);
f = createFont( "Arial" ,20,true);
// Initialize headline midscreen
x = width/2;
}
void draw() {
background(0);
fill(255);
// Display headline at x location
textFont(f,20);
textAlign (CENTER);
// A specific String from the array is displayed according to the value of the "index" variable.
text(headlines[index],x,height-200,width/2,100);
Hey I am very new to Processing and am trying to build something like Space Invaders for a class I'm taking. I'm sure much of this code is executed pretty clunkily but I've got two ArrayLists for bullets and and Array for the aliens. I'm happy with how this stage works but this is the crux of my problem -- I want multiple stages but cant figure out how to reinitialize the array of aliens into their original starting positions after all of these are cleared. I also want to alter the speed and color when they are reinstated. Any help anyone could give me would truly be appreciated.
//EARTH DEFENSE FORCE 1953 FINAL
Spaceship mySpaceship;
ArrayList bullets;
ArrayList bombs;
int cols= 10;
int rows =5;
int cols_select;
int rows_select;
Alien[][] aliens = new Alien[cols][rows];
Timer timer;
boolean gameOn=true;
int deadAliens=0;
int lastGuy=0;
void setup(){
size(1300,1000);
colorMode(HSB,360,360,360);
smooth();
//initialize the Spaceship object, call for constructor;
mySpaceship = new Spaceship(200,200,200,500,900);
//initialize the bulletArrayList
bullets = new ArrayList();
bombs = new ArrayList();
//initialize the AlienArray
for (int i=0; i< cols; i++){
for (int j=0; j<rows; j++){
aliens[i][j] = new Alien(140, 300, 300, 360, i*100,j*80,1);
}
}
//initialize the Timer
timer = new Timer(200);
timer.start();
}