Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by KnightRiderGuy · Feb 02, 2016 at 02:35 PM · c#uitextaudiosourcecodepage

Convert Audio Beeps And Dashes into Text

Ok I thought this would be a cool sort of project using this morse code script I found in the Forum. Looking at it makes me think it should be possible to do the reverse, that is to say take the audio clips of the "Dash" and "Dot" and then convert them back into text (Alphabet) to make a Morse Code receiver.

Not quite sure where to begin on that but it looks possible so if someone could save be a little time and get me pointed in the right direction as to where to begin that would be great. My initial thought is that maybe the "Dash" and "Dot" clips could be identified by "AudioClip length?"

 public void PlayMorseCodeMessage(string message)
     {
         StartCoroutine("_PlayMorseCodeMessage", message);
     }
     
         private IEnumerator _PlayMorseCodeMessage(string message)
     {
         // Remove all characters that are not supported by Morse code...
         Regex regex = new Regex("[^A-z0-9 ]");
         message = regex.Replace(message.ToUpper(), "");
         
         // 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.
                     GetComponent<AudioSource>().PlayOneShot(sound);
                     yield return new WaitForSeconds(sound.length + letterDelay);
                 }
             }
         }
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image theLittleSettler · Feb 03, 2016 at 02:14 AM 0
Share

True enough, but that's kind of rough. Why not use unity's event system? iirc you can signal events from sounds...maybe that's only for animation. $$anonymous$$ight be annoying to set up if there's a bunch of different sounds though.

avatar image KnightRiderGuy theLittleSettler · Feb 03, 2016 at 01:29 PM 0
Share

Thanks @theLittleSettler, I thought of something like that. The current code uses just two short "Beep" sounds one a little longer for "Dash" and a short beep for "Dot"

I was thinking something through code to deter$$anonymous$$e the audio clip lengths and their spacing durations for word separation. I'm not great with code but it looks like a lot of that is already there in how it produces the dots and dashes. So I was wondering if it could be done in reverse somehow to turn the beeps back into a character string and print that out to a UI text. I'm just not sure where to begin with that, given enough time I'll figure it out but hoping someone will save me a lot of headache if they already have a pretty good idea ;)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

77 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

GameObject SetActive Component not working After return message 3 Answers

How do I call an DontDestroyOnLoad function on UI text 2 Answers

Changing the UI text value from server to Client side 0 Answers

Unity 4.6 Text Misbehaves During Gameplay 1 Answer

Hello, i am trying to implement Hitpoints UI for my player, so that everytime my player looses a hitpoint the value should decrement by 1. I have done creating the panel with score. Hereby attached the health script. Please Help 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges