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

Add the Microwave synthesizer to LMMS #5000

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 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
Binary file added data/themes/classic/lcd_microwave.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/lcd_microwave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion include/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class LMMS_EXPORT Graph : public QWidget, public ModelView
LinearStyle, //!< connect each 2 samples with a line, with wrapping
LinearNonCyclicStyle, //!< LinearStyle without wrapping
BarStyle, //!< draw thick bars
NumGraphStyles
NumGraphStyles,
BarCenterGradStyle //!< draw color gradient coming from center
PhysSong marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BarCenterGradStyle should go before NumGraphStyles.

It's a common idiom in C++ to add an extra enumerator to an enum that isn't used as a normal value of the enum, but instead indicates the number of values the enum can take. Because C++ assigns values sequentially to enumerators (unless you specify them yourself), putting this special enumerator last ensures it automatically has the correct value.

(In this case it doesn't have any effect since we don't seem to use NumGraphStyles anywhere, but it ought to be corrected anyway.)

};

/**
Expand Down Expand Up @@ -216,3 +217,4 @@ public slots:
};

#endif

37 changes: 21 additions & 16 deletions include/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TextFloat;

enum knobTypes
{
knobDark_28, knobBright_26, knobSmall_17, knobVintage_32, knobStyled
knobDark_28, knobBright_26, knobSmall_17, knobVintage_32, knobStyled, knobColored, knobSmallColored
} ;


Expand Down Expand Up @@ -109,6 +109,8 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView

QColor outerColor() const;
void setOuterColor( const QColor & c );
QColor innerColor() const;
void setInnerColor( const QColor & c );
QColor lineColor() const;
void setlineColor( const QColor & c );
QColor arcColor() const;
Expand Down Expand Up @@ -138,14 +140,28 @@ class LMMS_EXPORT Knob : public QWidget, public FloatModelView

virtual float getValue( const QPoint & _p );

QString displayValue() const;

static TextFloat * s_textFloat;

QPoint m_mouseOffset;
QPoint m_origMousePos;
float m_leftOver;
bool m_buttonPressed;

inline float pageSize() const
{
return ( model()->maxValue() - model()->minValue() ) / 100.0f;
}

bool m_updateColor;

private slots:
virtual void enterValue();
void friendlyUpdate();
void toggleScale();

private:
QString displayValue() const;

virtual void doConnections();

QLineF calculateLine( const QPointF & _mid, float _radius,
Expand All @@ -154,31 +170,19 @@ private slots:
void drawKnob( QPainter * _p );
void setPosition( const QPoint & _p );
bool updateAngle();
bool updateColor();

int angleFromValue( float value, float minValue, float maxValue, float totalAngle ) const
{
return static_cast<int>( ( value - 0.5 * ( minValue + maxValue ) ) / ( maxValue - minValue ) * m_totalAngle ) % 360;
}

inline float pageSize() const
{
return ( model()->maxValue() - model()->minValue() ) / 100.0f;
}


static TextFloat * s_textFloat;

QString m_label;

QPixmap * m_knobPixmap;
BoolModel m_volumeKnob;
FloatModel m_volumeRatio;

QPoint m_mouseOffset;
QPoint m_origMousePos;
float m_leftOver;
bool m_buttonPressed;

float m_totalAngle;
int m_angle;
QImage m_cache;
Expand All @@ -189,6 +193,7 @@ private slots:
float m_outerRadius;
float m_lineWidth;
QColor m_outerColor;
QColor m_innerColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be exposed as a Q_PROPERTY, like the other colours around it. See the top of the definition of this class for how it's done.

QColor m_lineColor; //!< unused yet
QColor m_arcColor; //!< unused yet

Expand Down
4 changes: 2 additions & 2 deletions include/SampleBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class LMMS_EXPORT SampleBuffer : public QObject, public sharedObject

// protect calls from the GUI to this function with dataReadLock() and
// dataUnlock(), out of loops for efficiency
inline sample_t userWaveSample( const float _sample ) const
inline sample_t userWaveSample( const float _sample, const int channel = 0 ) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily a problem, but this will probably conflict with #4994. Generally, whoever has their code merged last has to deal with the conflict, but @Reflexe can probably let you know whether there's likely to be a problem here.

{
f_cnt_t frames = m_frames;
sampleFrame * data = m_data;
Expand All @@ -238,7 +238,7 @@ class LMMS_EXPORT SampleBuffer : public QObject, public sharedObject
{
f1 += frames;
}
return linearInterpolate( data[f1][0], data[ (f1 + 1) % frames ][0], fraction( frame ) );
return linearInterpolate( data[f1][channel], data[ (f1 + 1) % frames ][channel], fraction( frame ) );
}

void dataReadLock()
Expand Down
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ IF("${PLUGIN_LIST}" STREQUAL "")
ladspa_browser
LadspaEffect
lb302
Microwave
MidiImport
MidiExport
MultitapEcho
Expand Down
6 changes: 6 additions & 0 deletions plugins/Microwave/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INCLUDE(BuildPlugin)

LINK_DIRECTORIES(${SAMPLERATE_LIBRARY_DIRS})
LINK_LIBRARIES(${SAMPLERATE_LIBRARIES})

BUILD_PLUGIN(microwave Microwave.cpp Microwave.h MOCFILES Microwave.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
Loading