Ejemplo n.º 1
0
        public static FmodRecordingDevice GetDevice(int deviceIndex)
        {
            string name;

            System.Guid  guid;
            int          systemrate;
            SPEAKERMODE  speakermode;
            int          speakermodechannels;
            DRIVER_STATE state;

            FmodUtils.Check(RuntimeManager.LowlevelSystem.getRecordDriverInfo(
                                deviceIndex,
                                out name,
                                100,
                                out guid,
                                out systemrate,
                                out speakermode,
                                out speakermodechannels,
                                out state
                                ),
                            "Failed to get recording device");

            return(new FmodRecordingDevice()
            {
                DeviceIndex = deviceIndex,
                Name = name,
                SampleRate = systemrate,
                Channels = speakermodechannels,
                State = state
            });
        }
Ejemplo n.º 2
0
        //--------------------------------------------------

        public static IEnumerable <FmodRecordingDevice> GetAllDevices()
        {
            int totalMicCount;
            int connectedMicCount;

            FmodUtils.Check(RuntimeManager.LowlevelSystem.getRecordNumDrivers(out totalMicCount, out connectedMicCount), "Failed to list recording devices.");

            for (int i = 0; i < connectedMicCount; i++)
            {
                yield return(GetDevice(i));
            }
        }
Ejemplo n.º 3
0
        public global::FMOD.Sound StartRecording()
        {
            /*
             *      Create user sound to record into, then start recording.
             */
            global::FMOD.CREATESOUNDEXINFO soundInfo = new global::FMOD.CREATESOUNDEXINFO()
            {
                cbsize           = Marshal.SizeOf(typeof(global::FMOD.CREATESOUNDEXINFO)),
                format           = global::FMOD.SOUND_FORMAT.PCM16,
                defaultfrequency = SampleRate,
                length           = (uint)(SampleRate * Channels * sizeof(short)),        /* 1 second buffer, size here doesn't change latency */
                numchannels      = Channels
            };

            global::FMOD.Sound sound;
            FmodUtils.Check(RuntimeManager.LowlevelSystem.createSound(string.Empty, global::FMOD.MODE.OPENUSER | global::FMOD.MODE.LOOP_NORMAL, ref soundInfo, out sound));
            FmodUtils.Check(RuntimeManager.LowlevelSystem.recordStart(this.DeviceIndex, sound, true));

            return(sound);
        }
Ejemplo n.º 4
0
        public static global::FMOD.Sound CreateSound(int sampleSize, int channels = 1, int sampleRate = 44100)
        {
            // Explicitly create the delegate object and assign it to a member so it doesn't get freed
            // by the garbage collected while it's being used
            //_pcmReadCallback = new global::FMOD.SOUND_PCMREADCALLBACK(PcmReadCallback);
            //_pcmSetPosCallback = new global::FMOD.SOUND_PCMSETPOSCALLBACK(PcmSetPosCallback);

            global::FMOD.CREATESOUNDEXINFO soundInfo = new global::FMOD.CREATESOUNDEXINFO()
            {
                cbsize           = Marshal.SizeOf(typeof(global::FMOD.CREATESOUNDEXINFO)),
                format           = global::FMOD.SOUND_FORMAT.PCMFLOAT,
                defaultfrequency = sampleRate,
                length           = (uint)(sampleSize * channels * sizeof(float)),
                numchannels      = channels,
                //pcmreadcallback = _pcmReadCallback,
                //pcmsetposcallback = _pcmSetPosCallback
            };

            global::FMOD.Sound sound;
            FmodUtils.Check(FMODUnity.RuntimeManager.LowlevelSystem.createSound(string.Empty, global::FMOD.MODE.OPENUSER | global::FMOD.MODE.LOOP_NORMAL, ref soundInfo, out sound));
            return(sound);
        }
Ejemplo n.º 5
0
 void Do(RESULT result, string error, FmodSeverity severity = FmodSeverity.Error)
 {
     FmodUtils.Check(result, error, this.EventPath, severity);
 }