Dear @akenaton,
I’ve updated my code in github:https://github.com/lolonulu/Geomerative_sound_reactive_text
not brillant, but that’s where I am for now. I hope you will have some time to help me today. Thanks. L
@lolonulu===
yes, i ll’ get a look at that today
@lolonulu===
ok; that’s done:
- firstly in your main class you add:
boolean estEnPause = false;
int duration1 = 0;
int duration2 = 0;
int duration3 = 0;
int duration4 = 0;
int dureeStrophe =0;
then in your SoundManager class you get the duration of your 4 stanzas, like that:
AudioPlayer [] phraseSounds;
for (int i =0; i<soundNames.length; i++) {
phraseSounds = new AudioPlayer[soundNames[i].length];
for (int j=0; j<soundNames[i].length; j++) {
phraseSounds[j] = minim.loadFile(soundNames[i][j]+".wav", 2048);
if(i==0 && j<=3){
duration1 = duration1+phraseSounds[j].length();
}else if(i==1 && j<=3){
duration2 = duration2+phraseSounds[j].length();
}else if(i==2 && j<=2){
duration3 = duration3+phraseSounds[j].length();
}else if(i==3 && j<=2){
duration4 = duration4+phraseSounds[j].length();
}
}
sounds[i]=phraseSounds;
}
- Then you go to your main class and add:
switch(indexPhraseSet){
case 0:
dureeStrophe = duration1;
break;
case 1:
dureeStrophe = duration2+duration1 + PAUSE_DURATION;
break;
case 2:
dureeStrophe = duration2+duration1+duration3 + (PAUSE_DURATION*2);
break;
case 3:
dureeStrophe = duration2+duration1 +duration3+ duration4 +PAUSE_DURATION*3;
}
if(!estEnPause){
timer1(dureeStrophe);
}else{
timer2(dureeStrophe);
}
- then in the same Class you create your timers:
void timer1(int dureeStrophe){
if(millis()>= (dureeStrophe*boucle)+startTime){
estEnPause= true;
};
void timer2(int dureestrophe){
if(millis()>= (dureestrophe*boucle)+startTime+PAUSE_DURATION){
estEnPause= false;
}
}
- Now you get rid of what does not work in your sound Manager class:
void update() {
// SOUND
if ( indexPhraseSet==-1) {
// tout initialsier
indexPhraseSet=0;
indexPhrase=0;
playSound(estEnPause);
nextPhraseSet();
} else if (!sounds[indexPhraseSet][indexPhrase].isPlaying() &&!estEnPause) {
// sound fils is finished read next one
indexPhrase++;
if (indexPhrase >= sounds[indexPhraseSet].length) {
// If phrases'index is greater than the stanza's index then go on to the next stanza
indexPhrase=0; // 1rst sentence
indexPhraseSet++; // increase stanza's index
if (indexPhraseSet >= sounds.length) {
indexPhraseSet=0;
boucle++;/////that s the int for looping
// reset from the beginning
}
// PUT BACK BACKGROUND LINES AT THEIR ORIGINAL POSITION
if (nodesAtEndPosition == null) {
nodesAtEndPosition= new PVector[myNodes.length];
for (int i =0; i<myNodes.length; i++) {
nodesAtEndPosition[i]=new PVector(myNodes[i].x, myNodes[i].y);
}
}
float d = map(millis(), 0, PAUSE_DURATION, 0.0, 1.0);
int i =0;
for (int x=0; x<xCount; x++) {
for (int y=0; y>yCount; y++) {
if (i<myNodes.length) {
myNodes[i].x= lerp(nodesAtEndPosition[i].x, nodesAtStartPosition[i].x, d);
myNodes[i].y= lerp(nodesAtEndPosition[i].y, nodesAtStartPosition[i].y, d);
myNodes[i].setBoundary(0, 0, width, height);
myNodes[i].update();
}
i++;
}
}
// pause
//timer();
//isInPause=true;
//delay(PAUSE_DURATION/2)
//if(!estEnPause){
nextPhraseSet();
//}
} else {
//on passe à la phrase suivante
//timerPauseDuration();
nextPhrase();
//isInPause= false;
}
playSound(estEnPause);
} else {
// on est en train de lire le son
// analyser le son
soundFFTAnalyse();
wordAttractorToSound();
linesAttractor();
}
}
- in the same classs modify your playsound method:
void playSound(boolean eep) {
AudioPlayer s = sounds[indexPhraseSet][indexPhrase];
if(!eep){
s.rewind();
s.play();
//println("lecture :"+ indexPhraseSet + ", "+ indexPhrase);
fft = new FFT(s.bufferSize(), s.sampleRate());
}else{
s.pause();
}
}
at this point test!
- this code runs for the first time; if you want to loop it you have to add some int which is ++ when the last stanza has been read and use this int to modify the initial value for the timer (*)
Thank youuuuuuuuuuuu ! akenaton you are ze best ;))
I will modify my sketch tomorrow morning and will keep you posted. Thank you so much for your precious help. I see I have so much to learn…
cu tomorrow
Dear @akenaton,
It works perfectly! Thank you so much. It’s a great lesson of code for me, I hope I understand enough the whole to be able to solve the problem next time. Any advice to give to me to improve?! I never learned properly and I see how I am limited…
Thanks for your great help. I’ll quote your name when I’ll exhibit the work(nov. in Karlsruhe).
(tu crèches où à Paname ?)
Best wishes,
L