Search Unity

MicControl 3

Discussion in 'Assets and Asset Store' started by MarkD, Dec 1, 2015.

  1. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193

    MicControl 3 C# is finaly here!
    (MicControl 2 users get this upgrade for free).



    After long waiting and lots of requests. MicControl is finally available in C#. Written from the ground up with several new approaches.
    With this overhaul update, users will have easier and better acces to their controller. Most of the variables are now exposed and performance has improved a lot.

    MicControl 3 has all the good old features MicControl 2 offered. Such as the well known loudness value and its bigger brother spectrumData[]! Dropping UnityScript and written in C# from the ground up.





    FAQ:

    How does it work?
    – MicControl 3 gathers data from your microphone and converts it into different types of usable values on a per frame basis. This makes it easy for users to utilize this value inside their own scripts.

    How does it perform?
    – Highly accurate and (near) real-time with little to no memory footprint.

    My devices are detected but not shown, what causes this?
    – This can happen because of your system’s language settings. When your system uses non “Latin alphabetical” characters (Mandarin, etc…) Unity might not be able to recognize your devices.
    Using the “Use default microphone device” option in your MicController, will still work though for using a single device. This will auto refer to your system default device. However unless you change your system’s language settings, you will not be albe to use multiple devices.

    Can I get detailed “spectrum data” with MicControl2?
    – Yes, support for gathering spectrum data was added in version 3.0.

    Are there any downsides to this asset?
    It costs money.
    – You might not own a microphone.
    -Because of a massive upgrade, the system no longer supports Unity version below 5.0.

    Are mobile platforms supported?
    -Yes with the exception of the Unity Web and WebGL players.
    -Supported platforms: Android (Might have issues with GearVR), iOS, Windows phone.
    -You do not have to do anything extra for mobile development. MicControl3 auto detects the platform and automatically asks the right permissions when launching your project from said platforms. So there is no need to write custom microphone permission request scripts.

    How do I access the loudness variable from C#?
    – As of MicControl 3 the system is written natively in C#!
    For legacy MicControl 2 users, simply drag the complete MicControl 2 asset folder inside the Plugins or Standard Assets folder. More info on this can be found in Unity’s scripting manual.

    I’ve read the manual provided with MicControl 3, but still cannot figure out how to call the microphone’s data. How do I do this?
    -First you must declare where the MicControl script is located (which GameObject contains this component), then use “GetComponent” to call the loudness variable.

    Create a variable in your script. Inside the editor, drag the desired MicController in here.
    public class Call_Loudness : MonoBehaviour {

    //create a slot to place our controller in which we want to call from. Instead of GameObject, one could also use MicControlC as a type.
    public GameObject controller;
    //next we need a float for easy acces to our loudness value. (Alternativly, you can also call the loudness value directly).
    float getLoudness=0.0f;

    void Update () {
    //update our float every frame with the new input value. Use this value in your code.
    getLoudness = controller.GetComponent<MicControlC> ().loudness;

    }
    }

    More examples can be found in the Code reference folder.

    I have multiple scenes that each have a controller inside them, but only the first scene works. Am I doing something wrong?
    In order to have a controller across multiple scenes, you must have a persistent controller, instead of giving each scene its own controller. You can do this by selecting “Don’t destroy on load” under advanced settings. Because this controller does not exist in other scenes, you cannot drag it into the inventory slot as you would with a single scene. Everything stays the same except one extra step, and that is to create a start function in each of your other scene scripts in order to search for your controller.

    Now you can create a script in any scene, without having a controller present.
    Tip: With a persistent controller it is best to create an empty scene with the controller in it. This is so that the controller can initialize properly and always be present in the upcoming scenes.




     
    Last edited: May 4, 2020
  2. acemullet

    acemullet

    Joined:
    Feb 6, 2016
    Posts:
    1
    Hello, I recently purchased this plugin. The demo works fine but I can't get the plugin to work. It recognizes the input devices but I don't get loudness above 0. Any ideas?
     
  3. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi, you are most likely an user with a Unity 5 version lower than 5.3 ?

    Unity 5.3 has this issue resolved (Unity 5 disables the complete audioSource when muting, this is the reason MicControl cannot get data).

    I have pushed an update out yesterday to fix this issue with all other unity versions (Unity 5.0 - 5.2.x). So the fix for those versions will be live in a few days.

    However if you send me your invoice (through the developer email), I will send you the package manually so that you can get started right away!
    http://markduisters.com/contact-2/


    greetings
    Mark Duisters
    Alzheimer Studio
     
  4. Deleted User

    Deleted User

    Guest

    Will this work on android?
     
  5. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Yes, the latest update supports mobile devices and does an automatic authentication for your device. You will need to select slot 1 (in the controller settings) as this will use the devices default build in microphone.

    Multiple clients have already utilized this on their Android devices, including myself.
     
  6. Nidhii

    Nidhii

    Joined:
    Jan 28, 2015
    Posts:
    26
    Does pick up background music of my game. This is something I don't want.
    Also does it gives me option to use mic as if its in loudspeaker mode? i want to use it from a distance as if I am using loudspeaker mode in phone
     
  7. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    1: I am not sure what you mean with background music. This asset has nothing to do with in-game audio recording. It gathers input from external (or internal) microphone and does not get in contact with any in-game AudioSources. So I guess the answer would be no, it does not pick up background music from your game.

    2: It does not give you the option to use your mic as if it is in loudspeaker mode as that mode is meant for audio output devices and not input devices such as a microphone. However I suppose you mean if it would be possible to change the microphones sensitivity and in that case yes you can change the sensitivity in order to pick up more subtle or distance audio. So you could say that it is possible to "mimic" loudspeaker mode on a microphone. Although loudspeaker mode would be for Audio output, not input.

    Several people have used this on game jams, where players had to yell from a distant into the microphone.

    I hope this answered your questions,
    have a nice day
    Mark Duisters
     
  8. minakhan01

    minakhan01

    Joined:
    Jun 17, 2016
    Posts:
    5
    If we have multiple scenes, and we add a mic control to each one, only the mic control in the first loaded scene works. "The microphone will only send data when game window is active", but what does being active mean? I am changing the scene using " SceneManager.LoadScene("SCENE_NAME", LoadSceneMode.Single);". Please help me add Mic Control in multiple scenes. Thank you :)
     
  9. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    If the controller is used for the same purpose, you can enable "Don't destroy on load" to keep the same controller across scenes.

    Are there any scripts calling on the Awake or Start function when switching to the new scene? If so, let them wait a second to give the new controller time to initialize after switching scenes.

    "While game window is active" means that as soon as the focus is no longer on the game window (clicking in the editor inspector for instance or on mobile, switching apps), the controller will stop listening to the device's microphone.
    If you are in the unity editor, the inspector will tell you if the mic is active or not. Make adjustments during runtime will pause the controller, clicking in the game window wel enable the controller.

    I hope this makes sense.
     
  10. minakhan01

    minakhan01

    Joined:
    Jun 17, 2016
    Posts:
    5
    thank you, Mark :)

    Can you give an example for "Are there any scripts calling on the Awake or Start function when switching to the new scene?". I am just calling " SceneManager.LoadScene("SCENE_NAME", LoadSceneMode.Single);" on a button click I'm googling this, but I'd really appreciate your help since I'm new to Unity.
     
  11. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    There appeared a bug in the past days that stops MicControl when switching scenes. I am working on a fix.

    In the meantime you can use a Controller with Don't destroy on load enabled. This way the same controller can be used throughout every scene.

    You can then use a gameObject search in the script that needs to call to MicControll.

    example:


    Code (JavaScript):
    1. //Place here the 'controller' you want to call loudness from in the inspector (in this case we search for it with the start function, instead of placing one in the inspector).
    2. var micController:GameObject;
    3.  
    4. function Start(){
    5. micController =  GameObject.Find("Your controller's name");
    6. }
    7. function Update(){
    8. //Use this in your script to call loudnes data from selected controller
    9. var ldness: float = micController.GetComponent(MicControl).loudness;
    10. }
     
  12. minakhan01

    minakhan01

    Joined:
    Jun 17, 2016
    Posts:
    5
    Here's the error that I'm getting, btw:

    06-18 08:47:01.908 16704 16726 I Unity : NullReferenceException: Object reference not set to an instance of an object

    06-18 08:47:01.908 16704 16726 I Unity : at MicControl.StopMicrophone () [0x00000] in <filename unknown>:0

    06-18 08:47:01.908 16704 16726 I Unity : at MicControl.Update () [0x00000] in <filename unknown>:0

    06-18 08:47:01.908 16704 16726 I Unity :

    06-18 08:47:01.908 16704 16726 I Unity : (Filename: Line: -1)
     
  13. minakhan01

    minakhan01

    Joined:
    Jun 17, 2016
    Posts:
    5
    so I have 2 game object. One MicController, which has "MicControl" attached to it and the other one "Cube", which has the script to access MicControl's data. Here's what the script looks like. I added a 5 sec delay in on start, is that what you meant by "let them wait a second to give the new controller time to initialize after switching scenes"?

    Code (CSharp):
    1.     GameObject micController;
    2.     bool micInitialized = false;
    3.  
    4.     // Use this for initialization
    5.     void Start () {
    6.         Invoke("InitializeMic", 5);
    7.     }
    8.  
    9.     void InitializeMic() {
    10.         micController = GameObject.Find ("MicController");
    11.         micInitialized = true;
    12.     }
    13.  
    14.     // Update is called once per frame
    15.     void Update () {
    16.         if (micInitialized) {
    17.             var loudness = micController.GetComponent<MicControl> ().loudness;
    18.             Debug.Log ("loudness: " + loudness);
    19.         }
    20.     }
     
  14. minakhan01

    minakhan01

    Joined:
    Jun 17, 2016
    Posts:
    5
    Hi, Mark :) It worked. I used a MicController object in my first scene and then, used Find to get it in other scenes, and it works :)
     
  15. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Yes. I am working on a new setup tutorial for multiple scenes that uses a similar setup. It is indeed best to keep the controller persistent and use a find fiction to attach your scripts.
     
  16. reesedonohue

    reesedonohue

    Joined:
    Jan 20, 2016
    Posts:
    2
    Hi, does Mic Control support multiple channels from a single Audio Source? In accessing Microphone.Start etc. I'm able to access only 2 channels per "microphone." Does MicControl 2 allow access to all inputs from an interface / Soundflower link?
     
  17. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    No, MicControl's core is build upon the microphone class of unity. It simply takes away the pain of setting everything up and puts it in an interface.

    Then all data gets converted in a simple single float value for people to interact with. Users can call this value to write "if statements" or to use it as "input" to drive physics or all other kind of things.

    MicControl 2 handles the audio part and lets users work with this single float value so that users to not have to handle these audio conversions themselves.

    The AudioSource that is used to catch this data is a mono channel audioSource. If it would be two channel, MicControl would merge them anyway.



    TL;DR: No MicControl does not support multiple AudioSource channels and only outputs 1 single float value.

    edit: As of version 3.0 MicControl gives acces to the complete Spectrum data. Users can now choose whether to use a single float, or do their own analysis.


    I hope this information is of any help.

    greetings
    Mark Duisters
    Alzheimer Studio
     
    Last edited: Sep 20, 2016
  18. AllanMSmith

    AllanMSmith

    Joined:
    Oct 2, 2012
    Posts:
    180
    Hello,

    My team is about to start working on a Karaoke type of game and I'd like to know if your plugin can be used to somehow detect accuracy between singer/music playing. Doesnt need to be ultra precise or anything, but the closest to the expected, the better. From what I've read I don't think your solution would be the right match honestly but I am hoping that Im wrong! =P

    Anyway, thanks for the attention, and btw, if you don't think your plugin would be the right fit for a game like this, would you recommend another that could help in this regard?

    Thank you very much,
    Best regards,
    Allan
     
  19. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193

    Wel, since the input is converted to a float value, you have an accurate realtime numerical value (based on the microphone input) that you can use in your scripts. You can increase the sensitivity and tweak the frequency (for more precision).

    But however, for karaoke there will be limitations to keep in mind as you are not interacting with the audio stream directly. This causes a slight micro delay, which you might not want in the case of precise voice tracking.

    There is also now way to differentiate between pitch, volume or speed in this float value. You can calculate averages to get close to this, but again this causes extra frames and thus deviates from your music line. This also means that people with an average voice will have better results with karaoke as they will most likely come closest to your set defaults.

    This all said, it is possible, as clients have used it for "karaoke" on mobiles. But they used MicControl as a base input and to detect voice strength and build a detection system around it.
    An example would be if you have 3 karaoke tabs passing by on screen (which is a system you have to write yourself). You can have an if statement listening to the controller:

    Code (JavaScript):
    1. //if the microphone strenght is between these limits score a point if(micController.loudness >= karaokeValue && micController.loudness <= karaokeValue2){
    2. //score points here?
    3. }
    The script is also written in UnityScript, so if you are using C# you will have to move it into a Plugins folder (compilation reasons).

    For more questions or detailed support feel free to contact me at duistersmark@hotmail.com
    As you will receive answers much faster.


    ps. The system supports multiple microphone setup, by simply placing two controllers in the scene.
     
  20. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193

    Hi there, I wanted to let you know that version 3.0 will be live soon, which provides acces to a microphone's spectrum data, this is detailed information of the audio that the microphone is receiving and not just a single float like before.

    greetings.
     
  21. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    Hi,
    your tech demo binary linked from the asset store page picks up connected Kinect microphone array and works reliably with it, which is why I purchased this.

    However, the latest version from the Assetstore doesn't start with Kinect set as default recording device - the Editor locks up as does standalone Windows build ( you should consider not having while/for loops without coroutine and proper yielding anywhere in your code ).

    What Unity version did you use to build version 2.7.1 of MicControl and/or did you make changes that would prevent MicControl not to properly detect Kinect microphone in later versions ?

    Thanks!
     
  22. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi there, the tech demo was build with Unity 5.2.x

    Since Unity 5.4 there have been some api changes, which caused the editor to crash. This is fixed in the latest update, which went live yesterday.

    Could you mail me some screenshots of your issue? I will be able to support you better this way.
    We will work this out together.

    contact form: http://markduisters.com/contact/

    greetings
    Mark Duisters
     
  23. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    no i don't have a screenshot
    - the editor becomes unresponsive as in 'does not react to mouse and keyboard input' upon hitting Play on the first scene ( the only way close it is to kill process ), same for standalone windows build

    the problem is probably this line:

    Code (CSharp):
    1. while (!(Microphone.GetPosition(selectedDevice) > 0)){} // Wait until the recording has started
    ( since it can't init the device this loops and blocks the editor/process )

    Nevertheless - even if you fixed startup while being unable to initialize the device this still wouldn't explain why Kinect initialization was fine in 2.7.1 version

    I will try Unity 5.2.x
     
  24. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    OK, so Unity 5.2.0f3 / 5.2.5f1 can use Kinect microphone without problems.

    Something else must have changed with the mic input from 5.3 onwards. I haven't looked into 5.4 / 5.5 yet, maybe it would be worth a shot. ( maybe not )

    Cheers!
     
  25. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi, that code snipped is not a "bug" or "issue" it is a safe guard, to only execute the code when at least 1 device is detected. So if that part is what is causing you issues, it simply means that either Unity or your System does not detect the device.

    As you can see below only two branches exist on the asset store. If older Unity versions do detect your kinect, it might be an issue with later Unity builds. As "algorithm wise" nothing has changed in the detection, calculation and interpretation process. The only thing added in the latest version is full spectrum data analysis, which is a complete algorithm on its own and does not interfere with the classic "loudness" value.

    upload_2016-10-5_20-21-43.png

    I will however conduct some research on which aspect of Unity could have the issue (all versions above 5.3.x). In the mean time, please do check your inspector settings. If your kinect is not your default device, it is best to manually select one from the inspector (by turning of use default device).

    upload_2016-10-5_20-26-25.png

    greetings
     
  26. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    the code is indeed a wrong way to write correct unity code - you see, until the
    Code (CSharp):
    1. Microphone.GetPosition(selectedDevice)
    returns > 0, that code loops and blocks the whole editor thread - and my suspicion (untested and unconfirmed though) is that this is exactly what is happening. If - for WHATEVER reason a device cannot be initialized ( and it is in my case with Kinect microphone on Unity 5.3. ) - that code would block - the best practice in this case is to wrap the init function in coroutine and yield null until the device is successfully initialized.

    I, of course, have Kinect microphone as DEFAULT system recording input device and this was the setup which I tested with. ( and I can see it in inspector, of course )
     
  27. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I will most definitely have a look at it! I myself never ran into any issues. But even if it just happens on a small basis, it should be fixed.

    It makes indeed sense now that I look into it, that the editor might get blocked. The problem never occurred (or did not get reported to me). It is a good thing you pointed this out. I will keep you posted.


    Edit: I tested out to manually cause a big error in both Unity 5.3 and 5.4 and even if no device is detected (thus equal or les than 0), the editor still responds, it simply does not execute the UI of the script (which was intended). It is weird that this same thing would freeze your editor, I of course believe you and will look further into it.
     
    Last edited: Oct 5, 2016
  28. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    I highly doubt your research would yield any fruits since you would need Kinect device to test with its mic in the first place. But you don't have to, really: I've already confirmed that Unity Microphone input ( and your plugin ) works in conjunction with Kinect microphone on pre-5.3, and later Unity versions are either buggy or incomplete in this regard.

    I might not use Kinect for our purposes at all, or I might look whether FMOD can see things differently with AudioStream.

    Thanks for now & cheers!
     
  29. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I am looking into a workaround, that could solve your freezing issue. The reason the while loop is also used, is to prevent delay in the connection. For instance, when I would use an if statement, the input will only start after the same time as it would buffer. Which means for a 1 second buffer time, it would be a 1 second delay. When using the while loop, this gets bypassed and a direct stream is allowed in MicControl2.
     
  30. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I think the workaround should work. I managed to create a situation that froze the editor. And I replaced the while loop with a new if statement containing a yield. This approach did not froze the editor. Would you fancy testing it out? If so send me an e-mail or dm me your mail adres so that a personal build can be send to you.

    greetings
    Mark
     
  31. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    All you have to do is yield the loop:
    Code (CSharp):
    1. while (!(Microphone.GetPosition(selectedDevice) > 0)) { yield return null; } // Wait until the recording has started
    EDIT: after checking the audio clip for null after Microphone.Start, of course. The loop cycle wouldn't be even executed then if it was...


    ( NOTE: it might not be the cause of not starting the app with invalid device; I've just skimmed the source, but tight non yielded while/for loops are the usual cause for editor freezes - that's why I mentioned it )

    Cheers!
     
    Last edited: Oct 6, 2016
  32. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I changed some things in the code. An update should be live in a few days (probably next week). If you still have issues, I suspect Unity might have changed something which is out of my reach (in its later versions).

    Thanks for pointing out my error in the while loop!

    have a nice day

    Mark Duisters
     
  33. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    Hello,

    I just imported your asset and moved the entire MicControl2 folder to the Plugins folder since I'm a C# user. I am getting 2 errors:

    get_activeGameObject is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'MicControlEditor'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEditor.Selection:get_activeGameObject()
    MicControlEditor:.ctor() (<PROJECT PATH> /Plugins/MicControl2/Source/Editor/MicControlEditor.js:9)

    and

    FileNotFoundException: D:/<PROJECT PATH>/Assets/MicControl2/Source/MicControlGizmo.tif does not exist
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:107)
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:86)
    MicControl.OnDrawGizmos () (at Assets/Plugins/MicControl2/Source/Code/MicControl.js:402)
    UnityEditor.DockArea:OnGUI()

    The second one is a mystery to me because that file does most certainly exist. I have noticed that its not trying to look in the plugins folder for it but rather the assets folder. Have I done something wrong?

    Thanks!
     
  34. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    issue 1: Have you updated the package? The first error was an editor bug in a previous version, a fix went live a few days ago. This error may also appear if you are in WebPlayer mode.

    issue 2: It seems that one of the gizmo icons is not available. Minimizing Unity and then re-opening Unity should trigger MicControl2 to create a new folder on the correct location. When you moved MicControl to the "Plugins" folder, did you by accident also move the "gizmo" folder? If so, simply place the gizmo folder back in the Asset root. That is where Unity expects it to be.

    The folder structure should look like this then: folder structure.PNG

    As you can see in the grey bar below, no errors.

    Your build settings should look like this (simply not select WebPlayer mode): build setting.PNG


    Should the "Plugins" folder still fail, you can try placing MicControl2 in the "Standard Assets" folder, as it has the same compilation order as the "Plugins" folder.

    I hope this helps you out. If you still run into problems, you can contact me with more detailed information of your problem through this form: http://markduisters.com/contact/
     
  35. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    I imported directly from the asset store last night. Maybe it is because I am not importing the examples with it?
     
  36. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    The examples do not influence the functionality of MicControl2, so that should not be the issue. Which Unity version are you using? Unity 5.3.x uses a slightly older version of MicControl2 which still might contain the editor bug. 5.4.x and up have the latest patched version of MicControl2.

    Could you perhaps send some more information: What devices are you using (microphones), Unity version, operating system, etc...
     
  37. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    ok - I redownloaded and reimported MicControl2 (with none of the examples). This time I left it in my assets folder - no longer getting the missing gizmo error.
    I do still get:

    get_activeGameObject is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'MicControlEditor'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEditor.Selection:get_activeGameObject()
    MicControlEditor:.ctor() (at Assets/MicControl2/Source/Editor/MicControlEditor.js:9)


    I'm on Win10, Unity 5.4.0f3, I have a Microsoft webcam set as default device for testing but also tested it with my Vive (this is for a VR game).

    Everything appears to work fine but when I try to find the component MicControl it doesn't find the component/class in C#...

    I have a public gameobject micController - this is fulled in in the inspector with my MicController. in script I have

    radius = micController.GetComponent<MicController>().loudness; <-- the bolded Mic Controller class is never found and due to that I cannot access the loudness variable. I assume this all stems

    Edit** I just moved the MicControl2 folder to standard assets and it no longer has the gizmo error as it did before. But the above error is still true and I still cannot access the MicControl class via script.

    Thanks for you help so far! I really appreciate it.
     
    Last edited: Oct 7, 2016
  38. Fairennuff

    Fairennuff

    Joined:
    Aug 19, 2016
    Posts:
    88
    Update**
    All fixed. I updated my unity to 5.4.1 and updated the asset then reimported and moved to plugins folder. Working like a charm! Thank you very much. Great asset!!
     
  39. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I received several e-mails having your issue in Unity 5.4.0fx, I suspect there is a bug in that specific version. Thanks for letting me know your version, this helps in future support. Have fun with the asset!

    Should you run into future problems or if you have questions, feel free to contact me again.
     
  40. ehmkey

    ehmkey

    Joined:
    Oct 18, 2014
    Posts:
    1
    Hi, i'm interested in this nice asset.

    I created a network game and I'd like to implement a push-to-talk functionality.
    It's thinkable to to do it with micControl?

    Thank you!
     
  41. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    No, MicControl is not a streaming asset. It converts audio to usable float values, in order to create interaction/game mechanics. I repeat it is not suited for VOIP or network based voice communication and not even capable of it!

    Hope this helps

    greetings
    Mark Duisters
    Alzheimer Studio
     
  42. trevorchico

    trevorchico

    Joined:
    Feb 1, 2016
    Posts:
    7
    Hi I can't get it to work, developing for Samsung Gear VR. Has this come up at all for you?

    In editor and when building to Android the asset works great. When I check "VR Enabled" The mic does not record. The script running because it can show me the frequency from the MicControl script, but registers 0 for loudness.

    Any thoughts?

    5.5.1f1
     
  43. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,
    Yes Samsung VR is one of the platforms that has some issues. However they are by-passable.
    There are two tings that need to be done:

    1-: Double check your microphone permission manifest.
    (quote from another forum) "For microphone input to work with the gearvr you have make sure the microphone permission is in your Androidmanifest.xml permissions sections.
    if you have no Androidmanifest.xml in your project make one in Plugins/Android/ and make sure that this line is in there: <uses-permission android:name="android.permission.MICROPHONE" />

    for the Androidminfest.xml i just de basic template of google vr manifest"



    2-: MicControl uses the "OnApplicationFocus and OnApplicationPause" to determine whether MicControl should receive data. This is done to prevent input lag (if you are not in your app but MicControl is active, it can introduce delays up to a few seconds). In the case of gear VR this is a blocker. Because of the external platform MicControl most of the time keeps thinking you are not inside your app, and simply pauses the input.

    So if you go to the source code (in the source folder) and comment away lines from 359 to 370 and then on line 62 manually set focused op true, your problem "should" be fixed for that specific situation. However this has sometimes worked and other times it has not. Lots of factor play a role in this, android distro, external connections (such as the gear VR), etc....

    But give it a go and let me know how it works out for you.


    I hope this was somewhat useful.

    greetings
    Mark Duisters
     
  44. trevorchico

    trevorchico

    Joined:
    Feb 1, 2016
    Posts:
    7
    Hey Mark, thanks for the response! you were right, I got it to work on the Gear VR by removing the focus code.

    I'm detecting when a user makes any loud noise, if you have any thoughts on how to optimize the tool to take the least amount of memory let me know! The MicControl.Update() sometimes takes up a good amount of space, I'm working in mobile VR so every drop in frame rate hurts me.

    Cheers,

    Trev
     
  45. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    If you use the regular .loudness value (thus disabling spectrum data analysis), the memory footprint will already be very low. However to reduce it even more (at the cost of accuracy), you can lower your "Sample amount", in order to buffer fewer frequencies values per call.

    And if you would go all out in reducing the memory footprint, you could get rid of the "Update()" for your own function and trigger it manually (however this might increase the risk of input lag/dealy).
     
  46. pramod_ramdurg

    pramod_ramdurg

    Joined:
    Mar 3, 2017
    Posts:
    1
    Hi Mark
    I am trying to detect air blow from mic using android device. Is it possible in your plugin?
     
  47. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Yes, this is exactly where the plugin was designed for in the first place.
    All you need to do is write an if statement of the blowing strength that needs to get passed and execute the code in there when it does!
     
  48. jogle

    jogle

    Joined:
    Dec 12, 2016
    Posts:
    1
    I'm getting error CS0103: The name 'MicControl' does not exist in the current context. Here's my script:


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class ballLoudness : MonoBehaviour {

    GameObject micController;


    // Use this for initialization
    void Start () {
    if (micController == null)
    {

    micController = GameObject.Find("MicController"); //this name can by any name given to your controller, if you have multiple controllers be sure to type the correct name here.

    }

    }

    // Update is called once per frame
    void Update () {
    float loudnessValue = micController.GetComponent<MicControl>().loudness;
    print("The loudness is" + loudnessValue);

    }
    }
     
  49. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi Jogle,

    Have you upgraded to MicControl 3 C#? If so, from that version you need to call "MicControlC" instead of "MicControl". This should fix your issue.

    If you have an older version (MicControl 2.x). Those versions are written in UnityScript, thus in order for C# to be able to call those values, you will have to place them inside either "Standard Assets" or a "Plugins" folder. This is due to Unity's order of compilations (see the Unity docs on compilation order).

    Since you are writing in C#, I highly recommend upgrading to MicControl 3 which is natively written in C#.

    Let me know if either solution works!
     
    jogle likes this.
  50. Stebello89

    Stebello89

    Joined:
    Feb 20, 2017
    Posts:
    1
    Hi Mark,

    Is MicControl 3 good to get a precise range of MHz? My question is if it's possible to detect the pitch from the microphone and translate it in a usable value, let's say to create a Singstar clone.

    Cheers,
    Stefano