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

Automatic adding and linking of mixer strips to tracks #6407

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
239d917
Automatic FX-mixer strip management #1215
spechtstatt May 15, 2022
2fb21b7
mend
spechtstatt May 20, 2022
c2bdf8a
made buildable
spechtstatt May 20, 2022
1e27fff
solve check issues
spechtstatt May 20, 2022
c6b2944
solve check issues
spechtstatt May 20, 2022
90f26ce
refactoring naming, removed unused methods, some optimization
spechtstatt May 21, 2022
2ba4982
Automatic mixer strip management #1215 - fix some issues with track n…
spechtstatt May 24, 2022
d1c5c29
Automatic mixer strip management #1215 - applied review recommendations
spechtstatt May 24, 2022
38cf295
Automatic mixer strip management #1215 - bugfix for 'frozen' mixer li…
spechtstatt May 24, 2022
5572288
Automatic mixer strip management #1215 - bugfix for broken mixer move
spechtstatt May 24, 2022
f7ed9be
make text/color changes work also from the mixer line side
spechtstatt Jun 2, 2022
fc785fd
button for enabling/disabling the functionality in the mixer
spechtstatt Jun 3, 2022
a7d0f68
Provide two-way linking, Prepared additional settings
spechtstatt Jun 10, 2022
76b0f50
Improved settings menu and added icons
spechtstatt Jun 11, 2022
dd139bf
Refactored setttings - set inactive alpha
spechtstatt Jun 11, 2022
e2c49ca
fixed settings menu - lambda capture for settings behaves strange
spechtstatt Jun 12, 2022
f8cec55
refactored settings menu - reduced redundancy
spechtstatt Jun 12, 2022
98b48ff
check also for channel send before deletion
spechtstatt Jun 12, 2022
c2c2acd
auto link text style update is now working correctly (was no SLOT)
spechtstatt Jun 13, 2022
14044ed
made buildable
spechtstatt Jun 23, 2022
8db4113
enable auto track linking when assigning new channel to track
spechtstatt Jul 10, 2022
b6e6e7a
update mixer line style after auto link is disabled
spechtstatt Jul 10, 2022
5e4d20a
made buildable
spechtstatt Jul 16, 2022
e2e7f8b
update mixerline style after autotrack link global enable/disable
spechtstatt Jul 16, 2022
477a433
auto sorting seems to work now but more testing needed
spechtstatt Jul 17, 2022
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
Binary file added data/themes/default/auto_link_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/auto_link_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 154 additions & 0 deletions include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#ifndef MIXER_H
#define MIXER_H

#include "ConfigManager.h"
#include "Model.h"
#include "Track.h"
#include "EffectChain.h"
#include "JournallingObject.h"
#include "ThreadableJob.h"
Expand Down Expand Up @@ -66,6 +68,7 @@ class MixerChannel : public ThreadableJob
int m_channelIndex; // what channel index are we
bool m_queued; // are we queued up for rendering yet?
bool m_muted; // are we muted? updated per period so we don't have to call m_muteModel.value() twice
BoolModel m_autoTrackLinkModel;

// pointers to other channels that this one sends to
MixerRouteVector m_sends;
Expand Down Expand Up @@ -142,6 +145,131 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject
{
Q_OBJECT
public:
struct autoTrackLinkSettings
{
// Remark: take care of the enum order as it is used for range checking during reading the values from config
enum class LinkStyle
{
Disabled, /* don't link any styles */
LinkNameAndColor, /* link namd and color */
LinkColorOnly, /* link only color */
};

enum class AutoAdd
{
Disabled, /* do not link tracks after add */
CreateNew, /* one channel for each track after add*/
UseFirstTrackOnly, /* use always the first channel in the editor for new tracks*/
};

enum class LinkMode
{
OneToOne, /* do not link song editor tracks */
OneToMany, /* one channel for each song editor track */
};

enum class AutoSort
{
Disabled, /* automatic sorting is disabled */
LinkedPattern, /* linked tracks first, pattern editor afterwards */
PatternLinked /* pattern editor first, linked tracks afterwards */
};

struct editorSettings
{
LinkStyle linkStyle;
AutoAdd autoAdd;

editorSettings()
{
linkStyle = LinkStyle::LinkNameAndColor;
autoAdd = AutoAdd::CreateNew;
}
};

bool enabled;
bool autoDelete;
LinkMode linkMode;
AutoSort autoSort;
editorSettings songEditor;
editorSettings patternEditor;

bool getAsBoolOrDefault(const QString & text, bool defaultValue)
{
return (bool)getIntInRangeOrDefault(text, 0,1,defaultValue);
}


AutoAdd getAsAutoAddOrDefault(const QString & text, AutoAdd defaultValue)
{
return (AutoAdd) getIntInRangeOrDefault(text,(int)AutoAdd::Disabled, (int)AutoAdd::UseFirstTrackOnly,(int)defaultValue);
}

LinkStyle getAsLinkStyleOrDefault(const QString & text, LinkStyle defaultValue)
{
return (LinkStyle) getIntInRangeOrDefault(text,(int)LinkStyle::Disabled, (int)LinkStyle::LinkColorOnly,(int)defaultValue);
}

AutoSort getAsAutoSortOrDefault(const QString & text, AutoSort defaultValue)
{
return (AutoSort) getIntInRangeOrDefault(text,(int)AutoSort::Disabled, (int)AutoSort::PatternLinked,(int)defaultValue);
}


LinkMode getAsLinkModeOrDefault(const QString & text, LinkMode defaultValue)
{
return (LinkMode) getIntInRangeOrDefault(text,(int)LinkMode::OneToOne, (int)LinkMode::OneToMany,(int)defaultValue);
}

bool autoAdd()
{
return songEditor.autoAdd != AutoAdd::Disabled || patternEditor.autoAdd != AutoAdd::Disabled;
}


bool linkName(bool isPatternEditor)
{
return isPatternEditor ?
patternEditor.linkStyle == LinkStyle::LinkNameAndColor :
songEditor.linkStyle == LinkStyle::LinkNameAndColor;
}

bool linkColor(bool isPatternEditor)
{
return isPatternEditor ?
(patternEditor.linkStyle == LinkStyle::LinkNameAndColor) || (patternEditor.linkStyle == LinkStyle::LinkColorOnly) :
(songEditor.linkStyle == LinkStyle::LinkNameAndColor) || (songEditor.linkStyle == LinkStyle::LinkColorOnly);
}

bool linkAnyStyles()
{
return patternEditor.linkStyle != LinkStyle::Disabled || songEditor.linkStyle != LinkStyle::Disabled;
}

autoTrackLinkSettings()
{
enabled = false;
autoDelete = true;
linkMode = LinkMode::OneToOne;
autoSort = AutoSort::Disabled;
}

private:
int getIntInRangeOrDefault(const QString & text, int lower, int upper, int defaultValue)
{
if (text == nullptr || text.isEmpty()) return defaultValue;
auto asInt = text.toInt();
if (asInt < lower || asInt >upper) return defaultValue;
return asInt;
}
};

enum class ProcessSortOrder
{
SongPattern,
PatternSong
};

Mixer();
~Mixer() override;

Expand Down Expand Up @@ -195,6 +323,22 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject
// re-arrange channels
void moveChannelLeft(int index);
void moveChannelRight(int index);
void swapChannels(int indexA, int indexB);

void toggleAutoTrackLink(int index);

// process tracks which have a mixer channel assigned
void processAssignedTracks(std::function<void(Track * track, IntModel * model, MixerChannel * channel)> process, ProcessSortOrder sortOrder = ProcessSortOrder::SongPattern);
// process tracks assigned to a specific channel
void processChannelTracks(MixerChannel * channel, std::function<void(Track * track)> process);
IntModel * getChannelModelByTrack(Track * track);
MixerChannel * getCustomChannelByTrack(Track * track);
std::vector<int> getUsedChannelCounts();
bool isAutoTrackLinkToggleAllowed(int index);
//bool autoLinkTrackConfigEnabled();

autoTrackLinkSettings getAutoLinkTrackSettings();
void saveAutoLinkTrackSettings(autoTrackLinkSettings settings);

// reset a channel's name, fx, sends, etc
void clearChannel(mix_ch_t channelIndex);
Expand All @@ -214,6 +358,16 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject
MixerRouteVector m_mixerRoutes;

private:
inline const QString & getAutoTrackCfg(ConfigManager * cfg, const QString & postFix)
{
return cfg->value("AutoTrackLink", "settings_"+postFix);
}

inline void setAutoTrackCfg(ConfigManager * cfg, const QString & postFix, int value)
{
cfg->setValue("AutoTrackLink", "settings_"+postFix, QString::number(value));
}

// the mixer channels in the mixer. index 0 is always master.
QVector<MixerChannel *> m_mixerChannels;

Expand Down
4 changes: 4 additions & 0 deletions include/MixerLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ class MixerLine : public QWidget

bool eventFilter (QObject *dist, QEvent *event) override;


private:
void drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isActive, bool sendToThis, bool receiveFromThis );
QString elideName( const QString & name );

MixerView * m_mv;
LcdWidget* m_lcd;
int m_channelIndex;
QPalette m_renameEditPalette;
QBrush m_backgroundActive;
QColor m_strokeOuterActive;
QColor m_strokeOuterInactive;
Expand All @@ -105,13 +107,15 @@ public slots:
void resetColor();
void selectColor();
void randomizeColor();
void refreshAutoTrackLinkStyle();

private slots:
void renameFinished();
void removeChannel();
void removeUnusedChannels();
void moveChannelLeft();
void moveChannelRight();
void toogleAutoTrackLink();
};


Expand Down
31 changes: 29 additions & 2 deletions include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@
#ifndef MIXER_VIEW_H
#define MIXER_VIEW_H

#include <QMenu>
#include <QWidget>
#include <QHBoxLayout>
#include <QStackedLayout>
#include <QScrollArea>

#include "ModelView.h"
#include "Mixer.h"
#include "Engine.h"
#include "Fader.h"
#include "PixmapButton.h"
#include "embed.h"
#include "EffectRackView.h"
#include "Track.h"

class QButtonGroup;

Expand Down Expand Up @@ -101,7 +104,6 @@ class LMMS_EXPORT MixerView : public QWidget, public ModelView,

// move the channel to the left or right
void moveChannelLeft(int index);
void moveChannelLeft(int index, int focusIndex);
void moveChannelRight(int index);

void renameChannel(int index);
Expand All @@ -110,6 +112,16 @@ class LMMS_EXPORT MixerView : public QWidget, public ModelView,
// useful for loading projects
void refreshDisplay();

// Auto track link support
void updateAfterTrackAdd(Track * track, QString name = "");
void updateAfterTrackStyleModify(Track * track);
void trackMixerLineCreate(Track * track);
void trackMixerLineAssign(Track * track, int channelIndex);
void updateAfterTrackMove(Track * track);
void updateBeforeTrackDelete(Track * track);
void toggleAutoTrackLink(int index);


public slots:
int addNewChannel();

Expand All @@ -119,6 +131,8 @@ public slots:
private slots:
void updateFaders();
void toggledSolo();
void updateAutoTrackLinkMenu();
void toogleAutoLinkTrackConfig();

private:
QVector<MixerChannelView *> m_mixerChannelViews;
Expand All @@ -130,9 +144,22 @@ private slots:
QWidget * m_channelAreaWidget;
QStackedLayout * m_racksLayout;
QWidget * m_racksWidget;
QPushButton * m_toogleAutoLinkTrackConfigBtn;
QPushButton * m_autoLinkTrackSettingsBtn;

void updateMaxChannelSelector();

void swapChannels(int indexA, int indexB);
void updateAutoTrackSortOrder(bool autoSort = true);
void deleteChannelInternal(int index);
void setAutoLinkTrackConfig(bool enabled);
void updateAutoLinkTrackConfigBtn(bool enabled);
void setAutoTrackConstraints();
void trackStyleToChannel(Track * track, MixerChannel * channel);
void channelStyleToTrack(MixerChannel * channel, Track * track);
void addAutoLinkTrackMenuEntry(QMenu* menu, const QString &text, bool state,
std::function<void(Mixer::autoTrackLinkSettings* settings)> setValue,
std::function<void()> after = nullptr);

friend class MixerChannelView;
} ;

Expand Down
Loading