diff --git a/ChangeLog b/ChangeLog index c893b84ba4..4ebb9b85b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-04-24 Paul Giblock + + * src/core/song.cpp: + Reset LFO counter on song play + + * src/core/controller.cpp: + * include/controller.h: + Change counter from signed int to unsigned + + * src/gui/piano_roll.cpp: + - Allow volume bars to be modified by clicking one bar, then + sweeping the mouse + - shade volume bars according to volume + + 2008-04-20 Tobias Doerffel * src/gui/widgets/group_box.cpp: diff --git a/include/controller.h b/include/controller.h index 8e1cbd0084..a7756bd9b4 100644 --- a/include/controller.h +++ b/include/controller.h @@ -70,7 +70,7 @@ public: return tLimit( _val, 0.0f, 1.0f ); } - static int runningFrames(); + static unsigned int runningFrames(); static float runningTime(); static void triggerFrameCounter( void ); diff --git a/src/core/controller.cpp b/src/core/controller.cpp index 275e8c6691..744ddcdcb1 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -74,7 +74,7 @@ float controller::value( int _offset ) // Get position in frames -int controller::runningFrames() +unsigned int controller::runningFrames() { return s_frames; } @@ -91,6 +91,10 @@ void controller::triggerFrameCounter( void ) { for( int i = 0; i < s_controllers.size(); ++i ) { + // This signal is for updating values for both stubborn knobs and for + // painting. If we ever get all the widgets to use or at least check + // currentValue() then we can throttle the signal and only use it for + // GUI. emit s_controllers.at(i)->valueChanged(); } diff --git a/src/core/song.cpp b/src/core/song.cpp index 6b9cde11ef..bb9f5a41b3 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -210,6 +210,7 @@ void song::doActions( void ) case ActionPlaySong: m_playMode = Mode_PlaySong; m_playing = TRUE; + controller::resetFrameCounter(); break; case ActionPlayTrack: diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index e104dfbb04..3069afbfea 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -457,8 +457,6 @@ pianoRoll::~pianoRoll() } - - void pianoRoll::setCurrentPattern( pattern * _new_pattern ) { m_pattern = _new_pattern; @@ -1183,11 +1181,61 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) } x -= WHITE_KEY_WIDTH; - if( edit_note == TRUE || m_action == CHANGE_NOTE_VOLUME ) + // Volume Bars + if( ( edit_note == TRUE || m_action == CHANGE_NOTE_VOLUME ) && + _me->buttons() & Qt::LeftButton ) { - if( m_action == CHANGE_NOTE_VOLUME && - m_currentNote != NULL ) + // Use nearest-note when changing volume so the bars can + // be "scribbled" + int pos_ticks = ( x * DefaultTicksPerTact ) / m_ppt + + m_currentPosition; + + // get note-vector of current pattern + const noteVector & notes = m_pattern->notes(); + + // will be our iterator in the following loop + noteVector::const_iterator it = notes.begin(); + + note * shortNote = NULL; + + // Max "snap length" 1/8 note on either side + int shortDistance = DefaultTicksPerTact/8; + + // loop through vector to find nearest note + while( it != notes.end() ) { + int tmp = abs( pos_ticks - (int)( (*it)->pos() ) ); + + if( tmp < shortDistance && (*it)->length().getTicks() > 0 ) + { + shortDistance = tmp; + shortNote = *it ; + + } + ++it; + + } + + if( shortNote != m_currentNote && + engine::getSong()->playing() == FALSE ) + { + if( m_currentNote != NULL ) { + m_pattern->getInstrumentTrack()->processInEvent( + midiEvent( NOTE_OFF, 0, + m_currentNote->key(), 0 ), midiTime() ); + } + + if( shortNote != NULL ) { + m_lastKey = shortNote->key(); + + m_pattern->getInstrumentTrack()->processInEvent( + midiEvent( NOTE_ON, 0, + shortNote->key(), shortNote->getVolume() ), midiTime() ); + } + } + m_currentNote = shortNote; + + if( m_currentNote != NULL ) { volume vol = tLimit( 2 * ( -_me->y() + height() - PR_BOTTOM_MARGIN ), @@ -1894,7 +1942,9 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) ( *it )->length() < 0 ); } // draw volume-line of note - p.setPen( QPen( QColor( 32, 255, 32, 160 ), + QColor color = QColor::fromHsv( 120, 221, + tMin(255, 60 + ( *it )->getVolume() ) ); + p.setPen( QPen( color, NE_LINE_WIDTH ) ); p.drawLine( x + WHITE_KEY_WIDTH, height() - PR_BOTTOM_MARGIN -