Files
RP412/MUNGA_L4/L4AUDLVL.h
T
CydandClaude Opus 5 25e25260b1 Home and End are the bass knob
The volume keys wanted a partner, and the bass trim could not be one as it
stood: it scaled the sample data as it loaded, so by the time anyone pressed
a key the audio was already sitting in OpenAL buffers and nothing short of a
restart would move it.

So the trim is now a per-zone gain applied in the mix instead. Each buffer's
depth - how much of the low band it occupies - is still worked out once at
load from its playback rate, but the trim itself is read every frame, which
is what lets Home and End move it while sounds are playing. It is the better
form regardless: no rewriting of sample data, and no quantisation on top of
audio that has already been through one gain stage.

Home raises, End lowers, in steps of 0.05, and the setting is written to
bass.cfg beside the exe exactly as the volume writes volume.cfg. Together
with PageUp and PageDown that is the amplifier and the crossover the
cabinets had in hardware and a desktop does not.

Builds clean, runs, and neither knob fires unprompted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 00:08:55 -05:00

190 lines
4.1 KiB
C++

#pragma once
#include "..\munga\audlvl.h"
#include "l4audhdw.h"
#include "openal/al.h"
enum SampleChannel
{
CHANNEL_LEFT,
CHANNEL_RIGHT,
CHANNEL_CENTER
};
enum SampleLoop
{
LoopAtWill, //Will play once or loop as desired
ForceStatic, //Plays only once even if looped
LoopAlways, //Ramp up and then down
SampleLoopMax
};
struct SAMPLEINFO
{
int bufferIndex;
bool implemented;
const char *file;
SampleChannel chan;
SampleLoop loop;
};
struct PRESETINFO
{
int sampleNum;
SAMPLEINFO samples[5];
bool is3d;
};
extern PRESETINFO allPresets[2][100];
//
// Defined in L4AUDRES.cpp; declared here rather than including that header so
// the level-of-detail and resource headers stay independent of each other.
//
float RPBufferBassGain(int buffer_index);
bool PRESET_isImplemented(int bank, int preset);
int PRESET_getNumSamples(int bank, int preset);
SAMPLEINFO PRESET_getSampleInfo(int bank, int preset, int sampleInd);
void PRESET_setBufferIndex(int bank, int preset, int sampleInd, int index);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PatchLevelOfDetail ~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef MIDIValue SBKPatchID;
typedef MIDIValue SBKBankID;
class PatchLevelOfDetail:
public AudioLevelOfDetail
{
public:
//
//-----------------------------------------------------------------------
// Construction, Destruction, Testing
//-----------------------------------------------------------------------
//
PatchLevelOfDetail(PlugStream *stream);
~PatchLevelOfDetail();
void PlayNote(SourceSet sourceSet);
void StopNote(SourceSet sourceSet);
Logical
TestInstance() const;
virtual AudioVoiceCount
GetVoiceCount()
{return PRESET_getNumSamples(bankID,patchID);}
//
// Gain this zone takes from the Home/End bass trim, 1.0 when untouched.
//
float
GetZoneBassGain(int zone_index)
{return RPBufferBassGain(
PRESET_getSampleInfo(bankID,patchID,zone_index).bufferIndex);}
//
//-----------------------------------------------------------------------
// BuildFromPage
//-----------------------------------------------------------------------
//
static void
BuildFromPage(
PlugStream *stream,
NameList *name_list,
ClassID class_ID,
ObjectID object_ID
);
//
//-----------------------------------------------------------------------
// Accessors
//-----------------------------------------------------------------------
//
void
SetupPatch(SourceSet sourceSet);
MIDINRPNValue
GetMaxMIDIFilterCutoff()
{return maxMIDIFilterCutoff;}
private:
//
//-----------------------------------------------------------------------
// Private data
//-----------------------------------------------------------------------
//
SBKBankID
bankID;
SBKPatchID
patchID;
MIDINRPNValue
maxMIDIFilterCutoff;
#ifdef LAB_ONLY
int
setupCount;
#endif
//
// Keep table of created patchs to verify that duplicates
// are not created
//
#if DEBUG_LEVEL>0
static TableOf<PatchLevelOfDetail*, unsigned int>
patchTableSocket;
#endif
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PatchResource ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class PatchResource:
public AudioResource
{
public:
//
//-----------------------------------------------------------------------
// Construction, Destruction, Testing
//-----------------------------------------------------------------------
//
PatchResource(PlugStream *stream);
~PatchResource();
void PlayNote(SourceSet sourceSet);
void StopNote(SourceSet sourceSet);
Logical
TestInstance() const;
//
//-----------------------------------------------------------------------
// BuildFromPage
//-----------------------------------------------------------------------
//
static void
BuildFromPage(
PlugStream *stream,
NameList *name_list,
ClassID class_ID,
ObjectID object_ID
);
//
//-----------------------------------------------------------------------
// Accessors
//-----------------------------------------------------------------------
//
void
SetupPatch(SourceSet sourceSet);
//
// Gain this zone takes from the Home/End bass trim, 1.0 when untouched.
//
float
GetZoneBassGain(int zone_index);
MIDINRPNValue
GetMaxMIDIFilterCutoff();
};