Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehjohn committed Aug 16, 2024
1 parent 5490ead commit d3d3bde
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/Zen.System/Modules/Audio/Engines/Bass/BassException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Zen.System.Modules.Audio.Engines.Bass;

public class BassException : Exception
{
public BassException(string message) : base(message)
{
}
}
14 changes: 11 additions & 3 deletions src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void Send(float[] data)

_channel = ManagedBass.BASS_SampleGetChannel(_sampleHandle, BassFlag.BASS_SAMCHAN_STREAM);

ManagedBass.BASS_ChannelSetSync(_channel, BassSync.BASS_SYNC_END | BassSync.BASS_SYNC_ONETIME, Constants.DefaultBufferSize * 4, PlayComplete, IntPtr.Zero);
Logger.LogException(ManagedBass.BASS_ChannelSetSync(_channel, BassSync.BASS_SYNC_END | BassSync.BASS_SYNC_ONETIME, Constants.DefaultBufferSize * 4, PlayComplete, IntPtr.Zero).ToString(), new Exception());

ManagedBass.BASS_ChannelPlay(_channel, false);
}
Expand All @@ -79,9 +79,17 @@ private void Initialise()
{
try
{
ManagedBass.BASS_Init(-1, Constants.SampleRate, BassInit.BASS_DEVICE_MONO, IntPtr.Zero);

if (! ManagedBass.BASS_Init(-1, Constants.SampleRate, BassInit.BASS_DEVICE_MONO, IntPtr.Zero))
{
throw new BassException("Error initialising BASS library.");
}

_sampleHandle = ManagedBass.BASS_SampleCreate(Constants.DefaultBufferSize * 4, Constants.SampleRate, 1, 1, BassFlag.BASS_SAMPLE_FLOAT);

if (_sampleHandle == 0)
{
throw new BassException("Error creating BASS sample.");
}
}
catch (Exception exception)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Zen.System/Modules/AyAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private void RunFrame()
try
{
_resetEvent.WaitOne();

_resetEvent.Reset();

for (var i = 0; i < Constants.DefaultBufferSize; i++)
Expand Down

0 comments on commit d3d3bde

Please sign in to comment.