2
\$\begingroup\$

I'm interested in old-school RPG dialogue boxes, where text appearing in dialogue boxes is accompanied by a subtle beeping sound. This is demonstrated in a video here.

Is this morse code translated to audio?

How can I achieve such an effect?

\$\endgroup\$
1
\$\begingroup\$

Assuming the text is displayed letter by letter, you can have a single 'beep' sound, and play it every time a letter is added to the text.

You can make some exceptions, for example, play a beep only if the letter is not a symbol, or to make it more dynamic, add an additional delay when a comma (or dot) is added to the text.

\$\endgroup\$
1
\$\begingroup\$

I use this in my game, wich is in Java.

public static String GetWords(String text, float wordCount)
{
    float words = wordCount;
    int soundcounter = 0;
    boolean IS_MARKUP = false;
    Random rand = new Random();
    // loop through each character in text
    for (int i = 0; i < text.length(); i++)
    { 

        if(i == text.length() - 1 && SceneHandler.lineFinished == false){
            SceneHandler.lineFinished = true;
        }
        words--;
        if (words <= 0)
        {
            return text.substring(0, i);
        }

    }
    return text;
}

You just draw your text in your render/update method, I assume you have one, and you feed it the String you want to typewrite, the time elapsed (wich is just deltatime++) and at what character speed per second you want it to type.

GameTools.fontText.draw(fontbatch, GameTools.GetWords(fullText, timeElapsed * wordsPerSecond), 204, 143);
\$\endgroup\$
  • \$\begingroup\$ A non-discrete number of words! \$\endgroup\$ – Vaillancourt Dec 20 '15 at 20:23
0
\$\begingroup\$

This is not morse code.

You don't need a library to do this.

You could achieve the same effect by having a sound file that has different lengths of beeps interleaved with silences. The sound file must be loopable. When the text starts to be written to the screen, you start the looping sound. And when the text is done being 'typed' to the screen, you stop the sound.

I would suggest you find a web site that offers free to use sound effects, load it in your favourite audio editor (Audacity could do the trick) and modify it until it fits your needs.

\$\endgroup\$
0
\$\begingroup\$

This little JavaScript code might help you

var textSpeed = 50;
var textHolder = document.getElementById('id');
var sound = new Audio(...);
var timer = setInterval(function(){
  textHolder.innerHTML += string[i];
  if(string[i]!=' '){   //if space sound doesnt play
    sound.pause();
    sound.currentTime = 0;
    sound.play();  
  }
  i++;
  if(i>=string.length){
    clearInterval(textTimer);   
  }
},textSpeed);
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.