Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1.     // Use this for initialization
  2.     void Start () {
  3.         _audioBand = new float[8];
  4.         _audioBandBuffer = new float[8];
  5.         _audioBand64 = new float[64];
  6.         _audioBandBuffer64 = new float[64];
  7.         _audioSource = GetComponent<AudioSource> ();
  8.         AudioProfile (_audioProfile);
  9.  
  10.         // microphone input
  11.  
  12.        
  13.  
  14.                 selectedDevice = Microphone.devices[0].ToString();
  15.                 _audioSource.outputAudioMixerGroup = _mixerGroupMicrophone;
  16.                 _audioSource.clip = Microphone.Start(null, true, 10, 44100);
  17.          
  18.             Debug.Log ("test");
  19.        
  20.  
  21.  
  22.        
  23.        
  24.  
  25.     }
  26.  
  27.     // Update is called once per frame
  28.     void Update () {
  29.  
  30.         if (_audioSource.clip != null)
  31.         {
  32.             GetSpectrumAudioSource();
  33.             MakeFrequencyBands();
  34.             MakeFrequencyBands64();
  35.             BandBuffer();
  36.             BandBuffer64();
  37.             CreateAudioBands();
  38.             CreateAudioBands64();
  39.             GetAmplitude();
  40.             MicrophoneInput();
  41.         }
  42.  
  43.     }
  44.  
  45.     // Microphone Input
  46.     void MicrophoneInput()
  47.     {
  48.        
  49.             _audioSource.outputAudioMixerGroup = _mixerGroupMicrophone;
  50.  
  51.  
  52.             if (Microphone.IsRecording(selectedDevice))
  53.             {
  54.                 ramFlushTimer += Time.fixedDeltaTime;
  55.                 RamFlush();
  56.             }
  57.  
  58.             if (!Microphone.IsRecording(selectedDevice))
  59.             {
  60.                 _audioSource.clip = Microphone.Start(selectedDevice, true, 10, 44100);//Starts recording
  61.                 while (!(Microphone.GetPosition(selectedDevice) > 0))
  62.                 {
  63.                 } // Wait until the recording has started
  64.                 _audioSource.Play(); // Play the audio source!
  65.             }
  66.      
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement