Skip to content

Commit

Permalink
fixup! Port XAudio to Silk.NET
Browse files Browse the repository at this point in the history
  • Loading branch information
Jklawreszuk committed Dec 6, 2024
1 parent 5a19df7 commit b563530
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sources/engine/Stride.Audio/Layers/XAudio/AudioProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Listener ListenerCreate(Device device)
{
var listener = new Listener();
listener.device = device;
listener.listener = null;
listener.listener = new();
return listener;
}

Expand All @@ -116,7 +116,6 @@ public void ListenerDisable(Listener listener)

public bool ListenerEnable(Listener listener)
{
//unused in Xaudio2
return true;
}

Expand Down Expand Up @@ -149,13 +148,11 @@ public unsafe Source SourceCreate(Listener listener, int sampleRate, int maxNumb
{
//if spatialized we also need those structures to calculate 3D audio
source.emitter = new();
//memset(source.emitter_, 0x0, sizeof(X3DAUDIO_EMITTER));
source.emitter.ChannelCount = 1;
source.emitter.CurveDistanceScaler = 1;
source.emitter.DopplerScaler = 1;

source.dsp_settings = new();
//memset(source.dsp_settings_, 0x0, sizeof(X3DAUDIO_DSP_SETTINGS));
source.dsp_settings.SrcChannelCount = 1;
source.dsp_settings.DstChannelCount = AUDIO_CHANNELS;
var matrix = stackalloc float[AUDIO_CHANNELS];
Expand Down Expand Up @@ -430,7 +427,7 @@ public unsafe void SourceSetPan(Source source, float pan)
{
if (source.Mono)
{
var panning = stackalloc float[2];
var panning = new float[2];
if (pan < 0)
{
panning[0] = 1.0f;
Expand All @@ -441,12 +438,14 @@ public unsafe void SourceSetPan(Source source, float pan)
panning[0] = 1.0f - pan;
panning[1] = 1.0f;
}
source.sourceVoice->SetOutputMatrix<IXAudio2MasteringVoice>(source.masteringVoice, 1, AUDIO_CHANNELS, panning, 0);
fixed(float* panningPtr = &panning[0]){
source.sourceVoice->SetOutputMatrix((IXAudio2Voice*)source.masteringVoice, 1, AUDIO_CHANNELS, panningPtr, 0);
}

}
else
{
var panning = stackalloc float[4];
var panning = new float[4];
if (pan < 0)
{
panning[0] = 1.0f;
Expand All @@ -461,7 +460,9 @@ public unsafe void SourceSetPan(Source source, float pan)
panning[2] = 0.0f;
panning[3] = 1.0f;
}
source.sourceVoice->SetOutputMatrix<IXAudio2MasteringVoice>(source.masteringVoice, 2, AUDIO_CHANNELS, panning, 0);
fixed(float* panningPtr = &panning[0]){
source.sourceVoice->SetOutputMatrix((IXAudio2Voice*)source.masteringVoice, 2, AUDIO_CHANNELS, panningPtr, 0);
}
}
}

Expand Down Expand Up @@ -529,8 +530,7 @@ public unsafe void SourceStop(Source source)
}

public void Update(Device device)
{
//TODO: Add IUpdateAudioProvider ?
{
}
}

Expand Down

0 comments on commit b563530

Please sign in to comment.