public void Play() { int bufferId = soundBuffer.OpenALDataBuffer; if (hasSourceId) { return; } bool isSourceAvailable = controller.ReserveSource(soundBuffer); if (!isSourceAvailable) { return; } AL.Source(soundBuffer.SourceId, ALSourcei.Buffer, bufferId); ApplyState(); controller.PlaySound(soundBuffer); //Console.WriteLine ("playing: " + sourceId + " : " + soundEffect.Name); soundState = SoundState.Playing; }
private void PlatformPlay() { if (hasSourceId) { return; } bool isSourceAvailable = controller.ReserveSource(soundBuffer); if (!isSourceAvailable) { throw new InstancePlayLimitException(); } int bufferId = soundBuffer.OpenALDataBuffer; AL.Source(soundBuffer.SourceId, ALSourcei.Buffer, bufferId); // Send the position, gain, looping, pitch, and distance model to the OpenAL driver. if (!hasSourceId) { return; } // Distance Model AL.DistanceModel(ALDistanceModel.InverseDistanceClamped); // Pan AL.Source(sourceId, ALSource3f.Position, _pan, 0, 0.1f); // Volume AL.Source(sourceId, ALSourcef.Gain, _volume * SoundEffect.MasterVolume); // Looping AL.Source(sourceId, ALSourceb.Looping, IsLooped); // Pitch AL.Source(sourceId, ALSourcef.Pitch, XnaPitchToAlPitch(_pitch)); controller.PlaySound(soundBuffer); //Console.WriteLine ("playing: " + sourceId + " : " + soundEffect.Name); soundState = SoundState.Playing; }
private void PlatformPlay() { SourceId = 0; HasSourceId = false; SourceId = controller.ReserveSource(); HasSourceId = true; int bufferId = _effect.SoundBuffer.OpenALDataBuffer; AL.Source(SourceId, ALSourcei.Buffer, bufferId); ALHelper.CheckError("Failed to bind buffer to source."); // Send the position, gain, looping, pitch, and distance model to the OpenAL driver. if (!HasSourceId) { return; } // Distance Model AL.DistanceModel(ALDistanceModel.InverseDistanceClamped); ALHelper.CheckError("Failed set source distance."); // Pan AL.Source(SourceId, ALSource3f.Position, _pan, 0, 0.1f); ALHelper.CheckError("Failed to set source pan."); // Volume AL.Source(SourceId, ALSourcef.Gain, _alVolume); ALHelper.CheckError("Failed to set source volume."); // Looping AL.Source(SourceId, ALSourceb.Looping, IsLooped); ALHelper.CheckError("Failed to set source loop state."); // Pitch AL.Source(SourceId, ALSourcef.Pitch, XnaPitchToAlPitch(_pitch)); ALHelper.CheckError("Failed to set source pitch."); controller.PlaySound(this); //Console.WriteLine ("playing: " + sourceId + " : " + soundEffect.Name); SoundState = SoundState.Playing; }