From 217c31af8c63319de541d4b6422baba6aa462e67 Mon Sep 17 00:00:00 2001 From: Hyunin Song Date: Wed, 28 Mar 2018 09:44:55 +0900 Subject: [PATCH] Reformat code --- include/Groove.h | 10 ++--- include/GrooveExperiments.h | 12 +++--- include/GrooveFactory.h | 2 +- include/HalfSwing.h | 12 +++--- include/HydrogenSwing.h | 14 +++---- include/MidiSwing.h | 8 ++-- src/core/Groove.cpp | 12 +++--- src/core/GrooveExperiments.cpp | 48 +++++++++++------------ src/core/GrooveFactory.cpp | 12 +++--- src/core/HalfSwing.cpp | 70 +++++++++++++++++----------------- src/core/HydrogenSwing.cpp | 70 +++++++++++++++++----------------- src/core/MidiSwing.cpp | 50 ++++++++++++------------ src/gui/widgets/GrooveView.cpp | 28 +++++++------- 13 files changed, 174 insertions(+), 174 deletions(-) diff --git a/include/Groove.h b/include/Groove.h index aa9cb0275..7157dcbfc 100644 --- a/include/Groove.h +++ b/include/Groove.h @@ -55,14 +55,14 @@ public: * returns 0 to play now on the tick, -1 to not play at all and the new offset * that the note should be shifted if it is to be played later in this tick. */ - virtual int isInTick( MidiTime * _cur_start, fpp_t _frames, f_cnt_t _offset, - Note * _n, Pattern * _p ); + virtual int isInTick(MidiTime * curStart, fpp_t frames, f_cnt_t offset, + Note * n, Pattern * p); int amount() const {return m_amount;} - virtual void saveSettings( QDomDocument & doc, QDomElement & element ); - virtual void loadSettings(const QDomElement & element ); + virtual void saveSettings(QDomDocument & doc, QDomElement & element); + virtual void loadSettings(const QDomElement & element); - virtual QWidget * instantiateView( QWidget * _parent ); + virtual QWidget * instantiateView(QWidget * parent); virtual QString nodeName() const { diff --git a/include/GrooveExperiments.h b/include/GrooveExperiments.h index aea9a3347..6f005bb35 100644 --- a/include/GrooveExperiments.h +++ b/include/GrooveExperiments.h @@ -17,13 +17,13 @@ class GrooveExperiments : public Groove { Q_OBJECT public: - GrooveExperiments(QObject *parent=0 ); + GrooveExperiments(QObject *parent = NULL); virtual ~GrooveExperiments(); void init(); - int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p ); + int isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, Note * n, Pattern * p); inline virtual QString nodeName() const { @@ -32,21 +32,21 @@ public: - QWidget * instantiateView( QWidget * _parent ); + QWidget * instantiateView(QWidget * parent); public slots: // valid values are from 0 - 127 void update(); private: - int m_frames_per_tick; + int m_framesPerTick; } ; class GrooveExperimentsView : public QWidget { Q_OBJECT public: - GrooveExperimentsView(GrooveExperiments * _m_ge, QWidget * parent=0 ); + GrooveExperimentsView(GrooveExperiments * groove, QWidget * parent = NULL); ~GrooveExperimentsView(); public slots: @@ -54,7 +54,7 @@ public slots: void valueChanged(int); private: - GrooveExperiments * m_ge; + GrooveExperiments * m_groove; IntModel * m_sliderModel; AutomatableSlider * m_slider; diff --git a/include/GrooveFactory.h b/include/GrooveFactory.h index 1a2c5dafd..4c6ecf40a 100644 --- a/include/GrooveFactory.h +++ b/include/GrooveFactory.h @@ -32,7 +32,7 @@ class GrooveFactory { public: - static Groove * create(QString type); + static Groove * create(QString grooveType); private: GrooveFactory(); diff --git a/include/HalfSwing.h b/include/HalfSwing.h index cf8ab80c2..2df407a69 100644 --- a/include/HalfSwing.h +++ b/include/HalfSwing.h @@ -17,34 +17,34 @@ class HalfSwing : public Groove { Q_OBJECT public: - HalfSwing(QObject *parent=0 ); + HalfSwing(QObject *parent = NULL); virtual ~HalfSwing(); void init(); - int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p ); + int isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, Note * n, Pattern * p); inline virtual QString nodeName() const { return "half"; } - QWidget * instantiateView( QWidget * _parent ); + QWidget * instantiateView(QWidget * parent); public slots: // valid values are from 0 - 127 void update(); private: - int m_frames_per_tick; + int m_framesPerTick; } ; class HalfSwingView : public QWidget { Q_OBJECT public: - HalfSwingView(HalfSwing * _half_swing, QWidget * parent=0 ); + HalfSwingView(HalfSwing * halfSwing, QWidget * parent = NULL); ~HalfSwingView(); public slots: @@ -52,7 +52,7 @@ public slots: void valueChanged(int); private: - HalfSwing * m_half_swing; + HalfSwing * m_swing; IntModel * m_sliderModel; AutomatableSlider * m_slider; diff --git a/include/HydrogenSwing.h b/include/HydrogenSwing.h index 1a6406e7d..1cae32a61 100644 --- a/include/HydrogenSwing.h +++ b/include/HydrogenSwing.h @@ -17,13 +17,13 @@ class HydrogenSwing : public Groove { Q_OBJECT public: - HydrogenSwing(QObject *parent=0 ); + HydrogenSwing(QObject *parent = NULL); virtual ~HydrogenSwing(); void init(); - int isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p ); + int isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, Note * n, Pattern * p); inline virtual QString nodeName() const { @@ -32,29 +32,29 @@ public: - QWidget * instantiateView( QWidget * _parent ); + QWidget * instantiateView(QWidget * parent); public slots: // valid values are from 0 - 127 void update(); private: - int m_frames_per_tick; + int m_framesPerTick; } ; class HydrogenSwingView : public QWidget { Q_OBJECT public: - HydrogenSwingView(HydrogenSwing * _hy_swing, QWidget * parent=0 ); + HydrogenSwingView(HydrogenSwing * swing, QWidget * parent = NULL); ~HydrogenSwingView(); public slots: void modelChanged(); - void valueChanged(int); + void valueChanged(int value); private: - HydrogenSwing * m_hy_swing; + HydrogenSwing * m_swing; IntModel * m_sliderModel; AutomatableSlider * m_slider; diff --git a/include/MidiSwing.h b/include/MidiSwing.h index 741641fca..c3e6ce494 100644 --- a/include/MidiSwing.h +++ b/include/MidiSwing.h @@ -17,20 +17,20 @@ class MidiSwing : public Groove { Q_OBJECT public: - MidiSwing(QObject * _parent=0 ); + MidiSwing(QObject * parent = NULL); ~MidiSwing(); // TODO why declaring this should it not come from super class? - int isInTick(MidiTime * cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * n, Pattern * p ); - int isInTick(MidiTime * _cur_start, Note * _n, Pattern * _p ); + int isInTick(MidiTime * cur_start, const fpp_t frames, const f_cnt_t offset, Note * n, Pattern * p); + int isInTick(MidiTime * curStart, Note * n, Pattern * p); inline virtual QString nodeName() const { return "midi"; } - QWidget * instantiateView( QWidget * _parent ); + QWidget * instantiateView(QWidget * parent); signals: diff --git a/src/core/Groove.cpp b/src/core/Groove.cpp index b5b32ffeb..b49d126be 100644 --- a/src/core/Groove.cpp +++ b/src/core/Groove.cpp @@ -18,10 +18,10 @@ Groove::Groove(QObject *parent) : * Default groove is no groove. Not even a wiggle. * @return 0 or -1 */ -int Groove::isInTick(MidiTime * _cur_start, fpp_t _frames, f_cnt_t _offset, - Note * _n, Pattern * _p ) { +int Groove::isInTick(MidiTime * curStart, fpp_t frames, f_cnt_t offset, + Note * n, Pattern * p) { - return _n->pos().getTicks() == _cur_start->getTicks() ? 0 : -1; + return n->pos().getTicks() == curStart->getTicks() ? 0 : -1; } void Groove::setAmount(int amount) @@ -40,13 +40,13 @@ void Groove::setAmount(int amount) } -void Groove::saveSettings(QDomDocument & doc, QDomElement & element ) +void Groove::saveSettings(QDomDocument & doc, QDomElement & element) { Q_UNUSED(doc); element.setAttribute("amount", m_amount); } -void Groove::loadSettings( const QDomElement & element ) +void Groove::loadSettings(const QDomElement & element) { bool ok; int amount = element.attribute("amount").toInt(&ok); @@ -60,7 +60,7 @@ void Groove::loadSettings( const QDomElement & element ) } } -QWidget * Groove::instantiateView( QWidget * _parent ) +QWidget * Groove::instantiateView(QWidget * parent) { return new QLabel(""); } diff --git a/src/core/GrooveExperiments.cpp b/src/core/GrooveExperiments.cpp index 5235a6509..0925ef0a4 100644 --- a/src/core/GrooveExperiments.cpp +++ b/src/core/GrooveExperiments.cpp @@ -64,19 +64,19 @@ void GrooveExperiments::init() void GrooveExperiments::update() { - m_frames_per_tick = Engine::framesPerTick(); + m_framesPerTick = Engine::framesPerTick(); } -int GrooveExperiments::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, Note * _n, Pattern * _p ) +int GrooveExperiments::isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, Note * n, Pattern * p ) { // TODO why is this wrong on boot how do we set it once not every loop - if ( m_frames_per_tick == 0 ) + if ( m_framesPerTick == 0 ) { - m_frames_per_tick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 + m_framesPerTick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 } // only ever delay notes by 12 ticks, so if the tick is earlier don't play - if ( _n->pos().getTicks() + 12 < _cur_start->getTicks()) + if ( n->pos().getTicks() + 12 < curStart->getTicks()) { return -1; } @@ -85,32 +85,32 @@ int GrooveExperiments::isInTick(MidiTime * _cur_start, const fpp_t _frames, cons // Where are we in the beat // 48 ticks to the beat, 192 ticks to the bar - int pos_in_beat = _n->pos().getTicks() % 48; + int pos_in_beat = n->pos().getTicks() % 48; - int pos_in_eigth = -1; + int posInEigth = -1; if ( pos_in_beat >= 36 && pos_in_beat < 48 ) { // third quarter - pos_in_eigth = pos_in_beat - 36; // 0-11 + posInEigth = pos_in_beat - 36; // 0-11 } - if ( pos_in_eigth >= 0 ) + if ( posInEigth >= 0 ) { - float ticks_to_shift = ((pos_in_eigth - 12) * -m_swingFactor); + float ticksToShift = ((posInEigth - 12) * -m_swingFactor); - f_cnt_t frames_to_shift = (int)(ticks_to_shift * m_frames_per_tick); + f_cnt_t framesToShift = (int)(ticksToShift * m_framesPerTick); - int tick_offset = (int)(frames_to_shift / m_frames_per_tick); // round down + int tickOffset = (int)(framesToShift / m_framesPerTick); // round down - if ( _cur_start->getTicks() == (_n->pos().getTicks() + tick_offset) ) + if ( curStart->getTicks() == (n->pos().getTicks() + tickOffset) ) { // play in this tick - f_cnt_t new_offset = (frames_to_shift % m_frames_per_tick) + _offset; + f_cnt_t newOffset = (framesToShift % m_framesPerTick) + offset; - return new_offset; + return newOffset; } else { @@ -120,20 +120,20 @@ int GrooveExperiments::isInTick(MidiTime * _cur_start, const fpp_t _frames, cons } // else no groove adjustments - return _n->pos().getTicks() == _cur_start->getTicks() ? 0 : -1; + return n->pos().getTicks() == curStart->getTicks() ? 0 : -1; } -QWidget * GrooveExperiments::instantiateView( QWidget * _parent ) +QWidget * GrooveExperiments::instantiateView(QWidget * parent) { - return new GrooveExperimentsView(this, _parent); + return new GrooveExperimentsView(this, parent); } // VIEW // -GrooveExperimentsView::GrooveExperimentsView(GrooveExperiments * _ge, QWidget * _parent) : - QWidget(_parent) +GrooveExperimentsView::GrooveExperimentsView(GrooveExperiments * groove, QWidget * parent) : + QWidget(parent) { m_sliderModel = new IntModel(0, 0, 127); // Unused m_slider = new AutomatableSlider(this, tr("Swinginess")); @@ -141,9 +141,9 @@ GrooveExperimentsView::GrooveExperimentsView(GrooveExperiments * _ge, QWidget * m_slider->setFixedSize( 90, 26 ); m_slider->setPageStep(1); m_slider->setModel(m_sliderModel); - m_sliderModel->setValue(_ge->amount()); + m_sliderModel->setValue(groove->amount()); - m_ge = _ge; + m_groove = groove; connect(m_slider, SIGNAL(sliderMoved(int)), this, SLOT(valueChanged(int))); connect(m_sliderModel, SIGNAL(dataChanged()), this, SLOT(modelChanged())); @@ -157,10 +157,10 @@ GrooveExperimentsView::~GrooveExperimentsView() void GrooveExperimentsView::modelChanged() { - m_ge->setAmount((int)m_sliderModel->value()); + m_groove->setAmount((int)m_sliderModel->value()); } void GrooveExperimentsView::valueChanged(int _i) // this value passed is gibberish { - m_ge->setAmount((int)m_sliderModel->value()); + m_groove->setAmount((int)m_sliderModel->value()); } diff --git a/src/core/GrooveFactory.cpp b/src/core/GrooveFactory.cpp index 10705f18d..df52891d5 100644 --- a/src/core/GrooveFactory.cpp +++ b/src/core/GrooveFactory.cpp @@ -18,20 +18,20 @@ GrooveFactory::GrooveFactory() * * TODO this is a bit Java-like how does C++ do this kind of thing normally */ -Groove * GrooveFactory::create(QString _grooveType) { - if (_grooveType == NULL || _grooveType == "none") { +Groove * GrooveFactory::create(QString grooveType) { + if (grooveType == NULL || grooveType == "none") { return new Groove(); } - if (_grooveType == "hydrogen") { + if (grooveType == "hydrogen") { return new HydrogenSwing(); } - if (_grooveType == "midi") { + if (grooveType == "midi") { return new MidiSwing(); } - if (_grooveType == "half") { + if (grooveType == "half") { return new HalfSwing(); } - if (_grooveType == "experiment") { + if (grooveType == "experiment") { return new GrooveExperiments(); } return new Groove(); diff --git a/src/core/HalfSwing.cpp b/src/core/HalfSwing.cpp index 9c98a439d..d7750e28e 100644 --- a/src/core/HalfSwing.cpp +++ b/src/core/HalfSwing.cpp @@ -39,8 +39,8 @@ #include "stdio.h" -HalfSwing::HalfSwing(QObject * _parent) : - Groove(_parent) +HalfSwing::HalfSwing(QObject * parent) : + Groove(parent) { m_amount = 0; m_swingFactor = 0.0; @@ -57,31 +57,31 @@ void HalfSwing::init() { Song * s = Engine::getSong(); - connect( s, SIGNAL(projectLoaded()), this, SLOT(update()) ); - connect( s, SIGNAL(lengthChanged(int)), this, SLOT(update()) ); - connect( s, SIGNAL(tempoChanged(bpm_t)), this, SLOT(update()) ); - connect( s, SIGNAL(timeSignatureChanged(int, int)), this, SLOT(update()) ); + connect(s, SIGNAL(projectLoaded()), this, SLOT(update())); + connect(s, SIGNAL(lengthChanged(int)), this, SLOT(update())); + connect(s, SIGNAL(tempoChanged(bpm_t)), this, SLOT(update())); + connect(s, SIGNAL(timeSignatureChanged(int, int)), this, SLOT(update())); } void HalfSwing::update() { - m_frames_per_tick = Engine::framesPerTick(); + m_framesPerTick = Engine::framesPerTick(); } -int HalfSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, - Note * _n, Pattern * _p ) +int HalfSwing::isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, + Note * n, Pattern * p) { // TODO why is this wrong on boot how do we set it once not every loop - if ( m_frames_per_tick == 0 ) + if (m_framesPerTick == 0) { - m_frames_per_tick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 + m_framesPerTick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 } // only ever delay notes by 7 ticks, so if the tick is earlier don't play - if ( _n->pos().getTicks() + 7 < _cur_start->getTicks()) + if (n->pos().getTicks() + 7 < curStart->getTicks()) { return -1; } @@ -90,68 +90,68 @@ int HalfSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_ // Where are we in the beat // 48 ticks to the beat, 192 ticks to the bar - int pos_in_beat = _n->pos().getTicks() % 48; + int pos_in_beat = n->pos().getTicks() % 48; - // The Half Swing algorthym. + // The Half Swing algorithm. // Basically we delay (shift) notes on the the 4th quarter of the beat. - int pos_in_eigth = -1; - if ( pos_in_beat >= 36 && pos_in_beat < 42 ) + int posInEigth = -1; + if (pos_in_beat >= 36 && pos_in_beat < 42) { // 1st half of third quarter - pos_in_eigth = pos_in_beat - 36; // 0-5 + posInEigth = pos_in_beat - 36; // 0-5 } - if ( pos_in_eigth >= 0 ) + if (posInEigth >= 0) { - float ticks_to_shift = ((pos_in_eigth - 6) * -m_swingFactor); + float ticksToShift = ((posInEigth - 6) * -m_swingFactor); - f_cnt_t frames_to_shift = (int)(ticks_to_shift * m_frames_per_tick); + f_cnt_t framesToShift = (int)(ticksToShift * m_framesPerTick); - int tick_offset = (int)(frames_to_shift / m_frames_per_tick); // round down + int tickOffset = (int)(framesToShift / m_framesPerTick); // round down - if ( _cur_start->getTicks() == (_n->pos().getTicks() + tick_offset) ) + if (curStart->getTicks() == (n->pos().getTicks() + tickOffset)) { // play in this tick - f_cnt_t new_offset = (frames_to_shift % m_frames_per_tick) + _offset; + f_cnt_t newOffset = (framesToShift % m_framesPerTick) + offset; - return new_offset; + return newOffset; } else - { + { // this note does not play in this tick return -1; } } // else no groove adjustments - return _n->pos().getTicks() == _cur_start->getTicks() ? 0 : -1; + return n->pos().getTicks() == curStart->getTicks() ? 0 : -1; } -QWidget * HalfSwing::instantiateView( QWidget * _parent ) +QWidget * HalfSwing::instantiateView(QWidget * parent) { - return new HalfSwingView(this, _parent); + return new HalfSwingView(this, parent); } // VIEW // -HalfSwingView::HalfSwingView(HalfSwing * _half_swing, QWidget * _parent) : - QWidget(_parent) +HalfSwingView::HalfSwingView(HalfSwing * halfSwing, QWidget * parent) : + QWidget(parent) { m_sliderModel = new IntModel(0, 0, 127); // Unused m_slider = new AutomatableSlider(this, tr("Swinginess")); m_slider->setOrientation(Qt::Horizontal); - m_slider->setFixedSize( 90, 26 ); + m_slider->setFixedSize(90, 26); m_slider->setPageStep(1); m_slider->setModel(m_sliderModel); - m_sliderModel->setValue(_half_swing->amount()); + m_sliderModel->setValue(halfSwing->amount()); - m_half_swing = _half_swing; + m_swing = halfSwing; connect(m_slider, SIGNAL(sliderMoved(int)), this, SLOT(valueChanged(int))); connect(m_sliderModel, SIGNAL(dataChanged()), this, SLOT(modelChanged())); @@ -165,10 +165,10 @@ HalfSwingView::~HalfSwingView() void HalfSwingView::modelChanged() { - m_half_swing->setAmount((int)m_sliderModel->value()); + m_swing->setAmount((int)m_sliderModel->value()); } void HalfSwingView::valueChanged(int _i) // this value passed is gibberish { - m_half_swing->setAmount((int)m_sliderModel->value()); + m_swing->setAmount((int)m_sliderModel->value()); } diff --git a/src/core/HydrogenSwing.cpp b/src/core/HydrogenSwing.cpp index 76fcd4719..6f76f0c15 100644 --- a/src/core/HydrogenSwing.cpp +++ b/src/core/HydrogenSwing.cpp @@ -57,29 +57,29 @@ void HydrogenSwing::init() { Song * s = Engine::getSong(); - connect( s, SIGNAL(projectLoaded()), this, SLOT(update()) ); - connect( s, SIGNAL(lengthChanged(int)), this, SLOT(update()) ); - connect( s, SIGNAL(tempoChanged(bpm_t)), this, SLOT(update()) ); - connect( s, SIGNAL(timeSignatureChanged(int, int)), this, SLOT(update()) ); + connect(s, SIGNAL(projectLoaded()), this, SLOT(update())); + connect(s, SIGNAL(lengthChanged(int)), this, SLOT(update())); + connect(s, SIGNAL(tempoChanged(bpm_t)), this, SLOT(update())); + connect(s, SIGNAL(timeSignatureChanged(int, int)), this, SLOT(update())); } void HydrogenSwing::update() { - m_frames_per_tick = Engine::framesPerTick(); + m_framesPerTick = Engine::framesPerTick(); } -int HydrogenSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, - Note * _n, Pattern * _p ) +int HydrogenSwing::isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, + Note * n, Pattern * p) { // TODO why is this wrong on boot how do we set it once not every loop - if ( m_frames_per_tick == 0 ) + if (m_framesPerTick == 0) { - m_frames_per_tick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 + m_framesPerTick = Engine::framesPerTick(); // e.g. 500 at 120BPM 4/4 } // only ever delay notes by 7 ticks, so if the tick is earlier don't play - if ( _n->pos().getTicks() + 7 < _cur_start->getTicks()) + if (n->pos().getTicks() + 7 < curStart->getTicks()) { return -1; } @@ -88,41 +88,41 @@ int HydrogenSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_ // Where are we in the beat // 48 ticks to the beat, 192 ticks to the bar - int pos_in_beat = _n->pos().getTicks() % 48; + int posInBeat = n->pos().getTicks() % 48; - // The Hydrogen Swing algorthym. + // The Hydrogen Swing algorithm. // Guessed by turning the knob and watching the possitions change in Audacity. // Basically we delay (shift) notes on the the 2nd and 4th quarter of the beat. - int pos_in_eigth = -1; - if ( pos_in_beat >= 12 && pos_in_beat < 18 ) + int posInEigth = -1; + if (posInBeat >= 12 && posInBeat < 18) { // 1st half of second quarter - pos_in_eigth = pos_in_beat - 12; // 0-5 + posInEigth = posInBeat - 12; // 0-5 } - else if ( pos_in_beat >= 36 && pos_in_beat < 42 ) + else if (posInBeat >= 36 && posInBeat < 42) { // 1st half of third quarter - pos_in_eigth = pos_in_beat - 36; // 0-5 + posInEigth = posInBeat - 36; // 0-5 } - if ( pos_in_eigth >= 0 ) + if (posInEigth >= 0) { - float ticks_to_shift = ((pos_in_eigth - 6) * -m_swingFactor); + float ticksToShift = ((posInEigth - 6) * -m_swingFactor); - f_cnt_t frames_to_shift = (int)(ticks_to_shift * m_frames_per_tick); + f_cnt_t framesToShift = (int)(ticksToShift * m_framesPerTick); - int tick_offset = (int)(frames_to_shift / m_frames_per_tick); // round down + int tickOffset = (int)(framesToShift / m_framesPerTick); // round down - if ( _cur_start->getTicks() == (_n->pos().getTicks() + tick_offset) ) + if (curStart->getTicks() == (n->pos().getTicks() + tickOffset)) { // play in this tick - f_cnt_t new_offset = (frames_to_shift % m_frames_per_tick) + _offset; + f_cnt_t newOffset = (framesToShift % m_framesPerTick) + offset; - return new_offset; + return newOffset; } else { @@ -132,28 +132,28 @@ int HydrogenSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_ } // else no groove adjustments - return _n->pos().getTicks() == _cur_start->getTicks() ? 0 : -1; + return n->pos().getTicks() == curStart->getTicks() ? 0 : -1; } -QWidget * HydrogenSwing::instantiateView( QWidget * _parent ) +QWidget * HydrogenSwing::instantiateView(QWidget * parent) { - return new HydrogenSwingView(this, _parent); + return new HydrogenSwingView(this, parent); } // VIEW // -HydrogenSwingView::HydrogenSwingView(HydrogenSwing * _hy_swing, QWidget * _parent) : - QWidget(_parent) +HydrogenSwingView::HydrogenSwingView(HydrogenSwing * swing, QWidget * parent) : + QWidget(parent) { m_sliderModel = new IntModel(0, 0, 127); // Unused m_slider = new AutomatableSlider(this, tr("Swinginess")); m_slider->setOrientation(Qt::Horizontal); - m_slider->setFixedSize( 90, 26 ); + m_slider->setFixedSize(90, 26); m_slider->setPageStep(1); m_slider->setModel(m_sliderModel); - m_sliderModel->setValue(_hy_swing->amount()); + m_sliderModel->setValue(swing->amount()); - m_hy_swing = _hy_swing; + m_swing = swing; connect(m_slider, SIGNAL(sliderMoved(int)), this, SLOT(valueChanged(int))); connect(m_sliderModel, SIGNAL(dataChanged()), this, SLOT(modelChanged())); @@ -167,10 +167,10 @@ HydrogenSwingView::~HydrogenSwingView() void HydrogenSwingView::modelChanged() { - m_hy_swing->setAmount((int)m_sliderModel->value()); + m_swing->setAmount((int)m_sliderModel->value()); } -void HydrogenSwingView::valueChanged(int _i) // this value passed is gibberish +void HydrogenSwingView::valueChanged(int value) // this value passed is gibberish { - m_hy_swing->setAmount((int)m_sliderModel->value()); + m_swing->setAmount((int)m_sliderModel->value()); } diff --git a/src/core/MidiSwing.cpp b/src/core/MidiSwing.cpp index 877eb3fa7..473439250 100644 --- a/src/core/MidiSwing.cpp +++ b/src/core/MidiSwing.cpp @@ -27,8 +27,8 @@ #include "MidiSwing.h" -MidiSwing::MidiSwing(QObject * _parent) : - Groove(_parent) +MidiSwing::MidiSwing(QObject * parent) : + Groove(parent) { } @@ -36,56 +36,56 @@ MidiSwing::~MidiSwing() { } -static int applyMidiSwing(int pos_in_eight); +static int applyMidiSwing(int posInEight); -int MidiSwing::isInTick(MidiTime * _cur_start, const fpp_t _frames, const f_cnt_t _offset, - Note * _n, Pattern * _p ) +int MidiSwing::isInTick(MidiTime * curStart, const fpp_t frames, const f_cnt_t offset, + Note * n, Pattern * p) { - return isInTick(_cur_start, _n, _p ); + return isInTick(curStart, n, p); } -int MidiSwing::isInTick(MidiTime * _cur_start, Note * _n, Pattern * _p ) +int MidiSwing::isInTick(MidiTime * curStart, Note * n, Pattern * p) { // Where are we in the beat - int pos_in_beat = _n->pos().getTicks() % 48; // assumes 48 ticks per beat, todo verify this + int posInBeat = n->pos().getTicks() % 48; // assumes 48 ticks per beat, todo verify this - // the Midi Swing algorthym. + // the Midi Swing algorithm. - int pos_in_eigth = -1; - if ( pos_in_beat >= 12 && pos_in_beat < 18 ) + int posInEigth = -1; + if (posInBeat >= 12 && posInBeat < 18) { // 1st half of second quarter //add a 0 - 24 tick shift - pos_in_eigth = pos_in_beat - 12; // 0-5 + posInEigth = posInBeat - 12; // 0-5 } - else if ( pos_in_beat >= 36 && pos_in_beat < 42 ) + else if (posInBeat >= 36 && posInBeat < 42) { // 1st half of third quarter - pos_in_eigth = pos_in_beat - 36; // 0-5 + posInEigth = posInBeat - 36; // 0-5 } - int swingTicks = applyMidiSwing(pos_in_eigth); + int swingTicks = applyMidiSwing(posInEigth); - return _cur_start->getTicks() == swingTicks + _n->pos().getTicks() ? 0 : -1; + return curStart->getTicks() == swingTicks + n->pos().getTicks() ? 0 : -1; } -QWidget * MidiSwing::instantiateView( QWidget * _parent ) +QWidget * MidiSwing::instantiateView(QWidget * parent) { return new QLabel(""); } -static int applyMidiSwing(int _pos_in_eigth) +static int applyMidiSwing(int posInEight) { // TODO case - if (_pos_in_eigth < 0) return 0; - if (_pos_in_eigth == 0) return 3; - if (_pos_in_eigth == 1) return 3; - if (_pos_in_eigth == 2) return 4; - if (_pos_in_eigth == 3) return 4; - if (_pos_in_eigth == 4) return 5; - if (_pos_in_eigth == 5) return 5; + if (posInEight < 0) return 0; + if (posInEight == 0) return 3; + if (posInEight == 1) return 3; + if (posInEight == 2) return 4; + if (posInEight == 3) return 4; + if (posInEight == 4) return 5; + if (posInEight == 5) return 5; return 0; } diff --git a/src/gui/widgets/GrooveView.cpp b/src/gui/widgets/GrooveView.cpp index e37845fab..ce8ad5ac6 100644 --- a/src/gui/widgets/GrooveView.cpp +++ b/src/gui/widgets/GrooveView.cpp @@ -25,28 +25,28 @@ GrooveView::GrooveView(QWidget * parent) : QWidget(parent) { m_layout = new QVBoxLayout(); - this->setLayout( m_layout ); + this->setLayout(m_layout); m_comboBox = new QComboBox(this); // Insert reverse order. - m_comboBox->insertItem(0, tr("Experiment swing") , QVariant::fromValue(5) ); - m_comboBox->insertItem(0, tr("Hydrogen swing") , QVariant::fromValue(4) ); - m_comboBox->insertItem(0, tr("Half swing") , QVariant::fromValue(3) ); - m_comboBox->insertItem(0, tr("MIDI swing") , QVariant::fromValue(2) ); - m_comboBox->insertItem(0, tr("No swing") , QVariant::fromValue(1) ); + m_comboBox->insertItem(0, tr("Experiment swing") , QVariant::fromValue(5)); + m_comboBox->insertItem(0, tr("Hydrogen swing") , QVariant::fromValue(4)); + m_comboBox->insertItem(0, tr("Half swing") , QVariant::fromValue(3)); + m_comboBox->insertItem(0, tr("MIDI swing") , QVariant::fromValue(2)); + m_comboBox->insertItem(0, tr("No swing") , QVariant::fromValue(1)); m_comboBox->setCurrentIndex(0); - m_layout->addWidget( m_comboBox ); - m_layout->addWidget( new QLabel("") ); + m_layout->addWidget(m_comboBox); + m_layout->addWidget(new QLabel("")); - connect( m_comboBox, SIGNAL( activated(int) ), - this, SLOT( grooveChanged(int) ) ); + connect(m_comboBox, SIGNAL(activated(int)), + this, SLOT(grooveChanged(int))); - connect( Engine::getSong(), SIGNAL( dataChanged() ), - this, SLOT( update() ) ); + connect(Engine::getSong(), SIGNAL(dataChanged()), + this, SLOT(update())); - connect( Engine::getSong(), SIGNAL( projectLoaded() ), - this, SLOT( update() ) ); + connect(Engine::getSong(), SIGNAL(projectLoaded()), + this, SLOT(update())); update(); }