コード例 #1
0
        public static void UpdateInterroot()
        {
            if (!initialised)
            {
                return;
            }
            //if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
            //   GameDataManager.GameType == GameDataManager.GameTypes.SDT))
            //{
            //    return;
            //}

            Main.WinForm.Invoke(new Action(() =>
            {
                string possiblePath = GetDirWithBackslash(
                    Utils.Frankenpath(GameDataManager.InterrootPath, GameDataManager.GameType == SoulsAssetPipeline.SoulsGames.BB ? "sound_win" : "sound"));
                result = _eventSystem.setMediaPath(possiblePath);
                if (result == RESULT.OK)
                {
                    MediaPath = possiblePath;
                }
                else
                {
                    ERRCHECK(result);
                    MediaPath = null;
                }
            }));
        }
コード例 #2
0
 // Checking the FMOD's result
 void ERRCHECK(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         Console.WriteLine("FMOD error! " + result + " - " + FMOD.Error.String(result));
     }
 }
コード例 #3
0
 public void SetPosition(uint pos)
 {
     if (channel != null)
     {
         result = channel.setPosition(pos, FMOD.TIMEUNIT.MS);
     }
 }
コード例 #4
0
 public void SetVolume(float fVolume)
 {
     if (channel != null)
     {
         result = channel.setVolume(fVolume);
     }
 }
コード例 #5
0
        public void PlaySong(String name)
        {
            if (!sCurrentTrack.Equals(name))
            {
                Stop();
                try
                {
                    if (dMusicDict[name] != null)
                    {
                        FMOD.RESULT r = FMODSystem.playSound(dMusicDict[name], null, false, out MusicChannel);
                        UpdateVolume(1.0f);
                        MusicChannel.setMode(FMOD.MODE.LOOP_NORMAL);
                        MusicChannel.setLoopCount(-1);

                        sCurrentTrack = name;
                    }
                    else
                    {
                        CConsole.Instance.Print("song " + name + " was null");
                    }
                }
                catch (KeyNotFoundException e)
                {
                    CConsole.Instance.Print("Track " + name + " wasn't found in dMusicDict, " + e.Message);
                }
            }
        }
コード例 #6
0
 public void SetMute(bool bMute)
 {
     if (channel != null)
     {
         result = channel.setMute(bMute);
     }
 }
コード例 #7
0
 public void LoadSong(string path, string name, string filetype)
 {
     FMOD.Sound  snd;
     FMOD.RESULT r = FMODSystem.createStream(path + "/" + name + "." + filetype, FMOD.MODE.DEFAULT, out snd);
     dMusicDict.Add(name, snd);
     CConsole.Instance.Print("loaded track " + name + ", got result " + r);
 }
コード例 #8
0
 public void LoadSong(int songId, string name)
 {
     FMOD.RESULT r = FMODSystem.createStream(System.IO.Directory.GetCurrentDirectory() + @"\BGM\" + name + ".wav", FMOD.MODE.DEFAULT, out Songs[songId]);
     if (r != RESULT.OK)         //song을 load하는 기능
     {
         MessageBox.Show("Load ERR");
     }
 }
コード例 #9
0
 public static RESULT fmodCheck(FMOD.RESULT result, string step = "non detailed.")
 {
     if (result != RESULT.OK)
     {
         LogWriter.getLog().Error($"problems excecuting a fmod function at {step} step {result}");
     }
     return(result);
 }
コード例 #10
0
ファイル: MediaObject.cs プロジェクト: tbutiu/radegast
 protected static void FMODExec(FMOD.RESULT result, string trace)
 {
     Logger.Log("FMOD call " + trace + " returned " + result.ToString(), Helpers.LogLevel.Info);
     if (result != FMOD.RESULT.OK)
     {
         throw new MediaException("FMOD error! " + result + " - " + FMOD.Error.String(result));
     }
 }
コード例 #11
0
ファイル: MediaObject.cs プロジェクト: IMA-DZ/RadegastV2
 protected static void FMODExec(FMOD.RESULT result, string trace)
 {
     Logger.Log($"FMOD call {trace} returned {result}", Helpers.LogLevel.Info);
     if (result != FMOD.RESULT.OK)
     {
         throw new MediaException($"FMOD error! {result} - {FMOD.Error.String(result)}");
     }
 }
コード例 #12
0
 public void Pause()
 {
     if (channel != null)
     {
         bool paused;
         result = channel.getPaused(out paused);
         result = channel.setPaused(!paused);
     }
 }
コード例 #13
0
        public static FMOD.EventProject GetEventProject(string name)
        {
            FMOD.EventProject proj = null;
            var numProjects        = 0;

            result          = _eventSystem.getNumProjects(ref numProjects);
            ERRCHECK(result = _eventSystem.getProjectByIndex(0, ref proj));
            return(proj);
        }
コード例 #14
0
 public bool Play()
 {
     result = system.playSound(sound, null, false, out channel);
     if (result != FMOD.RESULT.OK)
     {
         return(false);
     }
     return(true);
 }
コード例 #15
0
 public void init()
 {
     result = FMOD.Factory.System_Create(ref system);
     result = system.init(128, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
     result = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref dsplowpass);
     result = system.createDSPByType(FMOD.DSP_TYPE.FLANGE, ref dspflange);
     result = system.createDSPByType(FMOD.DSP_TYPE.DISTORTION, ref dspdistortion);
     result = system.createDSPByType(FMOD.DSP_TYPE.ECHO, ref dspecho);
 }
コード例 #16
0
 /// <summary>
 /// Вызывает проигрывание циклического звука
 /// </summary>
 /// <param name="soundName"></param>
 /// <param name="volume"></param>
 /// <param name="frequency"></param>
 /// <param name="echo"></param>
 /// <param name="soundFileLocation"></param>
 public void Play(string soundName, string soundType, double volume, double frequency,
                  bool echo, string soundFileLocation)
 {
     if (!SoundExists(soundName))
     {
         int[] indexes  = new int[2];
         float mainFreq = 0;
         for (int i = 0; i < sound.Length; i++)
         {
             if (soundType == "Непрерывный")
             {
                 result = system.createStream(soundFileLocation, FMOD.MODE.LOOP_NORMAL, ref sound[i]);
             }
             else
             {
                 result = system.createStream(soundFileLocation, FMOD.MODE.SOFTWARE, ref sound[i]);
             }
         }
         if (result == RESULT.OK)
         {
             for (int i = 0; i < channel.Length; i++)
             {
                 result = system.playSound(FMOD.CHANNELINDEX.FREE, sound[i], false, ref channel[i]);
                 channel[i].getIndex(ref indexes[i]);
             }
             for (int i = 0; i < channel.Length; i++)
             {
                 result = channel[i].setVolume(((float)volume));
                 channel[i].getFrequency(ref mainFreq);
             }
             result = channel[0].setPan(-1);
             result = channel[1].setPan(1);
             sounds.Add(soundName, indexes);
             soundsFreq.Add(soundName, mainFreq);
         }
     }
     else
     {
         int[] inds;
         float freq;
         sounds.TryGetValue(soundName, out inds);
         soundsFreq.TryGetValue(soundName, out freq);
         for (int i = 0; i < channel.Length; i++)
         {
             system.getChannel(inds[i], ref channel[i]);
             //if (soundName.Contains("Стартер"))
             //    result = channel[i].setVolume((float)1);
             //else
             result = channel[i].setVolume((float)(volume / 100));
             if (freq / 100 * frequency < freq)
             {
                 result = channel[i].setFrequency((float)(freq / 100 * frequency));
             }
         }
     }
 }
コード例 #17
0
        public uint GetPosition()
        {
            uint pos = 0;

            if (channel != null)
            {
                result = channel.getPosition(out pos, FMOD.TIMEUNIT.MS);
            }
            return(pos);//return pos / 1000.f;
        }
コード例 #18
0
 //Simple error checking function that returns information about FMOD_RESULT objects
 private void FMODErrorCheck(FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         //int meh;
         Console.WriteLine("FMOD error! (" + result + ") " + FMOD.Error.String(result));
         Console.ReadLine();
         //exit(-1);
     }
 }
コード例 #19
0
ファイル: Walkman.cs プロジェクト: starryangt/aoede
 public void Stop()
 {
     if (status != STATUS.STOP)
     {
         status = STATUS.STOP;
         result = channel.stop();
         CHECKERR(result, ErrorType.Playback);
         current.release();
     }
 }
コード例 #20
0
        /* 2010/01/24 del taglib#に変更
         * public void getTag(GridItemInfo gi)
         * {
         *  Dictionary<string, string> tagDic = new Dictionary<string, string>();
         *  FMOD.TAG tag = new FMOD.TAG();
         *
         *  for (; ; )
         *  {
         *      //
         *      //    An index of -1 means "get the first tag that's new or updated".
         *      //    If no tags are new or updated then getTag will return FMOD_ERR_TAGNOTFOUND.
         *      //    This is the first time we've read any tags so they'll all be new but after we've read them,
         *      //    they won't be new any more.
         *      //
         *      if (sound == null)
         *      {
         *          break;
         *      }
         *      if (sound.getTag(null, -1, ref tag) != FMOD.RESULT.OK)
         *      {
         *          break;
         *      }
         *      if (tag.datatype == FMOD.TAGDATATYPE.STRING)
         *      {
         *          tagDic[tag.name] = Marshal.PtrToStringAnsi(tag.data);
         *      }
         *      else if (tag.datatype == TAGDATATYPE.STRING_UTF8)
         *      {
         *          MarshalPtrToUtf8 mutf8 = new MarshalPtrToUtf8();
         *          tagDic[tag.name] = (string)mutf8.MarshalNativeToManaged(tag.data);
         *      }
         *      else if (tag.datatype == TAGDATATYPE.STRING_UTF16)
         *      {
         *          tagDic[tag.name] = Marshal.PtrToStringUni(tag.data);
         *      }
         *  }
         *  // タイトル
         *  if(tagDic.ContainsKey("TITLE")) {
         *      gi.Title = tagDic["TITLE"];
         *  }
         *  if (tagDic.ContainsKey("TIT2"))
         *  {
         *      gi.Title = tagDic["TIT2"];
         *  }
         *  // アーティスト
         *  if (tagDic.ContainsKey("ARTIST"))
         *  {
         *      gi.Artist = tagDic["ARTIST"];
         *  }
         *  if (tagDic.ContainsKey("TPE1"))
         *  {
         *      gi.Artist = tagDic["TPE1"];
         *  }
         *  // アルバム
         *  if (tagDic.ContainsKey("ALBUM"))
         *  {
         *      gi.Album = tagDic["ALBUM"];
         *  }
         *  if (tagDic.ContainsKey("TALB"))
         *  {
         *      gi.Album = tagDic["TALB"];
         *  }
         *  // トラック
         *  if (tagDic.ContainsKey("TRACK"))
         *  {
         *      gi.Track = tagDic["TRACK"];
         *  }
         *  if (tagDic.ContainsKey("TRCK"))
         *  {
         *      gi.Track = tagDic["TRCK"];
         *  }
         *  // ジャンル
         *  if (tagDic.ContainsKey("TCON"))
         *  {
         *      gi.Genre = tagDic["TCON"];
         *  }
         *  // 年
         *  if (tagDic.ContainsKey("YEAR"))
         *  {
         *      gi.Year = tagDic["YEAR"];
         *  }
         *  if (tagDic.ContainsKey("TDRC"))
         *  {
         *      gi.Year = tagDic["TDRC"];
         *  }
         * }
         */

        /* 2010/02/11 del BitrateはTagLib#で取得することにした
         * public uint getBitRate()
         * {
         *  uint rawlen = 0;
         *  uint mslen = 0;
         *  if (sound != null)
         *  {
         *      sound.getLength(ref rawlen, FMOD.TIMEUNIT.RAWBYTES);
         *      sound.getLength(ref mslen, FMOD.TIMEUNIT.MS);
         *
         *      //double aa = (Math.Round((double)rawlen / (double)mslen,0) * 8000);
         *      //Debug.WriteLine(aa);
         *      return (uint)(Math.Round((double)rawlen / (double)mslen, 0) * 8000) / 1000;
         *  }
         *  else
         *  {
         *      return 0;
         *  }
         * }
         */

        /*
         * /// <summary>
         * /// soundに設定する(メモリリード)
         * /// </summary>
         * /// <param name="filePath">設定するファイル</param>
         * public void setSoundFile(string filePath)
         * {
         *  FMOD.RESULT result;
         *  int length;
         *  FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
         *
         *  // 現在再生している場合は停止してリリースする。
         *  if (sound[PlayerController.MainChannel] != null)
         *  {
         *      stop(PlayerController.MainChannel);
         *  }
         *
         *  length = LoadFileIntoMemory(filePath);
         *
         *  exinfo.cbsize = Marshal.SizeOf(exinfo);
         *  exinfo.length = (uint)length;
         *
         *  result = system.createStream(audiodata, (FMOD.MODE.DEFAULT | MODE.OPENMEMORY | FMOD.MODE.CREATESTREAM), ref exinfo, ref sound[PlayerController.MainChannel]);
         *  checkFMODError(result);
         *
         * }
         */

        /*
         * /// <summary>
         * /// soundに設定する(ファイル直接リード)
         * /// </summary>
         * /// <param name="filePath">設定するファイル</param>
         * public void setSoundFile(string filePath)
         * {
         *  FMOD.RESULT result;
         *
         *  // 現在再生している場合は停止してリリースする。
         *  if (sound != null)
         *  {
         *      stop();
         *  }
         *
         *  result = system.createStream(filePath, (FMOD.MODE.DEFAULT | FMOD.MODE.CREATESTREAM), ref sound);
         *  checkFMODError(result);
         *
         * }
         */

        #endregion


        /*
         *  プライベートメソッド
         */
        #region PrivateMethod

        private static void checkFMODError(FMOD.RESULT result)
        {
            if (result != FMOD.RESULT.OK)
            {
                throw new LinearAudioPlayerException(FinalstreamException.ERROR_LEVEL.Warn,
                                                     "FMOD error! " + result + " - " + FMOD.Error.String(result) + " openFilePath: " + openFilePath);

                //Debug.WriteLine();
            }
        }
コード例 #21
0
ファイル: SoundPlayer.cs プロジェクト: madyanov/UEViewer
 private void Init()
 {
     if (system == null)
     {
         result = FMOD.Factory.System_Create(ref system);
         ErrorCheck();
         result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
         ErrorCheck();
     }
 }
コード例 #22
0
ファイル: SoundSystem.cs プロジェクト: Kuzy15/FMOD_Game
    private void LateUpdate()
    {
        _listenerAttributes3D = RuntimeUtils.To3DAttributes(sceneListener, sceneListener.GetComponent <Rigidbody>());
        _result = studioSystem.setListenerAttributes(0, _listenerAttributes3D);
        ErrorCheck(_result);
        _result = lowlevelSystem.set3DListenerAttributes(0, ref _listenerAttributes3D.position, ref _listenerAttributes3D.velocity, ref _listenerAttributes3D.forward, ref _listenerAttributes3D.up);
        ErrorCheck(_result);

        lowlevelSystem.update();
        studioSystem.update();
    }
コード例 #23
0
ファイル: Walkman.cs プロジェクト: starryangt/aoede
 public void Pause()
 {
     if (status != STATUS.STOP)
     {
         bool previous = false;
         result = channel.getPaused(out previous);
         CHECKERR(result, ErrorType.Playback);
         result = channel.setPaused(!previous);
         CHECKERR(result, ErrorType.Playback);
     }
 }
コード例 #24
0
ファイル: SoundSystem.cs プロジェクト: Kuzy15/FMOD_Game
    // Errors checking
    public int ErrorCheck(FMOD.RESULT result)
    {
        if (result != FMOD.RESULT.OK)
        {
            UnityEngine.Debug.LogError("FMOD ERROR " + FMOD.Error.String(result));

            return(1);
        }
        // Debug.Log("FMOD good");
        return(0);
    }
コード例 #25
0
        public string GetCurrentTimeDisplay()
        {
            string strCurTime = "";

            if (channel != null)
            {
                uint pos;
                result     = channel.getPosition(out pos, FMOD.TIMEUNIT.MS);
                strCurTime = string.Format("{0:D2}:{1:D2}", pos / 1000 / 60, pos / 1000 % 60);
            }
            return(strCurTime);
        }
コード例 #26
0
        public static void InitTest()
        {
            Main.WinForm.Invoke(new Action(() =>
            {
                ERRCHECK(result = FMOD.Event_Factory.EventSystem_Create(ref _eventSystem));
                ERRCHECK(result = _eventSystem.init(MAX_CHANNELS, FMOD.INITFLAGS.NORMAL, (IntPtr)null, FMOD.EVENT_INITFLAGS.NORMAL));
                ERRCHECK(result = _eventSystem.getSystemObject(ref _system));

                DbgPrimCamPos          = new DebugPrimitives.DbgPrimWireArrow("FMOD Camera", Transform.Default, Color.Lime);
                DbgPrimCamPos.Category = DebugPrimitives.DbgPrimCategory.SoundEvent;
            }));
        }
コード例 #27
0
        public string GetTotalTimeDisplay()
        {
            string strTotalTime = "";

            if (sound != null)
            {
                uint len = 0;
                result       = sound.getLength(out len, FMOD.TIMEUNIT.MS);
                strTotalTime = string.Format("{0:D2}:{1:D2}", len / 1000 / 60, len / 1000 % 60);
            }
            return(strTotalTime);
        }
コード例 #28
0
ファイル: RuntimeManager.cs プロジェクト: whisperlin/utils
 void CheckInitResult(FMOD.RESULT result, string cause)
 {
     if (result != FMOD.RESULT.OK)
     {
         if (studioSystem.isValid())
         {
             studioSystem.release();
             studioSystem.clearHandle();
         }
         throw new SystemNotInitializedException(result, cause);
     }
 }
コード例 #29
0
 public static bool ERRCHECK(this FMOD.RESULT result)
 {
     if (result != FMOD.RESULT.OK)
     {
         //this.timer.Stop();
         MessageBox.Show("FMOD error! " + result + " - " + FMOD.Error.String(result));
         // todo : show error info dialog
         //Environment.Exit(-1);
         return(false);
     }
     return(true);
 }
コード例 #30
0
ファイル: Walkman.cs プロジェクト: starryangt/aoede
            public Walkman()
            {
                //have proper errorchecking and shit
                result = FMOD.Factory.System_Create(out system);
                CHECKERR(result, ErrorType.Init);
                result = system.init(512, FMOD.INITFLAGS.NORMAL, (IntPtr)0);
                CHECKERR(result, ErrorType.Init);
                globalPlaylistList = new List <Playlist>();
                tagMaster          = new TagMaster();

                playlist = new Playlist();
                status   = STATUS.STOP;
            }
コード例 #31
0
        //This function is called by the loadSystem function. It sets up FMOD for the rest of
        //the program, like an "init" of sorts. Most of this code is boilerplate that is used in
        //every FMOD application.
        private FMOD.System fmodSetup()
        {
            FMOD.System t_system = new FMOD.System();
            FMOD.RESULT result = new FMOD.RESULT();
            uint version = 0;
            int numDrivers = 0;
            FMOD.SPEAKERMODE speakerMode = FMOD.SPEAKERMODE.STEREO;
            FMOD.CAPS caps = FMOD.CAPS.NONE;
            StringBuilder name = null;

            // Create FMOD interface object
            result = FMOD.Factory.System_Create(ref t_system);
            FMODErrorCheck(result);

            // Check version
            result = t_system.getVersion(ref version);
            FMODErrorCheck(result);

            if (version < FMOD.VERSION.number)
            {
                Console.WriteLine("Error! You are using an old version of FMOD " + version + ". This program requires " + FMOD.VERSION.number);
                return null;
            }

            //Check Sound Cards, if none, disable sound
            result = t_system.getNumDrivers(ref numDrivers);
            FMODErrorCheck(result);

            if (numDrivers == 0)
            {
                result = t_system.setOutput(FMOD.OUTPUTTYPE.NOSOUND);
                FMODErrorCheck(result);
            }
            // At least one sound card
            else
            {

                // Get the capabilities of the default (0) sound card
                result = t_system.getDriverCaps(0, ref caps, ref zero, ref speakerMode);
                FMODErrorCheck(result);

                // Set the speaker mode to match that in Control Panel
                result = t_system.setSpeakerMode(speakerMode);
                FMODErrorCheck(result);

                // Increase buffer size if user has Acceleration slider set to off
                if (FMOD.CAPS.HARDWARE_EMULATED.Equals(true))
                {
                    result = t_system.setDSPBufferSize(1024, 10);
                    FMODErrorCheck(result);
                }
                // Get name of driver
                FMOD.GUID temp = new FMOD.GUID();

                result = t_system.getDriverInfo(0, name, 256, ref temp);
                FMODErrorCheck(result);
            }
            System.IntPtr temp2 = new System.IntPtr();
            // Initialise FMOD
            result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);

            // If the selected speaker mode isn't supported by this sound card, switch it back to stereo
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = t_system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);
                FMODErrorCheck(result);

                result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2);
            }

            FMODErrorCheck(result);

            return t_system;
        }