コード例 #1
0
ファイル: FMODTrack.cs プロジェクト: Melamew/LMaML
 /// <summary>
 /// Initializes a new instance of the <see cref="FMODTrack" /> class.
 /// </summary>
 /// <param name="fmodSound">The fmod sound.</param>
 /// <param name="system">The system.</param>
 /// <param name="file">The file.</param>
 public FMODTrack(Sound fmodSound, global::FMOD.System system, string file)
 {
     fmodSound.Guard("fmodSound");
     system.Guard("system");
     this.fmodSound = fmodSound;
     this.file      = file;
     Length         = TimeSpan.FromMilliseconds(GetLengthMs(fmodSound));
     fmodChannel    = CreateChannel(system, fmodSound);
     Init();
 }
コード例 #2
0
        /// <summary>
        /// Creates the channel.
        /// </summary>
        /// <param name="system">The system.</param>
        /// <param name="sound">The sound.</param>
        /// <returns></returns>
        private static Channel CreateChannel(global::FMOD.System system, Sound sound)
        {
            Channel channel = null;
            var     result  = system.playSound(CHANNELINDEX.FREE, sound, true, ref channel);

            if (result != RESULT.OK)
            {
                throw FMODPlayer.GetException("Unable to play sound", result);
            }
            return(channel);
        }
コード例 #3
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            disposed = true;
            if (fmodSystem == null)
            {
                return;
            }
            var result = fmodSystem.close();

            if (result != RESULT.OK)
            {
                throw GetException("Unable to close FMOD System", result);
            }
            fmodSystem = null;
        }
コード例 #4
0
ファイル: FMODPlayer.cs プロジェクト: Melamew/LMaML
        /// <summary>
        /// Initializes a new instance of the <see cref="FMODPlayer" /> class.
        /// </summary>
        /// <param name="configurationManager">The configuration manager.</param>
        public FMODPlayer(IConfigurationManager configurationManager)
        {
            configurationManager.Guard("configurationManager");
            this.configurationManager = configurationManager;
            fmodSystem = new global::FMOD.System();
            var result = Factory.System_Create(ref fmodSystem);

            if (result != RESULT.OK)
            {
                throw GetException("Unable to create FMOD System", result);
            }
            result = fmodSystem.init(10, INITFLAGS.NORMAL, IntPtr.Zero);
            if (result != RESULT.OK)
            {
                throw GetException("Unable to Initialize FMOD System", result);
            }

            GetPlugins();
        }