From 2fcd8150d98c4dda0e277a3291e4392afb5a54f7 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 9 Apr 2008 22:16:52 +0000 Subject: [PATCH] changed internal MIDI-time-resolution from 64th to 192th resulting for example in better MIDI-import and allowing to use triplet-notes in LMMS git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@908 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 31 ++++ configure.in | 4 +- include/automation_editor.h | 6 +- include/engine.h | 8 +- include/midi_time.h | 59 +++---- include/pattern.h | 2 +- include/piano_roll.h | 6 +- include/song.h | 9 +- include/timeline.h | 2 +- include/types.h | 2 +- plugins/flp_import/flp_import.cpp | 16 +- plugins/midi_import/midi_import.cpp | 2 +- src/core/automation_pattern.cpp | 5 +- src/core/bb_track_container.cpp | 12 +- src/core/engine.cpp | 8 +- src/core/mixer.cpp | 3 +- src/core/mmp.cpp | 28 ++++ src/core/note_play_handle.cpp | 4 +- src/core/song.cpp | 54 +++--- src/core/timeline.cpp | 16 +- src/core/track.cpp | 48 +++--- src/gui/automation_editor.cpp | 186 +++++++++++---------- src/gui/piano_roll.cpp | 246 +++++++++++++++------------- src/gui/song_editor.cpp | 16 +- src/tracks/bb_track.cpp | 4 +- src/tracks/instrument_track.cpp | 31 +--- src/tracks/pattern.cpp | 19 ++- 27 files changed, 453 insertions(+), 374 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbed8a6a8b..44de7136d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2008-04-09 Tobias Doerffel + + * plugins/flp_import/flp_import.cpp: + * plugins/midi_import/midi_import.cpp: + * include/engine.h: + * include/song.h: + * include/pattern.h: + * include/piano_roll.h: + * include/midi_time.h: + * include/types.h: + * include/timeline.h: + * include/automation_editor.h: + * configure.in: + * src/gui/piano_roll.cpp: + * src/gui/song_editor.cpp: + * src/gui/automation_editor.cpp: + * src/tracks/bb_track.cpp: + * src/tracks/instrument_track.cpp: + * src/tracks/pattern.cpp: + * src/core/note_play_handle.cpp: + * src/core/song.cpp: + * src/core/bb_track_container.cpp: + * src/core/mixer.cpp: + * src/core/mmp.cpp: + * src/core/track.cpp: + * src/core/engine.cpp: + * src/core/timeline.cpp: + * src/core/automation_pattern.cpp: + changed internal MIDI-time-resolution from 64th to 192th resulting for + example in better MIDI-import and allowing to use triplet-notes in LMMS + 2008-04-09 Paul Giblock * include/controller.h: diff --git a/configure.in b/configure.in index 22a1a2ea75..92b7d7bdbd 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.4.0-svn20080406, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080406) +AC_INIT(lmms, 0.4.0-svn20080409, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080409) AM_CONFIG_HEADER(config.h) diff --git a/include/automation_editor.h b/include/automation_editor.h index 14bc49a57d..1b361869af 100644 --- a/include/automation_editor.h +++ b/include/automation_editor.h @@ -202,13 +202,13 @@ private: actions m_action; - Uint32 m_selectStartTact64th; - int m_selectedTact64th; + Uint32 m_selectStartTick; + int m_selectedTick; int m_selectStartLevel; int m_selectedLevels; int m_moveStartLevel; - int m_moveStartTact64th; + int m_moveStartTick; int m_moveXOffset; int m_ppt; diff --git a/include/engine.h b/include/engine.h index 4311937ccd..14adb56321 100644 --- a/include/engine.h +++ b/include/engine.h @@ -137,11 +137,11 @@ public: return( s_controllerRackView ); } - static float framesPerTact64th( void ) + static float framesPerTick( void ) { - return( s_framesPerTact64th ); + return( s_framesPerTick ); } - static void updateFramesPerTact64th( void ); + static void updateFramesPerTick( void ); static const QMap & sampleExtensions( void ) { @@ -151,7 +151,7 @@ public: private: static bool s_hasGUI; - static float s_framesPerTact64th; + static float s_framesPerTick; // core static mixer * s_mixer; diff --git a/include/midi_time.h b/include/midi_time.h index 03757a4f9e..69450beacf 100644 --- a/include/midi_time.h +++ b/include/midi_time.h @@ -2,7 +2,7 @@ * midi_time.h - declaration of class midiTime which provides data-type for * position- and length-variables * - * Copyright (c) 2004-2006 Tobias Doerffel + * Copyright (c) 2004-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,19 +29,20 @@ #include "types.h" +const int DefaultTicksPerTact = 192; class midiTime { public: - inline midiTime( const tact _tact, const tact64th _tact_64th ) : + inline midiTime( const tact _tact, const tick _ticks ) : m_tact( _tact ), - m_tact64th( _tact_64th ) + m_ticks( _ticks ) { } - inline midiTime( const Sint32 _abs = 0 ) : - m_tact( _abs / 64 ), - m_tact64th( _abs % 64 ) + inline midiTime( const int _abs = 0 ) : + m_tact( _abs / DefaultTicksPerTact ), + m_ticks( _abs % DefaultTicksPerTact ) { } @@ -52,30 +53,31 @@ public: inline midiTime toNearestTact( void ) const { - if( m_tact64th >= 32 ) + if( m_ticks >= DefaultTicksPerTact/2 ) { - return( m_tact * 64 + 64 ); + return( m_tact * DefaultTicksPerTact + + DefaultTicksPerTact ); } - return( m_tact * 64 ); + return( m_tact * DefaultTicksPerTact ); } inline midiTime & operator=( const midiTime & _t ) { m_tact = _t.m_tact; - m_tact64th = _t.m_tact64th; + m_ticks = _t.m_ticks; return( *this ); } inline midiTime & operator+=( const midiTime & _t ) { - return( *this = static_cast( *this ) + - static_cast( _t ) ); + return( *this = static_cast( *this ) + + static_cast( _t ) ); } inline midiTime & operator-=( const midiTime & _t ) { - return( *this = static_cast( *this ) - - static_cast( _t ) ); + return( *this = static_cast( *this ) - + static_cast( _t ) ); } inline void setTact( tact _t ) @@ -88,46 +90,47 @@ public: return( m_tact ); } - inline void setTact64th( tact64th _t ) + inline void setTicks( tick _t ) { - m_tact64th = _t; + m_ticks = _t; } - inline tact64th getTact64th( void ) const + inline tick getTicks( void ) const { - return( m_tact64th ); + return( m_ticks ); } // converts time-class in an absolute value, useful for calculations, // comparisons and so on... - inline operator Sint32( void ) const + inline operator int( void ) const { - return( static_cast( m_tact ) * 64 + - static_cast( m_tact64th ) ); + return( static_cast( m_tact ) * DefaultTicksPerTact + + static_cast( m_ticks ) ); } // calculate number of frame that are needed this time - inline f_cnt_t frames( const float _frames_per_tact64th ) const + inline f_cnt_t frames( const float _frames_per_tick ) const { if( m_tact >= 0 ) { - return( static_cast( ( m_tact * 64 - + m_tact64th ) * _frames_per_tact64th ) ); + return( static_cast( + ( m_tact * DefaultTicksPerTact + m_ticks ) * + _frames_per_tick ) ); } return( 0 ); } static inline midiTime fromFrames( const f_cnt_t _frames, - const float _frames_per_tact64th ) + const float _frames_per_tick ) { - return( midiTime( static_cast( _frames / - _frames_per_tact64th ) ) ); + return( midiTime( static_cast( _frames / + _frames_per_tick ) ) ); } private: tact m_tact; - tact64th m_tact64th; + tick m_ticks; } ; diff --git a/include/pattern.h b/include/pattern.h index ecc6a15860..2dd0ad03e2 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -48,7 +48,7 @@ class sampleBuffer; const int DEFAULT_STEPS_PER_TACT = 16; -const int BEATS_PER_TACT = 4; +const int BEATS_PER_TACT = DefaultTicksPerTact/DEFAULT_STEPS_PER_TACT; diff --git a/include/piano_roll.h b/include/piano_roll.h index 852db95dd3..4fafe70137 100644 --- a/include/piano_roll.h +++ b/include/piano_roll.h @@ -213,13 +213,13 @@ private: note * m_currentNote; actions m_action; - Uint32 m_selectStartTact64th; - int m_selectedTact64th; + Uint32 m_selectStartTick; + int m_selectedTick; int m_selectStartKey; int m_selectedKeys; int m_moveStartKey; - int m_moveStartTact64th; + int m_moveStartTick; int m_moveXOffset; int m_notesEditHeight; diff --git a/include/song.h b/include/song.h index 1505978dad..ab371f2605 100644 --- a/include/song.h +++ b/include/song.h @@ -210,7 +210,7 @@ private slots: void doActions( void ); - void updateFramesPerTact64th( void ); + void updateFramesPerTick( void ); @@ -225,12 +225,11 @@ private: return( m_playPos[m_playMode].getTact() ); } - inline tact64th currentTact64th( void ) const + inline tick currentTick( void ) const { - return( m_playPos[m_playMode].getTact64th() ); + return( m_playPos[m_playMode].getTicks() ); } - void setPlayPos( tact _tact_num, tact64th _t_64th, PlayModes - _play_mode ); + void setPlayPos( tact _tact_num, tick _tick, PlayModes _play_mode ); diff --git a/include/timeline.h b/include/timeline.h index 9a7c8ef5ff..8fa88f31da 100644 --- a/include/timeline.h +++ b/include/timeline.h @@ -139,7 +139,7 @@ private: inline int markerX( const midiTime & _t ) const { return( m_xOffset + static_cast( ( _t - m_begin ) * - m_ppt / 64.0f ) ); + m_ppt / DefaultTicksPerTact ) ); } diff --git a/include/types.h b/include/types.h index 09b020e75a..14a7e6b38f 100644 --- a/include/types.h +++ b/include/types.h @@ -39,7 +39,7 @@ typedef signed int Sint32; typedef Uint32 minute; typedef Sint8 second; typedef Sint32 tact; -typedef Sint8 tact64th; +typedef Sint16 tick; typedef Uint8 volume; typedef Sint8 panning; diff --git a/plugins/flp_import/flp_import.cpp b/plugins/flp_import/flp_import.cpp index f9c53d22c3..1797e06038 100644 --- a/plugins/flp_import/flp_import.cpp +++ b/plugins/flp_import/flp_import.cpp @@ -714,8 +714,8 @@ bool flpImport::tryImport( trackContainer * _tc ) int key = *( text + i*bpn + 12 ); int len = *( (int*)( text + i*bpn + 8 ) ); - pos /= 6; - len /= 6; + pos /= 384 / DefaultTicksPerTact; + len /= 384 / DefaultTicksPerTact; note n( len, pos ); n.setKey( key ); m_notes.push_back( qMakePair( @@ -742,8 +742,8 @@ bool flpImport::tryImport( trackContainer * _tc ) int key = *( text + i*bpn + 12 ); int len = *( (int*)( text + i*bpn + 8 ) ); - pos /= 6; - len /= 6; + pos /= 512 / DefaultTicksPerTact; + len /= 512 / DefaultTicksPerTact; /*note n( NULL, len, pos ); n.setKey( key ); m_notes.push_back( qMakePair( @@ -782,7 +782,8 @@ bool flpImport::tryImport( trackContainer * _tc ) { const int ch = ( *it ) >> 16; const int pat = ( ( *it ) & 0xffff ) / 16; - const int pos = ( ( ( *it ) & 0xffff ) % 16 ) * 4; + const int pos = ( ( ( *it ) & 0xffff ) % 16 ) * + (DefaultTicksPerTact/16); while( engine::getBBTrackContainer()->numOfBBs() <= pat ) { track::create( track::BBTrack, engine::getSong() ); @@ -793,7 +794,7 @@ bool flpImport::tryImport( trackContainer * _tc ) { continue; } - p->addNote( note( -64, pos ), FALSE ); + p->addNote( note( -DefaultTicksPerTact, pos ), FALSE ); } // now process all notes @@ -837,7 +838,8 @@ bool flpImport::tryImport( trackContainer * _tc ) bbTrack * bbt = bbTrack::findBBTrack( pat_num ); trackContentObject * tco = bbt->addTCO( bbt->createTCO( 0 ) ); - tco->movePosition( midiTime( ( ( *it ) & 0xffff ) * 64 ) ); + tco->movePosition( midiTime( ( ( *it ) & 0xffff ) * + DefaultTicksPerTact ) ); } if( project_cur_pat < engine::getBBTrackContainer()->numOfBBs() ) diff --git a/plugins/midi_import/midi_import.cpp b/plugins/midi_import/midi_import.cpp index 4a5ebf0c9d..a3639ee411 100644 --- a/plugins/midi_import/midi_import.cpp +++ b/plugins/midi_import/midi_import.cpp @@ -170,7 +170,7 @@ invalid_format: pd.show(); // calculate some timing stuff - int crotchet_time = 16; + int crotchet_time = 16*3; int divisor = m_timingDivision ? m_timingDivision : 96; int multiplier = crotchet_time; int g = gcd( crotchet_time, divisor ); diff --git a/src/core/automation_pattern.cpp b/src/core/automation_pattern.cpp index 37ffcd5c41..4305b873c5 100644 --- a/src/core/automation_pattern.cpp +++ b/src/core/automation_pattern.cpp @@ -125,9 +125,10 @@ midiTime automationPattern::length( void ) const { max_length = tMax( max_length, -it.key() ); } - if( max_length % 64 == 0 ) + if( max_length % DefaultTicksPerTact == 0 ) { - return( midiTime( tMax( max_length, 64 ) ) ); + return( midiTime( tMax( max_length, + DefaultTicksPerTact ) ) ); } return( midiTime( tMax( midiTime( max_length ).getTact() + 1, 1 ), 0 ) ); diff --git a/src/core/bb_track_container.cpp b/src/core/bb_track_container.cpp index 3bd98b766b..b6a254f99b 100644 --- a/src/core/bb_track_container.cpp +++ b/src/core/bb_track_container.cpp @@ -65,8 +65,9 @@ bool bbTrackContainer::play( midiTime _start, fpp_t _frames, return( played_a_note ); } - _start = ( _start.getTact() % lengthOfBB( _tco_num ) ) * 64 + - _start.getTact64th(); + _start = ( _start.getTact() % lengthOfBB( _tco_num ) ) * + DefaultTicksPerTact + + _start.getTicks(); QList tl = tracks(); for( int i = 0; i < tl.size(); ++i ) { @@ -104,7 +105,7 @@ tact bbTrackContainer::lengthOfBB( int _bb ) trackContentObject * tco = tl[i]->getTCO( _bb ); max_length = tMax( max_length, tco->length() ); } - if( max_length.getTact64th() == 0 ) + if( max_length.getTicks() == 0 ) { return( max_length.getTact() ); } @@ -129,7 +130,7 @@ void bbTrackContainer::removeBB( int _bb ) for( int i = 0; i < tl.size(); ++i ) { delete tl[i]->getTCO( _bb ); - tl[i]->removeTact( _bb * 64 ); + tl[i]->removeTact( _bb * DefaultTicksPerTact ); } if( _bb <= currentBB() ) { @@ -155,7 +156,8 @@ void bbTrackContainer::swapBB( int _bb1, int _bb2 ) void bbTrackContainer::updateBBTrack( trackContentObject * _tco ) { - bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64 ); + bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / + DefaultTicksPerTact ); if( t != NULL ) { t->dataChanged(); diff --git a/src/core/engine.cpp b/src/core/engine.cpp index c4d07d1582..f46b462386 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -45,7 +45,7 @@ bool engine::s_hasGUI = TRUE; -float engine::s_framesPerTact64th; +float engine::s_framesPerTick; mixer * engine::s_mixer = NULL; fxMixer * engine::s_fxMixer = NULL; fxMixerView * engine::s_fxMixerView = NULL; @@ -152,10 +152,10 @@ void engine::destroy( void ) -void engine::updateFramesPerTact64th( void ) +void engine::updateFramesPerTick( void ) { - s_framesPerTact64th = s_mixer->sampleRate() * 60.0f * BEATS_PER_TACT - / 64.0f / s_song->getTempo(); + s_framesPerTick = s_mixer->sampleRate() * 60.0f * 4 / + DefaultTicksPerTact / s_song->getTempo(); } diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index 70888900fb..4ddd6355b0 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -414,7 +414,8 @@ const surroundSampleFrame * mixer::renderNextBuffer( void ) song::Mode_PlayPattern ); if( engine::getSong()->playMode() == song::Mode_PlayPattern && engine::getPianoRoll()->isRecording() == TRUE && - p != last_metro_pos && p.getTact64th() % 16 == 0 ) + p != last_metro_pos && p.getTicks() % + (DefaultTicksPerTact / 4 ) == 0 ) { addPlayHandle( new samplePlayHandle( "misc/metronome01.ogg" ) ); last_metro_pos = p; diff --git a/src/core/mmp.cpp b/src/core/mmp.cpp index 4292ee88d5..e0a91a7ba0 100644 --- a/src/core/mmp.cpp +++ b/src/core/mmp.cpp @@ -603,6 +603,34 @@ void multimediaProject::upgrade( void ) } } + if( version < "0.4.0-svn20080409" ) + { + QStringList s; + s << "note" << "pattern" << "bbtco" << "sampletco" << "time"; + for( QStringList::iterator it = s.begin(); it < s.end(); ++it ) + { + QDomNodeList list = elementsByTagName( *it ); + for( int i = 0; !list.item( i ).isNull(); ++i ) + { + QDomElement el = list.item( i ).toElement(); + el.setAttribute( "pos", + el.attribute( "pos" ).toInt()*3 ); + el.setAttribute( "len", + el.attribute( "len" ).toInt()*3 ); + } + } + QDomNodeList list = elementsByTagName( "timeline" ); + for( int i = 0; !list.item( i ).isNull(); ++i ) + { + QDomElement el = list.item( i ).toElement(); + el.setAttribute( "lp0pos", + el.attribute( "lp0pos" ).toInt()*3 ); + el.setAttribute( "lp1pos", + el.attribute( "lp1pos" ).toInt()*3 ); + } + + } + if( !m_head.hasAttribute( "mastervol" ) ) { m_head.setAttribute( "mastervol", 100 ); diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 7e57576d5b..ec6b18e066 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -120,7 +120,7 @@ notePlayHandle::notePlayHandle( instrumentTrack * _it, ( m_instrumentTrack->getVolume() / 100.0f ) * 127 ), 0, 127 ) ), midiTime::fromFrames( offset(), - engine::framesPerTact64th() ) ); + engine::framesPerTick() ) ); } @@ -314,7 +314,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s ) m_instrumentTrack->m_midiPort->outputChannel(), key(), 0 ), midiTime::fromFrames( m_framesBeforeRelease, - engine::framesPerTact64th() ) ); + engine::framesPerTick() ) ); m_released = TRUE; } diff --git a/src/core/song.cpp b/src/core/song.cpp index 69a71ae3ea..f969f72773 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -98,7 +98,7 @@ song::song( void ) : connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), this, - SLOT( updateFramesPerTact64th() ) ); + SLOT( updateFramesPerTick() ) ); m_masterVolumeModel.setTrack( m_automationTrack ); @@ -147,7 +147,7 @@ void song::setTempo( void ) } // m_bpmSpinBox->setInitValue( _new_bpm ); - engine::updateFramesPerTact64th(); + engine::updateFramesPerTick(); emit tempoChanged( tempo ); } @@ -172,7 +172,7 @@ void song::doActions( void ) { case timeLine::BackToZero: m_playPos[m_playMode].setTact( 0 ); - m_playPos[m_playMode].setTact64th( 0 ); + m_playPos[m_playMode].setTicks( 0 ); break; case timeLine::BackToStart: @@ -180,8 +180,8 @@ void song::doActions( void ) { m_playPos[m_playMode].setTact( tl->savedPos().getTact() ); - m_playPos[m_playMode].setTact64th( - tl->savedPos().getTact64th() ); + m_playPos[m_playMode].setTicks( + tl->savedPos().getTicks() ); tl->savePos( -1 ); } break; @@ -195,7 +195,7 @@ void song::doActions( void ) else { m_playPos[m_playMode].setTact( 0 ); - m_playPos[m_playMode].setTact64th( 0 ); + m_playPos[m_playMode].setTicks( 0 ); } m_playPos[m_playMode].setCurrentFrame( 0 ); @@ -340,13 +340,13 @@ void song::processNextBuffer( void ) { m_playPos[m_playMode].setTact( tl->loopBegin().getTact() ); - m_playPos[m_playMode].setTact64th( - tl->loopBegin().getTact64th() ); + m_playPos[m_playMode].setTicks( + tl->loopBegin().getTicks() ); } } f_cnt_t total_frames_played = 0; - float frames_per_tact64th = engine::framesPerTact64th(); + float frames_per_tick = engine::framesPerTick(); while( total_frames_played < engine::getMixer()->framesPerPeriod() ) @@ -355,13 +355,13 @@ void song::processNextBuffer( void ) ->framesPerPeriod() - total_frames_played; float current_frame = m_playPos[m_playMode].currentFrame(); - // did we play a 64th of a tact? - if( current_frame >= frames_per_tact64th ) + // did we play a tick? + if( current_frame >= frames_per_tick ) { - int tact64th = m_playPos[m_playMode].getTact64th() - + (int)( current_frame / frames_per_tact64th ); + int ticks = m_playPos[m_playMode].getTicks() + + (int)( current_frame / frames_per_tick ); // did we play a whole tact? - if( tact64th >= 64 ) + if( ticks >= DefaultTicksPerTact ) { // per default we just continue playing even if // there's no more stuff to play @@ -398,7 +398,8 @@ void song::processNextBuffer( void ) m_playPos[m_playMode].setTact( 0 ); } } - m_playPos[m_playMode].setTact64th( tact64th % 64 ); + m_playPos[m_playMode].setTicks( ticks % + DefaultTicksPerTact ); if( check_loop ) { @@ -406,18 +407,17 @@ void song::processNextBuffer( void ) { m_playPos[m_playMode].setTact( tl->loopBegin().getTact() ); - m_playPos[m_playMode].setTact64th( - tl->loopBegin().getTact64th() ); + m_playPos[m_playMode].setTicks( + tl->loopBegin().getTicks() ); } } - current_frame = fmodf( current_frame, - frames_per_tact64th ); + current_frame = fmodf( current_frame, frames_per_tick ); m_playPos[m_playMode].setCurrentFrame( current_frame ); } - f_cnt_t last_frames = (f_cnt_t)frames_per_tact64th - - (f_cnt_t)current_frame; + f_cnt_t last_frames = (f_cnt_t)frames_per_tick - + (f_cnt_t) current_frame; // skip last frame fraction if( last_frames == 0 ) { @@ -426,7 +426,7 @@ void song::processNextBuffer( void ) + 1.0f ); continue; } - // do we have some samples left in this tact64th but this are + // do we have some samples left in this tick but these are // less then samples we have to play? if( last_frames < played_frames ) { @@ -435,7 +435,7 @@ void song::processNextBuffer( void ) played_frames = last_frames; } - if( (f_cnt_t)current_frame == 0 ) + if( (f_cnt_t) current_frame == 0 ) { if( m_playMode == Mode_PlaySong ) { @@ -555,10 +555,10 @@ void song::updateLength( void ) -void song::setPlayPos( tact _tact_num, tact64th _t_64th, PlayModes _play_mode ) +void song::setPlayPos( tact _tact_num, tick _tick, PlayModes _play_mode ) { m_playPos[_play_mode].setTact( _tact_num ); - m_playPos[_play_mode].setTact64th( _t_64th ); + m_playPos[_play_mode].setTicks( _tick ); m_playPos[_play_mode].setCurrentFrame( 0.0f ); } @@ -1034,9 +1034,9 @@ void song::exportProject( void ) -void song::updateFramesPerTact64th( void ) +void song::updateFramesPerTick( void ) { - engine::updateFramesPerTact64th(); + engine::updateFramesPerTick(); } diff --git a/src/core/timeline.cpp b/src/core/timeline.cpp index d0f4c71ee2..df91b2e018 100644 --- a/src/core/timeline.cpp +++ b/src/core/timeline.cpp @@ -68,7 +68,7 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt, m_moveXOff( 0 ) { m_loopPos[0] = 0; - m_loopPos[1] = 64; + m_loopPos[1] = DefaultTicksPerTact; if( s_timeLinePixmap == NULL ) { @@ -247,14 +247,16 @@ void timeLine::paintEvent( QPaintEvent * ) tact tact_num = m_begin.getTact(); int x = m_xOffset + s_posMarkerPixmap->width() / 2 - - ( ( static_cast( m_begin * m_ppt ) / 64 ) % + ( ( static_cast( m_begin * m_ppt ) / + DefaultTicksPerTact ) % static_cast( m_ppt ) ); for( int i = 0; x + i * m_ppt < width(); ++i ) { ++tact_num; if( ( tact_num - 1 ) % - tMax( 1, static_cast( 64.0f / m_ppt ) ) == 0 ) + tMax( 1, static_cast( (float) DefaultTicksPerTact / + m_ppt ) ) == 0 ) { p.setPen( QColor( 224, 224, 224 ) ); p.drawText( x + static_cast( i * m_ppt ) + 1, 15, @@ -292,7 +294,8 @@ void timeLine::mousePressEvent( QMouseEvent * _me ) else { const midiTime t = m_begin + - static_cast( _me->x() * 64 / m_ppt ); + static_cast( _me->x() * + DefaultTicksPerTact / m_ppt ); m_action = MoveLoopBegin; if( m_loopPos[0] > m_loopPos[1] ) { @@ -321,12 +324,13 @@ void timeLine::mousePressEvent( QMouseEvent * _me ) void timeLine::mouseMoveEvent( QMouseEvent * _me ) { const midiTime t = m_begin + static_cast( tMax( _me->x() - - m_xOffset - m_moveXOff, 0 ) * 64 / m_ppt ); + m_xOffset - m_moveXOff, 0 ) * + DefaultTicksPerTact / m_ppt ); switch( m_action ) { case MovePositionMarker: m_pos.setTact( t.getTact() ); - m_pos.setTact64th( t.getTact64th() ); + m_pos.setTicks( t.getTicks() ); m_pos.setCurrentFrame( 0 ); updatePosition(); break; diff --git a/src/core/track.cpp b/src/core/track.cpp index 41ff3ac2b2..5356c9ab02 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -285,7 +285,8 @@ void trackContentObjectView::updateLength( void ) { setFixedWidth( static_cast( m_tco->length() * pixelsPerTact() / - 64 ) + TCO_BORDER_WIDTH * 2 ); + DefaultTicksPerTact ) + + TCO_BORDER_WIDTH * 2 ); } m_trackView->getTrackContainerView()->update(); } @@ -461,7 +462,8 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) const int x = mapToParent( _me->pos() ).x() - m_initialMouseX; midiTime t = tMax( 0, (Sint32) m_trackView->getTrackContainerView()->currentPosition()+ - static_cast( x * 64 / ppt ) ); + static_cast( x * DefaultTicksPerTact / + ppt ) ); if( engine::getMainWindow()->isCtrlPressed() == FALSE && _me->button() == Qt::NoButton ) { @@ -471,7 +473,7 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) m_trackView->getTrackContentWidget()->changePosition(); s_textFloat->setText( QString( "%1:%2" ). arg( m_tco->startPosition().getTact() + 1 ). - arg( m_tco->startPosition().getTact64th() ) ); + arg( m_tco->startPosition().getTicks() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, 8 ) ); } else if( m_action == MoveSelection ) @@ -495,20 +497,23 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) tcos.push_back( tco ); smallest_pos = tMin( smallest_pos, (Sint32)tco->startPosition() + - static_cast( dx * 64 / ppt ) ); + static_cast( dx * + DefaultTicksPerTact / ppt ) ); } for( QVector::iterator it = tcos.begin(); it != tcos.end(); ++it ) { ( *it )->movePosition( ( *it )->startPosition() + - static_cast( dx * 64 / ppt ) - + static_cast( dx * + DefaultTicksPerTact / ppt ) - smallest_pos ); } } else if( m_action == Resize ) { - midiTime t = tMax( 64, - static_cast( _me->x() * 64 / ppt ) ); + midiTime t = tMax( DefaultTicksPerTact, + static_cast( _me->x() * + DefaultTicksPerTact / ppt ) ); if( engine::getMainWindow()->isCtrlPressed() == FALSE && _me->button() == Qt::NoButton ) { @@ -517,11 +522,11 @@ void trackContentObjectView::mouseMoveEvent( QMouseEvent * _me ) m_tco->changeLength( t ); s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ). arg( m_tco->length().getTact() ). - arg( m_tco->length().getTact64th() ). + arg( m_tco->length().getTicks() ). arg( m_tco->startPosition().getTact() + 1 ). - arg( m_tco->startPosition().getTact64th() ). + arg( m_tco->startPosition().getTicks() ). arg( m_tco->endPosition().getTact() + 1 ). - arg( m_tco->endPosition().getTact64th() ) ); + arg( m_tco->endPosition().getTicks() ) ); s_textFloat->moveGlobal( this, QPoint( width() + 2, 8 ) ); } else @@ -760,7 +765,8 @@ void trackContentWidget::changePosition( const midiTime & _new_pos ) ( ts <= begin && te >= end ) ) { tcov->move( static_cast( ( ts - begin ) * ppt / - 64 ), tcov->y() ); + DefaultTicksPerTact ), + tcov->y() ); tcov->show(); } else @@ -828,7 +834,8 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me ) else if( _me->button() == Qt::LeftButton && !m_trackView->getTrackContainerView()->fixedTCOs() ) { - const midiTime pos = getPosition( _me->x() ).getTact() * 64; + const midiTime pos = getPosition( _me->x() ).getTact() * + DefaultTicksPerTact; trackContentObject * tco = getTrack()->addTCO( getTrack()->createTCO( pos ) ); @@ -855,7 +862,7 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe ) tcv->pixelsPerTact() ); flip = tcv->currentPosition() % 256 < 128; - int flipper = (tcv->currentPosition()/64) % 8; + int flipper = (tcv->currentPosition()/DefaultTicksPerTact) % 8; for( int x = 0; x < width(); x+= (int) tcv->pixelsPerTact() ) { p.fillRect( QRect(x, 0, @@ -959,7 +966,8 @@ track * trackContentWidget::getTrack( void ) midiTime trackContentWidget::getPosition( int _mouse_x ) { return( midiTime( m_trackView->getTrackContainerView()-> - currentPosition() + _mouse_x * 64 / + currentPosition() + _mouse_x * + DefaultTicksPerTact / static_cast( m_trackView-> getTrackContainerView()->pixelsPerTact() ) ) ); } @@ -970,7 +978,8 @@ midiTime trackContentWidget::endPosition( const midiTime & _pos_start ) { const float ppt = m_trackView->getTrackContainerView()->pixelsPerTact(); const int w = width(); - return( _pos_start + static_cast( w * 64 / ppt ) ); + return( _pos_start + static_cast( w * DefaultTicksPerTact / + ppt ) ); } @@ -1496,7 +1505,7 @@ trackContentObject * track::getTCO( int _tco_num ) } printf( "called track::getTCO( %d ), " "but TCO %d doesn't exist\n", _tco_num, _tco_num ); - return( addTCO( createTCO( _tco_num * 64 ) ) ); + return( addTCO( createTCO( _tco_num * DefaultTicksPerTact ) ) ); } @@ -1588,7 +1597,8 @@ void track::insertTact( const midiTime & _pos ) { if( ( *it )->startPosition() >= _pos ) { - ( *it )->movePosition( (*it)->startPosition() + 64 ); + ( *it )->movePosition( (*it)->startPosition() + + DefaultTicksPerTact ); } } } @@ -1606,7 +1616,7 @@ void track::removeTact( const midiTime & _pos ) if( ( *it )->startPosition() >= _pos ) { ( *it )->movePosition( tMax( ( *it )->startPosition() - - 64, 0 ) ); + DefaultTicksPerTact, 0 ) ); } } } @@ -1627,7 +1637,7 @@ tact track::length( void ) const last = cur; } } - return( last/64 + 1 ); + return( last/DefaultTicksPerTact + 1 ); } diff --git a/src/gui/automation_editor.cpp b/src/gui/automation_editor.cpp index 8fa389e705..91f8ef8408 100644 --- a/src/gui/automation_editor.cpp +++ b/src/gui/automation_editor.cpp @@ -87,7 +87,7 @@ automationEditor::automationEditor( void ) : m_currentPosition(), m_action( NONE ), m_moveStartLevel( 0 ), - m_moveStartTact64th( 0 ), + m_moveStartTick( 0 ), m_ppt( DEFAULT_PPT ), m_y_delta( DEFAULT_Y_DELTA ), m_y_auto( TRUE ), @@ -462,8 +462,8 @@ inline void automationEditor::drawValueRect( QPainter & _p, void automationEditor::removeSelection( void ) { - m_selectStartTact64th = 0; - m_selectedTact64th = 0; + m_selectStartTick = 0; + m_selectedTick = 0; m_selectStartLevel = 0; m_selectedLevels = 0; } @@ -507,7 +507,7 @@ void automationEditor::keyPressEvent( QKeyEvent * _ke ) if( ( m_timeLine->pos() -= 16 ) < 0 ) { m_timeLine->pos().setTact( 0 ); - m_timeLine->pos().setTact64th( 0 ); + m_timeLine->pos().setTicks( 0 ); } m_timeLine->updatePosition(); break; @@ -626,7 +626,7 @@ void automationEditor::keyPressEvent( QKeyEvent * _ke ) case Qt::Key_Home: m_timeLine->pos().setTact( 0 ); - m_timeLine->pos().setTact64th( 0 ); + m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); break; @@ -671,8 +671,8 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) x -= VALUES_WIDTH; - // get tact-64th in which the user clicked - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the user clicked + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; // get time map of current pattern @@ -688,9 +688,9 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) // and check whether the user clicked on an // existing value - if( pos_tact_64th >= -it.key() && + if( pos_ticks >= -it.key() && len > 0 && - pos_tact_64th <= -it.key() + len && + pos_ticks <= -it.key() + len && it.value() == level ) { break; @@ -707,7 +707,7 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) if( it == time_map.end() ) { // then set new value - midiTime value_pos( pos_tact_64th ); + midiTime value_pos( pos_ticks ); midiTime new_time = m_pattern->putValue( value_pos, @@ -724,7 +724,7 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) int aligned_x = (int)( (float)( ( -it.key() - m_currentPosition ) * - m_ppt ) / 64.0f ); + m_ppt ) / DefaultTicksPerTact ); m_moveXOffset = x - aligned_x - 1; // set move-cursor QCursor c( Qt::SizeAllCursor ); @@ -750,8 +750,8 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) // select an area of values - m_selectStartTact64th = pos_tact_64th; - m_selectedTact64th = 0; + m_selectStartTick = pos_ticks; + m_selectedTick = 0; m_selectStartLevel = level; m_selectedLevels = 1; m_action = SELECT_VALUES; @@ -770,7 +770,7 @@ void automationEditor::mousePressEvent( QMouseEvent * _me ) // move selection (including selected values) // save position where move-process began - m_moveStartTact64th = pos_tact_64th; + m_moveStartTick = pos_ticks; m_moveStartLevel = level; m_action = MOVE_SELECTION; @@ -832,22 +832,22 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) { x -= m_moveXOffset; } - int pos_tact_64th = x * 64 / m_ppt + + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; if( m_action == MOVE_VALUE ) { // moving value - if( pos_tact_64th < 0 ) + if( pos_ticks < 0 ) { - pos_tact_64th = 0; + pos_ticks = 0; } // we moved the value so the value has to be // moved properly according to new starting- // time in the time map of pattern m_pattern->removeValue( - midiTime( pos_tact_64th ) ); - m_pattern->putValue( midiTime( pos_tact_64th ), + midiTime( pos_ticks ) ); + m_pattern->putValue( midiTime( pos_ticks ), level ); } @@ -858,8 +858,8 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) { // set move- or resize-cursor - // get tact-64th in which the cursor is posated - int pos_tact_64th = ( x * 64 ) / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = ( x * DefaultTicksPerTact ) / m_ppt + m_currentPosition; // get time map of current pattern @@ -873,8 +873,8 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) { // and check whether the cursor is over an // existing value - if( pos_tact_64th >= -it.key() && - pos_tact_64th <= -it.key() + + if( pos_ticks >= -it.key() && + pos_ticks <= -it.key() + //TODO: Add constant 4 && it.value() == level ) { @@ -948,17 +948,17 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) 4 ); } - // get tact-64th in which the cursor is posated - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - m_selectedTact64th = pos_tact_64th - - m_selectStartTact64th; - if( (int) m_selectStartTact64th + m_selectedTact64th < + m_selectedTick = pos_ticks - + m_selectStartTick; + if( (int) m_selectStartTick + m_selectedTick < 0 ) { - m_selectedTact64th = -static_cast( - m_selectStartTact64th ); + m_selectedTick = -static_cast( + m_selectStartTick ); } m_selectedLevels = level - m_selectStartLevel; if( level <= m_selectStartLevel ) @@ -973,33 +973,33 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) // move selection + selected values // do horizontal move-stuff - int pos_tact_64th = x * 64 / m_ppt + + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - int tact_64th_diff = pos_tact_64th - - m_moveStartTact64th; - if( m_selectedTact64th > 0 ) + int ticks_diff = pos_ticks - + m_moveStartTick; + if( m_selectedTick > 0 ) { - if( (int) m_selectStartTact64th + - tact_64th_diff < 0 ) + if( (int) m_selectStartTick + + ticks_diff < 0 ) { - tact_64th_diff = -m_selectStartTact64th; + ticks_diff = -m_selectStartTick; } } else { - if( (int) m_selectStartTact64th + - m_selectedTact64th + tact_64th_diff < + if( (int) m_selectStartTick + + m_selectedTick + ticks_diff < 0 ) { - tact_64th_diff = -( - m_selectStartTact64th + - m_selectedTact64th ); + ticks_diff = -( + m_selectStartTick + + m_selectedTick ); } } - m_selectStartTact64th += tact_64th_diff; + m_selectStartTick += ticks_diff; - int tact_diff = tact_64th_diff / 64; - tact_64th_diff = tact_64th_diff % 64; + int tact_diff = ticks_diff / DefaultTicksPerTact; + ticks_diff = ticks_diff % DefaultTicksPerTact; // do vertical move-stuff @@ -1049,18 +1049,18 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) { int value_tact = ( -it.key() >> 6 ) + tact_diff; - int value_tact_64th = ( -it.key() & 63 ) - + tact_64th_diff; - // ensure value_tact_64th range - if( value_tact_64th >> 6 ) + int value_ticks = ( -it.key() & 63 ) + + ticks_diff; + // ensure value_ticks range + if( value_ticks >> 6 ) { - value_tact += value_tact_64th + value_tact += value_ticks >> 6; - value_tact_64th &= 63; + value_ticks &= 63; } m_pattern->removeValue( -it.key() ); new_value_pos = midiTime( value_tact, - value_tact_64th ); + value_ticks ); } new_selValuesForMove[ -m_pattern->putValue( new_value_pos, @@ -1070,7 +1070,7 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) } m_selValuesForMove = new_selValuesForMove; - m_moveStartTact64th = pos_tact_64th; + m_moveStartTick = pos_ticks; m_moveStartLevel = level; } } @@ -1106,17 +1106,17 @@ void automationEditor::mouseMoveEvent( QMouseEvent * _me ) 4 ); } - // get tact-64th in which the cursor is posated - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - m_selectedTact64th = pos_tact_64th - - m_selectStartTact64th; - if( (int) m_selectStartTact64th + m_selectedTact64th < + m_selectedTick = pos_ticks - + m_selectStartTick; + if( (int) m_selectStartTick + m_selectedTick < 0 ) { - m_selectedTact64th = -static_cast( - m_selectStartTact64th ); + m_selectedTick = -static_cast( + m_selectStartTick ); } int level = getLevel( _me->y() ); @@ -1253,9 +1253,9 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) grid_height ); // draw vertical raster - int tact_16th = m_currentPosition / 4; - const int offset = ( m_currentPosition % 4 ) * m_ppt / - DEFAULT_STEPS_PER_TACT / 4; + int tact_16th = m_currentPosition / ( DefaultTicksPerTact / 16 ); + const int offset = ( m_currentPosition % (DefaultTicksPerTact/16) ) * + m_ppt / DEFAULT_STEPS_PER_TACT / 8; if( m_pattern ) { @@ -1330,8 +1330,8 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) // following code draws all visible values // setup selection-vars - int sel_pos_start = m_selectStartTact64th; - int sel_pos_end = m_selectStartTact64th + m_selectedTact64th; + int sel_pos_start = m_selectStartTick; + int sel_pos_end = m_selectStartTick + m_selectedTick; if( sel_pos_start > sel_pos_end ) { qSwap( sel_pos_start, sel_pos_end ); @@ -1351,14 +1351,14 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) do { --it; - Sint32 len_tact_64th = 4; + Sint32 len_ticks = 4; const int level = it.value(); - Sint32 pos_tact_64th = -it.key(); + Sint32 pos_ticks = -it.key(); - const int x = ( pos_tact_64th - m_currentPosition ) * - m_ppt / 64; + const int x = ( pos_ticks - m_currentPosition ) * + m_ppt / DefaultTicksPerTact; if( x > width() - VALUES_WIDTH ) { break; @@ -1369,9 +1369,10 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) { timeMap::iterator it_prev = it; --it_prev; - Sint32 next_pos_tact_64th = -it_prev.key(); - int next_x = ( next_pos_tact_64th - - m_currentPosition ) * m_ppt / 64; + Sint32 next_pos_ticks = -it_prev.key(); + int next_x = ( next_pos_ticks + - m_currentPosition ) * m_ppt / + DefaultTicksPerTact; // skip this value if not in visible area at all if( next_x < 0 ) { @@ -1405,8 +1406,8 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) } else if( level >= sel_level_start && level <= sel_level_end && - pos_tact_64th >= sel_pos_start && - pos_tact_64th + len_tact_64th <= + pos_ticks >= sel_pos_start && + pos_ticks + len_ticks <= sel_pos_end ) { is_selected = TRUE; @@ -1456,8 +1457,9 @@ void automationEditor::paintEvent( QPaintEvent * _pe ) } // now draw selection-frame - int x = ( sel_pos_start - m_currentPosition ) * m_ppt / 64; - int w = ( sel_pos_end - sel_pos_start ) * m_ppt / 64; + int x = ( sel_pos_start - m_currentPosition ) * m_ppt / + DefaultTicksPerTact; + int w = ( sel_pos_end - sel_pos_start ) * m_ppt / DefaultTicksPerTact; int y, h; if( m_y_auto ) { @@ -1787,13 +1789,13 @@ void automationEditor::selectAll( void ) } //TODO: Add constant - int len_tact_64th = 4; + int len_ticks = 4; timeMap & time_map = m_pattern->getTimeMap(); timeMap::iterator it = time_map.begin(); - m_selectStartTact64th = 0; - m_selectedTact64th = -it.key() + len_tact_64th; + m_selectStartTick = 0; + m_selectedTick = -it.key() + len_ticks; m_selectStartLevel = it.value(); m_selectedLevels = 1; @@ -1827,8 +1829,8 @@ void automationEditor::getSelectedValues( timeMap & _selected_values ) return; } - int sel_pos_start = m_selectStartTact64th; - int sel_pos_end = sel_pos_start + m_selectedTact64th; + int sel_pos_start = m_selectStartTick; + int sel_pos_end = sel_pos_start + m_selectedTick; if( sel_pos_start > sel_pos_end ) { qSwap( sel_pos_start, sel_pos_end ); @@ -1847,14 +1849,14 @@ void automationEditor::getSelectedValues( timeMap & _selected_values ) ++it ) { //TODO: Add constant - Sint32 len_tact_64th = 4; + Sint32 len_ticks = DefaultTicksPerTact / 16; int level = it.value(); - Sint32 pos_tact_64th = -it.key(); + Sint32 pos_ticks = -it.key(); if( level >= sel_level_start && level <= sel_level_end && - pos_tact_64th >= sel_pos_start && - pos_tact_64th + len_tact_64th <= sel_pos_end ) + pos_ticks >= sel_pos_start && + pos_ticks + len_ticks <= sel_pos_end ) { _selected_values[it.key()] = level; } @@ -1983,14 +1985,17 @@ void automationEditor::updatePosition( const midiTime & _t ) m_scrollBack == TRUE ) { const int w = width() - VALUES_WIDTH; - if( _t > m_currentPosition + w * 64 / m_ppt ) + if( _t > m_currentPosition + w * DefaultTicksPerTact / m_ppt ) { - m_leftRightScroll->setValue( _t.getTact() * 64 ); + m_leftRightScroll->setValue( _t.getTact() * + DefaultTicksPerTact ); } else if( _t < m_currentPosition ) { - midiTime t = tMax( _t - w * 64 * 64 / m_ppt, 0 ); - m_leftRightScroll->setValue( t.getTact() * 64 ); + midiTime t = tMax( _t - w * DefaultTicksPerTact * + DefaultTicksPerTact / m_ppt, 0 ); + m_leftRightScroll->setValue( t.getTact() * + DefaultTicksPerTact ); } m_scrollBack = FALSE; } @@ -2033,7 +2038,8 @@ void automationEditor::zoomingYChanged( void ) int automationEditor::quantization( void ) const { - return( 64 / m_quantizeComboBox->model()->currentText().right( + return( DefaultTicksPerTact / + m_quantizeComboBox->model()->currentText().right( m_quantizeComboBox->model()->currentText().length() - 2 ).toInt() ); } diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index 03dbf6171d..e104dfbb04 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -137,10 +137,10 @@ pianoRoll::pianoRoll( void ) : m_currentNote( NULL ), m_action( NONE ), m_moveStartKey( 0 ), - m_moveStartTact64th( 0 ), + m_moveStartTick( 0 ), m_notesEditHeight( 100 ), m_ppt( DEFAULT_PR_PPT ), - m_lenOfNewNotes( midiTime( 0, 16 ) ), + m_lenOfNewNotes( midiTime( 0, DefaultTicksPerTact/4 ) ), m_startKey( INITIAL_START_KEY ), m_lastKey( 0 ), m_editMode( DRAW ), @@ -368,6 +368,7 @@ pianoRoll::pianoRoll( void ) : { m_quantizeModel->addItem( "1/" + QString::number( 1 << i ) ); } + m_quantizeModel->addItem( "1/192" ); m_quantizeModel->setValue( m_quantizeModel->findText( "1/16" ) ); m_quantizeComboBox = new comboBox( m_toolBar ); m_quantizeComboBox->setModel( m_quantizeModel ); @@ -389,6 +390,7 @@ pianoRoll::pianoRoll( void ) : QString( "note_" + pixmaps[i] ). toAscii().constData() ) ) ); } + m_noteLenModel->addItem( "1/192" ); m_noteLenModel->setValue( 0 ); m_noteLenComboBox = new comboBox( m_toolBar ); m_noteLenComboBox->setModel( m_noteLenModel ); @@ -594,12 +596,12 @@ inline void pianoRoll::drawDetuningInfo( QPainter & _p, note * _n, Uint16 _x, do { --it; - Sint32 pos_tact_64th = -it.key(); - if( pos_tact_64th > _n->length() ) + Sint32 pos_ticks = -it.key(); + if( pos_ticks > _n->length() ) { break; } - Uint16 pos_x = _x + pos_tact_64th * m_ppt / 64; + Uint16 pos_x = _x + pos_ticks * m_ppt / DefaultTicksPerTact; const int level = it.value(); @@ -615,8 +617,8 @@ inline void pianoRoll::drawDetuningInfo( QPainter & _p, note * _n, Uint16 _x, void pianoRoll::removeSelection( void ) { - m_selectStartTact64th = 0; - m_selectedTact64th = 0; + m_selectStartTick = 0; + m_selectedTick = 0; m_selectStartKey = 0; m_selectedKeys = 0; } @@ -672,7 +674,7 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke ) if( ( m_timeLine->pos() -= 16 ) < 0 ) { m_timeLine->pos().setTact( 0 ); - m_timeLine->pos().setTact64th( 0 ); + m_timeLine->pos().setTicks( 0 ); } m_timeLine->updatePosition(); break; @@ -791,7 +793,7 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke ) case Qt::Key_Home: m_timeLine->pos().setTact( 0 ); - m_timeLine->pos().setTact64th( 0 ); + m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); break; @@ -886,8 +888,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) x -= WHITE_KEY_WIDTH; - // get tact-64th in which the user clicked - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the user clicked + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; @@ -907,16 +909,17 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) } // and check whether the user clicked on an // existing note or an edit-line - if( pos_tact_64th >= ( *it )->pos() && + if( pos_ticks >= ( *it )->pos() && len > 0 && ( ( edit_note == FALSE && - pos_tact_64th <= ( *it )->pos() + len && + pos_ticks <= ( *it )->pos() + len && ( *it )->key() == key_num ) || ( edit_note == TRUE && - pos_tact_64th <= ( *it )->pos() + - NE_LINE_WIDTH * 64 / + pos_ticks <= ( *it )->pos() + + NE_LINE_WIDTH * + DefaultTicksPerTact / m_ppt ) ) ) @@ -959,7 +962,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) // +32 to quanitize the note correctly when placing notes with // the mouse. We do this here instead of in note.quantized // because live notes should still be quantized at the half. - midiTime note_pos( pos_tact_64th - (quantization() / 2) ); + midiTime note_pos( pos_ticks - (quantization() / 2) ); midiTime note_len( newNoteLen() ); note new_note( note_len, note_pos, key_num ); @@ -981,9 +984,10 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) m_currentNote = *it; // clicked at the "tail" of the note? - if( pos_tact_64th*m_ppt/64 > + if( pos_ticks*m_ppt/DefaultTicksPerTact > ( m_currentNote->pos() + - m_currentNote->length() )*m_ppt/64 - + m_currentNote->length() )*m_ppt/ + DefaultTicksPerTact - RESIZE_AREA_WIDTH && m_currentNote->length() > 0 ) { @@ -1002,7 +1006,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) int aligned_x = (int)( (float)( ( m_currentNote->pos() - m_currentPosition ) * - m_ppt ) / 64.0f ); + m_ppt ) / + DefaultTicksPerTact ); m_moveXOffset = x - aligned_x - 1; // set move-cursor QCursor c( Qt::SizeAllCursor ); @@ -1038,8 +1043,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) // select an area of notes - m_selectStartTact64th = pos_tact_64th; - m_selectedTact64th = 0; + m_selectStartTick = pos_ticks; + m_selectedTick = 0; m_selectStartKey = key_num; m_selectedKeys = 1; m_action = SELECT_NOTES; @@ -1062,7 +1067,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) // move selection (including selected notes) // save position where move-process began - m_moveStartTact64th = pos_tact_64th; + m_moveStartTick = pos_ticks; m_moveStartKey = key_num; m_action = MOVE_SELECTION; @@ -1205,17 +1210,17 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) { x -= m_moveXOffset; } - int pos_tact_64th = x * 64 / m_ppt + + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; if( m_action == MOVE_NOTE ) { // moving note - if( pos_tact_64th < 0 ) + if( pos_ticks < 0 ) { - pos_tact_64th = 0; + pos_ticks = 0; } m_currentNote->setPos( midiTime( - pos_tact_64th ) ); + pos_ticks ) ); m_currentNote->setKey( key_num ); // we moved the note so the note has to be @@ -1227,14 +1232,14 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) else { // resizing note - int tact_64th_diff = pos_tact_64th - + int ticks_diff = pos_ticks - m_currentNote->pos(); - if( tact_64th_diff <= 0 ) + if( ticks_diff <= 0 ) { - tact_64th_diff = 1; + ticks_diff = 1; } m_currentNote->setLength( midiTime( - tact_64th_diff ) ); + ticks_diff ) ); m_currentNote->quantizeLength( quantization() ); m_lenOfNewNotes = m_currentNote->length(); m_pattern->dataChanged(); @@ -1247,8 +1252,8 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) { // set move- or resize-cursor - // get tact-64th in which the cursor is posated - int pos_tact_64th = ( x * 64 ) / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = ( x * DefaultTicksPerTact ) / m_ppt + m_currentPosition; // get note-vector of current pattern @@ -1262,8 +1267,8 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) { // and check whether the cursor is over an // existing note - if( pos_tact_64th >= ( *it )->pos() && - pos_tact_64th <= ( *it )->pos() + + if( pos_ticks >= ( *it )->pos() && + pos_ticks <= ( *it )->pos() + ( *it )->length() && ( *it )->key() == key_num && ( *it )->length() > 0 ) @@ -1285,9 +1290,10 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) } // cursor at the "tail" of the note? else if( ( *it )->length() > 0 && - pos_tact_64th*m_ppt/64 > + pos_ticks*m_ppt/DefaultTicksPerTact > ( ( *it )->pos() + - ( *it )->length() )*m_ppt/64 - + ( *it )->length() )*m_ppt/ + DefaultTicksPerTact - RESIZE_AREA_WIDTH ) { if( QApplication::overrideCursor() ) @@ -1375,17 +1381,17 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) 4 ); } - // get tact-64th in which the cursor is posated - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - m_selectedTact64th = pos_tact_64th - - m_selectStartTact64th; - if( (int) m_selectStartTact64th + m_selectedTact64th < + m_selectedTick = pos_ticks - + m_selectStartTick; + if( (int) m_selectStartTick + m_selectedTick < 0 ) { - m_selectedTact64th = -static_cast( - m_selectStartTact64th ); + m_selectedTick = -static_cast( + m_selectStartTick ); } m_selectedKeys = key_num - m_selectStartKey; if( key_num <= m_selectStartKey ) @@ -1400,33 +1406,33 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) // move selection + selected notes // do horizontal move-stuff - int pos_tact_64th = x * 64 / m_ppt + + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - int tact_64th_diff = pos_tact_64th - - m_moveStartTact64th; - if( m_selectedTact64th > 0 ) + int ticks_diff = pos_ticks - + m_moveStartTick; + if( m_selectedTick > 0 ) { - if( (int) m_selectStartTact64th + - tact_64th_diff < 0 ) + if( (int) m_selectStartTick + + ticks_diff < 0 ) { - tact_64th_diff = -m_selectStartTact64th; + ticks_diff = -m_selectStartTick; } } else { - if( (int) m_selectStartTact64th + - m_selectedTact64th + tact_64th_diff < + if( (int) m_selectStartTick + + m_selectedTick + ticks_diff < 0 ) { - tact_64th_diff = -( - m_selectStartTact64th + - m_selectedTact64th ); + ticks_diff = -( + m_selectStartTick + + m_selectedTick ); } } - m_selectStartTact64th += tact_64th_diff; + m_selectStartTick += ticks_diff; - int tact_diff = tact_64th_diff / 64; - tact_64th_diff = tact_64th_diff % 64; + int tact_diff = ticks_diff / DefaultTicksPerTact; + ticks_diff = ticks_diff % DefaultTicksPerTact; // do vertical move-stuff @@ -1471,23 +1477,22 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) { int note_tact = ( *it )->pos().getTact() + tact_diff; - int note_tact_64th = - ( *it )->pos().getTact64th() + - tact_64th_diff; - // ensure note_tact_64th range - if( note_tact_64th >> 6 ) + int note_ticks = ( *it )->pos().getTicks() + + ticks_diff; + // ensure note_ticks range + if( note_ticks >> 6 ) { - note_tact += note_tact_64th >> 6; - note_tact_64th &= 63; + note_tact += note_ticks >> 6; + note_ticks &= 63; } midiTime new_note_pos( note_tact, - note_tact_64th ); + note_ticks ); ( *it )->setPos( new_note_pos ); ( *it )->setKey( ( *it )->key() + key_diff ); *it = m_pattern->rearrangeNote( *it, FALSE ); } - m_moveStartTact64th = pos_tact_64th; + m_moveStartTick = pos_ticks; m_moveStartKey = key_num; } else if( m_editMode == OPEN && !( mouseOverNote() @@ -1529,17 +1534,17 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) 4 ); } - // get tact-64th in which the cursor is posated - int pos_tact_64th = x * 64 / m_ppt + + // get tick in which the cursor is posated + int pos_ticks = x * DefaultTicksPerTact / m_ppt + m_currentPosition; - m_selectedTact64th = pos_tact_64th - - m_selectStartTact64th; - if( (int) m_selectStartTact64th + m_selectedTact64th < + m_selectedTick = pos_ticks - + m_selectStartTick; + if( (int) m_selectStartTick + m_selectedTick < 0 ) { - m_selectedTact64th = -static_cast( - m_selectStartTact64th ); + m_selectedTick = -static_cast( + m_selectStartTick ); } @@ -1764,9 +1769,9 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) height() - PR_TOP_MARGIN - PR_BOTTOM_MARGIN ); // draw vertical raster - int tact_16th = m_currentPosition / 4; - const int offset = ( m_currentPosition % 4 ) * m_ppt / - DEFAULT_STEPS_PER_TACT / 4; + int tact_16th = m_currentPosition / ( DefaultTicksPerTact / 16 ); + const int offset = ( m_currentPosition % (DefaultTicksPerTact/16) ) * + m_ppt / DEFAULT_STEPS_PER_TACT / 8; for( int x = WHITE_KEY_WIDTH - offset; x < width(); x += m_ppt / DEFAULT_STEPS_PER_TACT, ++tact_16th ) { @@ -1797,8 +1802,8 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) // following code draws all notes in visible area + volume-lines // setup selection-vars - int sel_pos_start = m_selectStartTact64th; - int sel_pos_end = m_selectStartTact64th+m_selectedTact64th; + int sel_pos_start = m_selectStartTick; + int sel_pos_end = m_selectStartTick+m_selectedTick; if( sel_pos_start > sel_pos_end ) { qSwap( sel_pos_start, sel_pos_end ); @@ -1827,24 +1832,25 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) for( noteVector::const_iterator it = notes.begin(); it != notes.end(); ++it ) { - Sint32 len_tact_64th = ( *it )->length(); + Sint32 len_ticks = ( *it )->length(); - if( len_tact_64th == 0 ) + if( len_ticks == 0 ) { continue; } - else if( len_tact_64th < 0 ) + else if( len_ticks < 0 ) { - len_tact_64th = 4; + len_ticks = 4; } const int key = ( *it )->key() - m_startKey + 1; - Sint32 pos_tact_64th = ( *it )->pos(); + Sint32 pos_ticks = ( *it )->pos(); - int note_width = len_tact_64th * m_ppt / 64; - const int x = ( pos_tact_64th - m_currentPosition ) * - m_ppt / 64; + int note_width = len_ticks * m_ppt / + DefaultTicksPerTact; + const int x = ( pos_ticks - m_currentPosition ) * + m_ppt / DefaultTicksPerTact; // skip this note if not in visible area at all if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) ) @@ -1872,8 +1878,8 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) } else if( key > sel_key_start && key <= sel_key_end && - pos_tact_64th >= sel_pos_start && - pos_tact_64th + len_tact_64th <= + pos_ticks >= sel_pos_start && + pos_ticks + len_ticks <= sel_pos_end ) { is_selected = TRUE; @@ -1925,9 +1931,10 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) m_notesEditHeight - PR_BOTTOM_MARGIN ); // now draw selection-frame - int x = ( ( sel_pos_start - m_currentPosition ) * m_ppt ) / 64; + int x = ( ( sel_pos_start - m_currentPosition ) * m_ppt ) / + DefaultTicksPerTact; int w = ( ( ( sel_pos_end - m_currentPosition ) * m_ppt ) / - 64 ) - x; + DefaultTicksPerTact ) - x; int y = (int) y_base - sel_key_start * KEY_LINE_HEIGHT; int h = (int) y_base - sel_key_end * KEY_LINE_HEIGHT - y; p.setPen( QColor( 0, 64, 192 ) ); @@ -2228,13 +2235,13 @@ void pianoRoll::selectAll( void ) for( noteVector::const_iterator it = notes.begin(); it != notes.end(); ++it ) { - Uint32 len_tact_64th = ( *it )->length(); + Uint32 len_ticks = ( *it )->length(); - if( len_tact_64th > 0 ) + if( len_ticks > 0 ) { const int key = ( *it )->key(); - Uint32 pos_tact_64th = ( *it )->pos(); + Uint32 pos_ticks = ( *it )->pos(); if( key <= m_selectStartKey || first_time ) { // if we move start-key down, we have to add @@ -2250,18 +2257,18 @@ void pianoRoll::selectAll( void ) { m_selectedKeys = key - m_selectStartKey; } - if( pos_tact_64th < m_selectStartTact64th || + if( pos_ticks < m_selectStartTick || first_time ) { - m_selectStartTact64th = pos_tact_64th; + m_selectStartTick = pos_ticks; } - if( pos_tact_64th + len_tact_64th > - m_selectStartTact64th + m_selectedTact64th || + if( pos_ticks + len_ticks > + m_selectStartTick + m_selectedTick || first_time ) { - m_selectedTact64th = pos_tact_64th + - len_tact_64th - - m_selectStartTact64th; + m_selectedTick = pos_ticks + + len_ticks - + m_selectStartTick; } first_time = FALSE; } @@ -2279,8 +2286,8 @@ void pianoRoll::getSelectedNotes( noteVector & _selected_notes ) return; } - int sel_pos_start = m_selectStartTact64th; - int sel_pos_end = sel_pos_start + m_selectedTact64th; + int sel_pos_start = m_selectStartTick; + int sel_pos_end = sel_pos_start + m_selectedTick; if( sel_pos_start > sel_pos_end ) { qSwap( sel_pos_start, sel_pos_end ); @@ -2298,17 +2305,17 @@ void pianoRoll::getSelectedNotes( noteVector & _selected_notes ) for( noteVector::const_iterator it = notes.begin(); it != notes.end(); ++it ) { - Sint32 len_tact_64th = ( *it )->length(); + Sint32 len_ticks = ( *it )->length(); - if( len_tact_64th > 0 ) + if( len_ticks > 0 ) { int key = ( *it )->key(); - Sint32 pos_tact_64th = ( *it )->pos(); + Sint32 pos_ticks = ( *it )->pos(); if( key > sel_key_start && key <= sel_key_end && - pos_tact_64th >= sel_pos_start && - pos_tact_64th+len_tact_64th <= sel_pos_end ) + pos_ticks >= sel_pos_start && + pos_ticks+len_ticks <= sel_pos_end ) { _selected_notes.push_back( *it ); } @@ -2467,14 +2474,17 @@ void pianoRoll::updatePosition( const midiTime & _t ) m_scrollBack == TRUE ) { const int w = width() - WHITE_KEY_WIDTH; - if( _t > m_currentPosition + w * 64 / m_ppt ) + if( _t > m_currentPosition + w * DefaultTicksPerTact / m_ppt ) { - m_leftRightScroll->setValue( _t.getTact() * 64 ); + m_leftRightScroll->setValue( _t.getTact() * + DefaultTicksPerTact ); } else if( _t < m_currentPosition ) { - midiTime t = tMax( _t - w * 64 * 64 / m_ppt, 0 ); - m_leftRightScroll->setValue( t.getTact() * 64 ); + midiTime t = tMax( _t - w * DefaultTicksPerTact * + DefaultTicksPerTact / m_ppt, 0 ); + m_leftRightScroll->setValue( t.getTact() * + DefaultTicksPerTact ); } m_scrollBack = FALSE; } @@ -2500,7 +2510,7 @@ void pianoRoll::zoomingChanged( void ) int pianoRoll::quantization( void ) const { - return( 64 / m_quantizeModel->currentText().right( + return( DefaultTicksPerTact / m_quantizeModel->currentText().right( m_quantizeModel->currentText().length() - 2 ).toInt() ); } @@ -2514,7 +2524,7 @@ midiTime pianoRoll::newNoteLen( void ) const { return( m_lenOfNewNotes ); } - return( 64 / m_noteLenModel->currentText().right( + return( DefaultTicksPerTact / m_noteLenModel->currentText().right( m_noteLenModel->currentText().length() - 2 ).toInt() ); } @@ -2554,8 +2564,8 @@ noteVector::const_iterator pianoRoll::noteIteratorUnderMouse( void ) } int key_num = getKey( pos.y() ); - int pos_tact_64th = ( pos.x() - WHITE_KEY_WIDTH ) * 64 / m_ppt - + m_currentPosition; + int pos_ticks = ( pos.x() - WHITE_KEY_WIDTH ) * DefaultTicksPerTact / + m_ppt + m_currentPosition; // will be our iterator in the following loop noteVector::const_iterator it = notes.begin(); @@ -2565,8 +2575,8 @@ noteVector::const_iterator pianoRoll::noteIteratorUnderMouse( void ) { // and check whether the cursor is over an // existing note - if( pos_tact_64th >= ( *it )->pos() && - pos_tact_64th <= ( *it )->pos() + ( *it )->length() && + if( pos_ticks >= ( *it )->pos() && + pos_ticks <= ( *it )->pos() + ( *it )->length() && ( *it )->key() == key_num && ( *it )->length() > 0 ) { break; diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index 44dcb318ab..8cbecbabe4 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -411,9 +411,8 @@ void songEditor::keyPressEvent( QKeyEvent * _ke ) tact interesting_tact = m_s->currentTact(); if( interesting_tact > 0 ) { - m_s->setPlayPos( --interesting_tact, - m_s->currentTact64th(), - song::Mode_PlaySong ); + m_s->setPlayPos( --interesting_tact, m_s->currentTick(), + song::Mode_PlaySong ); } } else if( _ke->key() == Qt::Key_Right ) @@ -421,9 +420,8 @@ void songEditor::keyPressEvent( QKeyEvent * _ke ) tact interesting_tact = m_s->currentTact(); if( interesting_tact < MAX_SONG_LENGTH ) { - m_s->setPlayPos( ++interesting_tact, - m_s->currentTact64th(), - song::Mode_PlaySong ); + m_s->setPlayPos( ++interesting_tact, m_s->currentTick(), + song::Mode_PlaySong ); } } else if( _ke->key() == Qt::Key_Space ) @@ -595,13 +593,15 @@ void songEditor::updatePosition( const midiTime & _t ) { const int w = width() - DEFAULT_SETTINGS_WIDGET_WIDTH - TRACK_OP_WIDTH; - if( _t > m_currentPosition + w * 64 / pixelsPerTact() ) + if( _t > m_currentPosition + w * DefaultTicksPerTact / + pixelsPerTact() ) { m_leftRightScroll->setValue( _t.getTact() ); } else if( _t < m_currentPosition ) { - midiTime t = tMax( (int)( _t - w * 64 * 64 / + midiTime t = tMax( (int)( _t - w * DefaultTicksPerTact * + DefaultTicksPerTact / pixelsPerTact() ), 0 ); m_leftRightScroll->setValue( t.getTact() ); diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index a69d3ae25c..55c539c956 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -198,7 +198,7 @@ void bbTCOView::paintEvent( QPaintEvent * ) tact t = engine::getBBTrackContainer()->lengthOfBB( bbTrack::numOfBBTrack( m_bbTCO->getTrack() ) ); - if( m_bbTCO->length() > 64 && t > 0 ) + if( m_bbTCO->length() > DefaultTicksPerTact && t > 0 ) { for( int x = static_cast( t * pixelsPerTact() ); x < width()-2; @@ -362,7 +362,7 @@ bool bbTrack::play( const midiTime & _start, const fpp_t _frames, QList tcos; getTCOsInRange( tcos, _start, _start + static_cast( _frames / - engine::framesPerTact64th() ) ); + engine::framesPerTick() ) ); if ( tcos.size() == 0 ) { diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 4f841cd30b..3d5134d9a9 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -230,7 +230,7 @@ void instrumentTrack::processInEvent( const midiEvent & _me, notePlayHandle * nph = new notePlayHandle( this, _time.frames( - engine::framesPerTact64th() ), + engine::framesPerTick() ), valueRanges::max() / 2, n ); if( engine::getMixer()->addPlayHandle( @@ -256,7 +256,7 @@ void instrumentTrack::processInEvent( const midiEvent & _me, note done_note( midiTime( static_cast( n->totalFramesPlayed() / - engine::framesPerTact64th() ) ), + engine::framesPerTick() ) ), 0, n->key(), n->getVolume(), n->getPanning() ); if( _lock ) @@ -433,7 +433,7 @@ void instrumentTrack::deleteNotePluginData( notePlayHandle * _n ) { note done_note( midiTime( static_cast( _n->totalFramesPlayed() / - engine::framesPerTact64th() ) ), + engine::framesPerTick() ) ), 0, _n->key(), _n->getVolume(), _n->getPanning() ); _n->noteOff(); @@ -499,7 +499,7 @@ bool FASTCALL instrumentTrack::play( const midiTime & _start, const f_cnt_t _offset, Sint16 _tco_num ) { - float frames_per_tact64th = engine::framesPerTact64th(); + const float frames_per_tick = engine::framesPerTick(); QList tcos; bbTrack * bb_track; @@ -517,7 +517,7 @@ bool FASTCALL instrumentTrack::play( const midiTime & _start, else { getTCOsInRange( tcos, _start, _start + static_cast( - _frames / frames_per_tact64th ) ); + _frames / frames_per_tick ) ); bb_track = NULL; sendMidiTime( _start ); } @@ -601,26 +601,7 @@ bool FASTCALL instrumentTrack::play( const midiTime & _start, { const f_cnt_t note_frames = cur_note->length().frames( - frames_per_tact64th ); - -/* // generate according MIDI-events - processOutEvent( midiEvent( NOTE_ON, - m_midiPort->outputChannel(), - cur_note->key(), - cur_note->getVolume() * - 128 / 100 ), - midiTime::fromFrames( - _offset, - frames_per_tact64th ) ); - - processOutEvent( midiEvent( NOTE_OFF, - m_midiPort->outputChannel(), - cur_note->key(), 0 ), - midiTime::fromFrames( - _offset+ - note_frames, - frames_per_tact64th ) ); -*/ + frames_per_tick ); notePlayHandle * note_play_handle = new notePlayHandle( this, _offset, diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 82331e3a16..4b95270227 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -151,9 +151,10 @@ midiTime pattern::length( void ) const { max_length = tMax( max_length, ( *it )->endPos() ); } - if( max_length % 64 == 0 ) + if( max_length % DefaultTicksPerTact == 0 ) { - return( midiTime( tMax( max_length, 64 ) ) ); + return( midiTime( tMax( max_length, + DefaultTicksPerTact ) ) ); } return( midiTime( tMax( midiTime( max_length ).getTact() + 1, 1 ), 0 ) ); @@ -673,7 +674,7 @@ void patternFreezeThread::run( void ) song::playPos & ppp = engine::getSong()->getPlayPos( song::Mode_PlayPattern ); ppp.setTact( 0 ); - ppp.setTact64th( 0 ); + ppp.setTicks( 0 ); ppp.setCurrentFrame( 0 ); ppp.m_timeLineUpdate = FALSE; @@ -958,7 +959,7 @@ void patternView::mousePressEvent( QMouseEvent * _me ) } else { - n->setLength( -64 ); + n->setLength( -DefaultTicksPerTact ); } engine::getSong()->setModified(); update(); @@ -1004,7 +1005,7 @@ void patternView::wheelEvent( QWheelEvent * _we ) if( n->length() == 0 && _we->delta() > 0 ) { - n->setLength( -64 ); + n->setLength( -DefaultTicksPerTact ); n->setVolume( 5 ); } else if( _we->delta() > 0 ) @@ -1151,9 +1152,9 @@ void patternView::paintEvent( QPaintEvent * ) y_pos < central_y ) { Sint16 x1 = 2 * x_base + - static_cast( ( *it )->pos() * ppt / 64 ); + static_cast( ( *it )->pos() * ppt / DefaultTicksPerTact ); Sint16 x2 = - static_cast( ( ( *it )->pos() + ( *it )->length() ) * ppt / 64 ); + static_cast( ( ( *it )->pos() + ( *it )->length() ) * ppt / DefaultTicksPerTact ); p.drawLine( x1, y_base + y_pos, x2, y_base + y_pos ); @@ -1191,7 +1192,7 @@ void patternView::paintEvent( QPaintEvent * ) for( noteVector::iterator it = m_pat->m_notes.begin(); it != m_pat->m_notes.end(); ++it ) { - Sint16 no = ( *it )->pos() / 4; + Sint16 no = ( *it )->pos() / BEATS_PER_TACT; Sint16 x = TCO_BORDER_WIDTH + static_cast( no * w / steps ); Sint16 y = height() - s_stepBtnOff->height() - 1; @@ -1211,7 +1212,7 @@ void patternView::paintEvent( QPaintEvent * ) p.drawPixmap( x, y, stepoverlay ); } } - else if( ( no / BEATS_PER_TACT ) % 2 ) + else if( ( no / 4 ) % 2 ) { p.drawPixmap( x, y, stepoff ); }