Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FX Mixer for sample tracks and add controls to sample track window #3866

Merged
merged 3 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions include/FxLineLcdSpinBox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* FxLineLcdSpinBox.h - a specialization of LcdSpnBox for setting FX channels
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef FX_LINE_LCD_SPIN_BOX_H
#define FX_LINE_LCD_SPIN_BOX_H

#include "LcdSpinBox.h"

class TrackView;


class FxLineLcdSpinBox : public LcdSpinBox
{
Q_OBJECT
public:
FxLineLcdSpinBox(int numDigits, QWidget * parent, const QString& name, TrackView * tv = NULL) :
LcdSpinBox(numDigits, parent, name), m_tv(tv)
{}
virtual ~FxLineLcdSpinBox() {}

void setTrackView(TrackView * tv);

protected:
virtual void mouseDoubleClickEvent(QMouseEvent* event);
virtual void contextMenuEvent(QContextMenuEvent* event);

private:
TrackView * m_tv;

};

#endif
3 changes: 2 additions & 1 deletion include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class InstrumentTrackWindow;
class InstrumentMidiIOView;
class InstrumentMiscView;
class Knob;
class FxLineLcdSpinBox;
class LcdSpinBox;
class LeftRightNav;
class midiPortMenu;
Expand Down Expand Up @@ -440,7 +441,7 @@ protected slots:
QLabel * m_pitchLabel;
LcdSpinBox* m_pitchRangeSpinBox;
QLabel * m_pitchRangeLabel;
LcdSpinBox * m_effectChannelNumber;
FxLineLcdSpinBox * m_effectChannelNumber;



Expand Down
101 changes: 99 additions & 2 deletions include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@
#define SAMPLE_TRACK_H

#include <QDialog>
#include <QLayout>

#include "AudioPort.h"
#include "FxMixer.h"
#include "FxLineLcdSpinBox.h"
#include "Track.h"

class EffectRackView;
class Knob;
class SampleBuffer;
class SampleTrackWindow;
class TrackLabelButton;
class QLineEdit;


class SampleTCO : public TrackContentObject
Expand Down Expand Up @@ -140,6 +146,11 @@ class SampleTrack : public Track
QDomElement & _parent );
virtual void loadTrackSpecificSettings( const QDomElement & _this );

inline IntModel * effectChannelModel()
{
return &m_effectChannelModel;
}

inline AudioPort * audioPort()
{
return &m_audioPort;
Expand All @@ -153,15 +164,18 @@ class SampleTrack : public Track
public slots:
void updateTcos();
void setPlayingTcos( bool isPlaying );
void updateEffectChannel();

private:
FloatModel m_volumeModel;
FloatModel m_panningModel;
IntModel m_effectChannelModel;
AudioPort m_audioPort;



friend class SampleTrackView;
friend class SampleTrackWindow;

} ;

Expand All @@ -174,6 +188,24 @@ class SampleTrackView : public TrackView
SampleTrackView( SampleTrack* Track, TrackContainerView* tcv );
virtual ~SampleTrackView();

SampleTrackWindow * getSampleTrackWindow()
{
return m_window;
}

SampleTrack * model()
{
return castModel<SampleTrack>();
}

const SampleTrack * model() const
{
return castModel<SampleTrack>();
}


virtual QMenu * createFxMenu( QString title, QString newFxLabel );


public slots:
void showEffects();
Expand All @@ -187,12 +219,77 @@ public slots:
}


private slots:
void assignFxLine( int channelIndex );
void createFxLine();


private:
EffectRackView * m_effectRack;
QWidget * m_effWindow;
SampleTrackWindow * m_window;
Knob * m_volumeKnob;
Knob * m_panningKnob;

TrackLabelButton * m_tlb;


friend class SampleTrackWindow;

} ;



class SampleTrackWindow : public QWidget, public ModelView, public SerializingObjectHook
{
Q_OBJECT
public:
SampleTrackWindow(SampleTrackView * tv);
virtual ~SampleTrackWindow();

SampleTrack * model()
{
return castModel<SampleTrack>();
}

const SampleTrack * model() const
{
return castModel<SampleTrack>();
}

void setSampleTrackView(SampleTrackView * tv);

SampleTrackView *sampleTrackView()
{
return m_stv;
}


public slots:
void textChanged(const QString & new_name);
void toggleVisibility(bool on);
void updateName();


protected:
// capture close-events for toggling sample-track-button
virtual void closeEvent(QCloseEvent * ce);

virtual void saveSettings(QDomDocument & doc, QDomElement & element);
virtual void loadSettings(const QDomElement & element);

private:
virtual void modelChanged();

SampleTrack * m_track;
SampleTrackView * m_stv;

// widgets on the top of an sample-track-window
QLineEdit * m_nameLineEdit;
Knob * m_volumeKnob;
Knob * m_panningKnob;
FxLineLcdSpinBox * m_effectChannelNumber;

EffectRackView * m_effectRack;

} ;


Expand Down
4 changes: 4 additions & 0 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@ class TrackView : public QWidget, public ModelView, public JournallingObject

virtual void update();

// Create a menu for assigning/creating channels for this track
// Currently instrument track and sample track supports it
virtual QMenu * createFxMenu(QString title, QString newFxLabel);


public slots:
virtual bool close();
Expand Down
31 changes: 30 additions & 1 deletion src/core/FxMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Song.h"

#include "InstrumentTrack.h"
#include "SampleTrack.h"
#include "BBTrackContainer.h"

FxRoute::FxRoute( FxChannel * from, FxChannel * to, float amount ) :
Expand Down Expand Up @@ -305,6 +306,22 @@ void FxMixer::deleteChannel( int index )
inst->effectChannelModel()->setValue(val-1);
}
}
else if( t->type() == Track::SampleTrack )
{
SampleTrack* strk = dynamic_cast<SampleTrack *>( t );
int val = strk->effectChannelModel()->value(0);
if( val == index )
{
// we are deleting this track's fx send
// send to master
strk->effectChannelModel()->setValue(0);
}
else if( val > index )
{
// subtract 1 to make up for the missing channel
strk->effectChannelModel()->setValue(val-1);
}
}
}

FxChannel * ch = m_fxChannels[index];
Expand Down Expand Up @@ -379,6 +396,19 @@ void FxMixer::moveChannelLeft( int index )
inst->effectChannelModel()->setValue(a);
}
}
else if( trackList[i]->type() == Track::SampleTrack )
{
SampleTrack * strk = (SampleTrack *) trackList[i];
int val = strk->effectChannelModel()->value(0);
if( val == a )
{
strk->effectChannelModel()->setValue(b);
}
else if( val == b )
{
strk->effectChannelModel()->setValue(a);
}
}
}
}

Expand Down Expand Up @@ -780,4 +810,3 @@ void FxMixer::validateChannelName( int index, int oldIndex )
m_fxChannels[index]->m_name = tr( "FX %1" ).arg( index );
}
}

21 changes: 18 additions & 3 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1921,13 +1921,15 @@ void TrackOperationsWidget::updateMenu()
{
toMenu->addAction( tr( "Clear this track" ), this, SLOT( clearTrack() ) );
}
if( InstrumentTrackView * trackView = dynamic_cast<InstrumentTrackView *>( m_trackView ) )
if (QMenu *fxMenu = m_trackView->createFxMenu(tr("FX %1: %2"), tr("Assign to new FX Channel")))
{
QMenu *fxMenu = trackView->createFxMenu( tr( "FX %1: %2" ), tr( "Assign to new FX Channel" ));
toMenu->addMenu(fxMenu);
}

if (InstrumentTrackView * trackView = dynamic_cast<InstrumentTrackView *>(m_trackView))
{
toMenu->addSeparator();
toMenu->addMenu( trackView->midiMenu() );
toMenu->addMenu(trackView->midiMenu());
}
if( dynamic_cast<AutomationTrackView *>( m_trackView ) )
{
Expand Down Expand Up @@ -2672,6 +2674,19 @@ void TrackView::update()



/*! \brief Create a menu for assigning/creating channels for this track.
*
*/
QMenu * TrackView::createFxMenu(QString title, QString newFxLabel)
{
Q_UNUSED(title)
Q_UNUSED(newFxLabel)
return NULL;
}




/*! \brief Close this track View.
*
*/
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ SET(LMMS_SRCS
gui/widgets/FadeButton.cpp
gui/widgets/Fader.cpp
gui/widgets/FxLine.cpp
gui/widgets/FxLineLcdSpinBox.cpp
gui/widgets/Graph.cpp
gui/widgets/GroupBox.cpp
gui/widgets/InstrumentFunctionViews.cpp
Expand Down
Loading