Skip to content

Commit

Permalink
Remove track container parameter in Track constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Dec 8, 2024
1 parent 8b52a93 commit f20d308
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 53 deletions.
2 changes: 1 addition & 1 deletion include/AutomationTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AutomationTrack : public Track
{
Q_OBJECT
public:
AutomationTrack( TrackContainer* tc, bool _hidden = false );
AutomationTrack(bool hidden = false);
~AutomationTrack() override = default;

bool play( const TimePos & _start, const fpp_t _frames,
Expand Down
2 changes: 1 addition & 1 deletion include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor
Q_OBJECT
mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel);
public:
InstrumentTrack( TrackContainer* tc );
InstrumentTrack();
~InstrumentTrack() override;

// used by instrument
Expand Down
2 changes: 1 addition & 1 deletion include/PatternTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LMMS_EXPORT PatternTrack : public Track
{
Q_OBJECT
public:
PatternTrack(TrackContainer* tc);
PatternTrack();
~PatternTrack() override;

bool play( const TimePos & _start, const fpp_t _frames,
Expand Down
2 changes: 1 addition & 1 deletion include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SampleTrack : public Track
{
Q_OBJECT
public:
SampleTrack( TrackContainer* tc );
SampleTrack();
~SampleTrack() override;

bool play( const TimePos & _start, const fpp_t _frames,
Expand Down
4 changes: 3 additions & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
Count
} ;

Track( Type type, TrackContainer * tc );
Track(Type type);
~Track() override;

static Track * create( Type tt, TrackContainer * tc );
Expand Down Expand Up @@ -159,6 +159,8 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
return m_trackContainer;
}

void setTrackContainer(TrackContainer* trackContainer) { m_trackContainer = trackContainer; }

// name-stuff
virtual const QString & name() const
{
Expand Down
1 change: 1 addition & 0 deletions include/TrackContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class LMMS_EXPORT TrackContainer : public Model, public JournallingObject
m_tracksMutex.lockForWrite();

m_tracks.push_back(track);
track->setTrackContainer(this);
updateAfterTrackAdd(track);

m_tracksMutex.unlock();
Expand Down
2 changes: 1 addition & 1 deletion plugins/HydrogenImport/HydrogenImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool HydrogenImport::readSong()

if ( nLayer == 0 )
{
drum_track[sId] = Engine::patternStore()->addTrack<InstrumentTrack>(Engine::patternStore());
drum_track[sId] = Engine::patternStore()->addTrack<InstrumentTrack>();
drum_track[sId]->volumeModel()->setValue( fVolume * 100 );
drum_track[sId]->panningModel()->setValue( ( fPan_R - fPan_L ) * 100 );
ins = drum_track[sId]->loadInstrument( "audiofileprocessor" );
Expand Down
10 changes: 5 additions & 5 deletions plugins/MidiImport/MidiImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class smfMidiCC
// in the main thread. This should probably be
// removed if that ever changes.
qApp->processEvents();
at = tc->addTrack<AutomationTrack>(tc);
at = tc->addTrack<AutomationTrack>();
}
if( tn != "") {
at->setName( tn );
Expand Down Expand Up @@ -227,7 +227,7 @@ class smfMidiChannel
if( !it ) {
// Keep LMMS responsive
qApp->processEvents();
it = tc->addTrack<InstrumentTrack>(tc);
it = tc->addTrack<InstrumentTrack>();

#ifdef LMMS_HAVE_FLUIDSYNTH
it_inst = it->loadInstrument( "sf2player" );
Expand Down Expand Up @@ -331,10 +331,10 @@ bool MidiImport::readSMF( TrackContainer* tc )
// NOTE: unordered_map::operator[] creates a new element if none exists

MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel();
auto nt = Engine::getSong()->addTrack<AutomationTrack>(Engine::getSong());
auto nt = Engine::getSong()->addTrack<AutomationTrack>();

nt->setName(tr("MIDI Time Signature Numerator"));
auto dt = Engine::getSong()->addTrack<AutomationTrack>(Engine::getSong());
auto dt = Engine::getSong()->addTrack<AutomationTrack>();

dt->setName(tr("MIDI Time Signature Denominator"));
auto timeSigNumeratorPat = static_cast<AutomationClip*>(nt->createClip());
Expand Down Expand Up @@ -363,7 +363,7 @@ bool MidiImport::readSMF( TrackContainer* tc )
pd.setValue( 2 );

// Tempo stuff
auto tt = Engine::getSong()->addTrack<AutomationTrack>(Engine::getSong());
auto tt = Engine::getSong()->addTrack<AutomationTrack>();
tt->setName(tr("Tempo"));
auto tap = static_cast<AutomationClip*>(tt->createClip());
tap->setDisplayName(tr("Tempo"));
Expand Down
2 changes: 1 addition & 1 deletion src/core/PresetPreviewPlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PreviewTrackContainer : public TrackContainer
m_dataMutex()
{
setJournalling( false );
m_previewInstrumentTrack = addTrack<InstrumentTrack>(this);
m_previewInstrumentTrack = addTrack<InstrumentTrack>();
m_previewInstrumentTrack->setJournalling( false );
m_previewInstrumentTrack->setPreviewMode( true );
}
Expand Down
20 changes: 11 additions & 9 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tick_t TimePos::s_ticksPerBar = DefaultTicksPerBar;

Song::Song() :
TrackContainer(),
m_globalAutomationTrack(new AutomationTrack(this, true)),
m_globalAutomationTrack(new AutomationTrack(true)),
m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this, tr( "Tempo" ) ),
m_timeSigModel( this ),
m_oldTicksPerBar( DefaultTicksPerBar ),
Expand Down Expand Up @@ -98,6 +98,8 @@ Song::Song() :
m_loopRenderRemaining(1),
m_oldAutomatedValues()
{
m_globalAutomationTrack->setTrackContainer(this);

for (double& millisecondsElapsed : m_elapsedMilliSeconds) { millisecondsElapsed = 0; }
connect( &m_tempoModel, SIGNAL(dataChanged()),
this, SLOT(setTempo()), Qt::DirectConnection );
Expand Down Expand Up @@ -806,7 +808,7 @@ void Song::removeBar()

void Song::addPatternTrack()
{
const auto patternTrack = addTrack<PatternTrack>(this);
const auto patternTrack = addTrack<PatternTrack>();
Engine::patternStore()->setCurrentPattern(static_cast<PatternTrack*>(patternTrack)->patternIndex());
}

Expand All @@ -815,15 +817,15 @@ void Song::addPatternTrack()

void Song::addSampleTrack()
{
addTrack<SampleTrack>(this);
addTrack<SampleTrack>();
}




void Song::addAutomationTrack()
{
addTrack<AutomationTrack>(this);
addTrack<AutomationTrack>();
}


Expand Down Expand Up @@ -956,15 +958,15 @@ void Song::createNewProject()
m_oldFileName = "";
setProjectFileName("");

auto tripleOscTrack = addTrack<InstrumentTrack>(this);
auto tripleOscTrack = addTrack<InstrumentTrack>();
static_cast<InstrumentTrack*>(tripleOscTrack)->loadInstrument("tripleoscillator");

auto kickerTrack = Engine::patternStore()->addTrack<InstrumentTrack>(Engine::patternStore());
auto kickerTrack = Engine::patternStore()->addTrack<InstrumentTrack>();
static_cast<InstrumentTrack*>(kickerTrack)->loadInstrument("kicker");

addTrack<SampleTrack>(this);
addTrack<PatternTrack>(this);
addTrack<AutomationTrack>(this);
addTrack<SampleTrack>();
addTrack<PatternTrack>();
addTrack<AutomationTrack>();

m_tempoModel.setInitValue( DefaultTempo );
m_timeSigModel.reset();
Expand Down
6 changes: 3 additions & 3 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace lmms
*
* \todo check the definitions of all the properties - are they OK?
*/
Track::Track( Type type, TrackContainer * tc ) :
Model( tc ), /*!< The track Model */
m_trackContainer( tc ), /*!< The track container object */
Track::Track(Type type) :
Model(nullptr), /*!< The track Model */
m_trackContainer(), /*!< The track container object */
m_type( type ), /*!< The track type */
m_name(), /*!< The track's name */
m_mutedModel( false, this, tr( "Mute" ) ), /*!< For controlling track muting */
Expand Down
8 changes: 4 additions & 4 deletions src/core/TrackContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,18 @@ Track* TrackContainer::addTrack(const QDomElement& element)
switch (trackType)
{
case Track::Type::Instrument:
track = addTrack<InstrumentTrack>(this);
track = addTrack<InstrumentTrack>();
break;
case Track::Type::Pattern:
track = addTrack<PatternTrack>(this);
track = addTrack<PatternTrack>();
break;
case Track::Type::Sample:
track = addTrack<SampleTrack>(this);
track = addTrack<SampleTrack>();
break;
case Track::Type::HiddenAutomation:
[[fallthrough]];
case Track::Type::Automation:
track = addTrack<AutomationTrack>(this);
track = addTrack<AutomationTrack>();
break;
default:
std::cerr << "TrackContainer::addTrack - unimplemented type\n";
Expand Down
6 changes: 3 additions & 3 deletions src/gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item,
}
else if( f->handling() != FileItem::FileHandling::NotSupported )
{
auto it = Engine::patternStore()->addTrack<InstrumentTrack>(Engine::patternStore());
auto it = Engine::patternStore()->addTrack<InstrumentTrack>();
handleFile( f, it );
}
}
Expand All @@ -953,7 +953,7 @@ void FileBrowserTreeWidget::openInNewInstrumentTrack(TrackContainer* tc, FileIte
{
if(item->isTrack())
{
auto it = tc->addTrack<InstrumentTrack>(tc);
auto it = tc->addTrack<InstrumentTrack>();
handleFile(item, it);
}
}
Expand All @@ -978,7 +978,7 @@ bool FileBrowserTreeWidget::openInNewSampleTrack(FileItem* item)
if (item->type() != FileItem::FileType::Sample) { return false; }

// Create a new sample track for this sample
auto sampleTrack = Engine::getSong()->addTrack<SampleTrack>(Engine::getSong());
auto sampleTrack = Engine::getSong()->addTrack<SampleTrack>();

// Add the sample clip to the track
Engine::audioEngine()->requestChangeInModel();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/PluginBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void PluginDescWidget::contextMenuEvent(QContextMenuEvent* e)
void PluginDescWidget::openInNewInstrumentTrack(QString value)
{
TrackContainer* tc = Engine::getSong();
auto it = tc->addTrack<InstrumentTrack>(tc);
auto it = tc->addTrack<InstrumentTrack>();
auto ilt = new InstrumentLoaderThread(this, it, value);
ilt->start();
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editors/PatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ void PatternEditor::removeSteps()

void PatternEditor::addSampleTrack()
{
model()->addTrack<SampleTrack>(model());
model()->addTrack<SampleTrack>();
}




void PatternEditor::addAutomationTrack()
{
model()->addTrack<AutomationTrack>(model());
model()->addTrack<AutomationTrack>();
}


Expand Down
6 changes: 3 additions & 3 deletions src/gui/editors/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
QString value = StringPairDrag::decodeValue( _de );
if( type == "instrument" )
{
auto it = m_tc->addTrack<InstrumentTrack>(m_tc);
auto it = m_tc->addTrack<InstrumentTrack>();
auto ilt = new InstrumentLoaderThread(this, it, value);
ilt->start();
//it->toggledInstrumentTrackButton( true );
Expand All @@ -405,7 +405,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
|| type == "soundfontfile" || type == "vstpluginfile"
|| type == "patchfile" )
{
auto it = m_tc->addTrack<InstrumentTrack>(m_tc);
auto it = m_tc->addTrack<InstrumentTrack>();
PluginFactory::PluginInfoAndKey piakn =
getPluginFactory()->pluginSupportingExtension(FileItem::extension(value));
Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key);
Expand All @@ -416,7 +416,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
else if( type == "presetfile" )
{
DataFile dataFile( value );
auto it = m_tc->addTrack<InstrumentTrack>(m_tc);
auto it = m_tc->addTrack<InstrumentTrack>();
it->loadPreset(dataFile.content().toElement());

//it->toggledInstrumentTrackButton( true );
Expand Down
5 changes: 2 additions & 3 deletions src/tracks/AutomationTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
namespace lmms
{


AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) :
Track( _hidden ? Type::HiddenAutomation : Type::Automation, tc )
AutomationTrack::AutomationTrack(bool hidden)
: Track(hidden ? Type::HiddenAutomation : Type::Automation)
{
setName( tr( "Automation track" ) );
}
Expand Down
4 changes: 2 additions & 2 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ namespace lmms
{


InstrumentTrack::InstrumentTrack( TrackContainer* tc ) :
Track( Track::Type::Instrument, tc ),
InstrumentTrack::InstrumentTrack() :
Track(Track::Type::Instrument),
MidiEventProcessor(),
m_midiPort( tr( "unnamed_track" ), Engine::audioEngine()->midiClient(),
this, this ),
Expand Down
4 changes: 2 additions & 2 deletions src/tracks/PatternTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace lmms
PatternTrack::infoMap PatternTrack::s_infoMap;


PatternTrack::PatternTrack(TrackContainer* tc) :
Track(Track::Type::Pattern, tc)
PatternTrack::PatternTrack() :
Track(Track::Type::Pattern)
{
int patternNum = s_infoMap.size();
s_infoMap[this] = patternNum;
Expand Down
4 changes: 2 additions & 2 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace lmms
{


SampleTrack::SampleTrack(TrackContainer* tc) :
Track(Track::Type::Sample, tc),
SampleTrack::SampleTrack() :
Track(Track::Type::Sample),
m_volumeModel(DefaultVolume, MinVolume, MaxVolume, 0.1f, this, tr("Volume")),
m_panningModel(DefaultPanning, PanningLeft, PanningRight, 0.1f, this, tr("Panning")),
m_mixerChannelModel(0, 0, 0, this, tr("Mixer channel")),
Expand Down
Loading

0 comments on commit f20d308

Please sign in to comment.