Navigation Menu

Skip to content

Commit

Permalink
Adding SetVolume function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MainMemory committed Apr 4, 2015
1 parent 8568f23 commit 64d7403
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions SMPSOUT/SMPSOUT.cpp
Expand Up @@ -34,6 +34,7 @@ extern "C"
extern UINT32 SampleRate; // from Sound.c
extern UINT16 FrameDivider;
extern UINT32 SmplsPerFrame;
double VolumeLevel = 1;

__declspec(dllexport) BOOL PlaySega();
__declspec(dllexport) BOOL StopSega();
Expand Down Expand Up @@ -1407,6 +1408,11 @@ extern "C"
return PlaySound(NULL, NULL, SND_ASYNC);
}

__declspec(dllexport) void SetVolume(double volume)
{
VolumeLevel = volume;
}

void NotifySongStopped()
{
if (EnableSKCHacks)
Expand Down
4 changes: 3 additions & 1 deletion SMPSOUT/Sound.c
Expand Up @@ -6,7 +6,7 @@
#include "Engine/smps.h"
#include "Engine/dac.h"


extern double VolumeLevel;

typedef void (*strm_func)(UINT8 ChipID, stream_sample_t **outputs, int samples);

Expand Down Expand Up @@ -493,6 +493,8 @@ UINT32 FillBuffer(WAVE_16BS* Buffer, UINT32 BufferSize)

TempBuf.Left = TempBuf.Left >> 7;
TempBuf.Right = TempBuf.Right >> 7;
TempBuf.Left = (int)(TempBuf.Left * VolumeLevel);
TempBuf.Right = (int)(TempBuf.Right * VolumeLevel);
Buffer[CurSmpl].Left = Limit2Short(TempBuf.Left);
Buffer[CurSmpl].Right = Limit2Short(TempBuf.Right);
}
Expand Down

0 comments on commit 64d7403

Please sign in to comment.