当前位置: 首页>>代码示例>>C#>>正文


C# Audio.AudioContext类代码示例

本文整理汇总了C#中OpenTK.Audio.AudioContext的典型用法代码示例。如果您正苦于以下问题:C# AudioContext类的具体用法?C# AudioContext怎么用?C# AudioContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioContext类属于OpenTK.Audio命名空间,在下文中一共展示了AudioContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MusicPlayer

        /// <summary>
        /// MusicPlayer クラスの新しいインスタンスを初期化します。
        /// </summary>
        public MusicPlayer(MusicOptions options)
        {
            if (options == null)
                throw new ArgumentNullException("options");

            this.bufferSize = options.BufferSize;
            this.bufferCount = options.BufferCount;
            this.samplingRate = options.SamplingRate;
            this.updateInterval = options.UpdateInterval;

            this.context = new AudioContext();
            this.master = new Master(options.SamplingRate, 23);
            this.preset = new Preset();
            this.layer = new Dictionary<string, SequenceLayer>();

            this.source = AL.GenSource();
            this.buffers = AL.GenBuffers(this.bufferCount);
            this.sbuf = new short[this.bufferSize];
            this.fbuf = new float[this.bufferSize];

            foreach (int buffer in this.buffers)
                this.FillBuffer(buffer);

            AL.SourceQueueBuffers(this.source, this.buffers.Length, this.buffers);
            AL.SourcePlay(this.source);

            this.Updater = Task.Factory.StartNew(this.Update);
        }
开发者ID:nanase,项目名称:sitrine,代码行数:31,代码来源:MusicPlayer.cs

示例2: Sound

        //int NextPlayingBuffer;
        //int numPLayedBuffer;
        /// <summary>
        /// Constructor for Sound class
        /// </summary>
        /// <param name="StartThread">Are we starting the sound thread?</param>
        public Sound(bool StartThread)
        {
            disposed = false;
            SoundList = new Dictionary<string, SoundType>();
            context = new AudioContext(); // default audio device
            lock (context)
            {
                context.MakeCurrent();
            }
            //XRamExtension XRam = new XRamExtension();

            /*SoundBuffers = AL.GenBuffers(4); // number of buffers
            SoundSource = AL.GenSource();
            SoundStreamSource = AL.GenSource();*/
            RunSoundThread = true;

            isPlaying = false;
            NowPlayingName = string.Empty;
            //NowPlayingBuffer = -1;
            NextPlayingName = string.Empty;
            //NextPlayingBuffer = -1;
            //numPLayedBuffer = 0; //??
            /*OpenTK.Vector3 v3 = new OpenTK.Vector3(1, 1, 1);
            AL.Source(AL.GenBuffer(), ALSource3f.Position, ref v3);*/

            //Debug.WriteLine(AL.Get(ALGetString.Version));

            tr = new System.Threading.Thread(new ThreadStart(PlayThread));
            if (StartThread)
            {
                RunThread();
            }
        }
开发者ID:wach78,项目名称:Turbofest,代码行数:39,代码来源:Sound.cs

示例3: OpenTKAudioCue

        internal OpenTKAudioCue(Stream data, AudioContext ac)
        {
            this.ac = ac;

            buffer = AL.GenBuffer();
            ac.CheckErrors();

            source = AL.GenSource();
            ac.CheckErrors();

            AL.Source(source, ALSourcef.Gain, (float)this.Volume);
            ac.CheckErrors();

            using (AudioReader ar = new AudioReader(data))
            {
                SoundData d = ar.ReadToEnd();
                AL.BufferData(source, d);
                ac.CheckErrors();
            }

            AL.Source(source, ALSourcei.Buffer, buffer);
            ac.CheckErrors();

            this.VolumeChanged += new VolumeChangedEventHandler(OpenTKAudioCue_VolumeChanged);
            this.BalanceChanged += new BalanceChangedEventHandler(OpenTKAudioCue_BalanceChanged);
            this.FadeChanged += new FadeChangedEventHandler(OpenTKAudioCue_FadeChanged);
        }
开发者ID:eropple,项目名称:sharplike,代码行数:27,代码来源:OpenTKAudioCue.cs

示例4: Init

 public void Init(Client tclient, ClientCVar cvar)
 {
     if (Context != null)
     {
         Context.Dispose();
     }
     TheClient = tclient;
     CVars = cvar;
     Context = new AudioContext(AudioContext.DefaultDevice, 0, 0, false, true);
     Context.MakeCurrent();
     try
     {
         if (Microphone != null)
         {
             Microphone.StopEcho();
         }
         Microphone = new MicrophoneHandler(this);
     }
     catch (Exception ex)
     {
         SysConsole.Output("Loading microphone handling", ex);
     }
     if (Effects != null)
     {
         foreach (SoundEffect sfx in Effects.Values)
         {
             sfx.Internal = -2;
         }
     }
     Effects = new Dictionary<string, SoundEffect>();
     PlayingNow = new List<ActiveSound>();
     Noise = LoadSound(new DataStream(Convert.FromBase64String(NoiseDefault.NoiseB64)), "noise");
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:33,代码来源:SoundEngine.cs

示例5: Player

        public Player()
        {
            _context = new AudioContext();

            for (int i = 0; i < 10; ++i)
                _freeSources.Enqueue(AL.GenSource());
        }
开发者ID:cadahl,项目名称:defense,代码行数:7,代码来源:Player.cs

示例6: Sound

 static Sound()
 {
     App.Init();
     audio = new AudioContext();
     AL.DistanceModel(ALDistanceModel.ExponentDistanceClamped);
     Listener = Vec2.Zero;
 }
开发者ID:kuviman,项目名称:csVPE,代码行数:7,代码来源:Static.cs

示例7: Init

		public static void Init ()
		{
			if (context != null)
				return;
			
			context = new AudioContext ();
		}
开发者ID:Insane-96,项目名称:aiv-vorbis,代码行数:7,代码来源:AudioDevice.cs

示例8: Main

        public static void Main()
        {
            using (AudioContext context = new AudioContext())
            {
                int buffer = AL.GenBuffer();
                int source = AL.GenSource();
                int state;

                int channels, bits_per_sample, sample_rate;
                byte[] sound_data = LoadWave(File.Open(filename, FileMode.Open), out channels, out bits_per_sample, out sample_rate);
                AL.BufferData(buffer, GetSoundFormat(channels, bits_per_sample), sound_data, sound_data.Length, sample_rate);

                AL.Source(source, ALSourcei.Buffer, buffer);
                AL.SourcePlay(source);

                Trace.Write("Playing");

                // Query the source to find out when it stops playing.
                do
                {
                    Thread.Sleep(250);
                    Trace.Write(".");
                    AL.GetSource(source, ALGetSourcei.SourceState, out state);
                }
                while ((ALSourceState)state == ALSourceState.Playing);

                Trace.WriteLine("");

                AL.SourceStop(source);
                AL.DeleteSource(source);
                AL.DeleteBuffer(buffer);
            }
        }
开发者ID:PieterMarius,项目名称:PhysicsEngine,代码行数:33,代码来源:Playback.cs

示例9: WaveSoundPlayer

        public WaveSoundPlayer(WaveFile w, bool loop)
        {
            ac = new AudioContext ();

            bufferlist = new List<int> (NUM_BUFFERS);
            bufferlist.AddRange (AL.GenBuffers (NUM_BUFFERS));

            source = AL.GenSource ();
            this._PlayState = PlayState.NotLoaded;

            wfile = w;
            bufferlist.ForEach (x => {
                byte[] buf = new byte[BUFFER_SIZE];
                buf = wfile.DataBinary.ReadBytes(BUFFER_SIZE);
                AL.BufferData(x,wfile.SoundFormat,buf,buf.Length,wfile.SampleRate);
            });

            AL.SourceQueueBuffers (source, NUM_BUFFERS, bufferlist.ToArray ());
            if (loop)
                AL.Source (source, ALSourceb.Looping, true);

            System.Diagnostics.Debug.WriteLine (AL.GetSourceState(source).ToString());

            this._PlayState = PlayState.Stopped;
        }
开发者ID:Carrot031,项目名称:EasyOpenAL,代码行数:25,代码来源:WaveSoundPlayer.cs

示例10: PlaySound

 public override void PlaySound(string assetName)
 {
     if (audioContext == null)
         audioContext = new AudioContext ();
     Thread soundThread = new Thread (() => this.PlaySoundThread (assetName, false));
     soundThread.Start ();
 }
开发者ID:Insane-96,项目名称:aivengine-opentk,代码行数:7,代码来源:FastEngine.cs

示例11: Initialize

 public void Initialize(OpenTK.GameWindow window) {
     if (isInitialized) {
         Error("Trying to double initialize sound manager!");
     }
     context = new AudioContext();
     managedSounds = new List<SoundInstance>();
     isInitialized = true;
 }
开发者ID:gdbooks,项目名称:gdbooks.github.io,代码行数:8,代码来源:SoundManager.cs

示例12: AudioOutputAL

 public AudioOutputAL()
 {
     try {
         context = new AudioContext();
     } catch( Exception e ) {
         Console.WriteLine( e );
     }
 }
开发者ID:UnknownShadow200,项目名称:SharpWave,代码行数:8,代码来源:AudioOutputAL.cs

示例13: WavePlayer

        /// <summary>
        /// Initializes a new instance of the <see cref="WavePlayer"/> class.
        /// </summary>
        private WavePlayer()
        {
            this.context = new AudioContext();

            this.buffer = AL.GenBuffer();
            this.source = AL.GenSource();

            this.thread = new Thread(new ThreadStart(this.SourceStateListen));
            this.thread.Start();
        }
开发者ID:jakepetroules,项目名称:ksc-archive,代码行数:13,代码来源:WavePlayer.cs

示例14: Main

        public static void Main()
        {
            using (AudioContext context = new AudioContext())
            {
                Trace.WriteLine("Testing WaveReader({0}).ReadToEnd()", filename);

                EffectsExtension efx = new EffectsExtension();

                int buffer = AL.GenBuffer();
                int source = AL.GenSource();
                int state;

                int effect = efx.GenEffect();
                int slot = efx.GenAuxiliaryEffectSlot();

                efx.BindEffect(effect, EfxEffectType.Reverb);
                efx.Effect(effect, EfxEffectf.ReverbDecayTime, 3.0f);
                efx.Effect(effect, EfxEffectf.ReverbDecayHFRatio, 0.91f);
                efx.Effect(effect, EfxEffectf.ReverbDensity, 0.7f);
                efx.Effect(effect, EfxEffectf.ReverbDiffusion, 0.9f);
                efx.Effect(effect, EfxEffectf.ReverbRoomRolloffFactor, 3.1f);
                efx.Effect(effect, EfxEffectf.ReverbReflectionsGain, 0.723f);
                efx.Effect(effect, EfxEffectf.ReverbReflectionsDelay, 0.03f);
                efx.Effect(effect, EfxEffectf.ReverbGain, 0.23f);

                efx.AuxiliaryEffectSlot(slot, EfxAuxiliaryi.EffectslotEffect, effect);

                int channels, bits, rate;
                byte[] data = Playback.LoadWave(File.Open(filename, FileMode.Open), out channels, out bits, out rate);
                AL.BufferData(buffer, Playback.GetSoundFormat(channels, bits), data, data.Length, rate);

                AL.Source(source, ALSourcef.ConeOuterGain, 1.0f);
                AL.Source(source, ALSourcei.Buffer, buffer);
                AL.SourcePlay(source);

                Trace.Write("Playing");

                // Query the source to find out when it stops playing.
                do
                {
                    Thread.Sleep(250);
                    Trace.Write(".");
                    AL.GetSource(source, ALGetSourcei.SourceState, out state);
                }
                while ((ALSourceState)state == ALSourceState.Playing);

                Trace.WriteLine("");

                AL.SourceStop(source);
                AL.DeleteSource(source);
                AL.DeleteBuffer(buffer);
                efx.DeleteEffect(effect);
                efx.DeleteAuxiliaryEffectSlot(slot);
            }
        }
开发者ID:jpespartero,项目名称:OpenGlobe,代码行数:55,代码来源:EFXReverb.cs

示例15: EngineWindow

        public EngineWindow()
            : base(1200, 800, new GraphicsMode(32, 24, 8, 4), "OpenTK", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.ForwardCompatible)
        {
            Global.window = this;
            string versionOpenGL = GL.GetString(StringName.Version);
            string shaderVersion = GL.GetString(StringName.ShadingLanguageVersion);
            Console.WriteLine("OpenGL: " + versionOpenGL);
            Console.WriteLine("GLSL: " + shaderVersion);

            AC = new AudioContext();
        }
开发者ID:jikoriko,项目名称:OpentkEngine,代码行数:11,代码来源:EngineWindow.cs


注:本文中的OpenTK.Audio.AudioContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。