Issue with Geomerative library

Hello,
I face an issue I don’t mange to solve. I show a multilines text written with the Geomerative library, to each sentence corresponds a sound, when the stanza is written the program switch to the next one. My question is how can I still show my 1rst stanza when the 2nd start to be shown?! Now when I switch to the 2nd stanza the 1rst disappear!
Thanks a lot in advance for any help.
Best,
L

import processing.pdf.*;
import geomerative.*;

//TEXT
int indexPhraseSetFR;
int indexPhraseFR;
RFont font;
String [][]textTyped = {
  {"On me dit de te haïr et je m'y efforce", 
  "Je t'imagine cruel, violent, implacable", 
  "Mais à te voir je n'ai bientôt plus de force", 
  "Et de te blesser je suis bien incapable", 
  }
  , 
  {
    "Tous mes camarades combattent avec rage", 
    "Et pleurent la nuit au souvenir des supplices", 
    "Infligés à leurs frères qui sont du même âge", 
    "et rêvent comme eux de toucher une peau lisse"
  }
};
boolean doSave = false;
RPoint [][]pnts;
float bottomLeftPointsXFR;
float bottomRightPointsXFR;
int LINE_SPACING = 80;

//SOUND
SoundManager sm;
int loop=0;
AudioPlayer background;
Minim minim;
boolean isTransitioning = false;
int startTime;

void setup() {
  size(1920, 1000);  
  // make window resizable
  surface.setResizable(true); 
  smooth();

  //TEXT
  RG.init(this);
  font = new RFont("FreeSans.ttf", 100, RFont.LEFT);
  RCommand.setSegmentStep(11);
  RCommand.setSegmentator(RCommand.UNIFORMSTEP);
  RCommand.setSegmentLength (10);


  //SOUND
  sm= new SoundManager(this);
  indexPhraseFR = 0;
  indexPhraseSetFR = -1;
  minim= new Minim(this);
  background = minim.loadFile("WAR.wav");

  // TIME
  startTime=millis();
}


void draw() {
  background(255);
  // margin border
  translate(-1600, 200);
  sm.update();
  background.setGain(-20);
  sm.drawText();
}
void nextPhrase() {
  //println(phraseSet[indexPhraseSet][indexPhrase]);
}

void nextPhraseSet() {
  createPoint(textTyped[indexPhraseSetFR]);
}

void createPoint(String[] phrases) {
  pnts=new RPoint[phrases.length][];
  for (int i =0; i<phrases.length; i++) {
    // get the points on font outline
    RGroup grp;
    grp = font.toGroup(phrases[i]);
    grp = grp.toPolygonGroup();
    pnts[i] = grp.getPoints();
    grp.getBottomLeft();
    grp.getBottomRight();
    bottomLeftPointsXFR = grp.getBottomLeft().x;
    bottomRightPointsXFR = grp.getBottomRight().x;
  }
}

import ddf.minim.*;

String [][]soundNamesFR = {
  {"FR_01", "FR_02", "FR_03", "FR_04"}, 
  {"FR_05", "FR_06", "FR_07", "FR_08"}
};

class SoundManager {
  //SOUND
  Minim minim;
  AudioPlayer[][] soundsFR;

  float transitionTime = 0;
  int startTransitionTime;
  int transitionDuration = 1500;

  SoundManager(PApplet app) {

    minim = new Minim(app);
    soundsFR = new AudioPlayer[soundNamesFR.length][];
    // println(soundNamesFR.length);
    AudioPlayer [] phraseSoundsFR;
    for (int i =0; i<soundNamesFR.length; i++) {
      phraseSoundsFR = new AudioPlayer[soundNamesFR[i].length]; 
      for (int j=0; j<soundNamesFR[i].length; j++) {
        phraseSoundsFR[j] = minim.loadFile(soundNamesFR[i][j]+".wav", 512);
      }
      soundsFR[i]=phraseSoundsFR;
    }
  }

  void update() {

    if (isTransitioning) {
      if (millis() >= startTransitionTime+transitionDuration) {
        // transition end
        // si c'est pas fini on passe au suivant
        if (indexPhraseSetFR < soundsFR.length) {
          isTransitioning=false;
          transitionTime=0; 
          nextPhraseSet();
          playSound();

          // si on a lu tous les groupes on recommence à zero
        } else if (indexPhraseSetFR == soundsFR.length && millis() >= startTransitionTime+transitionDuration) {         
          // reset from the beginning 
          isTransitioning=false;
          transitionTime=0;    
          indexPhraseSetFR=0;
          indexPhraseFR=0;
          nextPhraseSet();
          background.shiftGain(-20, -80, 1000);
          background.rewind();
          background.pause();
          startTime = millis();
          playSound();
          background.play();
          background.shiftGain(-80, -20, 1000);
        }
      } else if (millis() <= startTransitionTime+transitionDuration) {       
        //  we are transiting 
        transitionTime = map(millis(), startTransitionTime, startTransitionTime+transitionDuration, 0., 1.);
      }
    } else {
      if ( indexPhraseSetFR==-1 ) { 
        // Initialise all
        indexPhraseSetFR=0;
        indexPhraseFR=0;
        playSound();
        nextPhraseSet();
        background.play();
        background.shiftGain(-80, -20, 1000);
      } else if ( !soundsFR[indexPhraseSetFR][indexPhraseFR].isPlaying()) {  
        // sound file is finished read next one
        indexPhraseFR++;
      
        if ( isTransitioning==false &&  indexPhraseFR >= soundsFR[indexPhraseSetFR].length && indexPhraseSetFR <soundsFR.length) {
          // If phrases'index is greater than the stanza's index then go on to the next stanza
          indexPhraseFR=0;// 1rst sentence
          indexPhraseSetFR++;// increase stanza's index
          isTransitioning = true;
          startTransitionTime = millis();
        } else {
          //go to the next phrase   
          nextPhrase();
        }
        if (millis() >= startTransitionTime+transitionDuration) {
          playSound();
        }
      } else { 
        // we're reading the sound file
      }
    }
  }

  void drawText() {
    // TEXT FR
    pushMatrix();
    if (indexPhraseSetFR ==0) {
      translate(100+bottomLeftPointsXFR+bottomRightPointsXFR, 100);
    } else if (indexPhraseSetFR==1) {
      translate(100+bottomLeftPointsXFR+bottomRightPointsXFR, 100+ LINE_SPACING*4);
    } 
    // draw phrases vertically centered by moving the top up by half the line spaces
    translate(0, -1.0*LINE_SPACING*(pnts.length-1)/2.0);
    // loop through lines
    for (int i=0; i< pnts.length; i++) {
      // draw a line
     for (int j=0; j< pnts[i].length; j++) {
        pushMatrix();
        if (i<=indexPhraseFR) {
          translate(pnts[i][j].x, pnts[i][j].y);
          noFill();
          stroke(0, 200);
          strokeWeight(0.5);
          float angle = TWO_PI*10;
          //rotate (j/angle*frameCount/10);
          rotate (i/angle*2);
          line(0,0,5,5);
          //bezier(-2*(noise(5)), 2, 3*(noise(5)), -2, 5*noise(5), -4, 2, 6);
        }
        popMatrix();
      }
      // move to the next line
      translate(0, LINE_SPACING);
    }
    popMatrix();
  }

  void pauseSound() {
    AudioPlayer fr = soundsFR[indexPhraseSetFR][indexPhraseFR];
    fr.rewind();
    fr.pause();
  }

  void playSound() {
    AudioPlayer fr = soundsFR[indexPhraseSetFR][indexPhraseFR];
    fr.rewind(); 
    fr.play();
  }  
}

Can you tell us anything about WAR.wav – where to get a similar file, or at least what length it is (if that matters)?

Can’t test the sketch without it…

Dear Jeremy,
Thank you very much for your message and help. Sorry I was working away for few days and couldn’t reply properly before. I’ll put the whole sketch+wav.files in a Github, this way you will be able to test the sketch.
I narrowed down the problem and I think I don’t get the way to:

  1. read sounds files one after the other
  2. display a new sentences for each sound
  3. continue to display the previous sentences until last sound
    4.loop from start
    Here is the link to my Github repository:
    https://github.com/laurentmareschal/geomerative_minim

Thanks a lot!
Best,
L

Hello,
I’ve worked on my sketch and it almost works.:

  1. The program reads the files with minim library one after the other
  2. It screens the corresponding sentence to each sound but
    it doesn’t loop after the last sound plays…

Here is the link to my Github repository with the wav.files:
https://github.com/laurentmareschal/geomerative_minim

Thanks a lot for your help!
Best,
L