From 852976ed74a0e0352234ce0d4947ab75464cdbc3 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 5 Aug 2009 12:23:08 +0200 Subject: [PATCH] Panning: fixed wrong type-conversion in panningToMidi() Casting to panning_t in calculation in panningToMidi() leads to integer overflows and thus to miscalculations. This resulted for example in wrong panning during note preview when editing panning of a note in PianoRoll. Casting to int instead fixes the issue. (cherry picked from commit 6e3e1513c7263416b227f25d79af1285e44938da) --- include/panning.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/panning.h b/include/panning.h index 56dcfaf53..29d2e5365 100644 --- a/include/panning.h +++ b/include/panning.h @@ -3,7 +3,7 @@ * panning of a note * * Copyright (c) 2004-2009 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -41,9 +41,10 @@ inline stereoVolumeVector panningToVolumeVector( panning_t _p, return v; } -inline Sint16 panningToMidi( panning_t _p ) + +inline int panningToMidi( panning_t _p ) { - return MidiMinPanning + (panning_t) ( + return MidiMinPanning + (int) ( ( (float)( _p - PanningLeft ) ) / ( (float)( PanningRight - PanningLeft ) ) * ( (float)( MidiMaxPanning - MidiMinPanning ) ) );