コード例 #1
0
ファイル: Sound.cs プロジェクト: gitter-badger/dEngine
        private void Reset()
        {
            var buffer = CurrentAudioBuffer;

            if (_voice.State.BuffersQueued > 0)
            {
                _voice.Stop();
                _voice.FlushSourceBuffers();
            }
            _voice.SubmitSourceBuffer(buffer);
            buffer.PlayBegin = GetPlayOffset(StartingPosition.totalSeconds);
            _voice.Start();
        }
コード例 #2
0
        private void voice_VoiceProcessingPassStart(uint bufferSize)
        {
            var bufferSamples = bufferSize / sizeof(float);
            var buffer        = new XAudio2Buffer(bufferSamples);

            for (uint i = 0; i < bufferSamples; ++i)
            {
                buffer.SetSample(i, (float)Math.Sin(phase));
                phase = (phase + (Delta * frequency)) % TwoPi;
            }

            voice.SubmitSourceBuffer(buffer);
        }