Skip to content

Commit

Permalink
Merge pull request #7 from LMMS/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
LostRobotMusic authored May 31, 2019
2 parents 271e20d + 46c74d0 commit d683a51
Show file tree
Hide file tree
Showing 49 changed files with 712 additions and 149 deletions.
1 change: 1 addition & 0 deletions .travis/debian_pkgs.sha256
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
314ef4af137903dfb13e8c3ef1e6ea56cfdb23808d52ec4f5f50e288c73610c5 pbuilder_0.229.1_all.deb
fa82aa8ed3055c6f6330104deedf080b26778295e589426d4c4dd0f2c2a5defa debootstrap_1.0.95_all.deb
2ef4c09f7841b72f93412803ddd142f72658536dbfabe00e449eb548f432f3f8 debian-archive-keyring_2017.7ubuntu1_all.deb
5 changes: 3 additions & 2 deletions .travis/linux.debian-sid.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
set -e

sudo apt-get install -y \
debian-archive-keyring \
dpkg \
pbuilder

# work around a pbuilder bug which breaks ccache
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666525
# and also missing signing keys in Trusty's debian-archive-keyring
cd /tmp
wget http://archive.ubuntu.com/ubuntu/pool/main/p/pbuilder/pbuilder_0.229.1_all.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.95_all.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/debian-archive-keyring/debian-archive-keyring_2017.7ubuntu1_all.deb
sha256sum -c "$TRAVIS_BUILD_DIR/.travis/debian_pkgs.sha256"
sudo dpkg -i pbuilder_0.229.1_all.deb debootstrap_1.0.95_all.deb
sudo dpkg -i pbuilder_0.229.1_all.deb debootstrap_1.0.95_all.deb debian-archive-keyring_2017.7ubuntu1_all.deb
cd "$OLDPWD"
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ SET(QT_LIBRARIES
Qt5::Xml
)

IF(LMMS_BUILD_LINUX)
IF(LMMS_BUILD_LINUX AND WANT_VST)
FIND_PACKAGE(Qt5 COMPONENTS X11Extras REQUIRED)
LIST(APPEND QT_LIBRARIES Qt5::X11Extras)
ENDIF()
Expand Down
4 changes: 3 additions & 1 deletion cmake/linux/package_linux.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ else
success "Downloaded $LINUXDEPLOYQT"
# Extract AppImage and replace LINUXDEPLOYQT variable with extracted binary
# to support systems without fuse
# Also, we need to set LD_LIBRARY_PATH, but linuxdepoyqt's AppRun unsets it
# See https://github.com/probonopd/linuxdeployqt/pull/370/
"$LINUXDEPLOYQT" --appimage-extract > /dev/null 2>&1
LINUXDEPLOYQT="squashfs-root/AppRun"
LINUXDEPLOYQT="squashfs-root/usr/bin/linuxdeployqt"
success "Extracted $APPIMAGETOOL"
fi

Expand Down
2 changes: 1 addition & 1 deletion doc/wiki
Submodule wiki updated from 42193f to 19179c
55 changes: 55 additions & 0 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "MidiTime.h"
#include "ValueBuffer.h"
#include "MemoryManager.h"
#include "ModelVisitor.h"

// simple way to map a property of a view to a model
#define mapPropertyFromModelPtr(type,getfunc,setfunc,modelname) \
Expand All @@ -59,6 +60,11 @@
modelname.setValue( (float) val ); \
}

// use this to make subclasses visitable
#define MODEL_IS_VISITABLE \
void accept(ModelVisitor& v) override { v.visit(*this); } \
void accept(ConstModelVisitor& v) const override { v.visit(*this); }



class ControllerConnection;
Expand All @@ -68,6 +74,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
Q_OBJECT
MM_OPERATORS
public:

typedef QVector<AutomatableModel *> AutoModelVector;

enum ScaleType
Expand All @@ -80,6 +87,35 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject

virtual ~AutomatableModel();

// Implement those by using the MODEL_IS_VISITABLE macro
virtual void accept(ModelVisitor& v) = 0;
virtual void accept(ConstModelVisitor& v) const = 0;

public:
/**
@brief Return this class casted to Target
@test AutomatableModelTest.cpp
@param doThrow throw an assertion if the cast fails, instead of
returning a nullptr
@return the casted class if Target is the exact or a base class of
*this, nullptr otherwise
*/
template<class Target>
Target* dynamicCast(bool doThrow = false)
{
DCastVisitor<Target> vis; accept(vis);
if (doThrow && !vis.result) { Q_ASSERT(false); }
return vis.result;
}

//! const overload, see overloaded function
template<class Target>
const Target* dynamicCast(bool doThrow = false) const
{
ConstDCastVisitor<Target> vis; accept(vis);
if (doThrow && !vis.result) { Q_ASSERT(false); }
return vis.result;
}

bool isAutomated() const;
bool isAutomatedOrControlled() const
Expand Down Expand Up @@ -283,6 +319,22 @@ public slots:


private:
// dynamicCast implementation
template<class Target>
struct DCastVisitor : public ModelVisitor
{
Target* result = nullptr;
void visit(Target& tar) { result = &tar; }
};

// dynamicCast implementation
template<class Target>
struct ConstDCastVisitor : public ConstModelVisitor
{
const Target* result = nullptr;
void visit(const Target& tar) { result = &tar; }
};

static bool mustQuoteName(const QString &name);

virtual void saveSettings( QDomDocument& doc, QDomElement& element )
Expand Down Expand Up @@ -382,6 +434,7 @@ template <typename T> class LMMS_EXPORT TypedAutomatableModel : public Automatab
class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
FloatModel( float val = 0, float min = 0, float max = 0, float step = 0,
Model * parent = NULL,
Expand All @@ -399,6 +452,7 @@ class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
IntModel( int val = 0, int min = 0, int max = 0,
Model* parent = NULL,
Expand All @@ -414,6 +468,7 @@ class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
class LMMS_EXPORT BoolModel : public TypedAutomatableModel<bool>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
BoolModel( const bool val = false,
Model* parent = NULL,
Expand Down
1 change: 1 addition & 0 deletions include/ComboBoxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
class LMMS_EXPORT ComboBoxModel : public IntModel
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
ComboBoxModel( Model* parent = NULL,
const QString& displayName = QString(),
Expand Down
7 changes: 7 additions & 0 deletions include/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ class LMMS_EXPORT Effect : public Plugin


protected:
/**
Effects should call this at the end of audio processing
If the setting "Keep effects running even without input" is disabled,
after "decay" ms of a signal below "gate", the effect is turned off
and won't be processed again until it receives new audio input
*/
void checkGate( double _out_sum );

virtual PluginView * instantiateView( QWidget * );
Expand Down
6 changes: 5 additions & 1 deletion include/FileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FileBrowser : public SideBarWidget

private slots:
void reloadTree( void );
void expandItems( QTreeWidgetItem * item=NULL );
void expandItems( QTreeWidgetItem * item=NULL, QList<QString> expandedDirs = QList<QString>() );
// call with item=NULL to filter the entire tree
bool filterItems( const QString & filter, QTreeWidgetItem * item=NULL );
void giveFocusToFilter();
Expand Down Expand Up @@ -87,6 +87,10 @@ class FileBrowserTreeWidget : public QTreeWidget
FileBrowserTreeWidget( QWidget * parent );
virtual ~FileBrowserTreeWidget() = default;

//! This method returns a QList with paths (QString's) of all directories
//! that are expanded in the tree.
QList<QString> expandedDirs( QTreeWidgetItem * item = nullptr ) const;


protected:
virtual void contextMenuEvent( QContextMenuEvent * e );
Expand Down
38 changes: 32 additions & 6 deletions include/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ class LMMS_EXPORT Graph : public QWidget, public ModelView
public:
enum graphStyle
{
NearestStyle,
LinearStyle,
LinearNonCyclicStyle,
BarStyle,
NearestStyle, //!< draw as stairs
LinearStyle, //!< connect each 2 samples with a line, with wrapping
LinearNonCyclicStyle, //!< LinearStyle without wrapping
BarStyle, //!< draw thick bars
NumGraphStyles
};

/**
* @brief Constructor
* @param _width Pixel width of widget
* @param _height Pixel height of widget
*/
Graph( QWidget * _parent, graphStyle _style = Graph::LinearStyle,
int _width = 132,
int _height = 104
Expand Down Expand Up @@ -111,10 +116,24 @@ protected slots:
} ;


/**
@brief 2 dimensional function plot
Function plot graph with discrete x scale and continous y scale
This makes it possible to display "#x" samples
*/
class LMMS_EXPORT graphModel : public Model
{
Q_OBJECT
public:
/**
* @brief Constructor
* @param _min Minimum y value to display
* @param _max Maximum y value to display
* @param _size Number of samples (e.g. x value)
* @param _step Step size on y axis where values snap to, or 0.0f
* for "no snapping"
*/
graphModel( float _min,
float _max,
int _size,
Expand Down Expand Up @@ -146,14 +165,21 @@ class LMMS_EXPORT graphModel : public Model
return( m_samples.data() );
}

void convolve(const float *convolution, const int convolutionLength, const int centerOffset);
//! Make cyclic convolution
//! @param convolution Samples to convolve with
//! @param convolutionLength Number of samples to take for each sum
//! @param centerOffset Offset for resulting values
void convolve(const float *convolution,
const int convolutionLength, const int centerOffset);

public slots:
//! Set range of y values
void setRange( float _min, float _max );

void setLength( int _size );

//! Update one sample
void setSampleAt( int x, float val );
//! Update samples array
void setSamples( const float * _value );

void setWaveToSine();
Expand Down
3 changes: 3 additions & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ protected slots:
private:
virtual void modelChanged();
void viewInstrumentInDirection(int d);
//! adjust size of any child widget of the main tab
//! required to keep the old look when using a variable sized tab widget
void adjustTabSize(QWidget *w);

InstrumentTrack * m_track;
InstrumentTrackView * m_itv;
Expand Down
64 changes: 64 additions & 0 deletions include/ModelVisitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* ModelVisitor.h - visitors for automatable models
*
* Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
*
* 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 MODELVISITOR_H
#define MODELVISITOR_H

class AutomatableModel;
class BoolModel;
class IntModel;
class FloatModel;
class ComboBoxModel;
class TempoSyncKnobModel;

class ModelVisitor
{
template<class ParentType = AutomatableModel, class ModelType>
void up(ModelType& m) { visit(static_cast<ParentType&>(m)); }
public:
virtual void visit(AutomatableModel& ) {}
virtual void visit(BoolModel& m);
virtual void visit(IntModel& m);
virtual void visit(FloatModel& m);
virtual void visit(ComboBoxModel& m);
virtual void visit(TempoSyncKnobModel& m);
virtual ~ModelVisitor();
};

class ConstModelVisitor
{
template<class ParentType = AutomatableModel, class ModelType>
void up(const ModelType& m) {
visit(static_cast<const ParentType&>(m)); }
public:
virtual void visit(const AutomatableModel& ) {}
virtual void visit(const BoolModel& m);
virtual void visit(const IntModel& m);
virtual void visit(const FloatModel& m);
virtual void visit(const ComboBoxModel& m);
virtual void visit(const TempoSyncKnobModel& m);
virtual ~ConstModelVisitor();
};

#endif // MODELVISITOR_H
1 change: 1 addition & 0 deletions include/NotePlayHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note
NotePlayHandleList m_subNotes; // used for chords and arpeggios
volatile bool m_released; // indicates whether note is released
bool m_releaseStarted;
bool m_hasMidiNote;
bool m_hasParent; // indicates whether note has parent
NotePlayHandle * m_parent; // parent note
bool m_hadChildren;
Expand Down
2 changes: 2 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ protected slots:
void testPlayNote( Note * n );
void testPlayKey( int _key, int _vol, int _pan );
void pauseTestNotes(bool pause = true );
void playChordNotes(int key, int velocity=-1);
void pauseChordNotes(int key);

QList<int> getAllOctavesForKey( int keyToMirror ) const;

Expand Down
Loading

0 comments on commit d683a51

Please sign in to comment.