예제 #1
0
        public static bool IsRecording(string deviceName)
        {
            int  microphoneDeviceIDFromName = Microphone.GetMicrophoneDeviceIDFromName(deviceName);
            bool flag = microphoneDeviceIDFromName == -1;

            return(!flag && Microphone.IsRecording(microphoneDeviceIDFromName));
        }
예제 #2
0
        public static AudioClip Start(string deviceName, bool loop, int lengthSec, int frequency)
        {
            int  microphoneDeviceIDFromName = Microphone.GetMicrophoneDeviceIDFromName(deviceName);
            bool flag = microphoneDeviceIDFromName == -1;

            if (flag)
            {
                throw new ArgumentException("Couldn't acquire device ID for device name " + deviceName);
            }
            bool flag2 = lengthSec <= 0;

            if (flag2)
            {
                throw new ArgumentException("Length of recording must be greater than zero seconds (was: " + lengthSec.ToString() + " seconds)");
            }
            bool flag3 = lengthSec > 3600;

            if (flag3)
            {
                throw new ArgumentException("Length of recording must be less than one hour (was: " + lengthSec.ToString() + " seconds)");
            }
            bool flag4 = frequency <= 0;

            if (flag4)
            {
                throw new ArgumentException("Frequency of recording must be greater than zero (was: " + frequency.ToString() + " Hz)");
            }
            return(Microphone.StartRecord(microphoneDeviceIDFromName, loop, (float)lengthSec, frequency));
        }
예제 #3
0
        public static void End(string deviceName)
        {
            int  microphoneDeviceIDFromName = Microphone.GetMicrophoneDeviceIDFromName(deviceName);
            bool flag = microphoneDeviceIDFromName == -1;

            if (!flag)
            {
                Microphone.EndRecord(microphoneDeviceIDFromName);
            }
        }
예제 #4
0
        public static void GetDeviceCaps(string deviceName, out int minFreq, out int maxFreq)
        {
            minFreq = 0;
            maxFreq = 0;
            int  microphoneDeviceIDFromName = Microphone.GetMicrophoneDeviceIDFromName(deviceName);
            bool flag = microphoneDeviceIDFromName == -1;

            if (!flag)
            {
                Microphone.GetDeviceCaps(microphoneDeviceIDFromName, out minFreq, out maxFreq);
            }
        }
예제 #5
0
        public static int GetPosition(string deviceName)
        {
            int  microphoneDeviceIDFromName = Microphone.GetMicrophoneDeviceIDFromName(deviceName);
            bool flag = microphoneDeviceIDFromName == -1;
            int  result;

            if (flag)
            {
                result = 0;
            }
            else
            {
                result = Microphone.GetRecordPosition(microphoneDeviceIDFromName);
            }
            return(result);
        }