We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, I asked this once, but still can't make it works..
I want to make the sentence I make to convert little melody when enterkey pressed.
those are codes
import ddf.minim.*;
Minim minim;
AudioPlayer c, d, e, f, g, a, b;
PFont font;
int num = 500;
char t[] = new char[num];
int key_num = 0;
int text_w_gap = 30;
int text_h_gap = 50;
int ypos = 50;
int xpos = 10;
int val;
boolean playSong=false;
void setup() {
size(500, 400);
font = createFont("whiteday10-48.vlw", 14);
textFont(font, 32);
fill(7,161,8);
minim = new Minim(this);
c = minim.loadFile("c.mp3");
d = minim.loadFile("d.mp3");
e = minim.loadFile("e.mp3");
f = minim.loadFile("f.mp3");
g = minim.loadFile("g.mp3");
a = minim.loadFile("a.mp3");
}
void draw() {
background(0);
if (playSong) {
for (int i=0; i<key_num; i++) {
playNote(t[i]);
}
} else
{
for (int i=0; i<key_num; i++) {
text(t[i],
(xpos+(i*text_w_gap))%width,
ypos+( (int(xpos+(i*text_w_gap))) / width * text_h_gap));
}
if (key_num >= num) {
key_num = 0;
}
}
}
void keyPressed() {
if (key!=8) {
t[key_num] = key;
key_num++;
} else if (key==RETURN||key==ENTER) {
playSong=true;
} else if (key==8) {
key_num--;
}
println("pressed " + int(key) + " " + keyCode);
}
void playNote(int KeyCode) {
if (KeyCode==65) {
c.play();
}
if (KeyCode==66) {
d.play();
}
if (KeyCode==67) {
e.play();
}
if (KeyCode==68) {
f.play();
}
if (KeyCode==69) {
g.play();
}
if (KeyCode==70) {
a.play();
}
if (KeyCode==71) {
b.play();
}
}
keycodes are just examples..
I hope someone shows me the functional code that I can understand. thanks for reading..
Answers
https://forum.Processing.org/two/discussion/16855/how-can-i-make-this-idea-possible-sound-alphabet
???
Didn't you like my way??
You are making it worse
No chrisir, I really appreciate your help really I do
I just can't make them work I'm crying right now...
I just started processing, I can't get it work..
Thing I did was try to make it sound but I have no clue right now..
In println section I can see the keycord for the sound but
how can I apply those keycord to minim?
I posted my version in the other thread
Did it work??
Where it says =='a'
Did you type abababb and hit return in my code?
after I typed abaaaaba, I hit enterkey
yes... returnkey
After I run this code, I typed aaccdd, when I hit return It doesn't sound
I've got the mp3 files matched name on data folder in same folder.
Now we are talking
when you write
c.play(); in draw does it work?
Maybe you need to turn the play for loop to just play and i++; after a few frames
I want the sound once, when I hit return,
like if I typed aabbcc and return, It sound aabbcc once sequentially.
like this way
Does it work?
You haven't answered.
I can't run your code, I don't have your mp3
nooooo It doesn't work...
Now we are talking
when you write
c.play(); in draw does it work?
Maybe you need to turn the play for loop to just play and i++; after a few frames
I can't understand the last sentence.
you mean c.play(); to c.loop(); ?
It still doesn't work.. I dont get it either I'm suck at english or suck at processing
maybe both..
You need to isolate the problem. You need find out exactly where the problem lies. So if you try to say c.play in setup() just to see if the audio file plays like it should. I think that's what Chrisir is trying to say.
thanks....
;-)
THANK YOU SO MUCH! Chrisir :)
I can't even explain how thankful I am right now! I just check this question!
It does work perfectly.
I change a bit. thank you so much!!
I try to add some bgm for the melody. I truly thank for you help! thank you so much!
this is proceeding code right now! ( I think I use thx so much too much haha)
the main issue was this btw
since we start with if (key!=8) { it failed, because return is also != 8, it never came to playsong = true............
Bad.
I found out by placing
println("1");
what never got executed, so I got suspicious....Then he played all notes at once, so I had to tear down the for-loop in draw() and place a timer there.... puuh!
Best, Chrisir ;-)
wow.. I got to study that part even though I can't understand right now
I'm gonna btw !!
thank you!! :) :)
;-)