示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }