Use "bar" instead of "tact"

Closes #4865
This commit is contained in:
Alexandre Almeida
2019-10-31 15:13:25 +01:00
committed by Lukas W
parent b8e499d6d8
commit 53e6b645c8
34 changed files with 439 additions and 443 deletions

View File

@@ -176,8 +176,8 @@ private:
static const int TOP_MARGIN = 16;
static const int DEFAULT_Y_DELTA = 6;
static const int DEFAULT_STEPS_PER_TACT = 16;
static const int DEFAULT_PPT = 12 * DEFAULT_STEPS_PER_TACT;
static const int DEFAULT_STEPS_PER_BAR = 16;
static const int DEFAULT_PPB = 12 * DEFAULT_STEPS_PER_BAR;
static const int VALUES_WIDTH = 64;
@@ -230,7 +230,7 @@ private:
float m_drawLastLevel;
tick_t m_drawLastTick;
int m_ppt;
int m_ppb;
int m_y_delta;
bool m_y_auto;

View File

@@ -48,8 +48,8 @@ public:
return "bbtrackcontainer";
}
tact_t lengthOfBB( int _bb ) const;
inline tact_t lengthOfCurrentBB()
bar_t lengthOfBB( int _bb ) const;
inline bar_t lengthOfCurrentBB()
{
return lengthOfBB( currentBB() );
}

View File

@@ -32,10 +32,10 @@
#include "lmms_export.h"
#include "lmms_basics.h"
// note: 1 "Tact" = 1 Measure
const int DefaultTicksPerTact = 192;
const int DefaultStepsPerTact = 16;
const int DefaultBeatsPerTact = DefaultTicksPerTact / DefaultStepsPerTact;
// note: a bar was erroneously called "tact" in older versions of LMMS
const int DefaultTicksPerBar = 192;
const int DefaultStepsPerBar = 16;
const int DefaultBeatsPerBar = DefaultTicksPerBar / DefaultStepsPerBar;
class MeterModel;
@@ -60,19 +60,19 @@ private:
class LMMS_EXPORT MidiTime
{
public:
MidiTime( const tact_t tact, const tick_t ticks );
MidiTime( const bar_t bar, const tick_t ticks );
MidiTime( const tick_t ticks = 0 );
MidiTime quantize(float) const;
MidiTime toAbsoluteTact() const;
MidiTime toAbsoluteBar() const;
MidiTime& operator+=( const MidiTime& time );
MidiTime& operator-=( const MidiTime& time );
// return the tact, rounded down and 0-based
tact_t getTact() const;
// return the tact, rounded up and 0-based
tact_t nextFullTact() const;
// return the bar, rounded down and 0-based
bar_t getBar() const;
// return the bar, rounded up and 0-based
bar_t nextFullBar() const;
void setTicks( tick_t ticks );
tick_t getTicks() const;
@@ -90,21 +90,21 @@ public:
// calculate number of frame that are needed this time
f_cnt_t frames( const float framesPerTick ) const;
double getTimeInMilliseconds(bpm_t beatsPerMinute) const;
double getTimeInMilliseconds( bpm_t beatsPerMinute ) const;
static MidiTime fromFrames( const f_cnt_t frames, const float framesPerTick );
static tick_t ticksPerTact();
static tick_t ticksPerTact( const TimeSig &sig );
static int stepsPerTact();
static void setTicksPerTact( tick_t tpt );
static tick_t ticksPerBar();
static tick_t ticksPerBar( const TimeSig &sig );
static int stepsPerBar();
static void setTicksPerBar( tick_t tpt );
static MidiTime stepPosition( int step );
static double ticksToMilliseconds(tick_t ticks, bpm_t beatsPerMinute);
static double ticksToMilliseconds(double ticks, bpm_t beatsPerMinute);
static double ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute );
static double ticksToMilliseconds( double ticks, bpm_t beatsPerMinute );
private:
tick_t m_ticks;
static tick_t s_ticksPerTact;
static tick_t s_ticksPerBar;
} ;

View File

@@ -382,7 +382,7 @@ private:
int m_oldNotesEditHeight;
int m_notesEditHeight;
int m_ppt; // pixels per tact
int m_ppb; // pixels per bar
int m_totalKeysToScroll;
// remember these values to use them

View File

@@ -45,7 +45,7 @@ class TimeLineWidget;
const bpm_t MinTempo = 10;
const bpm_t DefaultTempo = 140;
const bpm_t MaxTempo = 999;
const tick_t MaxSongLength = 9999 * DefaultTicksPerTact;
const tick_t MaxSongLength = 9999 * DefaultTicksPerBar;
class LMMS_EXPORT Song : public TrackContainer
@@ -155,14 +155,14 @@ public:
m_playPos[playMode].setTicks(ticks);
}
inline int getTacts() const
inline int getBars() const
{
return currentTact();
return currentBar();
}
inline int ticksPerTact() const
inline int ticksPerBar() const
{
return MidiTime::ticksPerTact(m_timeSigModel);
return MidiTime::ticksPerBar(m_timeSigModel);
}
// Returns the beat position inside the bar, 0-based
@@ -254,7 +254,7 @@ public:
}
void updateLength();
tact_t length() const
bar_t length() const
{
return m_length;
}
@@ -382,9 +382,9 @@ private:
virtual ~Song();
inline tact_t currentTact() const
inline bar_t currentBar() const
{
return m_playPos[m_playMode].getTact();
return m_playPos[m_playMode].getBar();
}
inline tick_t currentTick() const
@@ -415,7 +415,7 @@ private:
IntModel m_tempoModel;
MeterModel m_timeSigModel;
int m_oldTicksPerTact;
int m_oldTicksPerBar;
IntModel m_masterVolumeModel;
IntModel m_masterPitchModel;
@@ -445,14 +445,14 @@ private:
PlayModes m_playMode;
PlayPos m_playPos[Mode_Count];
tact_t m_length;
bar_t m_length;
const Pattern* m_patternToPlay;
bool m_loopPattern;
double m_elapsedMilliSeconds[Mode_Count];
tick_t m_elapsedTicks;
tact_t m_elapsedTacts;
bar_t m_elapsedBars;
VstSyncController m_vstSyncController;
@@ -473,9 +473,9 @@ signals:
void projectLoaded();
void playbackStateChanged();
void playbackPositionChanged();
void lengthChanged( int tacts );
void lengthChanged( int bars );
void tempoChanged( bpm_t newBPM );
void timeSignatureChanged( int oldTicksPerTact, int ticksPerTact );
void timeSignatureChanged( int oldTicksPerBar, int ticksPerBar );
void controllerAdded( Controller * );
void controllerRemoved( Controller * );
void updateSampleTracks();

View File

@@ -36,14 +36,14 @@ class StepRecorderWidget : public QWidget
public:
StepRecorderWidget(
QWidget * parent,
const int ppt,
const int ppb,
const int marginTop,
const int marginBottom,
const int marginLeft,
const int marginRight);
//API used by PianoRoll
void setPixelsPerTact(int ppt);
void setPixelsPerBar(int ppb);
void setCurrentPosition(MidiTime currentPosition);
void setBottomMargin(const int marginBottom);
@@ -68,7 +68,7 @@ private:
MidiTime m_curStepStartPos;
MidiTime m_curStepEndPos;
int m_ppt; // pixels per tact
int m_ppb; // pixels per bar
MidiTime m_currentPosition; // current position showed by on PianoRoll
QColor m_colorLineStart;

View File

@@ -72,15 +72,15 @@ public:
} ;
TimeLineWidget(int xoff, int yoff, float ppt, Song::PlayPos & pos,
TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos & pos,
const MidiTime & begin, Song::PlayModes mode, QWidget * parent);
virtual ~TimeLineWidget();
inline QColor const & getBarLineColor() const { return m_barLineColor; }
inline void setBarLineColor(QColor const & tactLineColor) { m_barLineColor = tactLineColor; }
inline void setBarLineColor(QColor const & barLineColor) { m_barLineColor = barLineColor; }
inline QColor const & getBarNumberColor() const { return m_barNumberColor; }
inline void setBarNumberColor(QColor const & tactNumberColor) { m_barNumberColor = tactNumberColor; }
inline void setBarNumberColor(QColor const & barNumberColor) { m_barNumberColor = barNumberColor; }
inline QColor const & getInactiveLoopColor() const { return m_inactiveLoopColor; }
inline void setInactiveLoopColor(QColor const & inactiveLoopColor) { m_inactiveLoopColor = inactiveLoopColor; }
@@ -135,18 +135,18 @@ public:
m_loopPos[0] : m_loopPos[1];
}
inline void savePos( const MidiTime & _pos )
inline void savePos( const MidiTime & pos )
{
m_savedPos = _pos;
m_savedPos = pos;
}
inline const MidiTime & savedPos() const
{
return m_savedPos;
}
inline void setPixelsPerTact( float _ppt )
inline void setPixelsPerBar( float ppb )
{
m_ppt = _ppt;
m_ppb = ppb;
update();
}
@@ -163,7 +163,7 @@ public:
inline int markerX( const MidiTime & _t ) const
{
return m_xOffset + static_cast<int>( ( _t - m_begin ) *
m_ppt / MidiTime::ticksPerTact() );
m_ppb / MidiTime::ticksPerBar() );
}
signals:
@@ -214,7 +214,7 @@ private:
int m_xOffset;
int m_posMarkerX;
float m_ppt;
float m_ppb;
Song::PlayPos & m_pos;
const MidiTime & m_begin;
const Song::PlayModes m_mode;

View File

@@ -266,7 +266,7 @@ protected:
selectableObject::resizeEvent( re );
}
float pixelsPerTact();
float pixelsPerBar();
DataFile createTCODataFiles(const QVector<TrackContentObjectView *> & tcos) const;
@@ -547,10 +547,10 @@ public:
void createTCOsForBB( int bb );
void insertTact( const MidiTime & pos );
void removeTact( const MidiTime & pos );
void insertBar( const MidiTime & pos );
void removeBar( const MidiTime & pos );
tact_t length() const;
bar_t length() const;
inline TrackContainer* trackContainer() const

View File

@@ -54,25 +54,25 @@ public:
QScrollArea * contentWidget()
{
return( m_scrollArea );
return m_scrollArea;
}
inline const MidiTime & currentPosition() const
{
return( m_currentPosition );
return m_currentPosition;
}
virtual bool fixedTCOs() const
{
return( false );
return false;
}
inline float pixelsPerTact() const
inline float pixelsPerBar() const
{
return( m_ppt );
return m_ppb;
}
void setPixelsPerTact( int _ppt );
void setPixelsPerBar( int ppb );
const TrackView * trackViewAt( const int _y ) const;
@@ -80,12 +80,12 @@ public:
inline bool rubberBandActive() const
{
return( m_rubberBand->isEnabled() && m_rubberBand->isVisible() );
return m_rubberBand->isEnabled() && m_rubberBand->isVisible();
}
inline QVector<selectableObject *> selectedObjects()
{
return( m_rubberBand->selectedObjects() );
return m_rubberBand->selectedObjects();
}
@@ -118,7 +118,7 @@ public:
virtual QString nodeName() const
{
return( "trackcontainerview" );
return "trackcontainerview";
}
@@ -139,7 +139,7 @@ public slots:
protected:
static const int DEFAULT_PIXELS_PER_TACT = 16;
static const int DEFAULT_PIXELS_PER_BAR = 16;
virtual void resizeEvent( QResizeEvent * );
@@ -176,7 +176,7 @@ private:
scrollArea * m_scrollArea;
QVBoxLayout * m_scrollLayout;
float m_ppt;
float m_ppb;
RubberBand * m_rubberBand;

View File

@@ -35,7 +35,7 @@
#endif
typedef int32_t tact_t;
typedef int32_t bar_t;
typedef int32_t tick_t;
typedef uint8_t volume_t;
typedef int8_t panning_t;

View File

@@ -188,9 +188,9 @@ public:
smfMidiCC & putValue( MidiTime time, AutomatableModel * objModel, float value )
{
if( !ap || time > lastPos + DefaultTicksPerTact )
if( !ap || time > lastPos + DefaultTicksPerBar )
{
MidiTime pPos = MidiTime( time.getTact(), 0 );
MidiTime pPos = MidiTime( time.getBar(), 0 );
ap = dynamic_cast<AutomationPattern*>(
at->createTCO(0) );
ap->movePosition( pPos );
@@ -200,7 +200,7 @@ public:
lastPos = time;
time = time - ap->startPosition();
ap->putValue( time, value, false );
ap->changeLength( MidiTime( time.getTact() + 1, 0 ) );
ap->changeLength( MidiTime( time.getBar() + 1, 0 ) );
return *this;
}
@@ -267,9 +267,9 @@ public:
void addNote( Note & n )
{
if( !p || n.pos() > lastEnd + DefaultTicksPerTact )
if( !p || n.pos() > lastEnd + DefaultTicksPerBar )
{
MidiTime pPos = MidiTime( n.pos().getTact(), 0 );
MidiTime pPos = MidiTime( n.pos().getBar(), 0 );
p = dynamic_cast<Pattern*>( it->createTCO( 0 ) );
p->movePosition( pPos );
}
@@ -325,8 +325,8 @@ bool MidiImport::readSMF( TrackContainer* tc )
timeSigDenominatorPat->addObject(&timeSigMM.denominatorModel());
// TODO: adjust these to Time.Sig changes
double beatsPerTact = 4;
double ticksPerBeat = DefaultTicksPerTact / beatsPerTact;
double beatsPerBar = 4;
double ticksPerBeat = DefaultTicksPerBar / beatsPerBar;
// Time-sig changes
Alg_time_sigs * timeSigs = &seq->time_sig;

View File

@@ -324,10 +324,10 @@ void CarlaInstrument::play(sampleFrame* workingBuffer)
fTimeInfo.playing = s->isPlaying();
fTimeInfo.frame = s->getPlayPos(s->playMode()).frames(Engine::framesPerTick());
fTimeInfo.usecs = s->getMilliseconds()*1000;
fTimeInfo.bbt.bar = s->getTacts() + 1;
fTimeInfo.bbt.bar = s->getBars() + 1;
fTimeInfo.bbt.beat = s->getBeat() + 1;
fTimeInfo.bbt.tick = s->getBeatTicks();
fTimeInfo.bbt.barStartTick = ticksPerBeat*s->getTimeSigModel().getNumerator()*s->getTacts();
fTimeInfo.bbt.barStartTick = ticksPerBeat*s->getTimeSigModel().getNumerator()*s->getBars();
fTimeInfo.bbt.beatsPerBar = s->getTimeSigModel().getNumerator();
fTimeInfo.bbt.beatType = s->getTimeSigModel().getDenominator();
fTimeInfo.bbt.ticksPerBeat = ticksPerBeat;

View File

@@ -180,7 +180,7 @@ MidiTime AutomationPattern::timeMapLength() const
{
if( m_timeMap.isEmpty() ) return 0;
timeMap::const_iterator it = m_timeMap.end();
return MidiTime( MidiTime( (it-1).key() ).nextFullTact(), 0 );
return MidiTime( MidiTime( (it-1).key() ).nextFullBar(), 0 );
}

View File

@@ -62,7 +62,7 @@ bool BBTrackContainer::play( MidiTime _start, fpp_t _frames,
return false;
}
_start = _start % ( lengthOfBB( _tco_num ) * MidiTime::ticksPerTact() );
_start = _start % ( lengthOfBB( _tco_num ) * MidiTime::ticksPerBar() );
TrackList tl = tracks();
for( TrackList::iterator it = tl.begin(); it != tl.end(); ++it )
@@ -90,9 +90,9 @@ void BBTrackContainer::updateAfterTrackAdd()
tact_t BBTrackContainer::lengthOfBB( int _bb ) const
bar_t BBTrackContainer::lengthOfBB( int _bb ) const
{
MidiTime max_length = MidiTime::ticksPerTact();
MidiTime max_length = MidiTime::ticksPerBar();
const TrackList & tl = tracks();
for (Track* t : tl)
@@ -104,7 +104,7 @@ tact_t BBTrackContainer::lengthOfBB( int _bb ) const
}
}
return max_length.nextFullTact();
return max_length.nextFullBar();
}
@@ -124,7 +124,7 @@ void BBTrackContainer::removeBB( int _bb )
for( TrackList::iterator it = tl.begin(); it != tl.end(); ++it )
{
delete ( *it )->getTCO( _bb );
( *it )->removeTact( _bb * DefaultTicksPerTact );
( *it )->removeBar( _bb * DefaultTicksPerBar );
}
if( _bb <= currentBB() )
{
@@ -151,7 +151,7 @@ void BBTrackContainer::swapBB( int _bb1, int _bb2 )
void BBTrackContainer::updateBBTrack( TrackContentObject * _tco )
{
BBTrack * t = BBTrack::findBBTrack( _tco->startPosition() /
DefaultTicksPerTact );
DefaultTicksPerBar );
if( t != NULL )
{
t->dataChanged();
@@ -247,16 +247,13 @@ AutomatedValueMap BBTrackContainer::automatedValuesAt(MidiTime time, int tcoNum)
Q_ASSERT(tcoNum >= 0);
Q_ASSERT(time.getTicks() >= 0);
auto length_tacts = lengthOfBB(tcoNum);
auto length_ticks = length_tacts * MidiTime::ticksPerTact();
if (time > length_ticks) {
auto length_bars = lengthOfBB(tcoNum);
auto length_ticks = length_bars * MidiTime::ticksPerBar();
if (time > length_ticks)
{
time = length_ticks;
}
return TrackContainer::automatedValuesAt(time + (MidiTime::ticksPerTact() * tcoNum), tcoNum);
return TrackContainer::automatedValuesAt(time + (MidiTime::ticksPerBar() * tcoNum), tcoNum);
}

View File

@@ -105,10 +105,10 @@ void LmmsCore::destroy()
delete ConfigManager::inst();
}
float LmmsCore::framesPerTick(sample_rate_t sample_rate)
float LmmsCore::framesPerTick(sample_rate_t sampleRate)
{
return sample_rate * 60.0f * 4 /
DefaultTicksPerTact / s_song->getTempo();
return sampleRate * 60.0f * 4 /
DefaultTicksPerBar / s_song->getTempo();
}
@@ -117,7 +117,7 @@ float LmmsCore::framesPerTick(sample_rate_t sample_rate)
void LmmsCore::updateFramesPerTick()
{
s_framesPerTick = s_mixer->processingSampleRate() * 60.0f * 4 /
DefaultTicksPerTact / s_song->getTempo();
DefaultTicksPerBar / s_song->getTempo();
}

View File

@@ -361,12 +361,12 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
// Stop crash with metronome if empty project
Engine::getSong()->countTracks() )
{
tick_t ticksPerTact = MidiTime::ticksPerTact();
if ( p.getTicks() % (ticksPerTact / 1 ) == 0 )
tick_t ticksPerBar = MidiTime::ticksPerBar();
if ( p.getTicks() % ( ticksPerBar / 1 ) == 0 )
{
addPlayHandle( new SamplePlayHandle( "misc/metronome02.ogg" ) );
}
else if ( p.getTicks() % (ticksPerTact /
else if ( p.getTicks() % ( ticksPerBar /
song->getTimeSigModel().getNumerator() ) == 0 )
{
addPlayHandle( new SamplePlayHandle( "misc/metronome01.ogg" ) );
@@ -1288,5 +1288,3 @@ void Mixer::fifoWriter::write( surroundSampleFrame * buffer )
m_mixer->m_doChangesMutex.unlock();
}

View File

@@ -55,7 +55,7 @@
#include "PeakController.h"
tick_t MidiTime::s_ticksPerTact = DefaultTicksPerTact;
tick_t MidiTime::s_ticksPerBar = DefaultTicksPerBar;
@@ -66,7 +66,7 @@ Song::Song() :
this ) ) ),
m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this, tr( "Tempo" ) ),
m_timeSigModel( this ),
m_oldTicksPerTact( DefaultTicksPerTact ),
m_oldTicksPerBar( DefaultTicksPerBar ),
m_masterVolumeModel( 100, 0, 200, this, tr( "Master volume" ) ),
m_masterPitchModel( 0, -12, 12, this, tr( "Master pitch" ) ),
m_fileName(),
@@ -86,7 +86,7 @@ Song::Song() :
m_patternToPlay( NULL ),
m_loopPattern( false ),
m_elapsedTicks( 0 ),
m_elapsedTacts( 0 ),
m_elapsedBars( 0 ),
m_loopRenderCount(1),
m_loopRenderRemaining(1)
{
@@ -162,10 +162,10 @@ void Song::setTempo()
void Song::setTimeSignature()
{
MidiTime::setTicksPerTact( ticksPerTact() );
emit timeSignatureChanged( m_oldTicksPerTact, ticksPerTact() );
MidiTime::setTicksPerBar( ticksPerBar() );
emit timeSignatureChanged( m_oldTicksPerBar, ticksPerBar() );
emit dataChanged();
m_oldTicksPerTact = ticksPerTact();
m_oldTicksPerBar = ticksPerBar();
m_vstSyncController.setTimeSignature(
getTimeSigModel().getNumerator(), getTimeSigModel().getDenominator() );
@@ -286,20 +286,20 @@ void Song::processNextBuffer()
int ticks = m_playPos[m_playMode].getTicks() +
( int )( currentFrame / framesPerTick );
// did we play a whole tact?
if( ticks >= MidiTime::ticksPerTact() )
// did we play a whole bar?
if( ticks >= MidiTime::ticksPerBar() )
{
// per default we just continue playing even if
// there's no more stuff to play
// (song-play-mode)
int maxTact = m_playPos[m_playMode].getTact()
int maxBar = m_playPos[m_playMode].getBar()
+ 2;
// then decide whether to go over to next tact
// or to loop back to first tact
// then decide whether to go over to next bar
// or to loop back to first bar
if( m_playMode == Mode_PlayBB )
{
maxTact = Engine::getBBTrackContainer()
maxBar = Engine::getBBTrackContainer()
->lengthOfCurrentBB();
}
else if( m_playMode == Mode_PlayPattern &&
@@ -307,17 +307,17 @@ void Song::processNextBuffer()
tl != NULL &&
tl->loopPointsEnabled() == false )
{
maxTact = m_patternToPlay->length()
.getTact();
maxBar = m_patternToPlay->length()
.getBar();
}
// end of played object reached?
if( m_playPos[m_playMode].getTact() + 1
>= maxTact )
if( m_playPos[m_playMode].getBar() + 1
>= maxBar )
{
// then start from beginning and keep
// offset
ticks %= ( maxTact * MidiTime::ticksPerTact() );
ticks %= ( maxBar * MidiTime::ticksPerBar() );
// wrap milli second counter
setToTimeByTicks(ticks);
@@ -407,8 +407,8 @@ void Song::processNextBuffer()
m_playPos[m_playMode].setCurrentFrame( framesToPlay +
currentFrame );
m_elapsedMilliSeconds[m_playMode] += MidiTime::ticksToMilliseconds(framesToPlay / framesPerTick, getTempo());
m_elapsedTacts = m_playPos[Mode_PlaySong].getTact();
m_elapsedTicks = ( m_playPos[Mode_PlaySong].getTicks() % ticksPerTact() ) / 48;
m_elapsedBars = m_playPos[Mode_PlaySong].getBar();
m_elapsedTicks = ( m_playPos[Mode_PlaySong].getTicks() % ticksPerBar() ) / 48;
}
}
@@ -619,7 +619,7 @@ void Song::updateLength()
continue;
}
const tact_t cur = ( *it )->length();
const bar_t cur = ( *it )->length();
if( cur > m_length )
{
m_length = cur;
@@ -805,7 +805,7 @@ void Song::insertBar()
for( TrackList::const_iterator it = tracks().begin();
it != tracks().end(); ++it )
{
( *it )->insertTact( m_playPos[Mode_PlaySong] );
( *it )->insertBar( m_playPos[Mode_PlaySong] );
}
m_tracksMutex.unlock();
}
@@ -819,7 +819,7 @@ void Song::removeBar()
for( TrackList::const_iterator it = tracks().begin();
it != tracks().end(); ++it )
{
( *it )->removeTact( m_playPos[Mode_PlaySong] );
( *it )->removeBar( m_playPos[Mode_PlaySong] );
}
m_tracksMutex.unlock();
}

View File

@@ -489,8 +489,8 @@ void TrackContentObjectView::updateLength()
else
{
setFixedWidth(
static_cast<int>( m_tco->length() * pixelsPerTact() /
MidiTime::ticksPerTact() ) + 1 /*+
static_cast<int>( m_tco->length() * pixelsPerBar() /
MidiTime::ticksPerBar() ) + 1 /*+
TCO_BORDER_WIDTH * 2-1*/ );
}
m_trackView->trackContainerView()->update();
@@ -528,6 +528,7 @@ void TrackContentObjectView::dragEnterEvent( QDragEnterEvent * dee )
{
TrackContentWidget * tcw = getTrackView()->getTrackContentWidget();
MidiTime tcoPos = MidiTime( m_tco->startPosition() );
if( tcw->canPasteSelection( tcoPos, dee ) == false )
{
dee->ignore();
@@ -567,6 +568,7 @@ void TrackContentObjectView::dropEvent( QDropEvent * de )
{
TrackContentWidget * tcw = getTrackView()->getTrackContentWidget();
MidiTime tcoPos = MidiTime( m_tco->startPosition() );
if( tcw->pasteSelection( tcoPos, de ) == true )
{
de->accept();
@@ -656,7 +658,7 @@ DataFile TrackContentObjectView::createTCODataFiles(
// initialTrackIndex is the index of the track that was touched
metadata.setAttribute( "initialTrackIndex", initialTrackIndex );
metadata.setAttribute( "trackContainerId", tc->id() );
// grabbedTCOPos is the pos of the tact containing the TCO we grabbed
// grabbedTCOPos is the pos of the bar containing the TCO we grabbed
metadata.setAttribute( "grabbedTCOPos", m_tco->startPosition() );
dataFile.content().appendChild( metadata );
@@ -770,23 +772,23 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * me )
{
s_textFloat->setTitle( tr( "Current position" ) );
s_textFloat->setText( QString( "%1:%2" ).
arg( m_tco->startPosition().getTact() + 1 ).
arg( m_tco->startPosition().getBar() + 1 ).
arg( m_tco->startPosition().getTicks() %
MidiTime::ticksPerTact() ) );
MidiTime::ticksPerBar() ) );
}
else if( m_action == Resize || m_action == ResizeLeft )
{
s_textFloat->setTitle( tr( "Current length" ) );
s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ).
arg( m_tco->length().getTact() ).
arg( m_tco->length().getBar() ).
arg( m_tco->length().getTicks() %
MidiTime::ticksPerTact() ).
arg( m_tco->startPosition().getTact() + 1 ).
MidiTime::ticksPerBar() ).
arg( m_tco->startPosition().getBar() + 1 ).
arg( m_tco->startPosition().getTicks() %
MidiTime::ticksPerTact() ).
arg( m_tco->endPosition().getTact() + 1 ).
MidiTime::ticksPerBar() ).
arg( m_tco->endPosition().getBar() + 1 ).
arg( m_tco->endPosition().getTicks() %
MidiTime::ticksPerTact() ) );
MidiTime::ticksPerBar() ) );
}
// s_textFloat->reparent( this );
// setup text-float as if TCO was already moved/resized
@@ -893,7 +895,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
m_hint = NULL;
}
const float ppt = m_trackView->trackContainerView()->pixelsPerTact();
const float ppb = m_trackView->trackContainerView()->pixelsPerBar();
if( m_action == Move )
{
MidiTime newPos = draggedTCOPos( me );
@@ -903,9 +905,9 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
m_tco->movePosition( newPos );
m_trackView->getTrackContentWidget()->changePosition();
s_textFloat->setText( QString( "%1:%2" ).
arg( newPos.getTact() + 1 ).
arg( newPos.getBar() + 1 ).
arg( newPos.getTicks() %
MidiTime::ticksPerTact() ) );
MidiTime::ticksPerBar() ) );
s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2 ) );
}
else if( m_action == MoveSelection )
@@ -945,12 +947,12 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
const bool unquantized = (me->modifiers() & Qt::ControlModifier) || (me->modifiers() & Qt::AltModifier);
const float snapSize = gui->songEditor()->m_editor->getSnapSize();
// Length in ticks of one snap increment
const MidiTime snapLength = MidiTime( (int)(snapSize * MidiTime::ticksPerTact()) );
const MidiTime snapLength = MidiTime( (int)(snapSize * MidiTime::ticksPerBar()) );
if( m_action == Resize )
{
// The clip's new length
MidiTime l = static_cast<int>( me->x() * MidiTime::ticksPerTact() / ppt );
MidiTime l = static_cast<int>( me->x() * MidiTime::ticksPerBar() / ppb );
if ( unquantized )
{ // We want to preserve this adjusted offset,
@@ -985,8 +987,8 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
const int x = mapToParent( me->pos() ).x() - m_initialMousePos.x();
MidiTime t = qMax( 0, (int)
m_trackView->trackContainerView()->currentPosition()+
static_cast<int>( x * MidiTime::ticksPerTact() / ppt ) );
m_trackView->trackContainerView()->currentPosition() +
static_cast<int>( x * MidiTime::ticksPerBar() / ppb ) );
if( unquantized )
{ // We want to preserve this adjusted offset,
@@ -1023,15 +1025,15 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
}
}
s_textFloat->setText( tr( "%1:%2 (%3:%4 to %5:%6)" ).
arg( m_tco->length().getTact() ).
arg( m_tco->length().getBar() ).
arg( m_tco->length().getTicks() %
MidiTime::ticksPerTact() ).
arg( m_tco->startPosition().getTact() + 1 ).
MidiTime::ticksPerBar() ).
arg( m_tco->startPosition().getBar() + 1 ).
arg( m_tco->startPosition().getTicks() %
MidiTime::ticksPerTact() ).
arg( m_tco->endPosition().getTact() + 1 ).
MidiTime::ticksPerBar() ).
arg( m_tco->endPosition().getBar() + 1 ).
arg( m_tco->endPosition().getTicks() %
MidiTime::ticksPerTact() ) );
MidiTime::ticksPerBar() ) );
s_textFloat->moveGlobal( this, QPoint( width() + 2, height() + 2) );
}
else
@@ -1127,13 +1129,13 @@ void TrackContentObjectView::contextMenuEvent( QContextMenuEvent * cme )
/*! \brief How many pixels a tact (bar) takes for this trackContentObjectView.
/*! \brief How many pixels a bar takes for this trackContentObjectView.
*
* \return the number of pixels per tact (bar).
* \return the number of pixels per bar.
*/
float TrackContentObjectView::pixelsPerTact()
float TrackContentObjectView::pixelsPerBar()
{
return m_trackView->trackContainerView()->pixelsPerTact();
return m_trackView->trackContainerView()->pixelsPerBar();
}
@@ -1181,11 +1183,11 @@ bool TrackContentObjectView::mouseMovedDistance( QMouseEvent * me, int distance
*/
MidiTime TrackContentObjectView::draggedTCOPos( QMouseEvent * me )
{
//Pixels per tact
const float ppt = m_trackView->trackContainerView()->pixelsPerTact();
//Pixels per bar
const float ppb = m_trackView->trackContainerView()->pixelsPerBar();
// The pixel distance that the mouse has moved
const int mouseOff = mapToGlobal(me->pos()).x() - m_initialMouseGlobalPos.x();
MidiTime newPos = m_initialTCOPos + mouseOff * MidiTime::ticksPerTact() / ppt;
MidiTime newPos = m_initialTCOPos + mouseOff * MidiTime::ticksPerBar() / ppb;
MidiTime offset = newPos - m_initialTCOPos;
// If the user is holding alt, or pressed ctrl after beginning the drag, don't quantize
if ( me->button() != Qt::NoButton
@@ -1264,13 +1266,13 @@ TrackContentWidget::~TrackContentWidget()
void TrackContentWidget::updateBackground()
{
const int tactsPerBar = 4;
const TrackContainerView * tcv = m_trackView->trackContainerView();
// Assume even-pixels-per-tact. Makes sense, should be like this anyways
int ppt = static_cast<int>( tcv->pixelsPerTact() );
// Assume even-pixels-per-bar. Makes sense, should be like this anyways
int ppb = static_cast<int>( tcv->pixelsPerBar() );
int w = ppt * tactsPerBar;
// alternate between a darker and a lighter color every 4 bars
int w = ppb * 4;
int h = height();
m_background = QPixmap( w * 2, height() );
QPainter pmp( &m_background );
@@ -1281,13 +1283,13 @@ void TrackContentWidget::updateBackground()
// draw lines
// vertical lines
pmp.setPen( QPen( gridColor(), 1 ) );
for( float x = 0; x < w * 2; x += ppt )
for( float x = 0; x < w * 2; x += ppb )
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
}
pmp.setPen( QPen( embossColor(), 1 ) );
for( float x = 1.0; x < w * 2; x += ppt )
for( float x = 1.0; x < w * 2; x += ppb )
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
}
@@ -1382,7 +1384,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos )
it != m_tcoViews.end(); ++it )
{
if( ( *it )->getTrackContentObject()->
startPosition().getTact() == curBB )
startPosition().getBar() == curBB )
{
( *it )->move( 0, ( *it )->y() );
( *it )->raise();
@@ -1398,7 +1400,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos )
it != m_tcoViews.end(); ++it )
{
if( ( *it )->getTrackContentObject()->
startPosition().getTact() != curBB )
startPosition().getBar() != curBB )
{
( *it )->hide();
}
@@ -1415,7 +1417,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos )
const int begin = pos;
const int end = endPosition( pos );
const float ppt = m_trackView->trackContainerView()->pixelsPerTact();
const float ppb = m_trackView->trackContainerView()->pixelsPerBar();
setUpdatesEnabled( false );
for( tcoViewVector::iterator it = m_tcoViews.begin();
@@ -1432,8 +1434,8 @@ void TrackContentWidget::changePosition( const MidiTime & newPos )
( te >= begin && te <= end ) ||
( ts <= begin && te >= end ) )
{
tcov->move( static_cast<int>( ( ts - begin ) * ppt /
MidiTime::ticksPerTact() ),
tcov->move( static_cast<int>( ( ts - begin ) * ppb /
MidiTime::ticksPerBar() ),
tcov->y() );
if( !tcov->isVisible() )
{
@@ -1454,7 +1456,7 @@ void TrackContentWidget::changePosition( const MidiTime & newPos )
/*! \brief Return the position of the trackContentWidget in Tacts.
/*! \brief Return the position of the trackContentWidget in bars.
*
* \param mouseX the mouse's current X position in pixels.
*/
@@ -1463,8 +1465,8 @@ MidiTime TrackContentWidget::getPosition( int mouseX )
TrackContainerView * tv = m_trackView->trackContainerView();
return MidiTime( tv->currentPosition() +
mouseX *
MidiTime::ticksPerTact() /
static_cast<int>( tv->pixelsPerTact() ) );
MidiTime::ticksPerBar() /
static_cast<int>( tv->pixelsPerBar() ) );
}
@@ -1477,7 +1479,7 @@ MidiTime TrackContentWidget::getPosition( int mouseX )
void TrackContentWidget::dragEnterEvent( QDragEnterEvent * dee )
{
MidiTime tcoPos = getPosition( dee->pos().x() );
if( canPasteSelection( tcoPos, dee ) == false )
if( canPasteSelection( tcoPos, dee ) == false )
{
dee->ignore();
}
@@ -1518,7 +1520,7 @@ bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QDropEvent* d
QDomElement metadata = dataFile.content().firstChildElement( "copyMetadata" );
QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" );
MidiTime grabbedTCOPos = tcoPosAttr.value().toInt();
MidiTime grabbedTCOTact = MidiTime( grabbedTCOPos.getTact(), 0 );
MidiTime grabbedTCOBar = MidiTime( grabbedTCOPos.getBar(), 0 );
// Extract the track index that was originally clicked
QDomAttr tiAttr = metadata.attributeNode( "initialTrackIndex" );
@@ -1528,10 +1530,10 @@ bool TrackContentWidget::canPasteSelection( MidiTime tcoPos, const QDropEvent* d
const TrackContainer::TrackList tracks = t->trackContainer()->tracks();
const int currentTrackIndex = tracks.indexOf( t );
// Don't paste if we're on the same tact
// Don't paste if we're on the same bar
auto sourceTrackContainerId = metadata.attributeNode( "trackContainerId" ).value().toUInt();
if( de->source() && sourceTrackContainerId == t->trackContainer()->id() &&
tcoPos == grabbedTCOTact && currentTrackIndex == initialTrackIndex )
tcoPos == grabbedTCOBar && currentTrackIndex == initialTrackIndex )
{
return false;
}
@@ -1596,7 +1598,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
QDomAttr tcoPosAttr = metadata.attributeNode( "grabbedTCOPos" );
MidiTime grabbedTCOPos = tcoPosAttr.value().toInt();
// Snap the mouse position to the beginning of the dropped tact, in ticks
// Snap the mouse position to the beginning of the dropped bar, in ticks
const TrackContainer::TrackList tracks = getTrack()->trackContainer()->tracks();
const int currentTrackIndex = tracks.indexOf( getTrack() );
@@ -1631,7 +1633,7 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * de )
// The new position is the old position plus the offset.
MidiTime pos = tcoElement.attributeNode( "pos" ).value().toInt() + offset;
// If we land on ourselves, offset by one snap
MidiTime shift = MidiTime::ticksPerTact() * gui->songEditor()->m_editor->getSnapSize();
MidiTime shift = MidiTime::ticksPerBar() * gui->songEditor()->m_editor->getSnapSize();
if (offset == 0) { pos += shift; }
TrackContentObject * tco = t->createTCO( pos );
@@ -1695,8 +1697,8 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me )
so.at( i )->setSelected( false);
}
getTrack()->addJournalCheckPoint();
const MidiTime pos = getPosition( me->x() ).getTact() *
MidiTime::ticksPerTact();
const MidiTime pos = getPosition( me->x() ).getBar() *
MidiTime::ticksPerBar();
TrackContentObject * tco = getTrack()->createTCO( pos );
tco->saveJournallingState( false );
@@ -1714,15 +1716,15 @@ void TrackContentWidget::mousePressEvent( QMouseEvent * me )
*/
void TrackContentWidget::paintEvent( QPaintEvent * pe )
{
// Assume even-pixels-per-tact. Makes sense, should be like this anyways
// Assume even-pixels-per-bar. Makes sense, should be like this anyways
const TrackContainerView * tcv = m_trackView->trackContainerView();
int ppt = static_cast<int>( tcv->pixelsPerTact() );
int ppb = static_cast<int>( tcv->pixelsPerBar() );
QPainter p( this );
// Don't draw background on BB-Editor
if( m_trackView->trackContainerView() != gui->getBBEditor()->trackContainerView() )
{
p.drawTiledPixmap( rect(), m_background, QPoint(
tcv->currentPosition().getTact() * ppt, 0 ) );
tcv->currentPosition().getBar() * ppb, 0 ) );
}
}
@@ -1755,15 +1757,15 @@ Track * TrackContentWidget::getTrack()
/*! \brief Return the end position of the trackContentWidget in Tacts.
/*! \brief Return the end position of the trackContentWidget in Bars.
*
* \param posStart the starting position of the Widget (from getPosition())
*/
MidiTime TrackContentWidget::endPosition( const MidiTime & posStart )
{
const float ppt = m_trackView->trackContainerView()->pixelsPerTact();
const float ppb = m_trackView->trackContainerView()->pixelsPerBar();
const int w = width();
return posStart + static_cast<int>( w * MidiTime::ticksPerTact() / ppt );
return posStart + static_cast<int>( w * MidiTime::ticksPerBar() / ppb );
}
@@ -2417,7 +2419,7 @@ TrackContentObject * Track::getTCO( int tcoNum )
}
printf( "called Track::getTCO( %d ), "
"but TCO %d doesn't exist\n", tcoNum, tcoNum );
return createTCO( tcoNum * MidiTime::ticksPerTact() );
return createTCO( tcoNum * MidiTime::ticksPerBar() );
}
@@ -2525,17 +2527,17 @@ void Track::createTCOsForBB( int bb )
* in ascending order by TCO time, once we hit a TCO that was earlier
* than the insert time, we could fall out of the loop early.
*/
void Track::insertTact( const MidiTime & pos )
void Track::insertBar( const MidiTime & pos )
{
// we'll increase the position of every TCO, positioned behind pos, by
// one tact
// one bar
for( tcoVector::iterator it = m_trackContentObjects.begin();
it != m_trackContentObjects.end(); ++it )
{
if( ( *it )->startPosition() >= pos )
{
( *it )->movePosition( (*it)->startPosition() +
MidiTime::ticksPerTact() );
MidiTime::ticksPerBar() );
}
}
}
@@ -2547,17 +2549,17 @@ void Track::insertTact( const MidiTime & pos )
*
* \param pos The time at which we want to remove the bar.
*/
void Track::removeTact( const MidiTime & pos )
void Track::removeBar( const MidiTime & pos )
{
// we'll decrease the position of every TCO, positioned behind pos, by
// one tact
// one bar
for( tcoVector::iterator it = m_trackContentObjects.begin();
it != m_trackContentObjects.end(); ++it )
{
if( ( *it )->startPosition() >= pos )
{
( *it )->movePosition( qMax( ( *it )->startPosition() -
MidiTime::ticksPerTact(), 0 ) );
MidiTime::ticksPerBar(), 0 ) );
}
}
}
@@ -2571,7 +2573,7 @@ void Track::removeTact( const MidiTime & pos )
* keeping track of the latest time found in ticks. Then we return
* that in bars by dividing by the number of ticks per bar.
*/
tact_t Track::length() const
bar_t Track::length() const
{
// find last end-position
tick_t last = 0;
@@ -2591,7 +2593,7 @@ tact_t Track::length() const
}
}
return last / MidiTime::ticksPerTact();
return last / MidiTime::ticksPerBar();
}

View File

@@ -313,7 +313,7 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra
MidiTime bbTime = time - tco->startPosition();
bbTime = std::min(bbTime, tco->length());
bbTime = bbTime % (bbContainer->lengthOfBB(bbIndex) * MidiTime::ticksPerTact());
bbTime = bbTime % (bbContainer->lengthOfBB(bbIndex) * MidiTime::ticksPerBar());
auto bbValues = bbContainer->automatedValuesAt(bbTime, bbIndex);
for (auto it=bbValues.begin(); it != bbValues.end(); it++)
@@ -344,8 +344,3 @@ DummyTrackContainer::DummyTrackContainer() :
m_dummyInstrumentTrack->setJournalling( false );
}

View File

@@ -53,8 +53,8 @@ int TimeSig::denominator() const
MidiTime::MidiTime( const tact_t tact, const tick_t ticks ) :
m_ticks( tact * s_ticksPerTact + ticks )
MidiTime::MidiTime( const bar_t bar, const tick_t ticks ) :
m_ticks( bar * s_ticksPerBar + ticks )
{
}
@@ -66,7 +66,7 @@ MidiTime::MidiTime( const tick_t ticks ) :
MidiTime MidiTime::quantize(float bars) const
{
//The intervals we should snap to, our new position should be a factor of this
int interval = s_ticksPerTact * bars;
int interval = s_ticksPerBar * bars;
//The lower position we could snap to
int lowPos = m_ticks / interval;
//Offset from the lower position
@@ -78,9 +78,9 @@ MidiTime MidiTime::quantize(float bars) const
}
MidiTime MidiTime::toAbsoluteTact() const
MidiTime MidiTime::toAbsoluteBar() const
{
return getTact() * s_ticksPerTact;
return getBar() * s_ticksPerBar;
}
@@ -98,15 +98,15 @@ MidiTime& MidiTime::operator-=( const MidiTime& time )
}
tact_t MidiTime::getTact() const
bar_t MidiTime::getBar() const
{
return m_ticks / s_ticksPerTact;
return m_ticks / s_ticksPerBar;
}
tact_t MidiTime::nextFullTact() const
bar_t MidiTime::nextFullBar() const
{
return (m_ticks + (s_ticksPerTact-1)) / s_ticksPerTact;
return ( m_ticks + ( s_ticksPerBar - 1 ) ) / s_ticksPerBar;
}
@@ -131,23 +131,23 @@ MidiTime::operator int() const
tick_t MidiTime::ticksPerBeat( const TimeSig &sig ) const
{
// (number of ticks per bar) divided by (number of beats per bar)
return ticksPerTact(sig) / sig.numerator();
return ticksPerBar(sig) / sig.numerator();
}
tick_t MidiTime::getTickWithinBar( const TimeSig &sig ) const
{
return m_ticks % ticksPerTact(sig);
return m_ticks % ticksPerBar( sig );
}
tick_t MidiTime::getBeatWithinBar( const TimeSig &sig ) const
{
return getTickWithinBar(sig) / ticksPerBeat(sig);
return getTickWithinBar( sig ) / ticksPerBeat( sig );
}
tick_t MidiTime::getTickWithinBeat( const TimeSig &sig ) const
{
return getTickWithinBar(sig) % ticksPerBeat(sig);
return getTickWithinBar( sig ) % ticksPerBeat( sig );
}
@@ -160,9 +160,9 @@ f_cnt_t MidiTime::frames( const float framesPerTick ) const
return 0;
}
double MidiTime::getTimeInMilliseconds(bpm_t beatsPerMinute) const
double MidiTime::getTimeInMilliseconds( bpm_t beatsPerMinute ) const
{
return ticksToMilliseconds(getTicks(), beatsPerMinute);
return ticksToMilliseconds( getTicks(), beatsPerMinute );
}
MidiTime MidiTime::fromFrames( const f_cnt_t frames, const float framesPerTick )
@@ -171,39 +171,39 @@ MidiTime MidiTime::fromFrames( const f_cnt_t frames, const float framesPerTick )
}
tick_t MidiTime::ticksPerTact()
tick_t MidiTime::ticksPerBar()
{
return s_ticksPerTact;
return s_ticksPerBar;
}
tick_t MidiTime::ticksPerTact( const TimeSig &sig )
tick_t MidiTime::ticksPerBar( const TimeSig &sig )
{
return DefaultTicksPerTact * sig.numerator() / sig.denominator();
return DefaultTicksPerBar * sig.numerator() / sig.denominator();
}
int MidiTime::stepsPerTact()
int MidiTime::stepsPerBar()
{
int steps = ticksPerTact() / DefaultBeatsPerTact;
int steps = ticksPerBar() / DefaultBeatsPerBar;
return qMax( 1, steps );
}
void MidiTime::setTicksPerTact( tick_t tpt )
void MidiTime::setTicksPerBar( tick_t tpb )
{
s_ticksPerTact = tpt;
s_ticksPerBar = tpb;
}
MidiTime MidiTime::stepPosition( int step )
{
return step * ticksPerTact() / stepsPerTact();
return step * ticksPerBar() / stepsPerBar();
}
double MidiTime::ticksToMilliseconds(tick_t ticks, bpm_t beatsPerMinute)
double MidiTime::ticksToMilliseconds( tick_t ticks, bpm_t beatsPerMinute )
{
return MidiTime::ticksToMilliseconds(static_cast<double>(ticks), beatsPerMinute);
return MidiTime::ticksToMilliseconds( static_cast<double>(ticks), beatsPerMinute );
}
double MidiTime::ticksToMilliseconds(double ticks, bpm_t beatsPerMinute)

View File

@@ -278,10 +278,10 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
p.fillRect( rect(), c );
}
const float ppt = fixedTCOs() ?
const float ppb = fixedTCOs() ?
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_pat->timeMapLength().getTact() :
pixelsPerTact();
/ (float) m_pat->timeMapLength().getBar() :
pixelsPerBar();
const int x_base = TCO_BORDER_WIDTH;
@@ -290,7 +290,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
const float y_scale = max - min;
const float h = ( height() - 2 * TCO_BORDER_WIDTH ) / y_scale;
const float ppTick = ppt / MidiTime::ticksPerTact();
const float ppTick = ppb / MidiTime::ticksPerBar();
p.translate( 0.0f, max * height() / y_scale - TCO_BORDER_WIDTH );
p.scale( 1.0f, -h );
@@ -372,9 +372,9 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
const int lineSize = 3;
p.setPen( c.darker( 300 ) );
for( tact_t t = 1; t < width() - TCO_BORDER_WIDTH; ++t )
for( bar_t t = 1; t < width() - TCO_BORDER_WIDTH; ++t )
{
const int tx = x_base + static_cast<int>( ppt * t ) - 2;
const int tx = x_base + static_cast<int>( ppb * t ) - 2;
p.drawLine( tx, TCO_BORDER_WIDTH, tx, TCO_BORDER_WIDTH + lineSize );
p.drawLine( tx, rect().bottom() - ( lineSize + TCO_BORDER_WIDTH ),
tx, rect().bottom() - TCO_BORDER_WIDTH );

View File

@@ -42,7 +42,7 @@
QPixmap * TimeLineWidget::s_posMarkerPixmap = NULL;
TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt,
TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb,
Song::PlayPos & pos, const MidiTime & begin, Song::PlayModes mode,
QWidget * parent ) :
QWidget( parent ),
@@ -61,7 +61,7 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt,
m_changedPosition( true ),
m_xOffset( xoff ),
m_posMarkerX( 0 ),
m_ppt( ppt ),
m_ppb( ppb ),
m_pos( pos ),
m_begin( begin ),
m_mode( mode ),
@@ -71,7 +71,7 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt,
m_moveXOff( 0 )
{
m_loopPos[0] = 0;
m_loopPos[1] = DefaultTicksPerTact;
m_loopPos[1] = DefaultTicksPerBar;
if( s_posMarkerPixmap == NULL )
{
@@ -247,18 +247,18 @@ void TimeLineWidget::paintEvent( QPaintEvent * )
QColor const & barLineColor = getBarLineColor();
QColor const & barNumberColor = getBarNumberColor();
tact_t barNumber = m_begin.getTact();
bar_t barNumber = m_begin.getBar();
int const x = m_xOffset + s_posMarkerPixmap->width() / 2 -
( ( static_cast<int>( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast<int>( m_ppt ) );
( ( static_cast<int>( m_begin * m_ppb ) / MidiTime::ticksPerBar() ) % static_cast<int>( m_ppb ) );
for( int i = 0; x + i * m_ppt < width(); ++i )
for( int i = 0; x + i * m_ppb < width(); ++i )
{
++barNumber;
if( ( barNumber - 1 ) %
qMax( 1, qRound( 1.0f / 3.0f *
MidiTime::ticksPerTact() / m_ppt ) ) == 0 )
MidiTime::ticksPerBar() / m_ppb ) ) == 0 )
{
const int cx = x + qRound( i * m_ppt );
const int cx = x + qRound( i * m_ppb );
p.setPen( barLineColor );
p.drawLine( cx, 5, cx, height() - 6 );
@@ -313,7 +313,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
else if( event->button() == Qt::RightButton )
{
m_moveXOff = s_posMarkerPixmap->width() / 2;
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerTact() / m_ppt );
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerBar() / m_ppb );
const MidiTime loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2;
if( t < loopMid )
@@ -349,7 +349,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event )
void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
{
parentWidget()->update(); // essential for widgets that this timeline had taken their mouse move event from.
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerTact() / m_ppt );
const MidiTime t = m_begin + static_cast<int>( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerBar() / m_ppb );
switch( m_action )
{
@@ -387,10 +387,14 @@ void TimeLineWidget::mouseMoveEvent( QMouseEvent* event )
{
// Note, swap 1 and 0 below and the behavior "skips" the other
// marking instead of pushing it.
if( m_action == MoveLoopBegin )
m_loopPos[0] -= MidiTime::ticksPerTact();
if( m_action == MoveLoopBegin )
{
m_loopPos[0] -= MidiTime::ticksPerBar();
}
else
m_loopPos[1] += MidiTime::ticksPerTact();
{
m_loopPos[1] += MidiTime::ticksPerBar();
}
}
update();
break;

View File

@@ -54,7 +54,7 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
m_tc( _tc ),
m_trackViews(),
m_scrollArea( new scrollArea( this ) ),
m_ppt( DEFAULT_PIXELS_PER_TACT ),
m_ppb( DEFAULT_PIXELS_PER_BAR ),
m_rubberBand( new RubberBand( m_scrollArea ) )
{
m_tc->setHook( this );
@@ -305,9 +305,9 @@ bool TrackContainerView::allowRubberband() const
void TrackContainerView::setPixelsPerTact( int _ppt )
void TrackContainerView::setPixelsPerBar( int ppb )
{
m_ppt = _ppt;
m_ppb = ppb;
// tell all TrackContentWidgets to update their background tile pixmap
for( trackViewList::Iterator it = m_trackViews.begin();

View File

@@ -92,7 +92,7 @@ AutomationEditor::AutomationEditor() :
m_moveStartTick( 0 ),
m_drawLastLevel( 0.0f ),
m_drawLastTick( 0 ),
m_ppt( DEFAULT_PPT ),
m_ppb( DEFAULT_PPB ),
m_y_delta( DEFAULT_Y_DELTA ),
m_y_auto( true ),
m_editMode( DRAW ),
@@ -149,7 +149,7 @@ AutomationEditor::AutomationEditor() :
}
// add time-line
m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppt,
m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb,
Engine::getSong()->getPlayPos(
Song::Mode_PlayAutomationPattern ),
m_currentPosition,
@@ -514,7 +514,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
x -= VALUES_WIDTH;
// get tick in which the user clicked
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
// get time map of current pattern
@@ -531,7 +531,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
if( pos_ticks >= it.key() &&
( it+1==time_map.end() ||
pos_ticks <= (it+1).key() ) &&
( pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt ) &&
( pos_ticks<= it.key() + MidiTime::ticksPerBar() *4 / m_ppb ) &&
( level == it.value() || mouseEvent->button() == Qt::RightButton ) )
{
break;
@@ -583,7 +583,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent )
int aligned_x = (int)( (float)( (
it.key() -
m_currentPosition ) *
m_ppt ) / MidiTime::ticksPerTact() );
m_ppb ) / MidiTime::ticksPerBar() );
m_moveXOffset = x - aligned_x - 1;
// set move-cursor
QCursor c( Qt::SizeAllCursor );
@@ -740,7 +740,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
x -= m_moveXOffset;
}
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == DRAW )
{
@@ -872,7 +872,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
}
// get tick in which the cursor is posated
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
m_selectedTick = pos_ticks - m_selectStartTick;
@@ -893,7 +893,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
// move selection + selected values
// do horizontal move-stuff
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
int ticks_diff = pos_ticks -
m_moveStartTick;
@@ -918,8 +918,8 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
}
m_selectStartTick += ticks_diff;
int tact_diff = ticks_diff / MidiTime::ticksPerTact();
ticks_diff = ticks_diff % MidiTime::ticksPerTact();
int bar_diff = ticks_diff / MidiTime::ticksPerBar();
ticks_diff = ticks_diff % MidiTime::ticksPerBar();
// do vertical move-stuff
@@ -967,24 +967,24 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
MidiTime new_value_pos;
if( it.key() )
{
int value_tact =
int value_bar =
( it.key() /
MidiTime::ticksPerTact() )
+ tact_diff;
MidiTime::ticksPerBar() )
+ bar_diff;
int value_ticks =
( it.key() %
MidiTime::ticksPerTact() )
MidiTime::ticksPerBar() )
+ ticks_diff;
// ensure value_ticks range
if( value_ticks / MidiTime::ticksPerTact() )
if( value_ticks / MidiTime::ticksPerBar() )
{
value_tact += value_ticks
/ MidiTime::ticksPerTact();
value_bar += value_ticks
/ MidiTime::ticksPerBar();
value_ticks %=
MidiTime::ticksPerTact();
MidiTime::ticksPerBar();
}
m_pattern->removeValue( it.key() );
new_value_pos = MidiTime( value_tact,
new_value_pos = MidiTime( value_bar,
value_ticks );
}
new_selValuesForMove[
@@ -1032,7 +1032,7 @@ void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent )
}
// get tick in which the cursor is posated
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
m_selectedTick = pos_ticks -
@@ -1116,7 +1116,7 @@ inline void AutomationEditor::drawAutomationPoint( QPainter & p, timeMap::iterat
{
int x = xCoordOfTick( it.key() );
int y = yCoordOfLevel( it.value() );
const int outerRadius = qBound( 3, ( m_ppt * AutomationPattern::quantization() ) / 576, 5 ); // man, getting this calculation right took forever
const int outerRadius = qBound( 3, ( m_ppb * AutomationPattern::quantization() ) / 576, 5 ); // man, getting this calculation right took forever
p.setPen( QPen( vertexColor().lighter( 200 ) ) );
p.setBrush( QBrush( vertexColor() ) );
p.drawEllipse( x - outerRadius, y - outerRadius, outerRadius * 2, outerRadius * 2 );
@@ -1288,20 +1288,20 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
/ static_cast<float>( Engine::getSong()->getTimeSigModel().getDenominator() );
float zoomFactor = m_zoomXLevels[m_zoomingXModel.value()];
//the bars which disappears at the left side by scrolling
int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerTact();
int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerBar();
//iterates the visible bars and draw the shading on uneven bars
for( int x = VALUES_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppt, ++barCount )
for( int x = VALUES_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppb, ++barCount )
{
if( ( barCount + leftBars ) % 2 != 0 )
{
p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, TOP_MARGIN, m_ppt,
p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, TOP_MARGIN, m_ppb,
height() - ( SCROLLBAR_SIZE + TOP_MARGIN ), backgroundShade() );
}
}
// Draw the beat grid
int ticksPerBeat = DefaultTicksPerTact /
int ticksPerBeat = DefaultTicksPerBar /
Engine::getSong()->getTimeSigModel().getDenominator();
for( tick = m_currentPosition - m_currentPosition % ticksPerBeat,
@@ -1314,10 +1314,10 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
}
// and finally bars
for( tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerTact(),
for( tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerBar(),
x = xCoordOfTick( tick );
x<=width();
tick += MidiTime::ticksPerTact(), x = xCoordOfTick( tick ) )
tick += MidiTime::ticksPerBar(), x = xCoordOfTick( tick ) )
{
p.setPen( barLineColor() );
p.drawLine( x, grid_bottom, x, x_line_end );
@@ -1452,9 +1452,9 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
}
// now draw selection-frame
int x = ( sel_pos_start - m_currentPosition ) * m_ppt /
MidiTime::ticksPerTact();
int w = ( sel_pos_end - sel_pos_start ) * m_ppt / MidiTime::ticksPerTact();
int x = ( sel_pos_start - m_currentPosition ) * m_ppb /
MidiTime::ticksPerBar();
int w = ( sel_pos_end - sel_pos_start ) * m_ppb / MidiTime::ticksPerBar();
int y, h;
if( m_y_auto )
{
@@ -1526,7 +1526,7 @@ void AutomationEditor::paintEvent(QPaintEvent * pe )
int AutomationEditor::xCoordOfTick(int tick )
{
return VALUES_WIDTH + ( ( tick - m_currentPosition )
* m_ppt / MidiTime::ticksPerTact() );
* m_ppb / MidiTime::ticksPerBar() );
}
@@ -1687,11 +1687,11 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
}
x = qBound( 0, x, m_zoomingXModel.size() - 1 );
int mouseX = (we->x() - VALUES_WIDTH)* MidiTime::ticksPerTact();
int mouseX = (we->x() - VALUES_WIDTH)* MidiTime::ticksPerBar();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = mouseX / m_ppt;
int ticks = mouseX / m_ppb;
// what would be the ticks in the new zoom level on the very same mouse x
int newTicks = mouseX / (DEFAULT_PPT * m_zoomXLevels[x]);
int newTicks = mouseX / (DEFAULT_PPB * m_zoomXLevels[x]);
// scroll so the tick "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks);
@@ -1958,7 +1958,7 @@ void AutomationEditor::getSelectedValues( timeMap & selected_values )
++it )
{
//TODO: Add constant
tick_t len_ticks = MidiTime::ticksPerTact() / 16;
tick_t len_ticks = MidiTime::ticksPerBar() / 16;
float level = it.value();
tick_t pos_ticks = it.key();
@@ -2095,17 +2095,17 @@ void AutomationEditor::updatePosition(const MidiTime & t )
m_scrollBack == true )
{
const int w = width() - VALUES_WIDTH;
if( t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt )
if( t > m_currentPosition + w * MidiTime::ticksPerBar() / m_ppb )
{
m_leftRightScroll->setValue( t.getTact() *
MidiTime::ticksPerTact() );
m_leftRightScroll->setValue( t.getBar() *
MidiTime::ticksPerBar() );
}
else if( t < m_currentPosition )
{
MidiTime t_ = qMax( t - w * MidiTime::ticksPerTact() *
MidiTime::ticksPerTact() / m_ppt, 0 );
m_leftRightScroll->setValue( t_.getTact() *
MidiTime::ticksPerTact() );
MidiTime t_ = qMax( t - w * MidiTime::ticksPerBar() *
MidiTime::ticksPerBar() / m_ppb, 0 );
m_leftRightScroll->setValue( t_.getBar() *
MidiTime::ticksPerBar() );
}
m_scrollBack = false;
}
@@ -2116,11 +2116,11 @@ void AutomationEditor::updatePosition(const MidiTime & t )
void AutomationEditor::zoomingXChanged()
{
m_ppt = m_zoomXLevels[m_zoomingXModel.value()] * DEFAULT_PPT;
m_ppb = m_zoomXLevels[m_zoomingXModel.value()] * DEFAULT_PPB;
assert( m_ppt > 0 );
assert( m_ppb > 0 );
m_timeLine->setPixelsPerTact( m_ppt );
m_timeLine->setPixelsPerBar( m_ppb );
update();
}
@@ -2159,9 +2159,9 @@ void AutomationEditor::setQuantization()
}
else
{
quantization = DefaultTicksPerTact;
quantization = DefaultTicksPerBar;
}
quantization = DefaultTicksPerTact / quantization;
quantization = DefaultTicksPerBar / quantization;
AutomationPattern::setQuantization( quantization );
update();

View File

@@ -139,7 +139,7 @@ PianoRoll::PianoRollKeyTypes PianoRoll::prKeyOrder[] =
} ;
const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DefaultStepsPerTact;
const int DEFAULT_PR_PPB = KEY_LINE_HEIGHT * DefaultStepsPerBar;
const QVector<double> PianoRoll::m_zoomLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f };
@@ -168,8 +168,8 @@ PianoRoll::PianoRoll() :
m_lastMouseY( 0 ),
m_oldNotesEditHeight( 100 ),
m_notesEditHeight( 100 ),
m_ppt( DEFAULT_PR_PPT ),
m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerTact/4 ) ),
m_ppb( DEFAULT_PR_PPB ),
m_lenOfNewNotes( MidiTime( 0, DefaultTicksPerBar/4 ) ),
m_lastNoteVolume( DefaultVolume ),
m_lastNotePanning( DefaultPanning ),
m_startKey( INITIAL_START_KEY ),
@@ -178,7 +178,7 @@ PianoRoll::PianoRoll() :
m_ctrlMode( ModeDraw ),
m_mouseDownRight( false ),
m_scrollBack( false ),
m_stepRecorderWidget(this, DEFAULT_PR_PPT, PR_TOP_MARGIN, PR_BOTTOM_MARGIN + m_notesEditHeight, WHITE_KEY_WIDTH, 0),
m_stepRecorderWidget(this, DEFAULT_PR_PPB, PR_TOP_MARGIN, PR_BOTTOM_MARGIN + m_notesEditHeight, WHITE_KEY_WIDTH, 0),
m_stepRecorder(*this, m_stepRecorderWidget),
m_barLineColor( 0, 0, 0 ),
m_beatLineColor( 0, 0, 0 ),
@@ -302,7 +302,7 @@ PianoRoll::PianoRoll() :
setAttribute( Qt::WA_OpaquePaintEvent, true );
// add time-line
m_timeLine = new TimeLineWidget( WHITE_KEY_WIDTH, 0, m_ppt,
m_timeLine = new TimeLineWidget( WHITE_KEY_WIDTH, 0, m_ppb,
Engine::getSong()->getPlayPos(
Song::Mode_PlayPattern ),
m_currentPosition,
@@ -759,28 +759,28 @@ void PianoRoll::selectRegionFromPixels( int xStart, int xEnd )
xEnd -= WHITE_KEY_WIDTH;
// select an area of notes
int pos_ticks = xStart * MidiTime::ticksPerTact() / m_ppt +
int posTicks = xStart * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
int key_num = 0;
m_selectStartTick = pos_ticks;
int keyNum = 0;
m_selectStartTick = posTicks;
m_selectedTick = 0;
m_selectStartKey = key_num;
m_selectStartKey = keyNum;
m_selectedKeys = 1;
// change size of selection
// get tick in which the cursor is posated
pos_ticks = xEnd * MidiTime::ticksPerTact() / m_ppt +
posTicks = xEnd * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
key_num = 120;
keyNum = 120;
m_selectedTick = pos_ticks - m_selectStartTick;
m_selectedTick = posTicks - m_selectStartTick;
if( (int) m_selectStartTick + m_selectedTick < 0 )
{
m_selectedTick = -static_cast<int>(
m_selectStartTick );
}
m_selectedKeys = key_num - m_selectStartKey;
if( key_num <= m_selectStartKey )
m_selectedKeys = keyNum - m_selectStartKey;
if( keyNum <= m_selectStartKey )
{
--m_selectedKeys;
}
@@ -1033,7 +1033,7 @@ void PianoRoll::drawDetuningInfo( QPainter & _p, const Note * _n, int _x,
for( timeMap::ConstIterator it = map.begin(); it != map.end(); ++it )
{
int pos_ticks = it.key();
int pos_x = _x + pos_ticks * m_ppt / MidiTime::ticksPerTact();
int pos_x = _x + pos_ticks * m_ppb / MidiTime::ticksPerBar();
const float level = it.value();
@@ -1268,7 +1268,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke)
// Move selected notes by one bar to the left
if (hasValidPattern())
{
shiftPos( direction * MidiTime::ticksPerTact() );
shiftPos( direction * MidiTime::ticksPerBar() );
}
}
else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone)
@@ -1572,7 +1572,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
x -= WHITE_KEY_WIDTH;
// get tick in which the user clicked
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
@@ -1602,7 +1602,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
||
( edit_note &&
pos_ticks <= note->pos() +
NOTE_EDIT_LINE_WIDTH * MidiTime::ticksPerTact() / m_ppt )
NOTE_EDIT_LINE_WIDTH * MidiTime::ticksPerBar() / m_ppb )
)
)
{
@@ -1746,8 +1746,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// clicked at the "tail" of the note?
if( pos_ticks * m_ppt / MidiTime::ticksPerTact() >
m_currentNote->endPos() * m_ppt / MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH
if( pos_ticks * m_ppb / MidiTime::ticksPerBar() >
m_currentNote->endPos() * m_ppb / MidiTime::ticksPerBar() - RESIZE_AREA_WIDTH
&& m_currentNote->length() > 0 )
{
m_pattern->addJournalCheckPoint();
@@ -1902,10 +1902,10 @@ void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me )
int pixel_range = 4;
int x = me->x() - WHITE_KEY_WIDTH;
const int ticks_start = ( x-pixel_range/2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
const int ticks_end = ( x+pixel_range/2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
const int ticks_middle = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
const int ticks_middle = x * MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
// go through notes to figure out which one we want to change
bool altPressed = me->modifiers() & Qt::AltModifier;
@@ -2300,9 +2300,9 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// convert to ticks so that we can check which notes
// are in the range
int ticks_start = ( x-pixel_range/2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
int ticks_end = ( x+pixel_range/2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
// get note-vector of current pattern
const NoteVector & notes = m_pattern->notes();
@@ -2398,8 +2398,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// set move- or resize-cursor
// get tick in which the cursor is posated
int pos_ticks = ( x * MidiTime::ticksPerTact() ) /
m_ppt + m_currentPosition;
int pos_ticks = ( x * MidiTime::ticksPerBar() ) /
m_ppb + m_currentPosition;
// get note-vector of current pattern
const NoteVector & notes = m_pattern->notes();
@@ -2431,7 +2431,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
Note *note = *it;
// x coordinate of the right edge of the note
int noteRightX = ( note->pos() + note->length() -
m_currentPosition) * m_ppt/MidiTime::ticksPerTact();
m_currentPosition) * m_ppb/MidiTime::ticksPerBar();
// cursor at the "tail" of the note?
bool atTail = note->length() > 0 && x > noteRightX -
RESIZE_AREA_WIDTH;
@@ -2470,7 +2470,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// change size of selection
// get tick in which the cursor is posated
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
m_selectedTick = pos_ticks - m_selectStartTick;
@@ -2492,7 +2492,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// any key if in erase mode
// get tick in which the user clicked
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar() / m_ppb +
m_currentPosition;
@@ -2523,8 +2523,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
( edit_note &&
pos_ticks <= note->pos() +
NOTE_EDIT_LINE_WIDTH *
MidiTime::ticksPerTact() /
m_ppt )
MidiTime::ticksPerBar() /
m_ppb )
)
)
{
@@ -2573,7 +2573,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
}
// get tick in which the cursor is posated
int pos_ticks = x * MidiTime::ticksPerTact()/ m_ppt +
int pos_ticks = x * MidiTime::ticksPerBar()/ m_ppb +
m_currentPosition;
m_selectedTick = pos_ticks -
@@ -2634,7 +2634,7 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
// convert pixels to ticks and keys
int off_x = x - m_moveStartX;
int off_ticks = off_x * MidiTime::ticksPerTact() / m_ppt;
int off_ticks = off_x * MidiTime::ticksPerBar() / m_ppb;
int off_key = getKey( y ) - getKey( m_moveStartY );
// handle scroll changes while dragging
@@ -2818,10 +2818,10 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl )
Engine::getSong()->setModified();
}
int PianoRoll::xCoordOfTick(int tick )
int PianoRoll::xCoordOfTick( int tick )
{
return WHITE_KEY_WIDTH + ( ( tick - m_currentPosition )
* m_ppt / MidiTime::ticksPerTact() );
* m_ppb / MidiTime::ticksPerBar() );
}
void PianoRoll::paintEvent(QPaintEvent * pe )
@@ -3118,20 +3118,20 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
/ static_cast<float>( Engine::getSong()->getTimeSigModel().getDenominator() );
float zoomFactor = m_zoomLevels[m_zoomingModel.value()];
//the bars which disappears at the left side by scrolling
int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerTact();
int leftBars = m_currentPosition * zoomFactor / MidiTime::ticksPerBar();
//iterates the visible bars and draw the shading on uneven bars
for( int x = WHITE_KEY_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppt, ++barCount )
for( int x = WHITE_KEY_WIDTH, barCount = leftBars; x < width() + m_currentPosition * zoomFactor / timeSignature; x += m_ppb, ++barCount )
{
if( ( barCount + leftBars ) % 2 != 0 )
{
p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, PR_TOP_MARGIN, m_ppt,
p.fillRect( x - m_currentPosition * zoomFactor / timeSignature, PR_TOP_MARGIN, m_ppb,
height() - ( PR_BOTTOM_MARGIN + PR_TOP_MARGIN ), backgroundShade() );
}
}
// Draw the vertical beat lines
int ticksPerBeat = DefaultTicksPerTact /
int ticksPerBeat = DefaultTicksPerBar /
Engine::getSong()->getTimeSigModel().getDenominator();
for( tick = m_currentPosition - m_currentPosition % ticksPerBeat,
@@ -3143,9 +3143,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
}
// Draw the vertical bar lines
for( tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerTact(),
for( tick = m_currentPosition - m_currentPosition % MidiTime::ticksPerBar(),
x = xCoordOfTick( tick ); x <= width();
tick += MidiTime::ticksPerTact(), x = xCoordOfTick( tick ) )
tick += MidiTime::ticksPerBar(), x = xCoordOfTick( tick ) )
{
p.setPen( barLineColor() );
p.drawLine( x, PR_TOP_MARGIN, x, height() - PR_BOTTOM_MARGIN );
@@ -3217,9 +3217,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
int pos_ticks = note->pos();
int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact();
int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar();
const int x = ( pos_ticks - m_currentPosition ) *
m_ppt / MidiTime::ticksPerTact();
m_ppb / MidiTime::ticksPerBar();
// skip this note if not in visible area at all
if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) )
{
@@ -3259,9 +3259,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
int pos_ticks = note->pos();
int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact();
int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar();
const int x = ( pos_ticks - m_currentPosition ) *
m_ppt / MidiTime::ticksPerTact();
m_ppb / MidiTime::ticksPerBar();
// skip this note if not in visible area at all
if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) )
{
@@ -3347,9 +3347,9 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
int pos_ticks = note->pos();
int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact();
int note_width = len_ticks * m_ppb / MidiTime::ticksPerBar();
const int x = ( pos_ticks - m_currentPosition ) *
m_ppt / MidiTime::ticksPerTact();
m_ppb / MidiTime::ticksPerBar();
// skip this note if not in visible area at all
if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) )
{
@@ -3389,10 +3389,10 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
m_notesEditHeight - PR_BOTTOM_MARGIN );
// now draw selection-frame
int x = ( ( sel_pos_start - m_currentPosition ) * m_ppt ) /
MidiTime::ticksPerTact();
int w = ( ( ( sel_pos_end - m_currentPosition ) * m_ppt ) /
MidiTime::ticksPerTact() ) - x;
int x = ( ( sel_pos_start - m_currentPosition ) * m_ppb ) /
MidiTime::ticksPerBar();
int w = ( ( ( sel_pos_end - m_currentPosition ) * m_ppb ) /
MidiTime::ticksPerBar() ) - 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( selectedNoteColor() );
@@ -3508,9 +3508,9 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
int pixel_range = 8;
int x = we->x() - WHITE_KEY_WIDTH;
int ticks_start = ( x - pixel_range / 2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
int ticks_end = ( x + pixel_range / 2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
// When alt is pressed we only edit the note under the cursor
bool altPressed = we->modifiers() & Qt::AltModifier;
@@ -3611,11 +3611,11 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
}
z = qBound( 0, z, m_zoomingModel.size() - 1 );
int x = (we->x() - WHITE_KEY_WIDTH)* MidiTime::ticksPerTact();
int x = (we->x() - WHITE_KEY_WIDTH)* MidiTime::ticksPerBar();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = x / m_ppt;
int ticks = x / m_ppb;
// what would be the ticks in the new zoom level on the very same mouse x
int newTicks = x / (DEFAULT_PR_PPT * m_zoomLevels[z]);
int newTicks = x / (DEFAULT_PR_PPB * m_zoomLevels[z]);
// scroll so the tick "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks);
// update combobox with zooming-factor
@@ -4039,7 +4039,7 @@ void PianoRoll::copyToClipboard( const NoteVector & notes ) const
QDomElement note_list = dataFile.createElement( "note-list" );
dataFile.content().appendChild( note_list );
MidiTime start_pos( notes.front()->pos().getTact(), 0 );
MidiTime start_pos( notes.front()->pos().getBar(), 0 );
for( const Note *note : notes )
{
Note clip_note( *note );
@@ -4200,15 +4200,15 @@ void PianoRoll::deleteSelectedNotes()
void PianoRoll::autoScroll( const MidiTime & t )
{
const int w = width() - WHITE_KEY_WIDTH;
if( t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt )
if( t > m_currentPosition + w * MidiTime::ticksPerBar() / m_ppb )
{
m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() );
m_leftRightScroll->setValue( t.getBar() * MidiTime::ticksPerBar() );
}
else if( t < m_currentPosition )
{
MidiTime t2 = qMax( t - w * MidiTime::ticksPerTact() *
MidiTime::ticksPerTact() / m_ppt, (tick_t) 0 );
m_leftRightScroll->setValue( t2.getTact() * MidiTime::ticksPerTact() );
MidiTime t2 = qMax( t - w * MidiTime::ticksPerBar() *
MidiTime::ticksPerBar() / m_ppb, (tick_t) 0 );
m_leftRightScroll->setValue( t2.getBar() * MidiTime::ticksPerBar() );
}
m_scrollBack = false;
}
@@ -4262,12 +4262,12 @@ void PianoRoll::updatePositionStepRecording( const MidiTime & t )
void PianoRoll::zoomingChanged()
{
m_ppt = m_zoomLevels[m_zoomingModel.value()] * DEFAULT_PR_PPT;
m_ppb = m_zoomLevels[m_zoomingModel.value()] * DEFAULT_PR_PPB;
assert( m_ppt > 0 );
assert( m_ppb > 0 );
m_timeLine->setPixelsPerTact( m_ppt );
m_stepRecorderWidget.setPixelsPerTact( m_ppt );
m_timeLine->setPixelsPerBar( m_ppb );
m_stepRecorderWidget.setPixelsPerBar( m_ppb );
update();
}
@@ -4297,12 +4297,12 @@ int PianoRoll::quantization() const
}
else
{
return DefaultTicksPerTact / 16;
return DefaultTicksPerBar / 16;
}
}
QString text = m_quantizeModel.currentText();
return DefaultTicksPerTact / text.right( text.length() - 2 ).toInt();
return DefaultTicksPerBar / text.right( text.length() - 2 ).toInt();
}
@@ -4370,7 +4370,7 @@ MidiTime PianoRoll::newNoteLen() const
}
QString text = m_noteLenModel.currentText();
return DefaultTicksPerTact / text.right( text.length() - 2 ).toInt();
return DefaultTicksPerBar / text.right( text.length() - 2 ).toInt();
}
@@ -4398,7 +4398,7 @@ Note * PianoRoll::noteUnderMouse()
int key_num = getKey( pos.y() );
int pos_ticks = ( pos.x() - WHITE_KEY_WIDTH ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
MidiTime::ticksPerBar() / m_ppb + m_currentPosition;
// loop through whole note-vector...
for( Note* const& note : m_pattern->notes() )

View File

@@ -95,7 +95,7 @@ SongEditor::SongEditor( Song * song ) :
m_zoomingModel->setParent(this);
m_snappingModel->setParent(this);
m_timeLine = new TimeLineWidget( m_trackHeadWidth, 32,
pixelsPerTact(),
pixelsPerBar(),
m_song->m_playPos[Song::Mode_PlaySong],
m_currentPosition,
Song::Mode_PlaySong, this );
@@ -374,7 +374,7 @@ void SongEditor::selectRegionFromPixels(int xStart, int xEnd)
//calculate the song position where the mouse was clicked
m_rubberbandStartMidipos = MidiTime((xStart - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
/ pixelsPerBar() * MidiTime::ticksPerBar())
+ m_currentPosition;
m_rubberBandStartTrackview = 0;
}
@@ -409,7 +409,7 @@ void SongEditor::updateRubberband()
}
//take care of the scrollbar position
int hs = (m_leftRightScroll->value() - m_scrollPos.x()) * pixelsPerTact();
int hs = (m_leftRightScroll->value() - m_scrollPos.x()) * pixelsPerBar();
int vs = contentWidget()->verticalScrollBar()->value() - m_scrollPos.y();
//the adjusted origin point
@@ -425,7 +425,7 @@ void SongEditor::updateRubberband()
//the miditime the mouse is hover
MidiTime rubberbandMidipos = MidiTime((qMin(m_mousePos.x(), width()) - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
/ pixelsPerBar() * MidiTime::ticksPerBar())
+ m_currentPosition;
//are tcos in the rect of selection?
@@ -485,7 +485,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )
}
else if( ke->key() == Qt::Key_Left )
{
tick_t t = m_song->currentTick() - MidiTime::ticksPerTact();
tick_t t = m_song->currentTick() - MidiTime::ticksPerBar();
if( t >= 0 )
{
m_song->setPlayPos( t, Song::Mode_PlaySong );
@@ -493,7 +493,7 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )
}
else if( ke->key() == Qt::Key_Right )
{
tick_t t = m_song->currentTick() + MidiTime::ticksPerTact();
tick_t t = m_song->currentTick() + MidiTime::ticksPerBar();
if( t < MaxSongLength )
{
m_song->setPlayPos( t, Song::Mode_PlaySong );
@@ -549,20 +549,20 @@ void SongEditor::wheelEvent( QWheelEvent * we )
z = qBound( 0, z, m_zoomingModel->size() - 1 );
int x = (we->x() - m_trackHeadWidth);
// tact based on the mouse x-position where the scroll wheel was used
int tact= x / pixelsPerTact();
// what would be the tact in the new zoom level on the very same mouse x
int newTact = x / DEFAULT_PIXELS_PER_TACT / m_zoomLevels[z];
// scroll so the tact "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + tact - newTact);
int x = we->x() - m_trackHeadWidth;
// bar based on the mouse x-position where the scroll wheel was used
int bar = x / pixelsPerBar();
// what would be the bar in the new zoom level on the very same mouse x
int newBar = x / DEFAULT_PIXELS_PER_BAR / m_zoomLevels[z];
// scroll so the bar "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + bar - newBar);
// update combobox with zooming-factor
m_zoomingModel->setValue( z );
// update timeline
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerTact( pixelsPerTact() );
setPixelsPerBar( pixelsPerBar() );
// and make sure, all TCO's are resized and relocated
realignTracks();
}
@@ -614,7 +614,7 @@ void SongEditor::mousePressEvent(QMouseEvent *me)
//the trackView(index) and the miditime where the mouse was clicked
m_rubberBandStartTrackview = trackIndexFromSelectionPoint(me->y());
m_rubberbandStartMidipos = MidiTime((me->x() - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
/ pixelsPerBar() * MidiTime::ticksPerBar())
+ m_currentPosition;
}
QWidget::mousePressEvent(me);
@@ -791,14 +791,14 @@ void SongEditor::updatePosition( const MidiTime & t )
const int w = width() - widgetWidth
- trackOpWidth
- contentWidget()->verticalScrollBar()->width(); // width of right scrollbar
if( t > m_currentPosition + w * MidiTime::ticksPerTact() /
pixelsPerTact() )
if( t > m_currentPosition + w * MidiTime::ticksPerBar() /
pixelsPerBar() )
{
animateScroll( m_leftRightScroll, t.getTact(), m_smoothScroll );
animateScroll( m_leftRightScroll, t.getBar(), m_smoothScroll );
}
else if( t < m_currentPosition )
{
animateScroll( m_leftRightScroll, t.getTact(), m_smoothScroll );
animateScroll( m_leftRightScroll, t.getBar(), m_smoothScroll );
}
m_scrollBack = false;
}
@@ -831,10 +831,10 @@ void SongEditor::updatePositionLine()
void SongEditor::zoomingChanged()
{
setPixelsPerTact( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_PER_TACT );
setPixelsPerBar( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_PER_BAR );
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerTact( pixelsPerTact() );
setPixelsPerBar( pixelsPerBar() );
realignTracks();
updateRubberband();
}

View File

@@ -26,7 +26,7 @@
StepRecorderWidget::StepRecorderWidget(
QWidget * parent,
const int ppt,
const int ppb,
const int marginTop,
const int marginBottom,
const int marginLeft,
@@ -42,15 +42,15 @@ StepRecorderWidget::StepRecorderWidget(
m_colorLineStart = baseColor.darker(120);
setAttribute(Qt::WA_NoSystemBackground, true);
setPixelsPerTact(ppt);
setPixelsPerBar(ppb);
m_top = m_marginTop;
m_left = m_marginLeft;
}
void StepRecorderWidget::setPixelsPerTact(int ppt)
void StepRecorderWidget::setPixelsPerBar(int ppb)
{
m_ppt = ppt;
m_ppb = ppb;
}
void StepRecorderWidget::setCurrentPosition(MidiTime currentPosition)
@@ -125,7 +125,7 @@ void StepRecorderWidget::paintEvent(QPaintEvent * pe)
int StepRecorderWidget::xCoordOfTick(int tick)
{
return m_marginLeft + ((tick - m_currentPosition) * m_ppt / MidiTime::ticksPerTact());
return m_marginLeft + ((tick - m_currentPosition) * m_ppb / MidiTime::ticksPerBar());
}

View File

@@ -100,11 +100,11 @@ void TimeDisplayWidget::updateTime()
case BarsTicks:
int tick;
tick = s->getPlayPos().getTicks();
m_majorLCD.setValue((int)(tick / s->ticksPerTact()) + 1);
m_minorLCD.setValue((tick % s->ticksPerTact()) /
(s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1);
m_milliSecondsLCD.setValue((tick % s->ticksPerTact()) %
(s->ticksPerTact() / s->getTimeSigModel().getNumerator()));
m_majorLCD.setValue((int)(tick / s->ticksPerBar()) + 1);
m_minorLCD.setValue((tick % s->ticksPerBar()) /
(s->ticksPerBar() / s->getTimeSigModel().getNumerator() ) +1);
m_milliSecondsLCD.setValue((tick % s->ticksPerBar()) %
(s->ticksPerBar() / s->getTimeSigModel().getNumerator()));
break;
default: break;

View File

@@ -121,9 +121,9 @@ void AutomationTrackView::dropEvent( QDropEvent * _de )
currentPosition() +
( _de->pos().x() -
getTrackContentWidget()->x() ) *
MidiTime::ticksPerTact() /
static_cast<int>( trackContainerView()->pixelsPerTact() ) )
.toAbsoluteTact();
MidiTime::ticksPerBar() /
static_cast<int>( trackContainerView()->pixelsPerBar() ) )
.toAbsoluteBar();
if( pos.getTicks() < 0 )
{

View File

@@ -51,7 +51,7 @@ BBTCO::BBTCO( Track * _track ) :
m_color( 128, 128, 128 ),
m_useStyleColor( true )
{
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
if( t > 0 )
{
saveJournallingState( false );
@@ -237,12 +237,12 @@ void BBTCOView::paintEvent( QPaintEvent * )
const int lineSize = 3;
p.setPen( c.darker( 200 ) );
tact_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerTact() && t > 0 )
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
if( m_bbTCO->length() > MidiTime::ticksPerBar() && t > 0 )
{
for( int x = static_cast<int>( t * pixelsPerTact() );
for( int x = static_cast<int>( t * pixelsPerBar() );
x < width() - 2;
x += static_cast<int>( t * pixelsPerTact() ) )
x += static_cast<int>( t * pixelsPerBar() ) )
{
p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize );
p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ),

View File

@@ -677,7 +677,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
if( cur_start > 0 )
{
// skip notes which are posated before start-tact
// skip notes which are posated before start-bar
while( nit != notes.end() && ( *nit )->pos() < cur_start )
{
++nit;

View File

@@ -56,7 +56,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) :
TrackContentObject( _instrument_track ),
m_instrumentTrack( _instrument_track ),
m_patternType( BeatPattern ),
m_steps( MidiTime::stepsPerTact() )
m_steps( MidiTime::stepsPerBar() )
{
setName( _instrument_track->name() );
if( _instrument_track->trackContainer()
@@ -161,7 +161,7 @@ void Pattern::updateLength()
return;
}
tick_t max_length = MidiTime::ticksPerTact();
tick_t max_length = MidiTime::ticksPerBar();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -172,8 +172,8 @@ void Pattern::updateLength()
( *it )->endPos() );
}
}
changeLength( MidiTime( max_length ).nextFullTact() *
MidiTime::ticksPerTact() );
changeLength( MidiTime( max_length ).nextFullBar() *
MidiTime::ticksPerBar() );
updateBBTrack();
}
@@ -182,7 +182,7 @@ void Pattern::updateLength()
MidiTime Pattern::beatPatternLength() const
{
tick_t max_length = MidiTime::ticksPerTact();
tick_t max_length = MidiTime::ticksPerBar();
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -194,13 +194,13 @@ MidiTime Pattern::beatPatternLength() const
}
}
if( m_steps != MidiTime::stepsPerTact() )
if( m_steps != MidiTime::stepsPerBar() )
{
max_length = m_steps * MidiTime::ticksPerTact() /
MidiTime::stepsPerTact();
max_length = m_steps * MidiTime::ticksPerBar() /
MidiTime::stepsPerBar();
}
return MidiTime( max_length ).nextFullTact() * MidiTime::ticksPerTact();
return MidiTime( max_length ).nextFullBar() * MidiTime::ticksPerBar();
}
@@ -298,7 +298,7 @@ void Pattern::clearNotes()
Note * Pattern::addStepNote( int step )
{
return addNote( Note( MidiTime( -DefaultTicksPerTact ),
return addNote( Note( MidiTime( -DefaultTicksPerBar ),
MidiTime::stepPosition( step ) ), false );
}
@@ -417,7 +417,7 @@ void Pattern::loadSettings( const QDomElement & _this )
m_steps = _this.attribute( "steps" ).toInt();
if( m_steps == 0 )
{
m_steps = MidiTime::stepsPerTact();
m_steps = MidiTime::stepsPerBar();
}
checkType();
@@ -466,7 +466,7 @@ void Pattern::clear()
void Pattern::addSteps()
{
m_steps += MidiTime::stepsPerTact();
m_steps += MidiTime::stepsPerBar();
updateLength();
emit dataChanged();
}
@@ -497,7 +497,7 @@ void Pattern::cloneSteps()
void Pattern::removeSteps()
{
int n = MidiTime::stepsPerTact();
int n = MidiTime::stepsPerBar();
if( n < m_steps )
{
for( int i = m_steps - n; i < m_steps; ++i )
@@ -555,19 +555,19 @@ bool Pattern::empty()
void Pattern::changeTimeSignature()
{
MidiTime last_pos = MidiTime::ticksPerTact() - 1;
MidiTime last_pos = MidiTime::ticksPerBar() - 1;
for( NoteVector::ConstIterator cit = m_notes.begin();
cit != m_notes.end(); ++cit )
{
if( ( *cit )->length() < 0 && ( *cit )->pos() > last_pos )
{
last_pos = ( *cit )->pos()+MidiTime::ticksPerTact() /
MidiTime::stepsPerTact();
last_pos = ( *cit )->pos()+MidiTime::ticksPerBar() /
MidiTime::stepsPerBar();
}
}
last_pos = last_pos.nextFullTact() * MidiTime::ticksPerTact();
m_steps = qMax<tick_t>( MidiTime::stepsPerTact(),
last_pos.getTact() * MidiTime::stepsPerTact() );
last_pos = last_pos.nextFullBar() * MidiTime::ticksPerBar();
m_steps = qMax<tick_t>( MidiTime::stepsPerBar(),
last_pos.getBar() * MidiTime::stepsPerBar() );
updateLength();
}
@@ -715,7 +715,7 @@ void PatternView::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
m_pat->m_patternType == Pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ) &&
( fixedTCOs() || pixelsPerBar() >= 96 ) &&
_me->y() > height() - s_stepBtnOff->height() )
// when mouse button is pressed in beat/bassline -mode
@@ -785,7 +785,7 @@ void PatternView::mouseDoubleClickEvent(QMouseEvent *_me)
void PatternView::wheelEvent( QWheelEvent * _we )
{
if( m_pat->m_patternType == Pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ) &&
( fixedTCOs() || pixelsPerBar() >= 96 ) &&
_we->y() > height() - s_stepBtnOff->height() )
{
// get the step number that was wheeled on and
@@ -902,14 +902,14 @@ void PatternView::paintEvent( QPaintEvent * )
textBoxHeight = fontMetrics.height() + 2 * textTop;
}
// Compute pixels per tact
// Compute pixels per bar
const int baseWidth = fixedTCOs() ? parentWidget()->width() - 2 * TCO_BORDER_WIDTH
: width() - TCO_BORDER_WIDTH;
const float pixelsPerTact = baseWidth / (float) m_pat->length().getTact();
const float pixelsPerBar = baseWidth / (float) m_pat->length().getBar();
// Length of one tact/beat in the [0,1] x [0,1] coordinate system
const float tactLength = 1. / m_pat->length().getTact();
const float tickLength = tactLength / MidiTime::ticksPerTact();
// Length of one bar/beat in the [0,1] x [0,1] coordinate system
const float barLength = 1. / m_pat->length().getBar();
const float tickLength = barLength / MidiTime::ticksPerBar();
const int x_base = TCO_BORDER_WIDTH;
@@ -1029,7 +1029,7 @@ void PatternView::paintEvent( QPaintEvent * )
}
// beat pattern paint event
else if( beatPattern && ( fixedTCOs() || pixelsPerTact >= 96 ) )
else if( beatPattern && ( fixedTCOs() || pixelsPerBar >= 96 ) )
{
QPixmap stepon0;
QPixmap stepon200;
@@ -1097,14 +1097,14 @@ void PatternView::paintEvent( QPaintEvent * )
const int lineSize = 3;
p.setPen( c.darker( 200 ) );
for( tact_t t = 1; t < m_pat->length().getTact(); ++t )
for( bar_t t = 1; t < m_pat->length().getBar(); ++t )
{
p.drawLine( x_base + static_cast<int>( pixelsPerTact * t ) - 1,
p.drawLine( x_base + static_cast<int>( pixelsPerBar * t ) - 1,
TCO_BORDER_WIDTH, x_base + static_cast<int>(
pixelsPerTact * t ) - 1, TCO_BORDER_WIDTH + lineSize );
p.drawLine( x_base + static_cast<int>( pixelsPerTact * t ) - 1,
pixelsPerBar * t ) - 1, TCO_BORDER_WIDTH + lineSize );
p.drawLine( x_base + static_cast<int>( pixelsPerBar * t ) - 1,
rect().bottom() - ( lineSize + TCO_BORDER_WIDTH ),
x_base + static_cast<int>( pixelsPerTact * t ) - 1,
x_base + static_cast<int>( pixelsPerBar * t ) - 1,
rect().bottom() - TCO_BORDER_WIDTH );
}

View File

@@ -157,7 +157,7 @@ void SampleTCO::setSampleFile( const QString & _sf )
{ //When creating an empty sample pattern make it a bar long
float nom = Engine::getSong()->getTimeSigModel().getNumerator();
float den = Engine::getSong()->getTimeSigModel().getDenominator();
length = DefaultTicksPerTact * ( nom / den );
length = DefaultTicksPerBar * ( nom / den );
}
else
{ //Otherwise set it to the sample's length
@@ -521,18 +521,18 @@ void SampleTCOView::paintEvent( QPaintEvent * pe )
p.setPen( !muted ? painter.pen().brush().color() : mutedColor() );
const int spacing = TCO_BORDER_WIDTH + 1;
const float ppt = fixedTCOs() ?
const float ppb = fixedTCOs() ?
( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
/ (float) m_tco->length().getTact() :
pixelsPerTact();
/ (float) m_tco->length().getBar() :
pixelsPerBar();
float nom = Engine::getSong()->getTimeSigModel().getNumerator();
float den = Engine::getSong()->getTimeSigModel().getDenominator();
float ticksPerTact = DefaultTicksPerTact * nom / den;
float ticksPerBar = DefaultTicksPerBar * nom / den;
float offset = m_tco->startTimeOffset() / ticksPerTact * pixelsPerTact();
float offset = m_tco->startTimeOffset() / ticksPerBar * pixelsPerBar();
QRect r = QRect( TCO_BORDER_WIDTH + offset, spacing,
qMax( static_cast<int>( m_tco->sampleLength() * ppt / ticksPerTact ), 1 ), rect().bottom() - 2 * spacing );
qMax( static_cast<int>( m_tco->sampleLength() * ppb / ticksPerBar ), 1 ), rect().bottom() - 2 * spacing );
m_tco->m_sampleBuffer->visualize( p, r, pe->rect() );
QFileInfo fileInfo(m_tco->m_sampleBuffer->audioFile());
@@ -928,8 +928,8 @@ void SampleTrackView::dropEvent(QDropEvent *de)
MidiTime tcoPos = trackContainerView()->fixedTCOs()
? MidiTime(0)
: MidiTime(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerTact()
* MidiTime::ticksPerTact()) + trackContainerView()->currentPosition()
: MidiTime(((xPos - trackHeadWidth) / trackContainerView()->pixelsPerBar()
* MidiTime::ticksPerBar()) + trackContainerView()->currentPosition()
).quantize(1.0);
SampleTCO * sTco = static_cast<SampleTCO*>(getTrack()->createTCO(tcoPos));

View File

@@ -186,12 +186,12 @@ private slots:
QVERIFY(! bbContainer->automatedValuesAt(5, bbTrack2.index()).size());
BBTCO tco(&bbTrack);
tco.changeLength(MidiTime::ticksPerTact() * 2);
tco.changeLength(MidiTime::ticksPerBar() * 2);
tco.movePosition(0);
QCOMPARE(song->automatedValuesAt(0)[&model], 0.0f);
QCOMPARE(song->automatedValuesAt(5)[&model], 0.5f);
QCOMPARE(song->automatedValuesAt(MidiTime::ticksPerTact() + 5)[&model], 0.5f);
QCOMPARE(song->automatedValuesAt(MidiTime::ticksPerBar() + 5)[&model], 0.5f);
}
void testGlobalAutomation()