Exemplo n.º 1
0
 public void ShutDown()
 {
     if (!Enabled)
     {
         return;
     }
     if (musicChannel != null)
     {
         musicChannel.Stop();
     }
     if (music != null)
     {
         music.Release();
     }
     if (sounds != null)
     {
         foreach (var s in sounds.Values)
         {
             s.Channel.Stop();
             s.InnerSound.Release();
         }
     }
     system.Close();
     system = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Stop and try to release FMOD sound resources
        /// </summary>
        void Stop_Internal()
        {
            this.GetComponent <AudioSource>().Stop();

            this.isRecording = false;
            this.isPaused    = false;

            /*
             *  Shut down sound
             */
            if (sound != null)
            {
                result = sound.release();
                ERRCHECK(result, "sound.release", false);
            }

            sound = null;

            /*
             * Shut down
             */
            if (system != null)
            {
                result = system.close();
                ERRCHECK(result, "system.close", false);

                result = system.release();
                ERRCHECK(result, "system.release", false);
            }

            system = null;
        }
Exemplo n.º 3
0
        public static void StaticLoadPlugins(List <string> pluginNames, FMOD.System coreSystem,
                                             Dictionary <string, uint> loadedPlugins, Action <FMOD.RESULT, string> reportResult)
        {
#if USE_FMOD_NATIVE_PLUGIN_INIT
            FmodUnityNativePluginInit(coreSystem.handle);
#endif
        }
Exemplo n.º 4
0
        public static FMOD.RESULT createSound(this FMOD.System system, IntPtr data, FMOD.MODE mode, ref FMOD.CREATESOUNDEXINFO exinfo, ref FMOD.Sound sound)
        {
            FMOD.RESULT result   = FMOD.RESULT.OK;
            IntPtr      soundraw = new IntPtr();

            FMOD.Sound soundnew = null;

            try
            {
                result = FMOD_System_CreateSound(system.getRaw(), data, mode, ref exinfo, ref soundraw);
            }
            catch
            {
                result = FMOD.RESULT.ERR_INVALID_PARAM;
            }
            if (result != FMOD.RESULT.OK)
            {
                return(result);
            }

            if (sound == null)
            {
                soundnew = new FMOD.Sound();
                soundnew.setRaw(soundraw);
                sound = soundnew;
            }
            else
            {
                sound.setRaw(soundraw);
            }

            return(result);
        }
Exemplo n.º 5
0
        public SoundSystem()
        {
            var ret = FMOD.Result.OK;

            system = null;

            try
            {
                FMOD.Factory.CreateSystem(ref system);
            }
            catch (DllNotFoundException)
            {
                return;
            }
            if (ret != FMOD.Result.OK)
            {
                return;
            }
            ret = system.Initialize(8, FMOD.InitFlags.Normal, IntPtr.Zero);
            if (ret != FMOD.Result.OK)
            {
                system = null;
                return;
            }
            sounds       = new Dictionary <string, Sound>();
            music        = null;
            musicChannel = null;
        }
Exemplo n.º 6
0
        public static Equalizer GetEqualizer(FMOD.System system, PlayerSettings settings)
        {
            var eq = new Equalizer(system, settings);

            eq.Initializied = true;
            return(eq);
        }
Exemplo n.º 7
0
 public SoundOut(FMOD.System newsys)
 {
     system          = newsys;
     thisLock        = new Object();
     readySound      = new SoundProvider(this.system);
     soundDataBuffer = new CircularBuffer(frequency * soundDataBufferTime * channelCount);
 }
            public RESULT getLowLevelSystem(out FMOD.System system)
            {
                RESULT result    = RESULT.OK;
                IntPtr systemraw = new IntPtr();

                system = null;

                try
                {
                    result = FMOD_Studio_System_GetLowLevelSystem(rawPtr, out systemraw);
                }
                catch
                {
                    result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                    return(result);
                }

                system = new FMOD.System();
                system.setRaw(systemraw);

                return(result);
            }
Exemplo n.º 9
0
            public SoundLib()
            {
                if (system != null)
                {
                    return;
                }

                FMOD.RESULT result = FMOD.Factory.System_Create(out system);
                if (ERRCHECK(result, "System_Create"))
                {
                    return;
                }

                uint version;

                result = system.getVersion(out version);
                ERRCHECK(result, "system.getVersion");
                if (version < FMOD.VERSION.number)
                {
                    Report.ReportLog("Error! Old version of FMOD " + version.ToString("X") + " detected.  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                    system.close();
                    system.release();
                    system = null;
                    return;
                }

                result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                if (ERRCHECK(result, "system.init"))
                {
                    system.close();
                    system.release();
                    system = null;
                    return;
                }
            }
Exemplo n.º 10
0
        public static Sound CreateJingle(FMOD.System newsys, string filename)
        {
            Sound sound = new Sound(newsys);

            sound.JingleInit(filename);
            return(sound);
        }
Exemplo n.º 11
0
        void OnDisable()
        {
            this.StopFMODSound();

            if (this.pcmReadCallbackBuffer != null)
            {
                this.pcmReadCallbackBuffer[0].Clear();
                this.pcmReadCallbackBuffer[1].Clear();

                this.pcmReadCallbackBuffer[0] = null;
                this.pcmReadCallbackBuffer[1] = null;

                this.pcmReadCallbackBuffer.Clear();
                this.pcmReadCallbackBuffer = null;
            }

            this.pcmreadcallback   = null;
            this.pcmsetposcallback = null;

            if (system != null)
            {
                result = system.close();
                // ERRCHECK(result, "system.close", false);

                result = system.release();
                // ERRCHECK(result, "system.release", false);
            }

            system = null;
        }
Exemplo n.º 12
0
        // static constructors
        public static Sound CreateSound(FMOD.System newsys)
        {
            Sound sound = new Sound(newsys);

            // sound.SoundInit(pcmReadCallback, pcmSetPosCallback);
            return(sound);
        }
Exemplo n.º 13
0
        public static Sound CreateStream(FMOD.System newsys, string connectionUrl, FMOD.SOUND_PCMREADCALLBACK pcmReadCallback, FMOD.SOUND_PCMSETPOSCALLBACK pcmSetPosCallback)
        {
            Sound sound = new Sound(newsys);

            sound.StreamInit(connectionUrl, pcmReadCallback, pcmSetPosCallback);
            return(sound);
        }
Exemplo n.º 14
0
        public SoundSource(FMOD.System system, FMOD.Sound sound, int posx, int posy)
        {
            FMOD.RESULT result;

            mPos.x = posx;
            mPos.y = posy;
            mPos.z = 0;

            mVel.x = 0;
            mVel.y = 0;
            mVel.z = 0;

            mSystem = system;

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, true, ref mChannel);
            VirtualVoices.ERRCHECK(result);

            SetPosition(mPos.x, mPos.y);

            Random r = new Random(posx);

            result = mChannel.setFrequency(r.Next(22050, 44100));
            VirtualVoices.ERRCHECK(result);

            result = mChannel.setPaused(false);
            VirtualVoices.ERRCHECK(result);

            mBrushBlue = new SolidBrush(Color.Blue);
            mBrushRed  = new SolidBrush(Color.Red);
        }
Exemplo n.º 15
0
 public void CleanUp()
 {
     this.DeInit(this.fmodSystem);
     this.Bands.Clear();
     this.fmodSystem     = null;
     this.playerSettings = null;
 }
Exemplo n.º 16
0
        public SoundSystem()
        {
            var ret = FMOD.Result.OK;

            system = null;
            Program.WriteLine("SoundSystem: _ctor");
            if (!IniFile.GetValue("audio", "enabled", true))
            {
                return;
            }
            musicVolume = IniFile.GetValue("audio", "musicvolume", 100) / 100f;
            soundVolume = IniFile.GetValue("audio", "soundvolume", 100) / 100f;

            Program.Write("SoundSystem: trying to create FMOD system...");
            try
            {
                FMOD.Factory.CreateSystem(ref system);
            }
            catch (DllNotFoundException)
            {
                Program.WriteLine(" Library not found. Disabling sound.");
                return;
            }
            Program.WriteLine(" " + ret.ToString());
            if (ret != FMOD.Result.OK)
            {
                return;
            }
            Program.Write("SoundSystem: system.init...");
            ret = system.Initialize(8, FMOD.InitFlags.Normal, IntPtr.Zero);
            Program.WriteLine(" " + ret.ToString());
            if (ret != FMOD.Result.OK)
            {
                system = null;
                return;
            }
            music        = null;
            musicChannel = null;

            sounds = new Dictionary <string, Sound>();

            Program.WriteLine("SoundSystem: loading libraries...");
            musicLibrary = Mix.GetTokenTree("music.tml");
            soundLibrary = Mix.GetTokenTree("sound.tml");

            Program.WriteLine("SoundSystem: _ctor DONE");
            Program.WriteLine("Null report:");
            if (system == null)
            {
                Program.WriteLine(" * system");
            }
            if (music == null)
            {
                Program.WriteLine(" * music");
            }
            if (musicChannel == null)
            {
                Program.WriteLine(" * musicChannel");
            }
        }
Exemplo n.º 17
0
        private void Init(FMOD.System system, bool setToDefaultValues = false)
        {
            system.lockDSP().ERRCHECK();

            this.Bands.Clear();
            var gainValues = !setToDefaultValues && this.playerSettings.PlayerEngine.EqualizerSettings != null
                ? this.playerSettings.PlayerEngine.EqualizerSettings.GainValues
                : null;

            foreach (var value in EqDefaultValues)
            {
                var band = EqualizerBand.GetEqualizerBand(system, this.IsEnabled, value[0], value[1], value[2]);
                if (band != null)
                {
                    float savedValue;
                    if (gainValues != null && gainValues.TryGetValue(band.BandCaption, out savedValue))
                    {
                        band.Gain = savedValue;
                    }
                    this.Bands.Add(band);
                }
            }

            system.unlockDSP().ERRCHECK();
            system.update().ERRCHECK();
        }
Exemplo n.º 18
0
        // Loads dynamic FMOD plugins for this platform.
        public virtual void LoadDynamicPlugins(FMOD.System coreSystem, Action <FMOD.RESULT, string> reportResult)
        {
            List <string> pluginNames = Plugins;

            if (pluginNames == null)
            {
                return;
            }

            foreach (string pluginName in pluginNames)
            {
                if (string.IsNullOrEmpty(pluginName))
                {
                    continue;
                }

                string pluginPath = GetPluginPath(pluginName);
                uint   handle;

                FMOD.RESULT result = coreSystem.loadPlugin(pluginPath, out handle);

#if UNITY_64 || UNITY_EDITOR_64
                // Add a "64" suffix and try again
                if (result == FMOD.RESULT.ERR_FILE_BAD || result == FMOD.RESULT.ERR_FILE_NOTFOUND)
                {
                    string pluginPath64 = GetPluginPath(pluginName + "64");
                    result = coreSystem.loadPlugin(pluginPath64, out handle);
                }
#endif

                reportResult(result, string.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath));
            }
        }
Exemplo n.º 19
0
        ///<summary>
        ///    Return an array of strings which are the driver names for the "microphone" devices.
        ///</summary>
        public string[] GetAllMicrophoneDevices(FMOD.System fmod)
        {
            FMOD.RESULT   result;
            int           numSoundSources = 0;
            StringBuilder drivername      = new StringBuilder(256);

//             result = system.setDriver(selected);
//             ERRCHECK(result);

            // Get Record drivers
            result = fmod.getRecordNumDrivers(ref numSoundSources);
            CheckRetCode(result);

            string[] soundSourceNames = new string[numSoundSources];

            for (int count = 0; count < numSoundSources; count++)
            {
                FMOD.GUID guid = new FMOD.GUID();
                result = fmod.getRecordDriverInfo(count, drivername, drivername.Capacity, ref guid);
                // result = fmod.getRecordDriverName(count, drivername, drivername.Capacity);
                CheckRetCode(result);
                soundSourceNames[count] = drivername.ToString();
            }
            return(soundSourceNames);
        }
Exemplo n.º 20
0
 public void Dispose()
 {
     if (_fmodEngine != null)
     {
         _fmodEngine.release();
         _fmodEngine = null;
     }
 }
Exemplo n.º 21
0
        public FMOD_SoundBuffer(FMOD_Audio audio, string filename)
        {
            mAudio  = audio;
            mSystem = mAudio.FMODSystem;


            FMOD_Audio.CheckFMODResult(mSystem.createSound(filename, FMOD.MODE.DEFAULT, ref mSound));
        }
Exemplo n.º 22
0
        // Loads static FMOD plugins for this platform.
#if ENABLE_IL2CPP
        public virtual void LoadStaticPlugins(FMOD.System coreSystem, Action <FMOD.RESULT, string> reportResult)
        {
            if (StaticPlugins.Count > 0)
            {
                FMOD.RESULT result = FMOD_Unity_RegisterStaticPlugins(FMOD.VERSION.dll, coreSystem.handle);
                reportResult(result, "Registering static plugins");
            }
        }
Exemplo n.º 23
0
 public virtual void LoadStaticPlugins(FMOD.System coreSystem, Action <FMOD.RESULT, string> reportResult)
 {
     if (StaticPlugins.Count > 0)
     {
         Debug.LogWarningFormat(
             "{0} static plugins specified, but static plugins are only supported on the IL2CPP scripting backend",
             StaticPlugins.Count);
     }
 }
Exemplo n.º 24
0
        public override void Dispose()
        {
            if (mSystem != null)
            {
                mSystem.release();
                mSystem = null;
            }

            mIsDisposed = true;
        }
Exemplo n.º 25
0
        public static void StaticLoadPlugins(Platform platform, FMOD.System coreSystem,
                                             Action <FMOD.RESULT, string> reportResult)
        {
            platform.LoadStaticPlugins(coreSystem, reportResult);

#if USE_FMOD_NATIVE_PLUGIN_INIT
            // Legacy static plugin system
            FmodUnityNativePluginInit(coreSystem.handle);
#endif
        }
Exemplo n.º 26
0
        public FMOD_Music(FMOD_Audio audio, string filename)
        {
            mAudio  = audio;
            mSystem = mAudio.FMODSystem;

            FMOD.RESULT result = mSystem.createStream(filename,
                                                      FMOD.MODE.LOOP_NORMAL | FMOD.MODE.ACCURATETIME, ref mSound);

            CreateChannel();
        }
Exemplo n.º 27
0
 public void ShutDown()
 {
     if (!Enabled)
     {
         return;
     }
     StopEverything();
     system.Close();
     system = null;
 }
Exemplo n.º 28
0
        public void Dispose()
        {
            if (_system != null)
            {
                _system.close();
                _system.release();

                _system = null;
            }
        }
Exemplo n.º 29
0
        static GmfSound()
        {
            sys = new FMOD.System();
            FMOD.Factory.System_Create(ref sys);
            sys.init(64, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);

            for (int i = 0; i < sounds.Length; ++i)
            {
                sys.createStream(string.Format("Sound/{0}.wav", i), FMOD.MODE.DEFAULT, ref sounds[i]);
            }
        }
Exemplo n.º 30
0
 public SoundIn(FMOD.System newsys, string connectionUrl)
 {
     newsys.CheckNull("SoundIn newsys");
     system           = newsys;
     ads              = new AdKillingThread();
     ads.ThreadReady += this.HandleThreadReady;
     SoundDataBuffer  = new CircularBuffer(pumpedBuffer);
     streamSound      = new SoundProvider(this.system, connectionUrl);
     this.SoundSource = streamSound;
     streamSound.Sounds.PlaySound();
 }
Exemplo n.º 31
0
        public Listener(FMOD.System system, float posx, float posy)
        {
            mUp.x = 0;
            mUp.y = 0;
            mUp.z = 1;

            mForward.x = 1;
            mForward.y = 0;
            mForward.z = 0;

            mVel.x = 0;
            mVel.y = 0;
            mVel.z = 0;

            mSystem = system;

            SetPosition(posx, posy);

            mBrush = new SolidBrush(Color.Black);
        }
Exemplo n.º 32
0
        private Equalizer(FMOD.System system, PlayerSettings settings)
        {
            this.playerSettings = settings;
            this.Name = "DefaultEqualizer";
            this.fmodSystem = system;
            this.Initializied = false;
            this.Bands = new ObservableCollection<EqualizerBand>();
            this.IsEnabled = settings.PlayerEngine.EqualizerSettings == null || settings.PlayerEngine.EqualizerSettings.IsEnabled;

            this.WhenAnyValue(x => x.IsEnabled)
                .Subscribe(enabled => {
                    if (!this.Initializied || enabled)
                    {
                        this.Init(this.fmodSystem);
                    }
                    else if (this.Initializied)
                    {
                        this.SaveEqualizerSettings();
                        this.DeInit(this.fmodSystem);
                    }
                });
        }
Exemplo n.º 33
0
        public SoundSource(FMOD.System system, FMOD.Sound sound, int posx, int posy)
        {
            FMOD.RESULT result;

            mPos.x = posx;
            mPos.y = posy;
            mPos.z = 0;

            mVel.x = 0;
            mVel.y = 0;
            mVel.z = 0;

            mSystem = system;

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, true, ref mChannel);
            VirtualVoices.ERRCHECK(result);

            SetPosition(mPos.x, mPos.y);

            Random r = new Random(posx);

            result = mChannel.setFrequency(r.Next(22050, 44100));
            VirtualVoices.ERRCHECK(result);

            result = mChannel.setPaused(false);
            VirtualVoices.ERRCHECK(result);

            mBrushBlue = new SolidBrush(Color.Blue);
            mBrushRed  = new SolidBrush(Color.Red);
        }
Exemplo n.º 34
0
 public FMODSystem(FMOD.System system)
 {
     this.system = system;
 }
Exemplo n.º 35
0
 public void Dispose()
 {
     if (_fmodEngine != null)
     {
         _fmodEngine.release();
         _fmodEngine = null;
     }
 }
Exemplo n.º 36
0
        public RESULT getLowLevelSystem(out FMOD.System system)
        {
            system = null;

            IntPtr systemraw = new IntPtr();
            RESULT result = FMOD_Studio_System_GetLowLevelSystem(rawPtr, out systemraw);
            if (result != RESULT.OK)
            {
                return result;
            }

            system = new FMOD.System(systemraw);

            return result;
        }
Exemplo n.º 37
0
        private void ResetEverything()
        {
            // Stopping Music
            if(fmodChannel != null)
                fmodChannel.stop();

            fmodSystem = null;
            fmodChannel = null;
            theSong = null;
            szSongName = "";
            nCurrentPositionMS = 0;
            nLengthMS = 0;
            bPlaying = false;
            bIsFastforwarding = false;
            bIsRewinding = false;
            bPaused = false;
            //bFreq = false;
            bRunning = true;
            bListChanged = false;

            listBeats = new List<Beat>();

            MouseAddBeat = new Beat();
            szClickedEventEdit = "";

            nMouseScroll = 0;

            MouseSelectStartPoint = new Point();

            MouseSelectRect = Rectangle.Empty;

            SelectedBeats.Clear();
            CopiedBeats.Clear();

            TimeCurrentLabel.Text = "0(s)";
            TimeLengthLabel.Text = "0(s)";
            BeatCountLabel.Text = "0";
            BPMCurrentLabel.Text = "0";

            // Clean shit up RIGHT NAO!!!
            GC.Collect();
        }
Exemplo n.º 38
0
            public RESULT getLowLevelSystem(out FMOD.System system)
            {
                RESULT result = RESULT.OK;
                IntPtr systemraw = new IntPtr();
                system = null;

                try
                {
                result = FMOD_Studio_System_GetLowLevelSystem(rawPtr, out systemraw);
                }
                catch
                {
                result = RESULT.ERR_INVALID_PARAM;
                }
                if (result != RESULT.OK)
                {
                return result;
                }

                system = new FMOD.System();
                system.setRaw(systemraw);

                return result;
            }
 ///<summary>
 ///    The constructor creates the channels, and the null
 ///    sound, but doesn't make any of the channels active.
 ///
 ///    It should take name/value pair command-line args in an
 ///    string[] container, like main args
 ///</summary>
 private VoiceManager(FMOD.System fmod, Object[] parmArray, ConnectToServerEvent connectEvent, LoginStatusEvent loginStatusEvent, bool runningVoiceBot, string[] playbackFiles)
 {
     log.Info(null, "VoiceManager constructor: " + StringifyParms(parmArray));
     if (connectEvent != null)
         onConnectedToServer += connectEvent;
     if (loginStatusEvent != null)
         onLoginStatusReceived += loginStatusEvent;
     this.parameters = parmArray;
     this.runningVoiceBot = runningVoiceBot;
     this.playbackFiles = playbackFiles;
     currentVoiceParms = new VoiceParmSet(parmArray);
     string MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     string ClientAppDataFolder = Path.Combine(MyDocumentsFolder, "Multiverse World Browser");
     logFolder = Path.Combine(ClientAppDataFolder, "Logs");
     log.Debug(null, "VoiceManager constructor: Applying parms");
     playerListenerProperties = new ListenerProperties();
     playerListenerProperties.Init();
     ApplyConstructorParms(currentVoiceParms);
     ApplyPlaybackSettings(currentVoiceParms, false);
     log.Debug(this, "VoiceManager constructor: Encaching sound sources");
     voiceChannels = new Dictionary<Byte, VoiceChannel>();
     micChannels = new MicrophoneChannel[1];
     if (!runningVoiceBot) {
         if (fmod != null) {
             log.Debug(this, "VoiceManager constructor: Using fmod instance passed in: " + fmod);
             this.fmod = fmod;
         }
         else {
             log.Debug(this, "VoiceManager constructor: Creating new fmod instance");
             InitFmod();
         }
     }
     log.Debug(this, "VoiceManager constructor: Creating mic channel");
     micChannels[0] = new MicrophoneChannel(this, playerOid, micDeviceNumber, micRecordWAV, micRecordSpeex);
     recentSpeakers = new List<VoiceChannel>();
     noSoundShorts = new short[defaultSamplesPerFrame * 8];
     MaybeDeleteRecordedFile(micRecordWAV, LogFolderPath("RecordMic.wav"));
     MaybeDeleteRecordedFile(micRecordSpeex, LogFolderPath("RecordMic.speex"));
     ApplyGroupParms(currentVoiceParms, false);
     if (runningVoiceBot)
         log.DebugFormat(this, "VoiceManager constructor: Running voice bot oid {0}", playerOid);
     if (connectToServer) {
         log.Debug(this, "VoiceManager constructor: Initializing connection to server at " +
             voiceServerHost + ", port " + voiceServerPort);
         receiveBuffer = new byte[receiveBufferSize];
         connectedToServer = true;
         InitializeVoiceServerConnection();
     }
     else
         micChannels[0].InitMicrophone(currentVoiceParms, false);
 }
Exemplo n.º 40
0
 public void CleanUp()
 {
     this.DeInit(this.fmodSystem);
     this.Bands.Clear();
     this.fmodSystem = null;
     this.playerSettings = null;
 }
Exemplo n.º 41
0
        public void Dispose()
        {
            if (this.tokenSource != null)
              {
            this.tokenSource.Cancel();
              }

              this.StopMusic();

              if(this.fmodSystem != null)
              {
            this.fmodSystem.release();
            this.fmodSystem = null;
              }
        }