The freeware translation script Text to R2D2

Not sure where else to go? Then check here! This forum is for general questions and comments about my Freeware.
Post Reply
Posts: 2
Joined: Fri Nov 18, 2011 2:36 am

The freeware translation script Text to R2D2

Post by patforkin »

Is it possible to acquire or test the code of the "text to R2D2 translation script"?
I am interested in knowing how it works.
Regards, patforkin.
User avatar
Site Admin
Posts: 385
Joined: Fri Apr 24, 2009 12:41 am

Re: The freeware translation script Text to R2D2

Post by roger »

While I don't want to reveal the entire source code, I can at least post the code for the routine that analyzes the text and generates beeps for each character.

The application has 94 different sounds that are stored in an array called beeps(). Individual sounds in this array can be accessed by specifying an index, e.g. beeps(index) where "index" is in the range 0..93. The following code translates a string (named "Text") into an array of ASCII codes. The routine then loops through the array and determines which sound to play by subtracting 33 from each ASCII code and then playing the sound with the resulting index.

Code: Select all

  // Split Text into an array of characters
  dim chars() as string = split(Text,"")
  // Convert array of characters to an array of ASCII codes
  dim asciis() as integer
  for each char as string in chars
    asciis.Append asc(char)
  // Play the corresponding sound for each ASCII code
  for i as integer = 0 to UBound(asciis)
    dim ascii as integer = asciis(i)
    dim s as sound
    // Determine which sound to play
    if ascii < 33 or ascii > 126 then
      s = silence
      s = beeps(ascii-33)
    // Play the sound
    // wait until the sound is done playing
    loop until not s.IsPlaying
Post Reply