Hi,
rotary.diff adds course and fine adjustment to the rotary controls.
Default is course adjustment, and pressing the control key gives fine
adjustment. Also cleaned up the wheel code a bit.
While working on this, I noticed that the pan control in the mixer was
not working right. Using the mouse wheel to pan right acted strange. I
saw that the mixer was casting the pan values from float to int and back
to float again for no obvious reason. I believe that truncation and
rounding were affecting the rotary control. So the second patch removes
the int casting, and keeps pan as float and fixes the pan control.
Having looked through the code, I think the pan code in general needs to
be worked over. From what I can see it's working properly now, but the
code is inconsistent, and hard to follow and debug. I have started
looking into this. Not sure if it will be ready for 0.9.4 freeze or even
necessary because it would just be code cleanup.
Cheers,
Scott
Index: gui/src/Mixer/MixerLine.h
===================================================================
--- gui/src/Mixer/MixerLine.h (revision 233)
+++ gui/src/Mixer/MixerLine.h (working copy)
@@ -103,8 +103,8 @@
void setName(QString name) { m_pNameWidget->setText( name ); }
QString getName() { return m_pNameWidget->text(); }
- int getPan();
- void setPan(int value);
+ float getPan();
+ void setPan(float value);
int getActivity() { return m_nActivity; }
void setActivity( uint value ) { m_nActivity = value; }
Index: gui/src/Mixer/Mixer.cpp
===================================================================
--- gui/src/Mixer/Mixer.cpp (revision 233)
+++ gui/src/Mixer/Mixer.cpp (working copy)
@@ -455,9 +455,8 @@
else {
fPanValue = fPan_R / 2.0;
}
- fPanValue = fPanValue * 100.0;
- pLine->setPan( (int)fPanValue ); /// \todo perche' setPan prende un'intero???
+ pLine->setPan( fPanValue );
// activity
if ( pLine->getActivity() > 0 ) {
@@ -602,18 +601,16 @@
void Mixer::panChanged(MixerLine* ref) {
float panValue = ref->getPan();
- float pan_L = (100.0 - panValue) / 100.0;
- float pan_R = panValue / 100.0;
+ float pan_L;
+ float pan_R;
- panValue = panValue / 100.0;
-
if (panValue >= 0.5) {
pan_L = (1.0 - panValue) * 2;
pan_R = 1.0;
}
else {
pan_L = 1.0;
- pan_R = ( 1.0 - ( 1.0 - panValue) ) * 2;
+ pan_R = panValue * 2;
}
int nLine = findMixerLineByRef(ref);
Index: gui/src/Mixer/MixerLine.cpp
===================================================================
--- gui/src/Mixer/MixerLine.cpp (revision 233)
+++ gui/src/Mixer/MixerLine.cpp (working copy)
@@ -367,35 +367,43 @@
emit panChanged( this );
float panValue = ref->getValue();
- float pan_L = (1.0 - panValue) / 1.0;
- float pan_R = panValue / 1.0;
+ float pan_L, pan_R;
+ if (panValue > 0.5) {
+ pan_L = (1.0 - panValue) * 2.0;
+ pan_R = 1.0;
+ } else {
+ pan_L = 1.0;
+ pan_R = panValue * 2.0;
+ }
char m_pFaderPos[100];
sprintf( m_pFaderPos, "%#.2fL, %#.2fR", pan_L, pan_R);
- HydrogenApp::getInstance()->setStatusBarMessage( trUtf8( "Set instrument pan [%1]" ).arg( m_pFaderPos ), 2000 );
+ HydrogenApp::getInstance()->setStatusBarMessage( trUtf8( "Set instr. pan [%1]" ).arg( m_pFaderPos ), 2000 );
m_pPanRotary->setToolTip( QString("Pan ") + QString( m_pFaderPos ) );
}
-
-
-int MixerLine::getPan()
+float MixerLine::getPan()
{
- return (int)( m_pPanRotary->getValue() * 100.0 );
+ return m_pPanRotary->getValue();
}
-void MixerLine::setPan(int value)
+void MixerLine::setPan(float fValue)
{
- float fValue = value / 100.0;
-
if ( fValue != m_pPanRotary->getValue() ) {
m_pPanRotary->setValue( fValue );
- float pan_L = (1.0 - fValue) / 1.0;
- float pan_R = fValue / 1.0;
+ float pan_L, pan_R;
+ if (fValue > 0.5) {
+ pan_L = (1.0 - fValue) * 2.0;
+ pan_R = 1.0;
+ } else {
+ pan_L = 1.0;
+ pan_R = fValue * 2.0;
+ }
char m_pFaderPos[100];
sprintf( m_pFaderPos, "Pan %#.2fL, %#.2fR", pan_L, pan_R);
m_pPanRotary->setToolTip( QString( m_pFaderPos ) );
Index: gui/src/widgets/Rotary.cpp
===================================================================
--- gui/src/widgets/Rotary.cpp (revision 233)
+++ gui/src/widgets/Rotary.cpp (working copy)
@@ -198,28 +198,23 @@
void Rotary::wheelEvent ( QWheelEvent *ev )
{
-// infoLog("wheelEvent delta: " + toString( ev->delta() ) );
ev->accept();
- if ( m_bUseIntSteps ) {
- if ( ev->delta() > 0 ) {
- setValue( getValue() + 1 );
- }
- else {
- setValue( getValue() - 1 );
- }
+ float stepfactor = 5.0; // course adjustment
+ float delta = 1.0;
+
+ // Control Modifier = fine adjustment
+ if (ev->modifiers() == Qt::ControlModifier) {
+ stepfactor = 1.0;
}
- else {
+ if ( !m_bUseIntSteps ) {
float fRange = abs( m_fMax ) + abs( m_fMin );
- float delta = fRange / 100.0;
-
- if ( ev->delta() > 0 ) {
- setValue( m_fValue + delta );
- }
- else {
- setValue( m_fValue - delta );
- }
+ delta = fRange / 100.0;
}
+ if ( ev->delta() < 0 ) {
+ delta = delta * -1.0;
+ }
+ setValue( getValue() + (delta * stepfactor) );
emit valueChanged(this);
}
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel