diff --git a/.travis.yml b/.travis.yml
index 93ad9ea4b..a8bb8c652 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,8 +9,8 @@ before_install:
- sudo apt-get update -qq
install:
- if [ $TARGET_OS != linux ]; then sudo apt-get install -y nsis cloog-isl libmpc2 mingw32; fi
- - if [ $TARGET_OS != linux ]; then sudo apt-get install -y mingw32-x-qt mingw32-x-sdl mingw32-x-libvorbis mingw32-x-fluidsynth mingw32-x-stk mingw32-x-glib2 mingw32-x-portaudio mingw32-x-libsndfile mingw32-x-fftw mingw32-x-flac mingw32-x-fltk mingw32-x-libsamplerate mingw32-x-pkgconfig mingw32-x-binutils mingw32-x-gcc mingw32-x-runtime; fi
- - if [ $TARGET_OS == win64 ]; then sudo apt-get install -y mingw64-x-qt mingw64-x-sdl mingw64-x-libvorbis mingw64-x-fluidsynth mingw64-x-stk mingw64-x-glib2 mingw64-x-portaudio mingw64-x-libsndfile mingw64-x-fftw mingw64-x-flac mingw64-x-fltk mingw64-x-libsamplerate mingw64-x-pkgconfig mingw64-x-binutils mingw64-x-gcc mingw64-x-runtime; fi
+ - if [ $TARGET_OS != linux ]; then sudo apt-get install -y mingw32-x-qt mingw32-x-sdl mingw32-x-libvorbis mingw32-x-fluidsynth mingw32-x-stk mingw32-x-glib2 mingw32-x-portaudio mingw32-x-libsndfile mingw32-x-fftw mingw32-x-flac mingw32-x-fltk mingw32-x-libsamplerate mingw32-x-pkgconfig mingw32-x-binutils mingw32-x-gcc mingw32-x-runtime mingw32-x-libgig; fi
+ - if [ $TARGET_OS == win64 ]; then sudo apt-get install -y mingw64-x-qt mingw64-x-sdl mingw64-x-libvorbis mingw64-x-fluidsynth mingw64-x-stk mingw64-x-glib2 mingw64-x-portaudio mingw64-x-libsndfile mingw64-x-fftw mingw64-x-flac mingw64-x-fltk mingw64-x-libsamplerate mingw64-x-pkgconfig mingw64-x-binutils mingw64-x-gcc mingw64-x-runtime mingw64-x-libgig; fi
- if [ $TARGET_OS == linux ]; then sudo apt-get install -y libqt4-dev libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev libfluidsynth-dev portaudio19-dev wine-dev g++-multilib libfltk1.3-dev libgig-dev; fi
before_script:
- mkdir build && cd build
diff --git a/README.md b/README.md
index e451275cb..614b3bf72 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
- LMMS
+# LMMS
[](https://travis-ci.org/LMMS/lmms)
What is LMMS?
@@ -25,13 +25,17 @@ Features
* Compatible with many standards such as SoundFont2, VST(i), LADSPA, GUS Patches, and full MIDI support
* Import of MIDI and FLP (FL Studio®/Fruityloops® Project) files
-[Latest Stable Release (1.0.3)](https://github.com/LMMS/lmms/releases/tag/v1.0.3)
+[Latest Stable Release (1.1.0)](https://github.com/LMMS/lmms/releases/tag/v1.1.0)
---------------------
-* Fix zyn GUI crash on win32
-* Fix SF2 note volume
-* Localization updates
-* Updated LADSPA search paths
-* Bugfixes in plugins
+* New FX Mixer
+* New Instruments
+* Instrument Enhancements
+* Improved Demos/Presets
+* UI Improvements
+* Enabled toggling of knob scale in context menu (Linear/Logarithmic)
+* Added ability to record automations
+* Added support for undo/redo in Piano Roll
+* Bug Fixes
Building
---------
diff --git a/data/locale/ca.ts b/data/locale/ca.ts
index 4035efb53..9cd6ae404 100644
--- a/data/locale/ca.ts
+++ b/data/locale/ca.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/cs.ts b/data/locale/cs.ts
index 9b0a8e9fe..6aa7e566b 100644
--- a/data/locale/cs.ts
+++ b/data/locale/cs.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/de.ts b/data/locale/de.ts
index 167686614..c193d646f 100644
--- a/data/locale/de.ts
+++ b/data/locale/de.ts
@@ -203,6 +203,10 @@ Wenn Sie daran interessiert sind LMMS in eine andere Sprache zu übersetzen oder
With this knob you can set the point where the loop starts.
Mit diesem Regler können Sie festlegen, wo die Wiederholung beginnt.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/en.ts b/data/locale/en.ts
index ad6b6829c..76e145ebc 100644
--- a/data/locale/en.ts
+++ b/data/locale/en.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/es.ts b/data/locale/es.ts
index 1c62562c5..bd89815ea 100644
--- a/data/locale/es.ts
+++ b/data/locale/es.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/fa.ts b/data/locale/fa.ts
index b8628bdff..e38e2d970 100644
--- a/data/locale/fa.ts
+++ b/data/locale/fa.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/fr.ts b/data/locale/fr.ts
index 730db5a5b..6dcf0a8b8 100644
--- a/data/locale/fr.ts
+++ b/data/locale/fr.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/gl.ts b/data/locale/gl.ts
index 061fac646..96b19ccd6 100644
--- a/data/locale/gl.ts
+++ b/data/locale/gl.ts
@@ -195,6 +195,10 @@ Se lle interesa traducir o LMMS a outro idioma ou desexa mellorar as traducións
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/it.ts b/data/locale/it.ts
index ad6de8a1f..a046d158a 100644
--- a/data/locale/it.ts
+++ b/data/locale/it.ts
@@ -196,6 +196,10 @@ Se sei interessato a tradurre LMMS o vuoi migliorare una traduzione esistente, s
With this knob you can set the point where the loop starts.
Con questa modalità puoi impostare il punto dove la ripetizione comincia: la parte del suono tra il LoopBack e il punto di fine è quella che verà ripetuta.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/ja.ts b/data/locale/ja.ts
index 43c8cf233..49f272525 100644
--- a/data/locale/ja.ts
+++ b/data/locale/ja.ts
@@ -195,6 +195,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/ko.ts b/data/locale/ko.ts
index 76377dca3..aeee0b941 100644
--- a/data/locale/ko.ts
+++ b/data/locale/ko.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/nl.ts b/data/locale/nl.ts
index c2a8971b9..1b98f5417 100644
--- a/data/locale/nl.ts
+++ b/data/locale/nl.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/pl.ts b/data/locale/pl.ts
index fe28d3ce8..fec62d198 100644
--- a/data/locale/pl.ts
+++ b/data/locale/pl.ts
@@ -199,6 +199,10 @@ Zauważone błędy i propozycje zmian tłumaczenia proszę zgłaszać na e-mail:
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/pt.ts b/data/locale/pt.ts
index 4e0724c46..defb1e561 100644
--- a/data/locale/pt.ts
+++ b/data/locale/pt.ts
@@ -197,6 +197,10 @@ Esteban Viveros
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+ Amostra não encontrada: %1
+
AudioFileProcessorWaveView
diff --git a/data/locale/ru.ts b/data/locale/ru.ts
index 6acc4186a..ce01e3d40 100644
--- a/data/locale/ru.ts
+++ b/data/locale/ru.ts
@@ -197,6 +197,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/sv.ts b/data/locale/sv.ts
index 80f960d76..c170ed0d4 100644
--- a/data/locale/sv.ts
+++ b/data/locale/sv.ts
@@ -193,6 +193,10 @@ If you're interested in translating LMMS in another language or want to imp
With this knob you can set the point where the loop starts.
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/data/locale/zh.ts b/data/locale/zh.ts
index a4993226a..d1df46aee 100644
--- a/data/locale/zh.ts
+++ b/data/locale/zh.ts
@@ -201,6 +201,10 @@ Jeff Bai,邮箱:jeffbaichina@gmail.com
With this knob you can set the point where the loop starts.
调节此旋钮,以设置循环开始的地方。
+
+ Sample not found: %1
+
+
AudioFileProcessorWaveView
diff --git a/include/FileBrowser.h b/include/FileBrowser.h
index 97e20f4bc..4f9b78c48 100644
--- a/include/FileBrowser.h
+++ b/include/FileBrowser.h
@@ -161,6 +161,8 @@ private:
QStringList m_directories;
QString m_filter;
+ int m_dirCount;
+
} ;
diff --git a/include/MainWindow.h b/include/MainWindow.h
index 468a31524..d02b68494 100644
--- a/include/MainWindow.h
+++ b/include/MainWindow.h
@@ -30,6 +30,8 @@
#include
#include
+#include "export.h"
+
class QAction;
class QDomElement;
class QGridLayout;
@@ -40,7 +42,7 @@ class PluginView;
class ToolButton;
-class MainWindow : public QMainWindow
+class EXPORT MainWindow : public QMainWindow
{
Q_OBJECT
public:
@@ -96,9 +98,9 @@ public:
static void restoreWidgetState( QWidget * _w, const QDomElement & _de );
void collectErrors( const QList* errors );
- void collectError( const QString error );
+ void collectError( const QString & error );
void clearErrors();
- void showErrors( const QString reason );
+ void showErrors( const QString & reason );
public slots:
diff --git a/include/MidiTime.h b/include/MidiTime.h
index 5c49f780d..788e6fb57 100644
--- a/include/MidiTime.h
+++ b/include/MidiTime.h
@@ -137,7 +137,8 @@ public:
static int stepsPerTact()
{
- return qMax( 1, ticksPerTact() / DefaultBeatsPerTact );
+ int steps = ticksPerTact() / DefaultBeatsPerTact;
+ return qMax( 1, steps );
}
static void setTicksPerTact( tick_t _tpt )
diff --git a/include/Note.h b/include/Note.h
index cdd5a717e..d5cc0363e 100644
--- a/include/Note.h
+++ b/include/Note.h
@@ -91,9 +91,9 @@ public:
virtual ~Note();
// used by GUI
- inline void setSelected( const bool _selected ){ m_selected = _selected; }
- inline void setOldKey( const int _oldKey ){ m_oldKey = _oldKey; }
- inline void setOldPos( const MidiTime & _oldPos ){ m_oldPos = _oldPos; }
+ inline void setSelected( const bool _selected ) { m_selected = _selected; }
+ inline void setOldKey( const int _oldKey ) { m_oldKey = _oldKey; }
+ inline void setOldPos( const MidiTime & _oldPos ) { m_oldPos = _oldPos; }
inline void setOldLength( const MidiTime & _oldLength )
{
m_oldLength = _oldLength;
diff --git a/include/PianoRoll.h b/include/PianoRoll.h
index 34b6693a0..bc2a0d8cb 100644
--- a/include/PianoRoll.h
+++ b/include/PianoRoll.h
@@ -304,7 +304,7 @@ private:
volume_t m_lastNoteVolume;
panning_t m_lastNotePanning;
- int m_startKey; // first key when drawing
+ int m_startKey; // first key when drawing
int m_lastKey;
EditModes m_editMode;
diff --git a/include/PlayHandle.h b/include/PlayHandle.h
index b96ec55ad..ea66cc65c 100644
--- a/include/PlayHandle.h
+++ b/include/PlayHandle.h
@@ -55,6 +55,8 @@ public:
m_type = p.m_type;
m_offset = p.m_offset;
m_affinity = p.m_affinity;
+ m_usesBuffer = p.m_usesBuffer;
+ m_audioPort = p.m_audioPort;
return *this;
}
diff --git a/include/Track.h b/include/Track.h
index 800524a9e..d09b955fc 100644
--- a/include/Track.h
+++ b/include/Track.h
@@ -121,6 +121,16 @@ public:
return m_length;
}
+ inline void setAutoResize( const bool _r )
+ {
+ m_autoResize = _r;
+ }
+
+ inline const bool getAutoResize() const
+ {
+ return m_autoResize;
+ }
+
virtual void movePosition( const MidiTime & _pos );
virtual void changeLength( const MidiTime & _length );
@@ -165,6 +175,7 @@ private:
BoolModel m_mutedModel;
BoolModel m_soloModel;
+ bool m_autoResize;
bool m_selectViewOnCreate;
@@ -216,7 +227,6 @@ protected:
virtual void mouseMoveEvent( QMouseEvent * _me );
virtual void mouseReleaseEvent( QMouseEvent * _me );
- void setAutoResizeEnabled( bool _e = false );
float pixelsPerTact();
inline TrackView * getTrackView()
@@ -248,7 +258,6 @@ private:
TrackContentObject * m_tco;
TrackView * m_trackView;
Actions m_action;
- bool m_autoResize;
QPoint m_initialMousePos;
QPoint m_initialMouseGlobalPos;
diff --git a/include/TrackContainer.h b/include/TrackContainer.h
index d932f32dd..2e31e0814 100644
--- a/include/TrackContainer.h
+++ b/include/TrackContainer.h
@@ -42,6 +42,11 @@ class EXPORT TrackContainer : public Model, public JournallingObject
Q_OBJECT
public:
typedef QVector TrackList;
+ enum TrackContainerTypes
+ {
+ BBContainer,
+ SongContainer
+ } ;
TrackContainer();
virtual ~TrackContainer();
@@ -78,6 +83,16 @@ public:
return "trackcontainer";
}
+ inline void setType( TrackContainerTypes newType )
+ {
+ m_TrackContainerType = newType;
+ }
+
+ inline TrackContainerTypes type() const
+ {
+ return m_TrackContainerType;
+ }
+
signals:
void trackAdded( Track * _track );
@@ -88,6 +103,8 @@ protected:
private:
TrackList m_tracks;
+ TrackContainerTypes m_TrackContainerType;
+
friend class TrackContainerView;
friend class Track;
diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h
index 7e9dee437..3431289b1 100644
--- a/include/TrackContainerView.h
+++ b/include/TrackContainerView.h
@@ -33,6 +33,7 @@
#include "Track.h"
#include "JournallingObject.h"
+#include "InstrumentTrack.h"
class QVBoxLayout;
@@ -182,6 +183,19 @@ signals:
} ;
+class InstrumentLoaderThread : public QThread
+{
+ Q_OBJECT
+public:
+ InstrumentLoaderThread( QObject *parent = 0, InstrumentTrack *it = 0,
+ QString name = "" );
+ void run();
+
+private:
+ InstrumentTrack *m_it;
+ QString m_name;
+ QThread *m_containerThread;
+};
#endif
diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp
index d7318de3b..64e87b8da 100644
--- a/plugins/Eq/EqParameterWidget.cpp
+++ b/plugins/Eq/EqParameterWidget.cpp
@@ -234,7 +234,7 @@ EqBand* EqParameterWidget::selectNearestHandle( const int x, const int y )
{
selectedModel = &m_bands[shortestBand];
}
- delete distanceToHandles;
+ delete[] distanceToHandles;
return selectedModel;
}
diff --git a/plugins/GigPlayer/CMakeLists.txt b/plugins/GigPlayer/CMakeLists.txt
index 4be4dff82..24db813bd 100644
--- a/plugins/GigPlayer/CMakeLists.txt
+++ b/plugins/GigPlayer/CMakeLists.txt
@@ -6,8 +6,14 @@ if(LMMS_HAVE_GIG)
SET(GCC_COVERAGE_COMPILE_FLAGS "-fexceptions")
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
- LINK_DIRECTORIES(${GIG_LIBRARY_DIRS})
- LINK_LIBRARIES(${GIG_LIBRARIES})
+ # disable deprecated check for mingw-x-libgig
+ if(LMMS_BUILD_WIN32)
+ SET(GCC_GIG_COMPILE_FLAGS "-Wno-deprecated")
+ add_definitions(${GCC_GIG_COMPILE_FLAGS})
+ endif(LMMS_BUILD_WIN32)
+
+ LINK_DIRECTORIES(${GIG_LIBRARY_DIRS} ${SAMPLERATE_LIBRARY_DIRS})
+ LINK_LIBRARIES(${GIG_LIBRARIES} ${SAMPLERATE_LIBRARIES})
BUILD_PLUGIN(gigplayer GigPlayer.cpp GigPlayer.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui MOCFILES GigPlayer.h PatchesDialog.h UICFILES PatchesDialog.ui EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
endif(LMMS_HAVE_GIG)
diff --git a/plugins/LadspaEffect/LadspaControlDialog.cpp b/plugins/LadspaEffect/LadspaControlDialog.cpp
index b84fc9b0b..2ea15f1f7 100644
--- a/plugins/LadspaEffect/LadspaControlDialog.cpp
+++ b/plugins/LadspaEffect/LadspaControlDialog.cpp
@@ -107,7 +107,7 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl )
grouper->setAlignment( Qt::Vertical );
for( control_list_t::iterator it = controls.begin();
- it != controls.end(); it++ )
+ it != controls.end(); ++it )
{
if( (*it)->port()->proc == proc )
{
diff --git a/plugins/LadspaEffect/calf/src/organ.cpp b/plugins/LadspaEffect/calf/src/organ.cpp
index fad15edb5..c90fc50bd 100644
--- a/plugins/LadspaEffect/calf/src/organ.cpp
+++ b/plugins/LadspaEffect/calf/src/organ.cpp
@@ -983,7 +983,7 @@ bool drawbar_organ::check_percussion() {
void drawbar_organ::pitch_bend(int amt)
{
parameters->pitch_bend = pow(2.0, (amt * parameters->pitch_bend_range) / (1200.0 * 8192.0));
- for (list::iterator i = active_voices.begin(); i != active_voices.end(); i++)
+ for (list::iterator i = active_voices.begin(); i != active_voices.end(); ++i)
{
organ_voice *v = dynamic_cast(*i);
v->update_pitch();
diff --git a/plugins/LadspaEffect/calf/src/synth.cpp b/plugins/LadspaEffect/calf/src/synth.cpp
index fcda18b22..d7074a7c3 100644
--- a/plugins/LadspaEffect/calf/src/synth.cpp
+++ b/plugins/LadspaEffect/calf/src/synth.cpp
@@ -25,7 +25,7 @@ using namespace std;
void basic_synth::kill_note(int note, int vel, bool just_one)
{
- for (list::iterator it = active_voices.begin(); it != active_voices.end(); it++) {
+ for (list::iterator it = active_voices.begin(); it != active_voices.end(); ++it) {
// preserve sostenuto notes
if ((*it)->get_current_note() == note && !(sostenuto && (*it)->sostenuto)) {
(*it)->note_off(vel);
@@ -58,7 +58,7 @@ dsp::voice *basic_synth::steal_voice()
std::list::iterator found = active_voices.end();
float priority = 10000;
//int idx = 0;
- for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); i++)
+ for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); ++i)
{
//printf("Voice %d priority %f at %p\n", idx++, (*i)->get_priority(), *i);
if ((*i)->get_priority() < priority)
@@ -79,7 +79,7 @@ void basic_synth::trim_voices()
{
// count stealable voices
unsigned int count = 0;
- for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); i++)
+ for(std::list::iterator i = active_voices.begin(); i != active_voices.end(); ++i)
{
if ((*i)->get_priority() < 10000)
count++;
@@ -118,7 +118,7 @@ void basic_synth::note_off(int note, int vel)
kill_note(note, vel, false);
}
-#define for_all_voices(iter) for (std::list::iterator iter = active_voices.begin(); iter != active_voices.end(); iter++)
+#define for_all_voices(iter) for (std::list::iterator iter = active_voices.begin(); iter != active_voices.end(); ++iter)
void basic_synth::on_pedal_release()
{
@@ -204,7 +204,7 @@ void basic_synth::render_to(float (*output)[2], int nsamples)
unused_voices.push(v);
continue;
}
- i++;
+ ++i;
}
}
@@ -214,7 +214,7 @@ basic_synth::~basic_synth()
delete unused_voices.top();
unused_voices.pop();
}
- for (list::iterator i = active_voices.begin(); i != active_voices.end(); i++)
+ for (list::iterator i = active_voices.begin(); i != active_voices.end(); ++i)
delete *i;
}
diff --git a/plugins/LadspaEffect/calf/src/utils.cpp b/plugins/LadspaEffect/calf/src/utils.cpp
index c1c3eaff2..5d5f33b87 100644
--- a/plugins/LadspaEffect/calf/src/utils.cpp
+++ b/plugins/LadspaEffect/calf/src/utils.cpp
@@ -33,7 +33,7 @@ string encode_map(const dictionary &data)
osctl::string_buffer sb;
osc_stream str(sb);
str << (uint32_t)data.size();
- for(dictionary::const_iterator i = data.begin(); i != data.end(); i++)
+ for(dictionary::const_iterator i = data.begin(); i != data.end(); ++i)
{
str << i->first << i->second;
}
diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp
index 570908d85..2caf210ae 100644
--- a/plugins/audio_file_processor/audio_file_processor.cpp
+++ b/plugins/audio_file_processor/audio_file_processor.cpp
@@ -34,6 +34,8 @@
#include "audio_file_processor.h"
#include "Engine.h"
#include "Song.h"
+#include "MainWindow.h"
+#include "GuiApplication.h"
#include "InstrumentTrack.h"
#include "NotePlayHandle.h"
#include "interpolation.h"
@@ -234,6 +236,14 @@ void audioFileProcessor::loadSettings( const QDomElement & _this )
if( _this.attribute( "src" ) != "" )
{
setAudioFile( _this.attribute( "src" ), false );
+
+ QString absolutePath = m_sampleBuffer.tryToMakeAbsolute( m_sampleBuffer.audioFile() );
+ if ( !QFileInfo( absolutePath ).exists() )
+ {
+ QString message = tr( "Sample not found: %1" ).arg( m_sampleBuffer.audioFile() );
+
+ gui->mainWindow()->collectError( message );
+ }
}
else if( _this.attribute( "sampledata" ) != "" )
{
diff --git a/plugins/ladspa_browser/ladspa_description.cpp b/plugins/ladspa_browser/ladspa_description.cpp
index 76efcb182..fd00fb587 100644
--- a/plugins/ladspa_browser/ladspa_description.cpp
+++ b/plugins/ladspa_browser/ladspa_description.cpp
@@ -70,7 +70,7 @@ ladspaDescription::ladspaDescription( QWidget * _parent,
QList pluginNames;
for( l_sortable_plugin_t::iterator it = plugins.begin();
- it != plugins.end(); it++ )
+ it != plugins.end(); ++it )
{
if( _type != VALID ||
manager->getDescription( ( *it ).second )->inputChannels
diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp
index 91d9d6e8f..f2acd2f07 100644
--- a/plugins/sf2_player/sf2_player.cpp
+++ b/plugins/sf2_player/sf2_player.cpp
@@ -649,14 +649,19 @@ void sf2Instrument::play( sampleFrame * _working_buffer )
if( m_lastMidiPitch != currentMidiPitch )
{
m_lastMidiPitch = currentMidiPitch;
+ m_synthMutex.lock();
fluid_synth_pitch_bend( m_synth, m_channel, m_lastMidiPitch );
+ m_synthMutex.unlock();
+
}
const int currentMidiPitchRange = instrumentTrack()->midiPitchRange();
if( m_lastMidiPitchRange != currentMidiPitchRange )
{
m_lastMidiPitchRange = currentMidiPitchRange;
+ m_synthMutex.lock();
fluid_synth_pitch_wheel_sens( m_synth, m_channel, m_lastMidiPitchRange );
+ m_synthMutex.unlock();
}
// if we have no new noteons/noteoffs, just render a period and call it a day
if( m_playingNotes.isEmpty() )
diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp
index ecfa30d3f..beb11bd2d 100644
--- a/src/core/AutomationPattern.cpp
+++ b/src/core/AutomationPattern.cpp
@@ -51,6 +51,21 @@ AutomationPattern::AutomationPattern( AutomationTrack * _auto_track ) :
m_lastRecordedValue( 0 )
{
changeLength( MidiTime( 1, 0 ) );
+ if( getTrack() )
+ {
+ switch( getTrack()->trackContainer()->type() )
+ {
+ case TrackContainer::BBContainer:
+ setAutoResize( true );
+ break;
+
+ case TrackContainer::SongContainer:
+ // move down
+ default:
+ setAutoResize( false );
+ break;
+ }
+ }
}
@@ -69,6 +84,18 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) :
m_timeMap[it.key()] = it.value();
m_tangents[it.key()] = _pat_to_copy.m_tangents[it.key()];
}
+ switch( getTrack()->trackContainer()->type() )
+ {
+ case TrackContainer::BBContainer:
+ setAutoResize( true );
+ break;
+
+ case TrackContainer::SongContainer:
+ // move down
+ default:
+ setAutoResize( false );
+ break;
+ }
}
@@ -186,7 +213,7 @@ MidiTime AutomationPattern::putValue( const MidiTime & _time,
timeMap::const_iterator it = m_timeMap.find( newTime );
if( it != m_timeMap.begin() )
{
- it--;
+ --it;
}
generateTangents(it, 3);
@@ -219,7 +246,7 @@ void AutomationPattern::removeValue( const MidiTime & _time,
timeMap::const_iterator it = m_timeMap.lowerBound( newTime );
if( it != m_timeMap.begin() )
{
- it--;
+ --it;
}
generateTangents(it, 3);
@@ -260,7 +287,7 @@ MidiTime AutomationPattern::setDragValue( const MidiTime & _time, const float _v
//Restore to the state before it the point were being dragged
m_timeMap = m_oldTimeMap;
- for( timeMap::const_iterator it = m_timeMap.begin(); it != m_timeMap.end(); it++ )
+ for( timeMap::const_iterator it = m_timeMap.begin(); it != m_timeMap.end(); ++it )
{
generateTangents(it, 3);
}
diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp
index 7bf59f1d7..839e40994 100644
--- a/src/core/BBTrackContainer.cpp
+++ b/src/core/BBTrackContainer.cpp
@@ -42,6 +42,7 @@ BBTrackContainer::BBTrackContainer() :
// not change upon setCurrentBB()-call
connect( &m_bbComboBoxModel, SIGNAL( dataUnchanged() ),
this, SLOT( currentBBChanged() ) );
+ setType( BBContainer );
}
diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp
index 358e31171..e6d1767ff 100644
--- a/src/core/FxMixer.cpp
+++ b/src/core/FxMixer.cpp
@@ -230,7 +230,7 @@ int FxMixer::createChannel()
void FxMixer::activateSolo()
{
- for (int i = 0; i < m_fxChannels.size(); ++i)
+ for (int i = 1; i < m_fxChannels.size(); ++i)
{
m_fxChannels[i]->m_muteBeforeSolo = m_fxChannels[i]->m_muteModel.value();
m_fxChannels[i]->m_muteModel.setValue( true );
@@ -239,7 +239,7 @@ void FxMixer::activateSolo()
void FxMixer::deactivateSolo()
{
- for (int i = 0; i < m_fxChannels.size(); ++i)
+ for (int i = 1; i < m_fxChannels.size(); ++i)
{
m_fxChannels[i]->m_muteModel.setValue( m_fxChannels[i]->m_muteBeforeSolo );
}
diff --git a/src/core/Ladspa2LMMS.cpp b/src/core/Ladspa2LMMS.cpp
index 08489beff..7f8e4d67f 100644
--- a/src/core/Ladspa2LMMS.cpp
+++ b/src/core/Ladspa2LMMS.cpp
@@ -32,7 +32,7 @@ Ladspa2LMMS::Ladspa2LMMS()
l_sortable_plugin_t plugins = getSortedPlugins();
for( l_sortable_plugin_t::iterator it = plugins.begin();
- it != plugins.end(); it++ )
+ it != plugins.end(); ++it )
{
ladspa_key_t key = (*it).second;
ladspaManagerDescription * desc = getDescription( key );
diff --git a/src/core/LadspaManager.cpp b/src/core/LadspaManager.cpp
index 50e791b9e..8dcb20158 100644
--- a/src/core/LadspaManager.cpp
+++ b/src/core/LadspaManager.cpp
@@ -96,7 +96,7 @@ LadspaManager::LadspaManager()
l_ladspa_key_t keys = m_ladspaManagerMap.keys();
for( l_ladspa_key_t::iterator it = keys.begin();
- it != keys.end(); it++ )
+ it != keys.end(); ++it )
{
m_sortedPlugins.append( qMakePair( getName( *it ), *it ) );
}
diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp
index dceb5b0d2..69b550fdc 100644
--- a/src/core/PresetPreviewPlayHandle.cpp
+++ b/src/core/PresetPreviewPlayHandle.cpp
@@ -147,9 +147,19 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file,
else
{
DataFile dataFile( _preset_file );
- s_previewTC->previewInstrumentTrack()->
- loadTrackSpecificSettings(
- dataFile.content().firstChild().toElement() );
+ // vestige previews are bug prone; fallback on 3xosc with volume of 0
+ // without an instrument in preview track, it will segfault
+ if(dataFile.content().elementsByTagName( "vestige" ).length() == 0 )
+ {
+ s_previewTC->previewInstrumentTrack()->
+ loadTrackSpecificSettings(
+ dataFile.content().firstChild().toElement() );
+ }
+ else
+ {
+ s_previewTC->previewInstrumentTrack()->loadInstrument("tripleoscillator");
+ s_previewTC->previewInstrumentTrack()->setVolume( 0 );
+ }
}
Engine::setSuppressMessages( false );
diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp
index a881a5f8e..1bcf6691e 100644
--- a/src/core/SamplePlayHandle.cpp
+++ b/src/core/SamplePlayHandle.cpp
@@ -98,14 +98,15 @@ SamplePlayHandle::~SamplePlayHandle()
void SamplePlayHandle::play( sampleFrame * buffer )
{
+ const fpp_t fpp = Engine::mixer()->framesPerPeriod();
//play( 0, _try_parallelizing );
if( framesDone() >= totalFrames() )
{
+ memset( buffer, 0, sizeof( sampleFrame ) * fpp );
return;
}
sampleFrame * workingBuffer = buffer;
- const fpp_t fpp = Engine::mixer()->framesPerPeriod();
f_cnt_t frames = fpp;
// apply offset for the first period
diff --git a/src/core/Song.cpp b/src/core/Song.cpp
index b77431b22..07d55a0dd 100644
--- a/src/core/Song.cpp
+++ b/src/core/Song.cpp
@@ -116,6 +116,7 @@ Song::Song() :
this, SLOT( masterPitchChanged() ) );*/
qRegisterMetaType( "note" );
+ setType( SongContainer );
}
diff --git a/src/core/Track.cpp b/src/core/Track.cpp
index 1a2de1e3e..ad25f979c 100644
--- a/src/core/Track.cpp
+++ b/src/core/Track.cpp
@@ -249,7 +249,6 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * _tco,
m_tco( _tco ),
m_trackView( _tv ),
m_action( NoAction ),
- m_autoResize( false ),
m_initialMousePos( QPoint( 0, 0 ) ),
m_initialMouseGlobalPos( QPoint( 0, 0 ) ),
m_hint( NULL ),
@@ -657,7 +656,7 @@ void TrackContentObjectView::mousePressEvent( QMouseEvent * _me )
"a copy." ),
embed::getIconPixmap( "hint" ), 0 );
}
- else if( m_autoResize == false )
+ else if( !m_tco->getAutoResize() )
{
m_action = Resize;
m_oldTime = m_tco->length();
@@ -847,7 +846,7 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * _me )
}
else
{
- if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() )
+ if( _me->x() > width() - RESIZE_GRIP_WIDTH && !_me->buttons() && !m_tco->getAutoResize() )
{
if( QApplication::overrideCursor() != NULL &&
QApplication::overrideCursor()->shape() !=
@@ -958,19 +957,6 @@ float TrackContentObjectView::pixelsPerTact()
-/*! \brief Set whether this trackContentObjectView can resize.
- *
- * \param _e The boolean state of whether this track content object view
- * is allowed to resize.
- */
-void TrackContentObjectView::setAutoResizeEnabled( bool _e )
-{
- m_autoResize = _e;
-}
-
-
-
-
/*! \brief Detect whether the mouse moved more than n pixels on screen.
*
* \param _me The QMouseEvent.
@@ -1403,6 +1389,11 @@ bool TrackContentWidget::pasteSelection( MidiTime tcoPos, QDropEvent * _de )
{
tco->selectViewOnCreate( true );
}
+ //check tco name, if the same as source track name dont copy
+ if( tco->name() == tracks[trackIndex]->name() )
+ {
+ tco->setName( "" );
+ }
}
AutomationPattern::resolveAllIDs();
@@ -1770,7 +1761,7 @@ void TrackOperationsWidget::recordingOn()
if( atv )
{
const Track::tcoVector & tcov = atv->getTrack()->getTCOs();
- for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); it++ )
+ for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); ++it )
{
AutomationPattern * ap = dynamic_cast( *it );
if( ap ) { ap->setRecording( true ); }
@@ -1786,7 +1777,7 @@ void TrackOperationsWidget::recordingOff()
if( atv )
{
const Track::tcoVector & tcov = atv->getTrack()->getTCOs();
- for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); it++ )
+ for( Track::tcoVector::const_iterator it = tcov.begin(); it != tcov.end(); ++it )
{
AutomationPattern * ap = dynamic_cast( *it );
if( ap ) { ap->setRecording( false ); }
diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp
index 72efe883c..798418bf2 100644
--- a/src/core/audio/AudioFileOgg.cpp
+++ b/src/core/audio/AudioFileOgg.cpp
@@ -120,6 +120,7 @@ bool AudioFileOgg::startEncoding()
printf( "Mode initialization failed: invalid parameters for "
"bitrate\n" );
vorbis_info_clear( &m_vi );
+ delete[] user_comments;
return false;
}
diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp
index fb3a5d042..34bc81dfe 100644
--- a/src/gui/AutomationPatternView.cpp
+++ b/src/gui/AutomationPatternView.cpp
@@ -54,7 +54,6 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern,
setAttribute( Qt::WA_OpaquePaintEvent, true );
setFixedHeight( parentWidget()->height() - 2 );
- setAutoResizeEnabled( false );
ToolTip::add( this, tr( "double-click to open this pattern in "
"automation editor" ) );
@@ -267,7 +266,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * )
if( isSelected() == true )
{
- c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
+ c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
}
lingrad.setColorAt( 1, c.darker( 300 ) );
diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp
index e8effe9fb..80390293f 100644
--- a/src/gui/FileBrowser.cpp
+++ b/src/gui/FileBrowser.cpp
@@ -709,7 +709,8 @@ Directory::Directory(const QString & filename, const QString & path,
const QString & filter ) :
QTreeWidgetItem( QStringList( filename ), TypeDirectoryItem ),
m_directories( path ),
- m_filter( filter )
+ m_filter( filter ),
+ m_dirCount( 0 )
{
initPixmaps();
@@ -763,6 +764,7 @@ void Directory::update( void )
setIcon( 0, *s_folderOpenedPixmap );
if( !childCount() )
{
+ m_dirCount = 0;
for( QStringList::iterator it = m_directories.begin();
it != m_directories.end(); ++it )
{
@@ -777,7 +779,7 @@ void Directory::update( void )
"--- Factory files ---" ) );
sep->setIcon( 0, embed::getIconPixmap(
"factory_files" ) );
- insertChild( top_index, sep );
+ insertChild( m_dirCount + top_index - 1, sep );
}
}
}
@@ -815,6 +817,7 @@ bool Directory::addItems(const QString & path )
insertChild( i, new Directory( cur_file,
path, m_filter ) );
orphan = false;
+ m_dirCount++;
break;
}
else if( cur_file == d->text( 0 ) )
@@ -828,6 +831,7 @@ bool Directory::addItems(const QString & path )
{
addChild( new Directory( cur_file, path,
m_filter ) );
+ m_dirCount++;
}
added_something = true;
diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp
index 45768cddb..7211bd2e1 100644
--- a/src/gui/MainWindow.cpp
+++ b/src/gui/MainWindow.cpp
@@ -1235,7 +1235,7 @@ void MainWindow::collectErrors(const QList* errors )
-void MainWindow::collectError( const QString error )
+void MainWindow::collectError( const QString & error )
{
m_errors->append( error );
}
@@ -1249,7 +1249,7 @@ void MainWindow::clearErrors()
-void MainWindow::showErrors( const QString message )
+void MainWindow::showErrors( const QString & message )
{
if ( m_errors->length() != 0 )
{ QString* errors = new QString();
diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp
index e87eac326..5c10dd368 100644
--- a/src/gui/PluginBrowser.cpp
+++ b/src/gui/PluginBrowser.cpp
@@ -99,8 +99,8 @@ PluginDescList::PluginDescList(QWidget *parent) :
std::sort(m_pluginDescriptors.begin(), m_pluginDescriptors.end(), pluginBefore);
- for(Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin();
- it != m_pluginDescriptors.constEnd(); it++)
+ for( Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin();
+ it != m_pluginDescriptors.constEnd(); ++it )
{
if( it->type == Plugin::Instrument )
{
diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp
index 94c72d278..a2d3ce12b 100644
--- a/src/gui/TrackContainerView.cpp
+++ b/src/gui/TrackContainerView.cpp
@@ -325,7 +325,9 @@ void TrackContainerView::dropEvent( QDropEvent * _de )
InstrumentTrack * it = dynamic_cast(
Track::create( Track::InstrumentTrack,
m_tc ) );
- it->loadInstrument( value );
+ InstrumentLoaderThread *ilt = new InstrumentLoaderThread(
+ this, it, value );
+ ilt->start();
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
@@ -453,6 +455,22 @@ void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we )
+InstrumentLoaderThread::InstrumentLoaderThread( QObject *parent, InstrumentTrack *it, QString name ) :
+ QThread( parent ),
+ m_it( it ),
+ m_name( name )
+{
+ m_containerThread = thread();
+}
+
+void InstrumentLoaderThread::run()
+{
+ Instrument *i = m_it->loadInstrument( m_name );
+ QObject *parent = i->parent();
+ i->setParent( 0 );
+ i->moveToThread( m_containerThread );
+ i->setParent( parent );
+}
diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp
index cfb444f7b..c4e4bdcb8 100644
--- a/src/gui/editors/PianoRoll.cpp
+++ b/src/gui/editors/PianoRoll.cpp
@@ -80,9 +80,6 @@
typedef AutomationPattern::timeMap timeMap;
-extern Keys whiteKeys[]; // defined in piano_widget.cpp
-
-
// some constants...
const int INITIAL_PIANOROLL_HEIGHT = 480;
@@ -536,7 +533,7 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern )
m_currentNote = NULL;
m_startKey = INITIAL_START_KEY;
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
//resizeEvent( NULL );
setWindowTitle( tr( "Piano-Roll - no pattern" ) );
@@ -550,16 +547,17 @@ void PianoRoll::setCurrentPattern( Pattern* newPattern )
const NoteVector & notes = m_pattern->notes();
int central_key = 0;
- if( notes.empty() == false )
+ if( ! notes.empty() )
{
// determine the central key so that we can scroll to it
int total_notes = 0;
for( NoteVector::ConstIterator it = notes.begin();
it != notes.end(); ++it )
{
- if( ( *it )->length() > 0 )
+ Note *note = *it;
+ if( note->length() > 0 )
{
- central_key += ( *it )->key();
+ central_key += note->key();
++total_notes;
}
}
@@ -755,8 +753,6 @@ void PianoRoll::removeSelection()
m_selectedTick = 0;
m_selectStartKey = 0;
m_selectedKeys = 0;
-
-
}
@@ -770,12 +766,10 @@ void PianoRoll::clearSelectedNotes()
const NoteVector & notes = m_pattern->notes();
// will be our iterator in the following loop
- NoteVector::ConstIterator it = notes.begin();
- while( it != notes.end() )
- {
- ( *it )->setSelected( false );
-
- ++it;
+ NoteVector::ConstIterator it;
+ for( it = notes.begin(); it != notes.end(); ++it ) {
+ Note *note = *it;
+ note->setSelected( false );
}
}
}
@@ -787,21 +781,21 @@ void PianoRoll::shiftSemiTone( int amount ) // shift notes by amount semitones
{
bool useAllNotes = ! isSelection();
const NoteVector & notes = m_pattern->notes();
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end();
- ++it )
+ NoteVector::ConstIterator it;
+ for( it = notes.begin(); it != notes.end(); ++it )
{
+ Note *note = *it;
// if none are selected, move all notes, otherwise
// only move selected notes
- if( useAllNotes || ( *it )->selected() )
+ if( useAllNotes || note->selected() )
{
- ( *it )->setKey( ( *it )->key() + amount );
+ note->setKey( note->key() + amount );
}
}
// we modified the song
update();
gui->songEditor()->update();
-
}
@@ -811,26 +805,27 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount
{
bool useAllNotes = ! isSelection();
const NoteVector & notes = m_pattern->notes();
+ NoteVector::ConstIterator it;
bool first = true;
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end();
- ++it )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
+ Note *note = *it;
// if none are selected, move all notes, otherwise
// only move selected notes
- if( ( *it )->selected() || (useAllNotes && ( *it )->length() > 0) )
+ if( note->selected() || (useAllNotes && note->length() > 0) )
{
// don't let notes go to out of bounds
if( first )
{
- m_moveBoundaryLeft = ( *it )->pos();
+ m_moveBoundaryLeft = note->pos();
if( m_moveBoundaryLeft + amount < 0 )
{
amount += 0 - (amount + m_moveBoundaryLeft);
}
first = false;
}
- ( *it )->setPos( ( *it )->pos() + amount );
+ note->setPos( note->pos() + amount );
}
}
@@ -845,9 +840,11 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount
bool PianoRoll::isSelection() const // are any notes selected?
{
const NoteVector & notes = m_pattern->notes();
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it )
+ NoteVector::ConstIterator it;
+ for( it = notes.begin(); it != notes.end(); ++it )
{
- if( ( *it )->selected() )
+ Note *note = *it;
+ if( note->selected() )
{
return true;
}
@@ -863,9 +860,11 @@ int PianoRoll::selectionCount() const // how many notes are selected?
int sum = 0;
const NoteVector & notes = m_pattern->notes();
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it )
+ NoteVector::ConstIterator it;
+ for( it = notes.begin(); it != notes.end(); ++it )
{
- if( ( *it )->selected() )
+ Note *note = *it;
+ if( note->selected() )
{
++sum;
}
@@ -882,7 +881,7 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
{
const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave;
- if( ke->isAutoRepeat() == false && key_num > -1 )
+ if(! ke->isAutoRepeat() && key_num > -1)
{
m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num );
ke->accept();
@@ -1097,7 +1096,7 @@ void PianoRoll::keyReleaseEvent(QKeyEvent* ke )
{
const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave;
- if( ke->isAutoRepeat() == false && key_num > -1 )
+ if( ! ke->isAutoRepeat() && key_num > -1 )
{
m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( key_num );
ke->accept();
@@ -1195,7 +1194,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
{
m_startedWithShift = me->modifiers() & Qt::ShiftModifier;
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -1261,22 +1260,23 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// loop through whole note-vector...
for( int i = 0; i < notes.size(); ++i )
{
- MidiTime len = ( *it )->length();
+ Note *note = *it;
+ MidiTime len = note->length();
if( len < 0 )
{
len = 4;
}
// and check whether the user clicked on an
// existing note or an edit-line
- if( pos_ticks >= ( *it )->pos() &&
+ if( pos_ticks >= note->pos() &&
len > 0 &&
(
- ( edit_note == false &&
- pos_ticks <= ( *it )->pos() + len &&
- ( *it )->key() == key_num )
+ ( ! edit_note &&
+ pos_ticks <= note->pos() + len &&
+ note->key() == key_num )
||
- ( edit_note == true &&
- pos_ticks <= ( *it )->pos() +
+ ( edit_note &&
+ pos_ticks <= note->pos() +
NE_LINE_WIDTH *
MidiTime::ticksPerTact() /
m_ppt )
@@ -1290,7 +1290,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// first check whether the user clicked in note-edit-
// area
- if( edit_note == true )
+ if( edit_note )
{
m_pattern->addJournalCheckPoint();
// scribble note edit changes
@@ -1360,58 +1360,55 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
{
++it;
}
-
-
}
- m_currentNote = *it;
- m_lastNotePanning = ( *it )->getPanning();
- m_lastNoteVolume = ( *it )->getVolume();
- m_lenOfNewNotes = ( *it )->length();
+ Note *current_note = *it;
+ m_currentNote = current_note;
+ m_lastNotePanning = current_note->getPanning();
+ m_lastNoteVolume = current_note->getVolume();
+ m_lenOfNewNotes = current_note->length();
// remember which key and tick we started with
m_mouseDownKey = m_startKey;
m_mouseDownTick = m_currentPosition;
bool first = true;
- it = notes.begin();
- while( it != notes.end() )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
+ Note *note = *it;
// remember note starting positions
- ( *it )->setOldKey( ( *it )->key() );
- ( *it )->setOldPos( ( *it )->pos() );
- ( *it )->setOldLength( ( *it )->length() );
+ note->setOldKey( note->key() );
+ note->setOldPos( note->pos() );
+ note->setOldLength( note->length() );
- if( ( *it )->selected() )
+ if( note->selected() )
{
// figure out the bounding box of all the selected notes
if( first )
{
- m_moveBoundaryLeft = ( *it )->pos().getTicks();
- m_moveBoundaryRight = ( *it )->pos() + ( *it )->length();
- m_moveBoundaryBottom = ( *it )->key();
- m_moveBoundaryTop = ( *it )->key();
+ m_moveBoundaryLeft = note->pos().getTicks();
+ m_moveBoundaryRight = note->pos() + note->length();
+ m_moveBoundaryBottom = note->key();
+ m_moveBoundaryTop = note->key();
first = false;
}
else
{
m_moveBoundaryLeft = qMin(
- ( *it )->pos().getTicks(),
- m_moveBoundaryLeft );
- m_moveBoundaryRight = qMax( ( *it )->pos() +
- ( *it )->length(),
+ note->pos().getTicks(),
+ (tick_t) m_moveBoundaryLeft );
+ m_moveBoundaryRight = qMax( note->pos() +
+ note->length(),
m_moveBoundaryRight );
- m_moveBoundaryBottom = qMin( ( *it )->key(),
+ m_moveBoundaryBottom = qMin( note->key(),
m_moveBoundaryBottom );
- m_moveBoundaryTop = qMax( ( *it )->key(),
+ m_moveBoundaryTop = qMax( note->key(),
m_moveBoundaryTop );
}
}
-
- ++it;
}
// if clicked on an unselected note, remove selection
@@ -1428,8 +1425,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
// clicked at the "tail" of the note?
- if( pos_ticks*m_ppt/MidiTime::ticksPerTact() >
- ( m_currentNote->pos() + m_currentNote->length() )*m_ppt/ MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH &&
+ if( pos_ticks * m_ppt/MidiTime::ticksPerTact() >
+ ( m_currentNote->pos() + m_currentNote->length() ) * m_ppt/ MidiTime::ticksPerTact() - RESIZE_AREA_WIDTH &&
m_currentNote->length() > 0 )
{
m_pattern->addJournalCheckPoint();
@@ -1455,18 +1452,18 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
QApplication::setOverrideCursor( c );
// if they're holding shift, copy all selected notes
- if( //*it != created_new_note &&
- ! is_new_note && me->modifiers() & Qt::ShiftModifier )
+ if( ! is_new_note && me->modifiers() & Qt::ShiftModifier )
{
// vector to hold new notes until we're through the loop
QVector newNotes;
it = notes.begin();
while( it != notes.end() )
{
- if( ( *it )->selected() )
+ Note *note = *it;
+ if( note->selected() )
{
// copy this note
- Note noteCopy( (Note) **it );
+ Note noteCopy( *note );
newNotes.push_back( noteCopy );
}
++it;
@@ -1475,7 +1472,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
if( newNotes.size() != 0 )
{
//put notes from vector into piano roll
- for( int i=0; iaddNote( newNotes[i] );
newNote->setSelected( false );
@@ -1502,14 +1499,15 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
m_mouseDownRight = true;
if( it != notes.begin()-1 )
{
+ Note *note = *it;
m_pattern->addJournalCheckPoint();
- if( ( *it )->length() > 0 )
+ if( note->length() > 0 )
{
- m_pattern->removeNote( *it );
+ m_pattern->removeNote( note );
}
else
{
- ( *it )->setLength( 0 );
+ note->setLength( 0 );
m_pattern->dataChanged();
}
Engine::getSong()->setModified();
@@ -1526,7 +1524,6 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
m_selectedKeys = 1;
m_action = ActionSelectNotes;
-
// call mousemove to fix glitch where selection
// appears in wrong spot on mousedown
mouseMoveEvent( me );
@@ -1546,11 +1543,8 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
{
// left click - play the note
m_lastKey = key_num;
- //if( ! m_recording && ! engine::getSong()->isPlaying() )
- {
- int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity;
- m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v );
- }
+ int v = ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity;
+ m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num, v );
}
}
else
@@ -1561,7 +1555,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
m_noteEditMode = (NoteEditMode)(((int)m_noteEditMode)+1);
if( m_noteEditMode == NoteEditCount )
{
- m_noteEditMode = (NoteEditMode)0;
+ m_noteEditMode = (NoteEditMode) 0;
}
repaint();
}
@@ -1579,7 +1573,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me )
void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me )
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -1630,7 +1624,8 @@ void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me )
NoteVector::Iterator it = nv.begin();
while( it != nv.end() )
{
- if( ( *it )->pos().getTicks() != closest->pos().getTicks() )
+ Note *note = *it;
+ if( note->pos().getTicks() != closest->pos().getTicks() )
{
it = nv.erase( it );
}
@@ -1652,7 +1647,7 @@ void PianoRoll::testPlayNote( Note * n )
{
m_lastKey = n->key();
- if( n->isPlaying() == false && m_recording == false )
+ if( ! n->isPlaying() && ! m_recording )
{
n->setIsPlaying( true );
@@ -1677,18 +1672,19 @@ void PianoRoll::pauseTestNotes( bool pause )
NoteVector::ConstIterator it = notes.begin();
while( it != notes.end() )
{
- if( ( *it )->isPlaying() )
+ Note *note = *it;
+ if( note->isPlaying() )
{
if( pause )
{
// stop note
- m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() );
+ m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() );
}
else
{
// start note
- ( *it )->setIsPlaying( false );
- testPlayNote( *it );
+ note->setIsPlaying( false );
+ testPlayNote( note );
}
}
@@ -1741,20 +1737,21 @@ void PianoRoll::computeSelectedNotes(bool shift)
}
//int y_base = noteEditTop() - 1;
- if( hasValidPattern() == true )
+ if( hasValidPattern() )
{
const NoteVector & notes = m_pattern->notes();
+ NoteVector::ConstIterator it;
- for( NoteVector::ConstIterator it = notes.begin();
- it != notes.end(); ++it )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
+ Note *note = *it;
// make a new selection unless they're holding shift
if( ! shift )
{
- ( *it )->setSelected( false );
+ note->setSelected( false );
}
- int len_ticks = ( *it )->length();
+ int len_ticks = note->length();
if( len_ticks == 0 )
{
@@ -1765,9 +1762,9 @@ void PianoRoll::computeSelectedNotes(bool shift)
len_ticks = 4;
}
- const int key = ( *it )->key() - m_startKey + 1;
+ const int key = note->key() - m_startKey + 1;
- int pos_ticks = ( *it )->pos();
+ int pos_ticks = note->pos();
// if the selection even barely overlaps the note
if( key > sel_key_start &&
@@ -1776,14 +1773,8 @@ void PianoRoll::computeSelectedNotes(bool shift)
pos_ticks < sel_pos_end )
{
// remove from selection when holding shift
- if( shift && ( *it )->selected() )
- {
- ( *it )->setSelected(false);
- }
- else
- {
- ( *it )->setSelected(true);
- }
+ bool selected = shift && note->selected();
+ note->setSelected( ! selected);
}
}
}
@@ -1843,7 +1834,7 @@ void PianoRoll::mouseReleaseEvent(QMouseEvent * me )
}
- if( hasValidPattern() == true )
+ if( hasValidPattern() )
{
// turn off all notes that are playing
const NoteVector & notes = m_pattern->notes();
@@ -1851,10 +1842,11 @@ void PianoRoll::mouseReleaseEvent(QMouseEvent * me )
NoteVector::ConstIterator it = notes.begin();
while( it != notes.end() )
{
- if( ( *it )->isPlaying() )
+ Note *note = *it;
+ if( note->isPlaying() )
{
- m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() );
- ( *it )->setIsPlaying( false );
+ m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() );
+ note->setIsPlaying( false );
}
++it;
@@ -1884,7 +1876,7 @@ void PianoRoll::mouseReleaseEvent(QMouseEvent * me )
void PianoRoll::mouseMoveEvent( QMouseEvent * me )
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
update();
return;
@@ -1958,7 +1950,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
pauseTestNotes( false );
}
}
- else if( ( edit_note == true || m_action == ActionChangeNoteProperty ) &&
+ else if( ( edit_note || m_action == ActionChangeNoteProperty ) &&
( me->buttons() & Qt::LeftButton || me->buttons() & Qt::MiddleButton
|| ( me->buttons() & Qt::RightButton && me->modifiers() & Qt::ShiftModifier ) ) )
{
@@ -2107,13 +2099,14 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// loop through whole note-vector...
for( int i = 0; i < notes.size(); ++i )
{
+ Note *note = *it;
// and check whether the cursor is over an
// existing note
- if( pos_ticks >= ( *it )->pos() &&
- pos_ticks <= ( *it )->pos() +
- ( *it )->length() &&
- ( *it )->key() == key_num &&
- ( *it )->length() > 0 )
+ if( pos_ticks >= note->pos() &&
+ pos_ticks <= note->pos() +
+ note->length() &&
+ note->key() == key_num &&
+ note->length() > 0 )
{
break;
}
@@ -2124,12 +2117,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// no note??
if( it != notes.begin()-1 )
{
+ Note *note = *it;
// cursor at the "tail" of the note?
- if( ( *it )->length() > 0 &&
+ if( note->length() > 0 &&
pos_ticks*m_ppt /
MidiTime::ticksPerTact() >
- ( ( *it )->pos() +
- ( *it )->length() )*m_ppt/
+ ( note->pos() +
+ note->length() )*m_ppt/
MidiTime::ticksPerTact()-
RESIZE_AREA_WIDTH )
{
@@ -2227,22 +2221,23 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// loop through whole note-vector...
while( it != notes.end() )
{
- MidiTime len = ( *it )->length();
+ Note *note = *it;
+ MidiTime len = note->length();
if( len < 0 )
{
len = 4;
}
// and check whether the user clicked on an
// existing note or an edit-line
- if( pos_ticks >= ( *it )->pos() &&
+ if( pos_ticks >= note->pos() &&
len > 0 &&
(
- ( edit_note == false &&
- pos_ticks <= ( *it )->pos() + len &&
- ( *it )->key() == key_num )
+ ( ! edit_note &&
+ pos_ticks <= note->pos() + len &&
+ note->key() == key_num )
||
- ( edit_note == true &&
- pos_ticks <= ( *it )->pos() +
+ ( edit_note &&
+ pos_ticks <= note->pos() +
NE_LINE_WIDTH *
MidiTime::ticksPerTact() /
m_ppt )
@@ -2252,13 +2247,13 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * me )
// delete this note
if( it != notes.end() )
{
- if( ( *it )->length() > 0 )
+ if( note->length() > 0 )
{
- m_pattern->removeNote( *it );
+ m_pattern->removeNote( note );
}
else
{
- ( *it )->setLength( 0 );
+ note->setLength( 0 );
m_pattern->dataChanged();
}
Engine::getSong()->setModified();
@@ -2408,50 +2403,41 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift )
NoteVector::ConstIterator it = notes.begin();
while( it != notes.end() )
{
- const int pos = ( *it )->pos().getTicks();
+ Note *note = *it;
+ const int pos = note->pos().getTicks();
// when resizing a note and holding shift: shift the following
// notes to preserve the melody
if( m_action == ActionResizeNote && shift )
{
- int shifted_pos = ( *it )->oldPos().getTicks() + shift_offset;
+ int shifted_pos = note->oldPos().getTicks() + shift_offset;
if( shifted_pos && pos == shift_ref_pos )
{
shifted_pos -= off_ticks;
}
- ( *it )->setPos( MidiTime( shifted_pos ) );
+ note->setPos( MidiTime( shifted_pos ) );
}
- if( ( *it )->selected() )
+ if( note->selected() )
{
if( m_action == ActionMoveNote && ! ( shift && ! m_startedWithShift ) )
{
// moving note
- int pos_ticks = ( *it )->oldPos().getTicks()
- + off_ticks;
- int key_num = ( *it )->oldKey() + off_key;
+ int pos_ticks = note->oldPos().getTicks() + off_ticks;
+ int key_num = note->oldKey() + off_key;
- if( pos_ticks < 0 )
- {
- pos_ticks = 0;
- }
+ // ticks can't be negative
+ pos_ticks = qMax(0, pos_ticks);
// upper/lower bound checks on key_num
- if( key_num < 0 )
- {
- key_num = 0;
- }
- else if( key_num > NumKeys )
- {
- key_num = NumKeys;
- }
+ key_num = qMax(0, key_num);
+ key_num = qMin(key_num, NumKeys);
- ( *it )->setPos( MidiTime( pos_ticks ) );
- ( *it )->setKey( key_num );
+ note->setPos( MidiTime( pos_ticks ) );
+ note->setKey( key_num );
}
else if( m_action == ActionResizeNote )
{
// resizing note
- int ticks_new = ( *it )->oldLength().getTicks()
- + off_ticks;
+ int ticks_new = note->oldLength().getTicks() + off_ticks;
if( ticks_new <= 0 )
{
ticks_new = 1;
@@ -2466,20 +2452,20 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift )
shift_ref_pos = pos;
}
}
- ( *it )->setLength( MidiTime( ticks_new ) );
+ note->setLength( MidiTime( ticks_new ) );
- m_lenOfNewNotes = ( *it )->length();
+ m_lenOfNewNotes = note->length();
}
else if( m_action == ActionMoveNote && ( shift && ! m_startedWithShift ) )
{
// quick resize, toggled by holding shift after starting a note move, but not before
- int ticks_new = ( *it )->oldLength().getTicks() + off_ticks;
+ int ticks_new = note->oldLength().getTicks() + off_ticks;
if( ticks_new <= 0 )
{
ticks_new = 1;
}
- ( *it )->setLength( MidiTime( ticks_new ) );
- m_lenOfNewNotes = ( *it )->length();
+ note->setLength( MidiTime( ticks_new ) );
+ m_lenOfNewNotes = note->length();
}
}
++it;
@@ -2492,7 +2478,9 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift )
static QString calculateNoteLabel(QString note, int octave)
{
if(note.isEmpty())
+ {
return "";
+ }
return note + QString::number(octave);
}
@@ -2526,7 +2514,7 @@ static void printNoteHeights(QPainter& p, int bottom, int width, int startKey)
y -= KEY_LINE_HEIGHT, key++)
{
const unsigned note = key % KeysPerOctave;
- assert( note < ( sizeof( labels ) / sizeof( *labels) ));
+ assert( note < ( sizeof( labels ) / sizeof( labels[0] ) ));
const KeyLabel& noteLabel( labels[note] );
const int octave = key / KeysPerOctave;
const KeyLabel notes = {
@@ -2535,7 +2523,6 @@ static void printNoteHeights(QPainter& p, int bottom, int width, int startKey)
calculateNoteLabel(noteLabel.major, octave),
};
-
const int drawWidth( width - WHITE_KEY_WIDTH );
const int hspace = 300;
const int columnCount = drawWidth/hspace + 1;
@@ -2563,7 +2550,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
QBrush bgColor = p.background();
// fill with bg color
- p.fillRect( 0,0, width(), height(), bgColor );
+ p.fillRect( 0, 0, width(), height(), bgColor );
// set font-size to 8
p.setFont( pointSize<8>( p.font() ) );
@@ -2574,8 +2561,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// calculate y_offset according to first key
switch( prKeyOrder[m_startKey % KeysPerOctave] )
{
- case PR_BLACK_KEY: y_offset = KEY_LINE_HEIGHT/4; break;
- case PR_WHITE_KEY_BIG: y_offset = KEY_LINE_HEIGHT/2; break;
+ case PR_BLACK_KEY: y_offset = KEY_LINE_HEIGHT / 4; break;
+ case PR_WHITE_KEY_BIG: y_offset = KEY_LINE_HEIGHT / 2; break;
case PR_WHITE_KEY_SMALL:
if( prKeyOrder[( ( m_startKey + 1 ) %
KeysPerOctave)] != PR_BLACK_KEY )
@@ -2606,7 +2593,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
break;
}
- p.fillRect( WHITE_KEY_WIDTH+1, y-KEY_LINE_HEIGHT/2,
+ p.fillRect( WHITE_KEY_WIDTH + 1, y - KEY_LINE_HEIGHT / 2,
width() - 10, KEY_LINE_HEIGHT,
QColor( 0, 80 - ( key_num % KeysPerOctave ) * 3, 64 + key_num / 2) );
}
@@ -2650,8 +2637,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
y -= WHITE_KEY_SMALL_HEIGHT;
}
- else if( prKeyOrder[key % KeysPerOctave] ==
- PR_WHITE_KEY_BIG )
+ else if( prKeyOrder[key % KeysPerOctave] == PR_WHITE_KEY_BIG )
{
// draw a big one while checking if it is pressed or not
if( hasValidPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
@@ -2676,7 +2662,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
{
const QString cLabel = "C" + QString::number( static_cast( key / KeysPerOctave ) );
p.setPen( QColor( 240, 240, 240 ) );
- p.drawText( C_KEY_LABEL_X + 1, y+14, cLabel );
+ p.drawText( C_KEY_LABEL_X + 1, y + 14, cLabel );
p.setPen( QColor( 0, 0, 0 ) );
p.drawText( C_KEY_LABEL_X, y + 13, cLabel );
horizCol.setAlpha( 192 );
@@ -2764,7 +2750,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// erase the area below the piano, because there might be keys that
// should be only half-visible
p.fillRect( QRect( 0, keyAreaBottom(),
- WHITE_KEY_WIDTH, noteEditBottom()-keyAreaBottom() ), bgColor );
+ WHITE_KEY_WIDTH, noteEditBottom() - keyAreaBottom() ), bgColor );
// display note editing info
QFont f = p.font();
@@ -2828,7 +2814,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
p.setPen( vertCol );
}
- p.drawLine( (int)x, PR_TOP_MARGIN, (int)x, height() -
+ p.drawLine( (int) x, PR_TOP_MARGIN, (int) x, height() -
PR_BOTTOM_MARGIN );
// extra 32nd's line
@@ -2836,8 +2822,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
{
vertCol.setAlpha( 80 );
p.setPen( vertCol );
- p.drawLine( (int)(x + pp16th/2) , PR_TOP_MARGIN,
- (int)(x + pp16th/2), height() -
+ p.drawLine( (int)(x + pp16th / 2) , PR_TOP_MARGIN,
+ (int)(x + pp16th / 2), height() -
PR_BOTTOM_MARGIN );
}
}
@@ -2864,7 +2850,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
}
int y_base = keyAreaBottom() - 1;
- if( hasValidPattern() == true )
+ if( hasValidPattern() )
{
p.setClipRect( WHITE_KEY_WIDTH, PR_TOP_MARGIN,
width() - WHITE_KEY_WIDTH,
@@ -2876,11 +2862,12 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
KEY_LINE_HEIGHT + 2;
QPolygon editHandles;
+ NoteVector::ConstIterator it;
- for( NoteVector::ConstIterator it = notes.begin();
- it != notes.end(); ++it )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
- int len_ticks = ( *it )->length();
+ Note *note = *it;
+ int len_ticks = note->length();
if( len_ticks == 0 )
{
@@ -2891,17 +2878,15 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
len_ticks = 4;
}
- const int key = ( *it )->key() - m_startKey + 1;
+ const int key = note->key() - m_startKey + 1;
- int pos_ticks = ( *it )->pos();
+ int pos_ticks = note->pos();
- int note_width = len_ticks * m_ppt /
- MidiTime::ticksPerTact();
+ int note_width = len_ticks * m_ppt / MidiTime::ticksPerTact();
const int x = ( pos_ticks - m_currentPosition ) *
m_ppt / MidiTime::ticksPerTact();
// skip this note if not in visible area at all
- if( !( x + note_width >= 0 &&
- x <= width() - WHITE_KEY_WIDTH ) )
+ if( !( x + note_width >= 0 && x <= width() - WHITE_KEY_WIDTH ) )
{
continue;
}
@@ -2914,22 +2899,22 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// note
drawNoteRect( p, x + WHITE_KEY_WIDTH,
y_base - key * KEY_LINE_HEIGHT,
- note_width, *it, noteColor() );
+ note_width, note, noteColor() );
}
// draw note editing stuff
int editHandleTop = 0;
if( m_noteEditMode == NoteEditVolume )
{
- QColor color = barColor().lighter( 30 + ( ( *it )->getVolume() * 90 / MaxVolume ) );
- if( ( *it )->selected() )
+ QColor color = barColor().lighter( 30 + ( note->getVolume() * 90 / MaxVolume ) );
+ if( note->selected() )
{
color.setRgb( 0x00, 0x40, 0xC0 );
}
p.setPen( QPen( color, NE_LINE_WIDTH ) );
editHandleTop = noteEditBottom() -
- ( (float)( ( *it )->getVolume() - MinVolume ) ) /
+ ( (float)( note->getVolume() - MinVolume ) ) /
( (float)( MaxVolume - MinVolume ) ) *
( (float)( noteEditBottom() - noteEditTop() ) );
@@ -2940,7 +2925,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
else if( m_noteEditMode == NoteEditPanning )
{
QColor color( noteColor() );
- if( ( *it )->selected() )
+ if( note->selected() )
{
color.setRgb( 0x00, 0x40, 0xC0 );
}
@@ -2948,7 +2933,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
p.setPen( QPen( color, NE_LINE_WIDTH ) );
editHandleTop = noteEditBottom() -
- ( (float)( ( *it )->getPanning() - PanningLeft ) ) /
+ ( (float)( note->getPanning() - PanningLeft ) ) /
( (float)( (PanningRight - PanningLeft ) ) ) *
( (float)( noteEditBottom() - noteEditTop() ) );
@@ -2959,7 +2944,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
editHandles << QPoint( x + noteEditLeft(),
editHandleTop+1 );
- if( ( *it )->hasDetuningInfo() )
+ if( note->hasDetuningInfo() )
{
drawDetuningInfo( p, *it,
x + WHITE_KEY_WIDTH,
@@ -2999,7 +2984,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
p.drawRect( x + WHITE_KEY_WIDTH, y, w, h );
// TODO: Get this out of paint event
- int l = ( hasValidPattern() == true )? (int) m_pattern->length() : 0;
+ int l = ( hasValidPattern() )? (int) m_pattern->length() : 0;
// reset scroll-range
if( m_leftRightScroll->maximum() != l )
@@ -3012,7 +2997,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
horizCol.setAlpha( 64 );
// horizontal line for the key under the cursor
- if( hasValidPattern() == true )
+ if( hasValidPattern() )
{
int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() );
p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT *
@@ -3064,7 +3049,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe )
// responsible for moving/resizing scrollbars after window-resizing
void PianoRoll::resizeEvent(QResizeEvent * re)
{
- m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, height() -
+ m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH,
+ height() -
SCROLLBAR_SIZE,
width()-WHITE_KEY_WIDTH,
SCROLLBAR_SIZE );
@@ -3105,9 +3091,9 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
// get values for going through notes
int pixel_range = 8;
int x = we->x() - WHITE_KEY_WIDTH;
- int ticks_start = ( x-pixel_range/2 ) *
+ int ticks_start = ( x - pixel_range / 2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
- int ticks_end = ( x+pixel_range/2 ) *
+ int ticks_end = ( x + pixel_range / 2 ) *
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
// get note-vector of current pattern
@@ -3268,7 +3254,7 @@ Song::PlayModes PianoRoll::desiredPlayModeForAccompany() const
void PianoRoll::play()
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -3292,7 +3278,7 @@ void PianoRoll::record()
{
stop();
}
- if( m_recording == true || hasValidPattern() == false )
+ if( m_recording || ! hasValidPattern() )
{
return;
}
@@ -3311,7 +3297,7 @@ void PianoRoll::recordAccompany()
{
stop();
}
- if( m_recording == true || hasValidPattern() == false )
+ if( m_recording || ! hasValidPattern() )
{
return;
}
@@ -3344,7 +3330,7 @@ void PianoRoll::stop()
void PianoRoll::startRecordNote(const Note & n )
{
- if(m_recording && hasValidPattern() &&
+ if( m_recording && hasValidPattern() &&
Engine::getSong()->isPlaying() &&
(Engine::getSong()->playMode() == desiredPlayModeForAccompany() ||
Engine::getSong()->playMode() == Song::Mode_PlayPattern ))
@@ -3369,7 +3355,7 @@ void PianoRoll::startRecordNote(const Note & n )
void PianoRoll::finishRecordNote(const Note & n )
{
- if( m_recording == true && hasValidPattern() == true &&
+ if( m_recording && hasValidPattern() &&
Engine::getSong()->isPlaying() &&
( Engine::getSong()->playMode() ==
desiredPlayModeForAccompany() ||
@@ -3428,7 +3414,7 @@ void PianoRoll::setEditMode(int mode)
void PianoRoll::selectAll()
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -3437,16 +3423,18 @@ void PianoRoll::selectAll()
// if first_time = true, we HAVE to set the vars for select
bool first_time = true;
+ NoteVector::ConstIterator it;
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
- int len_ticks = ( *it )->length();
+ Note *note = *it;
+ int len_ticks = note->length();
if( len_ticks > 0 )
{
- const int key = ( *it )->key();
+ const int key = note->key();
- int pos_ticks = ( *it )->pos();
+ int pos_ticks = note->pos();
if( key <= m_selectStartKey || first_time )
{
// if we move start-key down, we have to add
@@ -3486,19 +3474,20 @@ void PianoRoll::selectAll()
// returns vector with pointers to all selected notes
void PianoRoll::getSelectedNotes(NoteVector & selected_notes )
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
const NoteVector & notes = m_pattern->notes();
+ NoteVector::ConstIterator it;
- for( NoteVector::ConstIterator it = notes.begin(); it != notes.end();
- ++it )
+ for( it = notes.begin(); it != notes.end(); ++it )
{
- if( ( *it )->selected() )
+ Note *note = *it;
+ if( note->selected() )
{
- selected_notes.push_back( *it );
+ selected_notes.push_back( note );
}
}
}
@@ -3578,7 +3567,7 @@ void PianoRoll::copySelectedNotes()
NoteVector selected_notes;
getSelectedNotes( selected_notes );
- if( selected_notes.empty() == false )
+ if( ! selected_notes.empty() )
{
copy_to_clipboard( selected_notes );
}
@@ -3589,7 +3578,7 @@ void PianoRoll::copySelectedNotes()
void PianoRoll::cutSelectedNotes()
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -3597,18 +3586,19 @@ void PianoRoll::cutSelectedNotes()
NoteVector selected_notes;
getSelectedNotes( selected_notes );
- if( selected_notes.empty() == false )
+ if( ! selected_notes.empty() )
{
copy_to_clipboard( selected_notes );
Engine::getSong()->setModified();
+ NoteVector::Iterator it;
- for( NoteVector::Iterator it = selected_notes.begin();
- it != selected_notes.end(); ++it )
+ for( it = selected_notes.begin(); it != selected_notes.end(); ++it )
{
+ Note *note = *it;
// note (the memory of it) is also deleted by
// pattern::removeNote(...) so we don't have to do that
- m_pattern->removeNote( *it );
+ m_pattern->removeNote( note );
}
}
@@ -3621,7 +3611,7 @@ void PianoRoll::cutSelectedNotes()
void PianoRoll::pasteNotes()
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -3630,7 +3620,7 @@ void PianoRoll::pasteNotes()
->mimeData( QClipboard::Clipboard )
->data( Clipboard::mimeType() );
- if( !value.isEmpty() )
+ if( ! value.isEmpty() )
{
DataFile dataFile( value.toUtf8() );
@@ -3639,12 +3629,12 @@ void PianoRoll::pasteNotes()
// remove selection and select the newly pasted notes
clearSelectedNotes();
- if( !list.isEmpty() )
+ if( ! list.isEmpty() )
{
m_pattern->addJournalCheckPoint();
}
- for( int i = 0; !list.item( i ).isNull(); ++i )
+ for( int i = 0; ! list.item( i ).isNull(); ++i )
{
// create the note
Note cur_note;
@@ -3671,7 +3661,7 @@ void PianoRoll::pasteNotes()
void PianoRoll::deleteSelectedNotes()
{
- if( hasValidPattern() == false )
+ if( ! hasValidPattern() )
{
return;
}
@@ -3687,10 +3677,11 @@ void PianoRoll::deleteSelectedNotes()
NoteVector::ConstIterator it = notes.begin();
while( it != notes.end() )
{
- if( ( *it )->selected() )
+ Note *note = *it;
+ if( note->selected() )
{
// delete this note
- m_pattern->removeNote( ( *it ) );
+ m_pattern->removeNote( note );
update_after_delete = true;
// start over, make sure we get all the notes
@@ -3702,7 +3693,7 @@ void PianoRoll::deleteSelectedNotes()
}
}
- if( update_after_delete == true )
+ if( update_after_delete )
{
Engine::getSong()->setModified();
update();
@@ -3719,15 +3710,13 @@ void PianoRoll::autoScroll( const MidiTime & t )
const int w = width() - WHITE_KEY_WIDTH;
if( t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt )
{
- m_leftRightScroll->setValue( t.getTact() *
- MidiTime::ticksPerTact() );
+ m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() );
}
else if( t < m_currentPosition )
{
MidiTime t2 = qMax( t - w * MidiTime::ticksPerTact() *
- MidiTime::ticksPerTact() / m_ppt, 0 );
- m_leftRightScroll->setValue( t2.getTact() *
- MidiTime::ticksPerTact() );
+ MidiTime::ticksPerTact() / m_ppt, (tick_t) 0 );
+ m_leftRightScroll->setValue( t2.getTact() * MidiTime::ticksPerTact() );
}
m_scrollBack = false;
}
@@ -3737,11 +3726,10 @@ void PianoRoll::autoScroll( const MidiTime & t )
void PianoRoll::updatePosition( const MidiTime & t )
{
- if( ( Engine::getSong()->isPlaying() &&
- Engine::getSong()->playMode() ==
- Song::Mode_PlayPattern &&
- m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ) ||
- m_scrollBack == true )
+ if( ( Engine::getSong()->isPlaying()
+ && Engine::getSong()->playMode() == Song::Mode_PlayPattern
+ && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled
+ ) || m_scrollBack )
{
autoScroll( t );
}
@@ -3782,7 +3770,6 @@ void PianoRoll::zoomingChanged()
m_timeLine->setPixelsPerTact( m_ppt );
update();
-
}
@@ -3808,8 +3795,7 @@ int PianoRoll::quantization() const
}
}
return DefaultTicksPerTact / m_quantizeModel.currentText().right(
- m_quantizeModel.currentText().length() -
- 2 ).toInt();
+ m_quantizeModel.currentText().length() - 2 ).toInt();
}
@@ -3837,8 +3823,7 @@ MidiTime PianoRoll::newNoteLen() const
return m_lenOfNewNotes;
}
return DefaultTicksPerTact / m_noteLenModel.currentText().right(
- m_noteLenModel.currentText().length() -
- 2 ).toInt();
+ m_noteLenModel.currentText().length() - 2 ).toInt();
}
@@ -3871,17 +3856,19 @@ Note * PianoRoll::noteUnderMouse()
MidiTime::ticksPerTact() / m_ppt + m_currentPosition;
// will be our iterator in the following loop
- NoteVector::ConstIterator it = notes.begin()+notes.size()-1;
+ NoteVector::ConstIterator it = notes.end() - 1;
+ Note *note = *it;
// loop through whole note-vector...
int i;
for( i = 0; i < notes.size(); ++i )
{
+ note = *it;
// and check whether the cursor is over an
// existing note
- if( pos_ticks >= ( *it )->pos() &&
- pos_ticks <= ( *it )->pos() + ( *it )->length() &&
- ( *it )->key() == key_num && ( *it )->length() > 0 )
+ if( pos_ticks >= note->pos() &&
+ pos_ticks <= note->endPos() &&
+ note->key() == key_num && note->length() > 0 )
{
break;
}
@@ -3893,7 +3880,7 @@ Note * PianoRoll::noteUnderMouse()
return NULL;
}
- return *it;
+ return note;
}
diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp
index a06a1c3fb..d6e1e5210 100644
--- a/src/gui/widgets/TimeDisplayWidget.cpp
+++ b/src/gui/widgets/TimeDisplayWidget.cpp
@@ -107,12 +107,13 @@ void TimeDisplayWidget::updateTime()
break;
case BarsTicks:
- m_majorLCD.setValue( s->getTacts() + 1 );
- m_minorLCD.setValue( ( s->getTicks() % s->ticksPerTact() ) /
- ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 );
-;
- m_milliSecondsLCD.setValue( ( s->getTicks() % s->ticksPerTact() ) %
- ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) );
+ int tick;
+ tick = ( s->getMilliseconds() * s->getTempo() * (DefaultTicksPerTact / 4 ) ) / 60000 ;
+ m_majorLCD.setValue( (int)(tick / s->ticksPerTact() ) + 1);
+ m_minorLCD.setValue( ( tick % s->ticksPerTact() ) /
+ ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1 );
+ m_milliSecondsLCD.setValue( ( tick % s->ticksPerTact() ) %
+ ( s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) );
break;
default: break;
diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp
index 90d5da2f7..45210b05f 100644
--- a/src/tracks/BBTrack.cpp
+++ b/src/tracks/BBTrack.cpp
@@ -59,6 +59,7 @@ BBTCO::BBTCO( Track * _track ) :
changeLength( MidiTime( t, 0 ) );
restoreJournallingState();
}
+ setAutoResize( false );
}
@@ -216,18 +217,23 @@ void BBTCOView::paintEvent( QPaintEvent * )
{
QPainter p( this );
- QColor col = m_bbTCO->m_useStyleColor
- ? p.pen().brush().color()
- : m_bbTCO->colorObj();
-
+ QColor col;
if( m_bbTCO->getTrack()->isMuted() || m_bbTCO->isMuted() )
{
col = QColor( 160, 160, 160 );
}
+ else if ( m_bbTCO->m_useStyleColor )
+ {
+ col = p.pen().brush().color();
+ }
+ else
+ {
+ col = m_bbTCO->colorObj();
+ }
if( isSelected() == true )
{
- col = QColor( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 );
+ col.setRgb( qMax( col.red() - 128, 0 ), qMax( col.green() - 128, 0 ), 255 );
}
QLinearGradient lingrad( 0, 0, 0, height() );
diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp
index 7a7acd43a..b5d2da75b 100644
--- a/src/tracks/Pattern.cpp
+++ b/src/tracks/Pattern.cpp
@@ -66,6 +66,7 @@ Pattern::Pattern( InstrumentTrack * _instrument_track ) :
{
setName( _instrument_track->name() );
init();
+ setAutoResize( true );
}
@@ -83,6 +84,18 @@ Pattern::Pattern( const Pattern& other ) :
}
init();
+ switch( getTrack()->trackContainer()->type() )
+ {
+ case TrackContainer::BBContainer:
+ setAutoResize( true );
+ break;
+
+ case TrackContainer::SongContainer:
+ // move down
+ default:
+ setAutoResize( false );
+ break;
+ }
}
@@ -486,12 +499,15 @@ void Pattern::ensureBeatNotes()
for( int i = 0; i < m_steps; ++i )
{
bool found = false;
- for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); ++it )
+ NoteVector::Iterator it;
+
+ for( it = m_notes.begin(); it != m_notes.end(); ++it )
{
+ Note *note = *it;
// if a note in this position is the one we want
- if( ( *it )->pos() ==
+ if( note->pos() ==
( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact()
- && ( *it )->length() <= 0 )
+ && note->length() <= 0 )
{
found = true;
break;
@@ -511,10 +527,12 @@ void Pattern::ensureBeatNotes()
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); )
{
bool needed = false;
+ Note *note = *it;
+
for( int i = 0; i < m_steps; ++i )
{
- if( ( *it )->pos() == ( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact()
- || ( *it )->length() != 0 )
+ if( note->pos() == ( i * MidiTime::ticksPerTact() ) / MidiTime::stepsPerTact()
+ || note->length() != 0 )
{
needed = true;
break;
@@ -522,10 +540,12 @@ void Pattern::ensureBeatNotes()
}
if( needed == false )
{
- delete *it;
+ delete note;
it = m_notes.erase( it );
}
- else ++it;
+ else {
+ ++it;
+ }
}
}
@@ -635,7 +655,6 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) :
}
setFixedHeight( parentWidget()->height() - 2 );
- setAutoResizeEnabled( false );
ToolTip::add( this,
tr( "double-click to open this pattern in piano-roll\n"
@@ -905,16 +924,19 @@ void PatternView::paintEvent( QPaintEvent * )
QLinearGradient lingrad( 0, 0, 0, height() );
QColor c;
-
if(( m_pat->m_patternType != Pattern::BeatPattern ) &&
- !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ))
+ !( m_pat->getTrack()->isMuted() || m_pat->isMuted() ))
+ {
c = styleColor;
+ }
else
+ {
c = QColor( 80, 80, 80 );
+ }
if( isSelected() == true )
{
- c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
+ c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
}
if( m_pat->m_patternType != Pattern::BeatPattern )
diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp
index 915de3e2d..3ee683605 100644
--- a/src/tracks/SampleTrack.cpp
+++ b/src/tracks/SampleTrack.cpp
@@ -63,6 +63,18 @@ SampleTCO::SampleTCO( Track * _track ) :
// change length of this TCO
connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
this, SLOT( updateLength( bpm_t ) ) );
+ switch( getTrack()->trackContainer()->type() )
+ {
+ case TrackContainer::BBContainer:
+ setAutoResize( true );
+ break;
+
+ case TrackContainer::SongContainer:
+ // move down
+ default:
+ setAutoResize( false );
+ break;
+ }
}
@@ -341,13 +353,17 @@ void SampleTCOView::paintEvent( QPaintEvent * _pe )
QColor c;
if( !( m_tco->getTrack()->isMuted() || m_tco->isMuted() ) )
+ {
c = styleColor;
+ }
else
+ {
c = QColor( 80, 80, 80 );
+ }
if( isSelected() == true )
{
- c = QColor( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
+ c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 );
}
QLinearGradient grad( 0, 0, 0, height() );