Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

simple Microphone Input problem

Discussion in 'Audio & Video' started by wheatgrinder, Feb 11, 2016.

  1. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    I just started working with mic input and have been searching for confirmation that Im doing it right and that something else (dodgy driver etc) must be the problem.

    The expected behavior is that I play this game and I can hear my self in the microphone.
    The actual behavior is that I play the game and I do hear my self in the microphone, however after about 5 mins. the sound starts to get loopy.. i can hear what I said before and then the sound quickly breaks down to a noisy glitchey crackly mess.

    I broke this down to a simple to reproduce steps.
    Create new project
    Add AudioSource to my main camera
    Add new script to my main camera : micInputScript
    Contents of new script are:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.Audio;

    public class micInputScript : MonoBehaviour {
    private AudioClip _clip;

    // Use this for initialization
    void Start () {

    AudioSource aud = GetComponent<AudioSource>();
    _clip = aud.clip = Microphone.Start(null, true, 10, 16000);
    aud.loop = true; // Set the AudioClip to loop

    while (!(Microphone.GetPosition(null) > 0)) { } // Wait until the recording has started

    aud.Play(); // Play the audio source!


    }


    }

    All pretty typical from all the examples I can find on the Internets. Anyone else have this type of problem.

    Thanks
     
  2. wheatgrinder

    wheatgrinder

    Joined:
    Mar 20, 2015
    Posts:
    21
    The issue was indeed caused by dodgy hardware. Not a unity issue at all