Skip to content

Commit 17bb243

Browse files
committed
RSARInstrSet: Adjust ADSR
1 parent 271c159 commit 17bb243

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/main/formats/RSARInstrSet.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "pch.h"
22
#include "RSARInstrSet.h"
33

4-
static const double INTR_FREQUENCY = 1.0 / 192.0;
5-
64
static float GetFallingRate(uint8_t DecayTime) {
75
if (DecayTime == 0x7F)
86
return 65535.0f;
@@ -54,9 +52,9 @@ static void SetupEnvelope(VGMRgn *rgn, uint8_t attack, uint8_t decay, uint8_t su
5452
float realAttack = attackTable[attack];
5553
int msecs = 0;
5654

57-
const float VOLUME_DB_MIN = -904.0f;
55+
const float VOLUME_DB_MIN = -90.4f;
5856

59-
float vol = VOLUME_DB_MIN;
57+
float vol = VOLUME_DB_MIN * 10.0f;
6058
while (vol <= -1.0f / 32.0f) {
6159
vol *= realAttack;
6260
msecs++;
@@ -89,14 +87,14 @@ static void SetupEnvelope(VGMRgn *rgn, uint8_t attack, uint8_t decay, uint8_t su
8987

9088
/* Decay time is the time it takes to get to the sustain level from max vol,
9189
* decaying by decayRate every 1ms. */
92-
rgn->decay_time = ((0.0f - sustainLev) / decayRate) * 1000.0;
90+
rgn->decay_time = ((0.0f - sustainLev) / decayRate) / 1000.0;
9391

9492
rgn->sustain_level = 1.0 - (sustainLev / VOLUME_DB_MIN);
9593

9694
float releaseRate = GetFallingRate(release);
9795

9896
/* Release time is the time it takes to get from sustain level to minimum volume. */
99-
rgn->release_time = ((sustainLev - VOLUME_DB_MIN) / -releaseRate) * 1000.0;
97+
rgn->release_time = ((sustainLev - VOLUME_DB_MIN) / releaseRate) / 1000.0;
10098
}
10199

102100
bool RBNKInstr::LoadInstr() {

0 commit comments

Comments
 (0)