Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Removed XACT.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 21, 2020
1 parent 57903f6 commit d6e7201
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 96 deletions.
32 changes: 16 additions & 16 deletions MonoGame/MonoGame.Framework/Audio/SoundEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ internal SoundEffect(byte[] header, byte[] buffer, int bufferSize, int durationM
}

// Only used from XACT WaveBank.
internal SoundEffect(MiniFormatTag codec, byte[] buffer, int channels, int sampleRate, int blockAlignment, int loopStart, int loopLength)
{
Initialize();
if (_systemState != SoundSystemState.Initialized)
throw new NoAudioHardwareException("Audio has failed to initialize. Call SoundEffect.Initialize() before sound operation to get more specific errors.");

// Handle the common case... the rest is platform specific.
if (codec == MiniFormatTag.Pcm)
{
_duration = TimeSpan.FromSeconds((float)buffer.Length / (sampleRate * blockAlignment));
PlatformInitializePcm(buffer, 0, buffer.Length, 16, sampleRate, (AudioChannels)channels, loopStart, loopLength);
return;
}

PlatformInitializeXact(codec, buffer, channels, sampleRate, blockAlignment, loopStart, loopLength, out _duration);
}
// internal SoundEffect(MiniFormatTag codec, byte[] buffer, int channels, int sampleRate, int blockAlignment, int loopStart, int loopLength)
// {
// Initialize();
// if (_systemState != SoundSystemState.Initialized)
// throw new NoAudioHardwareException("Audio has failed to initialize. Call SoundEffect.Initialize() before sound operation to get more specific errors.");
//
// // Handle the common case... the rest is platform specific.
// if (codec == MiniFormatTag.Pcm)
// {
// _duration = TimeSpan.FromSeconds((float)buffer.Length / (sampleRate * blockAlignment));
// PlatformInitializePcm(buffer, 0, buffer.Length, 16, sampleRate, (AudioChannels)channels, loopStart, loopLength);
// return;
// }
//
// PlatformInitializeXact(codec, buffer, channels, sampleRate, blockAlignment, loopStart, loopLength, out _duration);
// }

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This package provides you with MonoGame Framework that uses OpenGL for rendering
</ItemGroup>

<ItemGroup>
<Compile Remove="Audio\Xact\**" />
<Compile Remove="bin\**\*" />
<Compile Remove="Content\**" />
<Compile Remove="Design\**" />
Expand All @@ -32,6 +33,7 @@ This package provides you with MonoGame Framework that uses OpenGL for rendering
<Compile Remove="Platform\Media\**" />
<Compile Remove="Properties\**\*" />
<Compile Remove="Utilities\LzxStream\**" />
<EmbeddedResource Remove="Audio\Xact\**" />
<EmbeddedResource Remove="Content\**" />
<EmbeddedResource Remove="Design\**" />
<EmbeddedResource Remove="Graphics\PackedVector\**" />
Expand All @@ -41,6 +43,7 @@ This package provides you with MonoGame Framework that uses OpenGL for rendering
</ItemGroup>

<ItemGroup>
<None Remove="Audio\Xact\**" />
<None Remove="Content\**" />
<None Remove="Design\**" />
<None Remove="Graphics\PackedVector\**" />
Expand Down
108 changes: 54 additions & 54 deletions MonoGame/MonoGame.Framework/Platform/Audio/SoundEffect.OpenAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ private void PlatformInitializeBuffer(byte[] buffer, int bufferSize, ALFormat fo
}
}

private void PlatformInitializeXact(MiniFormatTag codec, byte[] buffer, int channels, int sampleRate, int blockAlignment, int loopStart, int loopLength, out TimeSpan duration)
{
if (codec == MiniFormatTag.Adpcm)
{
PlatformInitializeAdpcm(buffer, 0, buffer.Length, sampleRate, (AudioChannels)channels, (blockAlignment + 16) * channels, loopStart, loopLength);
duration = TimeSpan.FromSeconds(SoundBuffer.Duration);
return;
}

throw new NotSupportedException("Unsupported sound format!");
}
// private void PlatformInitializeXact(MiniFormatTag codec, byte[] buffer, int channels, int sampleRate, int blockAlignment, int loopStart, int loopLength, out TimeSpan duration)
// {
// if (codec == MiniFormatTag.Adpcm)
// {
// PlatformInitializeAdpcm(buffer, 0, buffer.Length, sampleRate, (AudioChannels)channels, (blockAlignment + 16) * channels, loopStart, loopLength);
// duration = TimeSpan.FromSeconds(SoundBuffer.Duration);
// return;
// }
//
// throw new NotSupportedException("Unsupported sound format!");
// }

#endregion

Expand All @@ -178,49 +178,49 @@ private void PlatformSetupInstance(SoundEffectInstance inst)

#endregion

internal static void PlatformSetReverbSettings(ReverbSettings reverbSettings)
{
if (!OpenALSoundController.Efx.IsInitialized)
return;

if (ReverbEffect != 0)
return;

var efx = OpenALSoundController.Efx;
efx.GenAuxiliaryEffectSlots (1, out ReverbSlot);
efx.GenEffect (out ReverbEffect);
efx.Effect (ReverbEffect, EfxEffecti.EffectType, (int)EfxEffectType.Reverb);
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbReflectionsDelay, reverbSettings.ReflectionsDelayMs / 1000.0f);
efx.Effect (ReverbEffect, EfxEffectf.LateReverbDelay, reverbSettings.ReverbDelayMs / 1000.0f);
// map these from range 0-15 to 0-1
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDiffusion, reverbSettings.EarlyDiffusion / 15f);
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDiffusion, reverbSettings.LateDiffusion / 15f);
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGainLF, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.LowEqGain - 8f), 1.0f));
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbLFReference, (reverbSettings.LowEqCutoff * 50f) + 50f);
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGainHF, XactHelpers.ParseVolumeFromDecibels (reverbSettings.HighEqGain - 8f));
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbHFReference, (reverbSettings.HighEqCutoff * 500f) + 1000f);
// According to Xamarin docs EaxReverbReflectionsGain Unit: Linear gain Range [0.0f .. 3.16f] Default: 0.05f
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbReflectionsGain, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.ReflectionsGainDb), 3.16f));
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGain, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.ReverbGainDb), 1.0f));
// map these from 0-100 down to 0-1
efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDensity, reverbSettings.DensityPct / 100f);
efx.AuxiliaryEffectSlot (ReverbSlot, EfxEffectSlotf.EffectSlotGain, reverbSettings.WetDryMixPct / 200f);

// Dont know what to do with these EFX has no mapping for them. Just ignore for now
// we can enable them as we go.
//efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionLeft, reverbSettings.PositionLeft);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionRight, reverbSettings.PositionRight);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionLeftMatrix, reverbSettings.PositionLeftMatrix);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionRightMatrix, reverbSettings.PositionRightMatrix);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RearDelayMs);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterFrequencyHz);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterMainDb);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterHighFrequencyDb);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.DecayTimeSec);
//efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomSizeFeet);

efx.BindEffectToAuxiliarySlot (ReverbSlot, ReverbEffect);
}
// internal static void PlatformSetReverbSettings(ReverbSettings reverbSettings)
// {
// if (!OpenALSoundController.Efx.IsInitialized)
// return;
//
// if (ReverbEffect != 0)
// return;
//
// var efx = OpenALSoundController.Efx;
// efx.GenAuxiliaryEffectSlots (1, out ReverbSlot);
// efx.GenEffect (out ReverbEffect);
// efx.Effect (ReverbEffect, EfxEffecti.EffectType, (int)EfxEffectType.Reverb);
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbReflectionsDelay, reverbSettings.ReflectionsDelayMs / 1000.0f);
// efx.Effect (ReverbEffect, EfxEffectf.LateReverbDelay, reverbSettings.ReverbDelayMs / 1000.0f);
// // map these from range 0-15 to 0-1
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDiffusion, reverbSettings.EarlyDiffusion / 15f);
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDiffusion, reverbSettings.LateDiffusion / 15f);
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGainLF, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.LowEqGain - 8f), 1.0f));
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbLFReference, (reverbSettings.LowEqCutoff * 50f) + 50f);
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGainHF, XactHelpers.ParseVolumeFromDecibels (reverbSettings.HighEqGain - 8f));
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbHFReference, (reverbSettings.HighEqCutoff * 500f) + 1000f);
// // According to Xamarin docs EaxReverbReflectionsGain Unit: Linear gain Range [0.0f .. 3.16f] Default: 0.05f
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbReflectionsGain, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.ReflectionsGainDb), 3.16f));
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbGain, Math.Min (XactHelpers.ParseVolumeFromDecibels (reverbSettings.ReverbGainDb), 1.0f));
// // map these from 0-100 down to 0-1
// efx.Effect (ReverbEffect, EfxEffectf.EaxReverbDensity, reverbSettings.DensityPct / 100f);
// efx.AuxiliaryEffectSlot (ReverbSlot, EfxEffectSlotf.EffectSlotGain, reverbSettings.WetDryMixPct / 200f);
//
// // Dont know what to do with these EFX has no mapping for them. Just ignore for now
// // we can enable them as we go.
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionLeft, reverbSettings.PositionLeft);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionRight, reverbSettings.PositionRight);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionLeftMatrix, reverbSettings.PositionLeftMatrix);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.PositionRightMatrix, reverbSettings.PositionRightMatrix);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RearDelayMs);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterFrequencyHz);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterMainDb);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomFilterHighFrequencyDb);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.DecayTimeSec);
// //efx.SetEffectParam (ReverbEffect, EfxEffectf.LowFrequencyReference, reverbSettings.RoomSizeFeet);
//
// efx.BindEffectToAuxiliarySlot (ReverbSlot, ReverbEffect);
// }

#region IDisposable Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,32 +324,32 @@ void ApplyFilter()
}
}

internal void PlatformSetFilter(FilterMode mode, float filterQ, float frequency)
{
if (!OpenALSoundController.Efx.IsInitialized)
return;

applyFilter = true;
switch (mode)
{
case FilterMode.BandPass:
filterType = EfxFilterType.Bandpass;
break;
case FilterMode.LowPass:
filterType = EfxFilterType.Lowpass;
break;
case FilterMode.HighPass:
filterType = EfxFilterType.Highpass;
break;
}
this.filterQ = filterQ;
this.frequency = frequency;
if (State == SoundState.Playing)
{
ApplyFilter();
applyFilter = false;
}
}
// internal void PlatformSetFilter(FilterMode mode, float filterQ, float frequency)
// {
// if (!OpenALSoundController.Efx.IsInitialized)
// return;
//
// applyFilter = true;
// switch (mode)
// {
// case FilterMode.BandPass:
// filterType = EfxFilterType.Bandpass;
// break;
// case FilterMode.LowPass:
// filterType = EfxFilterType.Lowpass;
// break;
// case FilterMode.HighPass:
// filterType = EfxFilterType.Highpass;
// break;
// }
// this.filterQ = filterQ;
// this.frequency = frequency;
// if (State == SoundState.Playing)
// {
// ApplyFilter();
// applyFilter = false;
// }
// }

internal void PlatformClearFilter()
{
Expand Down

0 comments on commit d6e7201

Please sign in to comment.