View Issue Details

IDProjectCategoryView StatusLast Update
0001835OpenMPTAudio I/Opublic2024-10-27 12:24
Reporterrkz Assigned ToSaga Musix  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx64OSWindowsOS Version11
Product VersionOpenMPT 1.31.12.00 / libopenmpt 0.7.11 (current stable) 
Target VersionOpenMPT 1.31.13.00 / libopenmpt 0.7.12 (upcoming stable)Fixed in VersionOpenMPT 1.31.13.00 / libopenmpt 0.7.12 (upcoming stable) 
Summary0001835: MIDI note velocity 'amplify by' only works with integer multiples
Description

Attempting to scale incoming midi note velocity by anything between 100% and 199% yields no modification. As soon as it hits 200% it applies the expected doubling but then doesn't change again until 300%. Seemed like an integer division issue so took a look at the code and have a patch which I did a quick test with after waiting for vs to upgrade. It seems to work fine.

diff --git a/mptrack/Mpt_midi.cpp b/mptrack/Mpt_midi.cpp
index c732a3991..5125db069 100644
--- a/mptrack/Mpt_midi.cpp
+++ b/mptrack/Mpt_midi.cpp
@@ -39,7 +39,8 @@ int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, const BYTE mid
        if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY)
        {
                nVol = (CDLSBank::DLSMidiVolumeToLinear(nVol)+255) >> 8;
-               nVol *= TrackerSettings::Instance().midiVelocityAmp / 100;
+               nVol *= TrackerSettings::Instance().midiVelocityAmp;
+               nVol /= 100;
                Limit(nVol, 1, 256);
                if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL)
                        nVol = static_cast<int>((midivolume / 127.0) * nVol);
Steps To Reproduce

Select midi input with "Record MIDI Note Velocity" set and its "amplify by" set to, e.g., 180%. The effect should be that the vNN is close to double that at 100% but it is not affected.

TagsNo tags attached.
Has the bug occurred in previous versions?
Tested code revision (in case you know it)

Activities

rkz

rkz

2024-10-27 00:38

reporter   ~0006153

Looks like the floating point conversion and cast in the MIDISETUP_MIDIVOL_TO_NOTEVOL case might be avoided with

                if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL)
-                       nVol = static_cast<int>((midivolume / 127.0) * nVol);
+                       nVol = (+midivolume * nVol) / 127;
        } else

but haven't tested that as I don't think my device sends the MIDICC_Volume_Coarse control.

Saga Musix

Saga Musix

2024-10-27 12:24

administrator   ~0006154

Thanks, that whole volume computation block looked a bit strange and could be simplified. Fixed in r22002.

Issue History

Date Modified Username Field Change
2024-10-27 00:19 rkz New Issue
2024-10-27 00:38 rkz Note Added: 0006153
2024-10-27 10:47 Saga Musix Assigned To => Saga Musix
2024-10-27 10:47 Saga Musix Status new => assigned
2024-10-27 12:24 Saga Musix Note Added: 0006154
2024-10-27 12:24 Saga Musix Status assigned => resolved
2024-10-27 12:24 Saga Musix Resolution open => fixed
2024-10-27 12:24 Saga Musix Fixed in Version => OpenMPT 1.31.13.00 / libopenmpt 0.7.12 (upcoming stable)
2024-10-27 12:24 Saga Musix Target Version => OpenMPT 1.31.13.00 / libopenmpt 0.7.12 (upcoming stable)