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.

The freeware translation script Text to R2D2

Postby patforkin » Sat Nov 19, 2011 5:42 am

Hallo!
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.
patforkin
 
Posts: 2
Joined: Fri Nov 18, 2011 2:36 am

Re: The freeware translation script Text to R2D2

Postby roger » Mon Nov 21, 2011 6:02 pm

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)
  next
 
  // 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
    else
      s = beeps(ascii-33)
    end
    // Play the sound
    s.Play
    // wait until the sound is done playing
    do
    loop until not s.IsPlaying
  next
 
User avatar
roger
Site Admin
 
Posts: 215
Joined: Fri Apr 24, 2009 12:41 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest