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);
        }
Exemple #2
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);
        }