Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Use this for initialization
- void Start () {
- _audioBand = new float[8];
- _audioBandBuffer = new float[8];
- _audioBand64 = new float[64];
- _audioBandBuffer64 = new float[64];
- _audioSource = GetComponent<AudioSource> ();
- AudioProfile (_audioProfile);
- // microphone input
- selectedDevice = Microphone.devices[0].ToString();
- _audioSource.outputAudioMixerGroup = _mixerGroupMicrophone;
- _audioSource.clip = Microphone.Start(null, true, 10, 44100);
- Debug.Log ("test");
- }
- // Update is called once per frame
- void Update () {
- if (_audioSource.clip != null)
- {
- GetSpectrumAudioSource();
- MakeFrequencyBands();
- MakeFrequencyBands64();
- BandBuffer();
- BandBuffer64();
- CreateAudioBands();
- CreateAudioBands64();
- GetAmplitude();
- MicrophoneInput();
- }
- }
- // Microphone Input
- void MicrophoneInput()
- {
- _audioSource.outputAudioMixerGroup = _mixerGroupMicrophone;
- if (Microphone.IsRecording(selectedDevice))
- {
- ramFlushTimer += Time.fixedDeltaTime;
- RamFlush();
- }
- if (!Microphone.IsRecording(selectedDevice))
- {
- _audioSource.clip = Microphone.Start(selectedDevice, true, 10, 44100);//Starts recording
- while (!(Microphone.GetPosition(selectedDevice) > 0))
- {
- } // Wait until the recording has started
- _audioSource.Play(); // Play the audio source!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement