Merge pull request #1622 from M374LX/coding

Progressive coding conventions update (new branch)
This commit is contained in:
Tres Finocchiaro
2015-03-04 01:55:28 +00:00
14 changed files with 729 additions and 688 deletions

View File

@@ -315,9 +315,9 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
{
m_profiler.startPeriod();
static Song::playPos last_metro_pos = -1;
static Song::PlayPos last_metro_pos = -1;
Song::playPos p = Engine::getSong()->getPlayPos(
Song::PlayPos p = Engine::getSong()->getPlayPos(
Song::Mode_PlayPattern );
if( Engine::getSong()->playMode() == Song::Mode_PlayPattern &&
gui->pianoRoll()->isRecording() == true &&
@@ -965,6 +965,3 @@ void Mixer::fifoWriter::run()

View File

@@ -2,7 +2,7 @@
* note.cpp - implementation of class note
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of LMMS - http://lmms.io
*
* This program is free software; you can redistribute it and/or
@@ -29,28 +29,30 @@
#include "Note.h"
#include "DetuningHelper.h"
#include "templates.h"
Note::Note( const MidiTime & _length, const MidiTime & _pos,
int _key, volume_t _volume, panning_t _panning,
DetuningHelper * _detuning ) :
Note::Note( const MidiTime & length, const MidiTime & pos,
int key, volume_t volume, panning_t panning,
DetuningHelper * detuning ) :
m_selected( false ),
m_oldKey( qBound( 0, _key, NumKeys ) ),
m_oldPos( _pos ),
m_oldLength( _length ),
m_oldKey( qBound( 0, key, NumKeys ) ),
m_oldPos( pos ),
m_oldLength( length ),
m_isPlaying( false ),
m_key( qBound( 0, _key, NumKeys ) ),
m_volume( qBound( MinVolume, _volume, MaxVolume ) ),
m_panning( qBound( PanningLeft, _panning, PanningRight ) ),
m_length( _length ),
m_pos( _pos ),
m_key( qBound( 0, key, NumKeys ) ),
m_volume( qBound( MinVolume, volume, MaxVolume ) ),
m_panning( qBound( PanningLeft, panning, PanningRight ) ),
m_length( length ),
m_pos( pos ),
m_detuning( NULL )
{
if( _detuning )
if( detuning )
{
m_detuning = sharedObject::ref( _detuning );
m_detuning = sharedObject::ref( detuning );
}
else
{
@@ -61,23 +63,23 @@ Note::Note( const MidiTime & _length, const MidiTime & _pos,
Note::Note( const Note & _note ) :
SerializingObject( _note ),
m_selected( _note.m_selected ),
m_oldKey( _note.m_oldKey ),
m_oldPos( _note.m_oldPos ),
m_oldLength( _note.m_oldLength ),
m_isPlaying( _note.m_isPlaying ),
m_key( _note.m_key),
m_volume( _note.m_volume ),
m_panning( _note.m_panning ),
m_length( _note.m_length ),
m_pos( _note.m_pos ),
Note::Note( const Note & note ) :
SerializingObject( note ),
m_selected( note.m_selected ),
m_oldKey( note.m_oldKey ),
m_oldPos( note.m_oldPos ),
m_oldLength( note.m_oldLength ),
m_isPlaying( note.m_isPlaying ),
m_key( note.m_key),
m_volume( note.m_volume ),
m_panning( note.m_panning ),
m_length( note.m_length ),
m_pos( note.m_pos ),
m_detuning( NULL )
{
if( _note.m_detuning )
if( note.m_detuning )
{
m_detuning = sharedObject::ref( _note.m_detuning );
m_detuning = sharedObject::ref( note.m_detuning );
}
}
@@ -95,93 +97,93 @@ Note::~Note()
void Note::setLength( const MidiTime & _length )
void Note::setLength( const MidiTime & length )
{
m_length = _length;
m_length = length;
}
void Note::setPos( const MidiTime & _pos )
void Note::setPos( const MidiTime & pos )
{
m_pos = _pos;
m_pos = pos;
}
void Note::setKey( const int _key )
void Note::setKey( const int key )
{
const int k = qBound( 0, _key, NumKeys );
const int k = qBound( 0, key, NumKeys );
m_key = k;
}
void Note::setVolume( volume_t _volume )
void Note::setVolume( volume_t volume )
{
const volume_t v = qBound( MinVolume, _volume, MaxVolume );
const volume_t v = qBound( MinVolume, volume, MaxVolume );
m_volume = v;
}
void Note::setPanning( panning_t _panning )
void Note::setPanning( panning_t panning )
{
const panning_t p = qBound( PanningLeft, _panning, PanningRight );
const panning_t p = qBound( PanningLeft, panning, PanningRight );
m_panning = p;
}
MidiTime Note::quantized( const MidiTime & _m, const int _q_grid )
MidiTime Note::quantized( const MidiTime & m, const int qGrid )
{
float p = ( (float) _m / _q_grid );
float p = ( (float) m / qGrid );
if( p - floorf( p ) < 0.5f )
{
return( static_cast<int>( p ) * _q_grid );
return static_cast<int>( p ) * qGrid;
}
return( static_cast<int>( p + 1 ) * _q_grid );
return static_cast<int>( p + 1 ) * qGrid;
}
void Note::quantizeLength( const int _q_grid )
void Note::quantizeLength( const int qGrid )
{
setLength( quantized( length(), _q_grid ) );
setLength( quantized( length(), qGrid ) );
if( length() == 0 )
{
setLength( _q_grid );
setLength( qGrid );
}
}
void Note::quantizePos( const int _q_grid )
void Note::quantizePos( const int qGrid )
{
setPos( quantized( pos(), _q_grid ) );
setPos( quantized( pos(), qGrid ) );
}
void Note::saveSettings( QDomDocument & _doc, QDomElement & _this )
void Note::saveSettings( QDomDocument & doc, QDomElement & parent )
{
_this.setAttribute( "key", m_key );
_this.setAttribute( "vol", m_volume );
_this.setAttribute( "pan", m_panning );
_this.setAttribute( "len", m_length );
_this.setAttribute( "pos", m_pos );
parent.setAttribute( "key", m_key );
parent.setAttribute( "vol", m_volume );
parent.setAttribute( "pan", m_panning );
parent.setAttribute( "len", m_length );
parent.setAttribute( "pos", m_pos );
if( m_detuning && m_length )
{
m_detuning->saveSettings( _doc, _this );
m_detuning->saveSettings( doc, parent );
}
}
@@ -229,4 +231,3 @@ bool Note::hasDetuningInfo() const

View File

@@ -38,9 +38,9 @@
#include "Song.h"
static PixmapLoader __dummy_loader;
static PixmapLoader __dummyLoader;
static Plugin::Descriptor dummy_plugin_descriptor =
static Plugin::Descriptor dummyPluginDescriptor =
{
"dummy",
"dummy",
@@ -48,21 +48,21 @@ static Plugin::Descriptor dummy_plugin_descriptor =
"Tobias Doerffel <tobydox/at/users.sf.net>",
0x0100,
Plugin::Undefined,
&__dummy_loader,
&__dummyLoader,
NULL
} ;
Plugin::Plugin( const Descriptor * _descriptor, Model * parent ) :
Plugin::Plugin( const Descriptor * descriptor, Model * parent ) :
Model( parent ),
JournallingObject(),
m_descriptor( _descriptor )
m_descriptor( descriptor )
{
if( m_descriptor == NULL )
{
m_descriptor = &dummy_plugin_descriptor;
m_descriptor = &dummyPluginDescriptor;
}
}
@@ -109,7 +109,7 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent,
return new DummyPlugin();
}
InstantiationHook instantiationHook = ( InstantiationHook ) pluginLibrary.resolve( "lmms_plugin_main" );
InstantiationHook instantiationHook = ( InstantiationHook )pluginLibrary.resolve( "lmms_plugin_main" );
if( instantiationHook == NULL )
{
if( Engine::hasGUI() )
@@ -126,13 +126,17 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent,
return inst;
}
void Plugin::collectErrorForUI( QString err_msg )
void Plugin::collectErrorForUI( QString errMsg )
{
Engine::getSong()->collectError( err_msg );
Engine::getSong()->collectError( errMsg );
}
void Plugin::getDescriptorsOfAvailPlugins( DescriptorList& pluginDescriptors )
{
QDir directory( ConfigManager::inst()->pluginDir() );
@@ -189,13 +193,13 @@ PluginView * Plugin::createView( QWidget * parent )
Plugin::Descriptor::SubPluginFeatures::Key::Key(
const QDomElement & _key ) :
Plugin::Descriptor::SubPluginFeatures::Key::Key( const QDomElement & key ) :
desc( NULL ),
name( _key.attribute( "key" ) ),
name( key.attribute( "key" ) ),
attributes()
{
QDomNodeList l = _key.elementsByTagName( "attribute" );
QDomNodeList l = key.elementsByTagName( "attribute" );
for( int i = 0; !l.item( i ).isNull(); ++i )
{
QDomElement e = l.item( i ).toElement();
@@ -208,13 +212,13 @@ Plugin::Descriptor::SubPluginFeatures::Key::Key(
QDomElement Plugin::Descriptor::SubPluginFeatures::Key::saveXML(
QDomDocument & _doc ) const
QDomDocument & doc ) const
{
QDomElement e = _doc.createElement( "key" );
for( AttributeMap::ConstIterator it = attributes.begin();
it != attributes.end(); ++it )
QDomElement e = doc.createElement( "key" );
for( AttributeMap::ConstIterator it = attributes.begin();
it != attributes.end(); ++it )
{
QDomElement a = _doc.createElement( "attribute" );
QDomElement a = doc.createElement( "attribute" );
a.setAttribute( "name", it.key() );
a.setAttribute( "value", it.value() );
e.appendChild( a );
@@ -222,3 +226,5 @@ QDomElement Plugin::Descriptor::SubPluginFeatures::Key::saveXML(
return e;
}

View File

@@ -163,7 +163,7 @@ void ProjectRenderer::run()
//skip first empty buffer
Engine::mixer()->nextBuffer();
Song::playPos & pp = Engine::getSong()->getPlayPos(
Song::PlayPos & pp = Engine::getSong()->getPlayPos(
Song::Mode_PlaySong );
m_progress = 0;
const int sl = ( Engine::getSong()->length() + 1 ) * 192;
@@ -230,5 +230,3 @@ void ProjectRenderer::updateConsoleProgress()

View File

@@ -31,18 +31,30 @@ int parseMajor(QString & version) {
return version.section( '.', 0, 0 ).toInt();
}
int parseMinor(QString & version) {
return version.section( '.', 1, 1 ).toInt();
}
int parseRelease(QString & version) {
return version.section( '.', 2 ).section( '-', 0, 0 ).toInt();
}
QString parseBuild(QString & version) {
return version.section( '.', 2 ).section( '-', 1 );
}
ProjectVersion::ProjectVersion(QString version, CompareType c) :
m_version(version),
m_major(parseMajor(m_version)),
@@ -53,41 +65,48 @@ ProjectVersion::ProjectVersion(QString version, CompareType c) :
{
}
ProjectVersion::ProjectVersion(const char* version, CompareType c) :
m_version(QString(version)),
m_major(parseMajor(m_version)),
m_minor(parseMinor(m_version)),
m_release(parseRelease(m_version)) ,
m_release(parseRelease(m_version)),
m_build(parseBuild(m_version)),
m_compareType(c)
{
}
int ProjectVersion::compare(const ProjectVersion& a, const ProjectVersion& b, CompareType c)
int ProjectVersion::compare(const ProjectVersion & a, const ProjectVersion & b, CompareType c)
{
if (a.getMajor() != b.getMajor())
if(a.getMajor() != b.getMajor())
{
return a.getMajor() - b.getMajor();
}
else if (c == CompareType::Major)
else if(c == CompareType::Major)
{
return 0;
}
if (a.getMinor() != b.getMinor())
if(a.getMinor() != b.getMinor())
{
return a.getMinor() - b.getMinor();
}
else if (c == CompareType::Minor)
else if(c == CompareType::Minor)
{
return 0;
}
if (a.getRelease() != b.getRelease())
if(a.getRelease() != b.getRelease())
{
return a.getRelease() - b.getRelease();
}
else if (c == CompareType::Release)
else if(c == CompareType::Release)
{
return 0;
}
@@ -105,8 +124,13 @@ int ProjectVersion::compare(const ProjectVersion& a, const ProjectVersion& b, Co
return QString::compare(a.getBuild(), b.getBuild());
}
int ProjectVersion::compare(ProjectVersion v1, ProjectVersion v2)
{
return compare(v1, v2, std::min(v1.getCompareType(), v2.getCompareType()));
}

View File

@@ -145,7 +145,7 @@ void Song::masterVolumeChanged()
void Song::setTempo()
{
Engine::mixer()->lockPlayHandleRemoval();
const bpm_t tempo = (bpm_t) m_tempoModel.value();
const bpm_t tempo = ( bpm_t ) m_tempoModel.value();
PlayHandleList & playHandles = Engine::mixer()->playHandles();
for( PlayHandleList::Iterator it = playHandles.begin();
it != playHandles.end(); ++it )
@@ -177,7 +177,8 @@ void Song::setTimeSignature()
emit dataChanged();
m_oldTicksPerTact = ticksPerTact();
m_vstSyncController.setTimeSignature( getTimeSigModel().getNumerator(), getTimeSigModel().getDenominator() );
m_vstSyncController.setTimeSignature(
getTimeSigModel().getNumerator(), getTimeSigModel().getDenominator() );
}
@@ -203,13 +204,13 @@ void Song::processNextBuffer()
return;
}
TrackList track_list;
int tco_num = -1;
TrackList trackList;
int tcoNum = -1;
switch( m_playMode )
{
case Mode_PlaySong:
track_list = tracks();
trackList = tracks();
// at song-start we have to reset the LFOs
if( m_playPos[Mode_PlaySong] == 0 )
{
@@ -218,25 +219,25 @@ void Song::processNextBuffer()
break;
case Mode_PlayTrack:
track_list.push_back( m_trackToPlay );
trackList.push_back( m_trackToPlay );
break;
case Mode_PlayBB:
if( Engine::getBBTrackContainer()->numOfBBs() > 0 )
{
tco_num = Engine::getBBTrackContainer()->
tcoNum = Engine::getBBTrackContainer()->
currentBB();
track_list.push_back( BBTrack::findBBTrack(
tco_num ) );
trackList.push_back( BBTrack::findBBTrack(
tcoNum ) );
}
break;
case Mode_PlayPattern:
if( m_patternToPlay != NULL )
{
tco_num = m_patternToPlay->getTrack()->
tcoNum = m_patternToPlay->getTrack()->
getTCONum( m_patternToPlay );
track_list.push_back(
trackList.push_back(
m_patternToPlay->getTrack() );
}
break;
@@ -246,41 +247,44 @@ void Song::processNextBuffer()
}
if( track_list.empty() == true )
if( trackList.empty() == true )
{
return;
}
// check for looping-mode and act if necessary
TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine;
bool check_loop = tl != NULL && m_exporting == false &&
tl->loopPointsEnabled();
if( check_loop )
bool checkLoop =
tl != NULL && m_exporting == false && tl->loopPointsEnabled();
if( checkLoop )
{
if( m_playPos[m_playMode] < tl->loopBegin() ||
m_playPos[m_playMode] >= tl->loopEnd() )
{
m_elapsedMilliSeconds = (tl->loopBegin().getTicks()*60*1000/48)/getTempo();
m_elapsedMilliSeconds =
( tl->loopBegin().getTicks() * 60 * 1000 / 48 ) / getTempo();
m_playPos[m_playMode].setTicks(
tl->loopBegin().getTicks() );
}
}
f_cnt_t total_frames_played = 0;
const float frames_per_tick = Engine::framesPerTick();
f_cnt_t totalFramesPlayed = 0;
const float framesPerTick = Engine::framesPerTick();
while( total_frames_played
< Engine::mixer()->framesPerPeriod() )
while( totalFramesPlayed < Engine::mixer()->framesPerPeriod() )
{
m_vstSyncController.update();
f_cnt_t played_frames = Engine::mixer()->framesPerPeriod() - total_frames_played;
f_cnt_t playedFrames = Engine::mixer()->framesPerPeriod() -
totalFramesPlayed;
float current_frame = m_playPos[m_playMode].currentFrame();
float currentFrame = m_playPos[m_playMode].currentFrame();
// did we play a tick?
if( current_frame >= frames_per_tick )
if( currentFrame >= framesPerTick )
{
int ticks = m_playPos[m_playMode].getTicks() + (int)( current_frame / frames_per_tick );
int ticks = m_playPos[m_playMode].getTicks() +
( int )( currentFrame / framesPerTick );
m_vstSyncController.setAbsolutePosition( ticks );
@@ -290,14 +294,14 @@ void Song::processNextBuffer()
// per default we just continue playing even if
// there's no more stuff to play
// (song-play-mode)
int max_tact = m_playPos[m_playMode].getTact()
int maxTact = m_playPos[m_playMode].getTact()
+ 2;
// then decide whether to go over to next tact
// or to loop back to first tact
if( m_playMode == Mode_PlayBB )
{
max_tact = Engine::getBBTrackContainer()
maxTact = Engine::getBBTrackContainer()
->lengthOfCurrentBB();
}
else if( m_playMode == Mode_PlayPattern &&
@@ -305,34 +309,39 @@ void Song::processNextBuffer()
tl != NULL &&
tl->loopPointsEnabled() == false )
{
max_tact = m_patternToPlay->length()
maxTact = m_patternToPlay->length()
.getTact();
}
// end of played object reached?
if( m_playPos[m_playMode].getTact() + 1
>= max_tact )
>= maxTact )
{
// then start from beginning and keep
// offset
ticks = ticks % ( max_tact * MidiTime::ticksPerTact() );
ticks %= ( maxTact * MidiTime::ticksPerTact() );
// wrap milli second counter
m_elapsedMilliSeconds = ( ticks * 60 * 1000 / 48 ) / getTempo();
m_elapsedMilliSeconds =
( ticks * 60 * 1000 / 48 ) / getTempo();
m_vstSyncController.setAbsolutePosition( ticks );
}
}
m_playPos[m_playMode].setTicks( ticks );
if( check_loop )
if( checkLoop )
{
m_vstSyncController.startCycle( tl->loopBegin().getTicks(), tl->loopEnd().getTicks() );
m_vstSyncController.startCycle(
tl->loopBegin().getTicks(), tl->loopEnd().getTicks() );
if( m_playPos[m_playMode] >= tl->loopEnd() )
{
m_playPos[m_playMode].setTicks( tl->loopBegin().getTicks() );
m_elapsedMilliSeconds = ((tl->loopBegin().getTicks())*60*1000/48)/getTempo();
m_elapsedMilliSeconds =
( ( tl->loopBegin().getTicks() ) * 60 * 1000 / 48 ) /
getTempo();
}
}
else
@@ -340,55 +349,57 @@ void Song::processNextBuffer()
m_vstSyncController.stopCycle();
}
current_frame = fmodf( current_frame, frames_per_tick );
m_playPos[m_playMode].setCurrentFrame( current_frame );
currentFrame = fmodf( currentFrame, framesPerTick );
m_playPos[m_playMode].setCurrentFrame( currentFrame );
}
f_cnt_t last_frames = (f_cnt_t)frames_per_tick -
(f_cnt_t) current_frame;
f_cnt_t lastFrames = ( f_cnt_t )framesPerTick -
( f_cnt_t )currentFrame;
// skip last frame fraction
if( last_frames == 0 )
if( lastFrames == 0 )
{
++total_frames_played;
m_playPos[m_playMode].setCurrentFrame( current_frame
++totalFramesPlayed;
m_playPos[m_playMode].setCurrentFrame( currentFrame
+ 1.0f );
continue;
}
// do we have some samples left in this tick but these are
// less then samples we have to play?
if( last_frames < played_frames )
if( lastFrames < playedFrames )
{
// then set played_samples to remaining samples, the
// rest will be played in next loop
played_frames = last_frames;
playedFrames = lastFrames;
}
if( (f_cnt_t) current_frame == 0 )
if( ( f_cnt_t ) currentFrame == 0 )
{
if( m_playMode == Mode_PlaySong )
{
m_globalAutomationTrack->play(
m_playPos[m_playMode],
played_frames,
total_frames_played, tco_num );
playedFrames,
totalFramesPlayed, tcoNum );
}
// loop through all tracks and play them
for( int i = 0; i < track_list.size(); ++i )
for( int i = 0; i < trackList.size(); ++i )
{
track_list[i]->play( m_playPos[m_playMode],
played_frames,
total_frames_played, tco_num );
trackList[i]->play( m_playPos[m_playMode],
playedFrames,
totalFramesPlayed, tcoNum );
}
}
// update frame-counters
total_frames_played += played_frames;
m_playPos[m_playMode].setCurrentFrame( played_frames +
current_frame );
m_elapsedMilliSeconds += (((played_frames/frames_per_tick)*60*1000/48)/getTempo());
totalFramesPlayed += playedFrames;
m_playPos[m_playMode].setCurrentFrame( playedFrames +
currentFrame );
m_elapsedMilliSeconds +=
( ( playedFrames / framesPerTick ) * 60 * 1000 / 48 )
/ getTempo();
m_elapsedTacts = m_playPos[Mode_PlaySong].getTact();
m_elapsedTicks = (m_playPos[Mode_PlaySong].getTicks()%ticksPerTact())/48;
m_elapsedTicks = ( m_playPos[Mode_PlaySong].getTicks() % ticksPerTact() ) / 48;
}
}
@@ -397,17 +408,21 @@ bool Song::isExportDone() const
if ( m_renderBetweenMarkers )
{
return m_exporting == true &&
m_playPos[Mode_PlaySong].getTicks() >= m_playPos[Mode_PlaySong].m_timeLine->loopEnd().getTicks();
m_playPos[Mode_PlaySong].getTicks() >=
m_playPos[Mode_PlaySong].m_timeLine->loopEnd().getTicks();
}
if( m_exportLoop)
{
return m_exporting == true &&
m_playPos[Mode_PlaySong].getTicks() >= length() * ticksPerTact();
m_playPos[Mode_PlaySong].getTicks() >=
length() * ticksPerTact();
}
else
{
return m_exporting == true &&
m_playPos[Mode_PlaySong].getTicks() >= ( length() + 1 ) * ticksPerTact();
m_playPos[Mode_PlaySong].getTicks() >=
( length() + 1 ) * ticksPerTact();
}
}
@@ -455,13 +470,13 @@ void Song::playAndRecord()
void Song::playTrack( Track * _trackToPlay )
void Song::playTrack( Track * trackToPlay )
{
if( isStopped() == false )
{
stop();
}
m_trackToPlay = _trackToPlay;
m_trackToPlay = trackToPlay;
m_playMode = Mode_PlayTrack;
m_playing = true;
@@ -498,7 +513,7 @@ void Song::playBB()
void Song::playPattern( const Pattern* patternToPlay, bool _loop )
void Song::playPattern( const Pattern* patternToPlay, bool loop )
{
if( isStopped() == false )
{
@@ -506,7 +521,7 @@ void Song::playPattern( const Pattern* patternToPlay, bool _loop )
}
m_patternToPlay = patternToPlay;
m_loopPattern = _loop;
m_loopPattern = loop;
if( m_patternToPlay != NULL )
{
@@ -544,12 +559,14 @@ void Song::updateLength()
void Song::setPlayPos( tick_t _ticks, PlayModes _play_mode )
void Song::setPlayPos( tick_t ticks, PlayModes playMode )
{
m_elapsedTicks += m_playPos[_play_mode].getTicks() - _ticks;
m_elapsedMilliSeconds += (((( _ticks - m_playPos[_play_mode].getTicks()))*60*1000/48)/getTempo());
m_playPos[_play_mode].setTicks( _ticks );
m_playPos[_play_mode].setCurrentFrame( 0.0f );
m_elapsedTicks += m_playPos[playMode].getTicks() - ticks;
m_elapsedMilliSeconds +=
( ( ( ( ticks - m_playPos[playMode].getTicks() ) ) * 60 * 1000 / 48) /
getTempo() );
m_playPos[playMode].setTicks( ticks );
m_playPos[playMode].setCurrentFrame( 0.0f );
// send a signal if playposition changes during playback
if( isPlaying() )
@@ -609,7 +626,9 @@ void Song::stop()
if( tl->savedPos() >= 0 )
{
m_playPos[m_playMode].setTicks( tl->savedPos().getTicks() );
m_elapsedMilliSeconds = (((tl->savedPos().getTicks())*60*1000/48)/getTempo());
m_elapsedMilliSeconds =
( ( ( tl->savedPos().getTicks() ) * 60 * 1000 / 48 ) /
getTempo() );
tl->savePos( -1 );
}
break;
@@ -714,7 +733,7 @@ void Song::addBBTrack()
void Song::addSampleTrack()
{
(void) Track::create( Track::SampleTrack, this );
( void )Track::create( Track::SampleTrack, this );
}
@@ -722,7 +741,7 @@ void Song::addSampleTrack()
void Song::addAutomationTrack()
{
(void) Track::create( Track::AutomationTrack, this );
( void )Track::create( Track::AutomationTrack, this );
}
@@ -730,7 +749,7 @@ void Song::addAutomationTrack()
bpm_t Song::getTempo()
{
return (bpm_t) m_tempoModel.value();
return ( bpm_t )m_tempoModel.value();
}
@@ -825,24 +844,23 @@ void Song::clearProject()
// create new file
void Song::createNewProject()
{
QString default_template = ConfigManager::inst()->userProjectsDir()
QString defaultTemplate = ConfigManager::inst()->userProjectsDir()
+ "templates/default.mpt";
if( QFile::exists( default_template ) )
if( QFile::exists( defaultTemplate ) )
{
createNewProjectFromTemplate( default_template );
createNewProjectFromTemplate( defaultTemplate );
return;
}
default_template = ConfigManager::inst()->factoryProjectsDir()
defaultTemplate = ConfigManager::inst()->factoryProjectsDir()
+ "templates/default.mpt";
if( QFile::exists( default_template ) )
if( QFile::exists( defaultTemplate ) )
{
createNewProjectFromTemplate( default_template );
createNewProjectFromTemplate( defaultTemplate );
return;
}
@@ -892,9 +910,9 @@ void Song::createNewProject()
void Song::createNewProjectFromTemplate( const QString & _template )
void Song::createNewProjectFromTemplate( const QString & templ )
{
loadProject( _template );
loadProject( templ );
// clear file-name so that user doesn't overwrite template when
// saving...
m_fileName = m_oldFileName = "";
@@ -910,7 +928,7 @@ void Song::createNewProjectFromTemplate( const QString & _template )
// load given song
void Song::loadProject( const QString & _file_name )
void Song::loadProject( const QString & fileName )
{
QDomNode node;
@@ -918,8 +936,8 @@ void Song::loadProject( const QString & _file_name )
Engine::projectJournal()->setJournalling( false );
m_fileName = _file_name;
m_oldFileName = _file_name;
m_fileName = fileName;
m_oldFileName = fileName;
DataFile dataFile( m_fileName );
// if file could not be opened, head-node is null and we create
@@ -1024,7 +1042,7 @@ void Song::loadProject( const QString & _file_name )
Engine::mixer()->unlock();
ConfigManager::inst()->addRecentlyOpenedProject( _file_name );
ConfigManager::inst()->addRecentlyOpenedProject( fileName );
Engine::projectJournal()->setJournalling( true );
@@ -1054,7 +1072,7 @@ void Song::loadProject( const QString & _file_name )
// only save current song as _filename and do nothing else
bool Song::saveProjectFile( const QString & _filename )
bool Song::saveProjectFile( const QString & filename )
{
DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeSave );
@@ -1080,7 +1098,7 @@ bool Song::saveProjectFile( const QString & _filename )
saveControllerStates( dataFile, dataFile.content() );
return dataFile.writeFile( _filename );
return dataFile.writeFile( filename );
}
@@ -1158,23 +1176,23 @@ void Song::importProject()
void Song::saveControllerStates( QDomDocument & _doc, QDomElement & _this )
void Song::saveControllerStates( QDomDocument & doc, QDomElement & element )
{
// save settings of controllers
QDomElement controllersNode =_doc.createElement( "controllers" );
_this.appendChild( controllersNode );
QDomElement controllersNode = doc.createElement( "controllers" );
element.appendChild( controllersNode );
for( int i = 0; i < m_controllers.size(); ++i )
{
m_controllers[i]->saveState( _doc, controllersNode );
m_controllers[i]->saveState( doc, controllersNode );
}
}
void Song::restoreControllerStates( const QDomElement & _this )
void Song::restoreControllerStates( const QDomElement & element )
{
QDomNode node = _this.firstChild();
QDomNode node = element.firstChild();
while( !node.isNull() )
{
Controller * c = Controller::create( node.toElement(), this );
@@ -1195,10 +1213,10 @@ void Song::restoreControllerStates( const QDomElement & _this )
void Song::exportProjectTracks()
{
exportProject(true);
exportProject( true );
}
void Song::exportProject(bool multiExport)
void Song::exportProject( bool multiExport )
{
if( isEmpty() )
{
@@ -1211,7 +1229,8 @@ void Song::exportProject(bool multiExport)
}
FileDialog efd( gui->mainWindow() );
if (multiExport)
if ( multiExport )
{
efd.setFileMode( FileDialog::Directory);
efd.setWindowTitle( tr( "Select directory for writing exported tracks..." ) );
@@ -1231,18 +1250,18 @@ void Song::exportProject(bool multiExport)
++idx;
}
efd.setNameFilters( types );
QString base_filename;
QString baseFilename;
if( !m_fileName.isEmpty() )
{
efd.setDirectory( QFileInfo( m_fileName ).absolutePath() );
base_filename = QFileInfo( m_fileName ).completeBaseName();
baseFilename = QFileInfo( m_fileName ).completeBaseName();
}
else
{
efd.setDirectory( ConfigManager::inst()->userProjectsDir() );
base_filename = tr( "untitled" );
baseFilename = tr( "untitled" );
}
efd.selectFile( base_filename + __fileEncodeDevices[0].m_extension );
efd.selectFile( baseFilename + __fileEncodeDevices[0].m_extension );
efd.setWindowTitle( tr( "Select file for project-export..." ) );
}
@@ -1269,8 +1288,8 @@ void Song::exportProject(bool multiExport)
}
}
const QString export_file_name = efd.selectedFiles()[0] + suffix;
ExportProjectDialog epd( export_file_name, gui->mainWindow(), multiExport );
const QString exportFileName = efd.selectedFiles()[0] + suffix;
ExportProjectDialog epd( exportFileName, gui->mainWindow(), multiExport );
epd.exec();
}
}
@@ -1360,11 +1379,11 @@ void Song::setModified()
void Song::addController( Controller * _c )
void Song::addController( Controller * c )
{
if( _c != NULL && !m_controllers.contains( _c ) )
if( c != NULL && m_controllers.contains( c ) == false )
{
m_controllers.append( _c );
m_controllers.append( c );
emit dataChanged();
}
}
@@ -1372,9 +1391,9 @@ void Song::addController( Controller * _c )
void Song::removeController( Controller * _controller )
void Song::removeController( Controller * controller )
{
int index = m_controllers.indexOf( _controller );
int index = m_controllers.indexOf( controller );
if( index != -1 )
{
m_controllers.remove( index );
@@ -1389,6 +1408,7 @@ void Song::removeController( Controller * _controller )
void Song::clearErrors()
{
m_errors->clear();
@@ -1424,3 +1444,7 @@ QString* Song::errorSummary()
return errors;
}

File diff suppressed because it is too large Load Diff

View File

@@ -52,19 +52,19 @@ QPixmap * TimeLineWidget::s_posMarkerPixmap = NULL;
QPixmap * TimeLineWidget::s_loopPointBeginPixmap = NULL;
QPixmap * TimeLineWidget::s_loopPointEndPixmap = NULL;
TimeLineWidget::TimeLineWidget( const int _xoff, const int _yoff, const float _ppt,
Song::playPos & _pos, const MidiTime & _begin,
QWidget * _parent ) :
QWidget( _parent ),
TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt,
Song::PlayPos & pos, const MidiTime & begin,
QWidget * parent ) :
QWidget( parent ),
m_autoScroll( AutoScrollEnabled ),
m_loopPoints( LoopPointsDisabled ),
m_behaviourAtStop( BackToZero ),
m_changedPosition( true ),
m_xOffset( _xoff ),
m_xOffset( xoff ),
m_posMarkerX( 0 ),
m_ppt( _ppt ),
m_pos( _pos ),
m_begin( _begin ),
m_ppt( ppt ),
m_pos( pos ),
m_begin( begin ),
m_savedPos( -1 ),
m_hint( NULL ),
m_action( NoAction ),
@@ -95,17 +95,17 @@ TimeLineWidget::TimeLineWidget( const int _xoff, const int _yoff, const float _p
}
setAttribute( Qt::WA_OpaquePaintEvent, true );
move( 0, _yoff );
move( 0, yoff );
setFixedHeight( s_timeLinePixmap->height() );
m_xOffset -= s_posMarkerPixmap->width() / 2;
m_pos.m_timeLine = this;
QTimer * update_timer = new QTimer( this );
connect( update_timer, SIGNAL( timeout() ),
QTimer * updateTimer = new QTimer( this );
connect( updateTimer, SIGNAL( timeout() ),
this, SLOT( updatePosition() ) );
update_timer->start( 50 );
updateTimer->start( 50 );
}
@@ -401,7 +401,3 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event )