Skip to content

Commit 35532a7

Browse files
committed
Implement logarithmic volume view for VRC7
- S5B volume 0 does not output anything
1 parent 687aab9 commit 35532a7

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Source/PatternEditor.cpp

+22-4
Original file line numberDiff line numberDiff line change
@@ -1960,17 +1960,17 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
19601960
DrawVolBar();
19611961

19621962
// 3db per step
1963-
const double vol = envelope_enable ? 1 : (std::pow(10.0, (((Volume + 1.0) * 3.0) / 20.0)) / 251.18864315095801110850320677993);
1963+
double vol = envelope_enable ? 1 : (std::pow(10.0, (((Volume + 1.0) * 3.0) / 20.0)) / 251.18864315095801110850320677993);
19641964

1965-
const BYTE vol_scaled = OETF_gamma_vol(Volume);
1965+
const BYTE vol_scaled = OETF_gamma_vol(vol);
19661966

19671967
const double note = NoteFromFreq(Freq);
19681968
const double note_envelope = NoteFromFreq(EnvelopeFreq);
19691969
const double note_noise = ((108.0 / double(0x1F)) * double(0x1F - NoisePeriod)) - 12.0;
19701970
const int note_conv = note >= 0 ? int(note + 0.5) : int(note - 0.5);
19711971

19721972

1973-
if (note_conv >= -12 && note_conv <= 96 && (vol_scaled || envelope_enable)) // // //
1973+
if (note_conv >= -12 && note_conv <= 96 && (Volume || envelope_enable)) // // //
19741974
if (noise_enable || envelope_enable)
19751975
DrawVolNote(PrecisePitch ? note : note_conv, vol_scaled, // !! !!
19761976
CTINT_S5B_T[0], CTINT_S5B_T[1], CTINT_S5B_T[2]);
@@ -1987,6 +1987,24 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
19871987
++vis_line;
19881988
};
19891989

1990+
// Draw envelope and noise pitch
1991+
const auto DrawVolFuncVRC7 = [&](double Freq, int Volume) {
1992+
DrawVolBar();
1993+
1994+
// 3db per step
1995+
const double vol = std::pow(10.0, (((Volume + 1.0) * 3.0) / 20.0)) / 251.18864315095801110850320677993;
1996+
1997+
const BYTE vol_scaled = OETF_gamma_vol(vol);
1998+
1999+
const double note = NoteFromFreq(Freq);
2000+
const int note_conv = note >= 0 ? int(note + 0.5) : int(note - 0.5);
2001+
2002+
2003+
if (note_conv >= -12 && note_conv <= 96 && vol_scaled) // // //
2004+
DrawVolNote(PrecisePitch ? note : note_conv, vol_scaled);
2005+
++vis_line;
2006+
};
2007+
19902008
const auto DrawTextFunc = [&] (int xOffsNoDPI, CString text) {
19912009
pDC->SetTextColor(BORDER_COLOR);
19922010
pDC->SetTextAlign(TA_NOUPDATECP);
@@ -2282,7 +2300,7 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
22822300
text.Format(_T("%s, vol = %02i, patch = $%01X"), GetPitchTextFunc(3, period, freq), vol, reg[2] >> 4);
22832301
DrawTextFunc(180, text);
22842302

2285-
DrawVolFunc(freq, (double)vol/(double)0x0F);
2303+
DrawVolFuncVRC7(freq, vol);
22862304
}
22872305
}
22882306

0 commit comments

Comments
 (0)