Reversing the process
I am still trying to figure out if there is a way to reverse the process on this to make it a 2 way morse code communicator. It would be cool if there was a way to read back in the beeps for dots and dashes and then convert that back to a UI text for the translation. I think the clue is in this part of the code but not sure how to go about reading the beeps back in to decode them from dots and dashes back to UI text?
// Convert the message into Morse code audio...
foreach(char letter in message)
{
if (letter == ' ')
yield return new WaitForSeconds(spaceDelay);
else
{
int index = letter - 'A';
if (index < 0)
index = letter - '0' + 26;
string letterCode = alphabet[index];
foreach(char bit in letterCode)
{
// Dot or Dash?
AudioClip sound = dotSound;
if (bit == '-') sound = dashSound;
// Play the audio clip and wait for it to end before playing the next one.
audio.PlayOneShot(sound);
yield return new WaitForSeconds(sound.length + letterDelay);
}
}
}
}
Your answer
Follow this Question
Related Questions
My audio doesn't play, I'm through my options... 1 Answer
Pulling and printing a random entry from a dictionary of a list of strings. C#. 1 Answer
Player rotation always resets. 0 Answers
Getting KeyNotFoundException and I can't understand why 1 Answer
Can Someone Explain Why Message does not show Anything In Inspector 0 Answers