How to control reading speed
in
Contributed Library Questions
•
1 year ago
I'm writing a code to "translate" word into sound but it plays it almost instantly!
I want to control how many letters/second is reading which means how many note/second it plays.
I used something to delay the processing but when I run it, the processing app freezes!
- import arb.soundcipher.*;
- SoundCipher sc = new SoundCipher(this);
- long lastTime = 0;
- void setup() {
- frameRate(10);
- sc.instrument(90);
- String geo[] = loadStrings ("dog.txt");
- String wholeText = join(geo, "");
- }
- void draw(){
- for (int i=0; i < wholeText.length(); i++) {
- char c;
- c = wholeText.charAt(i);
- println ("Now playing letter:" + c);
- sc.playNote (c -40, 100, 0.5);
- lastTime = millis();
- while (millis() - lastTime < 100){
- println("do every 1/10 of sec");
- }
- }
1