From df9d495571902cb739cecc8f37f5b8cd35366bda Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 22 Jan 2015 16:28:29 +0100 Subject: [PATCH] Some #include cleanups --- include/AutomatableModel.h | 19 ++- include/BBTrackContainer.h | 2 +- include/BandLimitedWave.h | 6 +- include/BufferManager.h | 13 +- include/ComboBoxModel.h | 1 - include/DataFile.h | 4 +- include/DrumSynth.h | 6 +- include/Engine.h | 11 -- include/Instrument.h | 11 +- include/MemoryManager.h | 3 +- include/MixerWorkerThread.h | 12 +- include/Model.h | 2 +- include/ModelView.h | 1 + include/NotePlayHandle.h | 11 +- include/Oscillator.h | 2 - include/fft_helpers.h | 1 - src/core/AutomatableModel.cpp | 25 ++-- src/core/AutomationPattern.cpp | 15 +-- src/core/BBTrackContainer.cpp | 4 +- src/core/BandLimitedWave.cpp | 25 ++-- src/core/BufferManager.cpp | 14 +- src/core/ControllerConnection.cpp | 10 +- src/core/DataFile.cpp | 5 +- src/core/DrumSynth.cpp | 181 +++++++++++++------------- src/core/EffectChain.cpp | 17 ++- src/core/Engine.cpp | 3 - src/core/EnvelopeAndLfoParameters.cpp | 5 +- src/core/FxMixer.cpp | 1 - src/core/Instrument.cpp | 1 - src/core/JournallingObject.cpp | 3 +- src/core/LfoController.cpp | 29 ++--- src/core/MemoryManager.cpp | 1 + src/core/MixHelpers.cpp | 2 +- src/core/Mixer.cpp | 30 ++--- src/core/MixerWorkerThread.cpp | 14 +- src/core/Note.cpp | 6 +- src/core/NotePlayHandle.cpp | 25 ++-- src/core/PeakController.cpp | 14 +- src/core/base64.cpp | 5 +- src/core/fft_helpers.cpp | 56 ++++---- src/core/main.cpp | 10 +- src/gui/editors/BBEditor.cpp | 4 +- 42 files changed, 281 insertions(+), 329 deletions(-) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 92f7df68e..57c2a6f0f 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -25,7 +25,6 @@ #ifndef AUTOMATABLE_MODEL_H #define AUTOMATABLE_MODEL_H -#include "lmms_math.h" #include #include "JournallingObject.h" @@ -174,7 +173,7 @@ public: { return castValue( m_step ); } - + //! @brief Returns value scaled with the scale type and min/max values of this model float scaledValue( float value ) const; //! @brief Returns value applied with the inverse of this model's scale type @@ -265,22 +264,22 @@ public: } float globalAutomationValueAt( const MidiTime& time ); - + bool hasStrictStepSize() const { return m_hasStrictStepSize; } - + void setStrictStepSize( const bool b ) { m_hasStrictStepSize = b; } - + static void incrementPeriodCounter() { ++s_periodCounter; } - + static void resetPeriodCounter() { s_periodCounter = 0; @@ -333,13 +332,13 @@ private: float m_step; float m_range; float m_centerValue; - + bool m_valueChanged; // currently unused? float m_oldValue; int m_setValueDepth; - + // used to determine if step size should be applied strictly (ie. always) // or only when value set from gui (default) bool m_hasStrictStepSize; @@ -357,9 +356,9 @@ private: ValueBuffer m_valueBuffer; long m_lastUpdatedPeriod; static long s_periodCounter; - + bool m_hasSampleExactData; - + // prevent several threads from attempting to write the same vb at the same time QMutex m_valueBufferMutex; diff --git a/include/BBTrackContainer.h b/include/BBTrackContainer.h index a224495f0..a9e1eb3c2 100644 --- a/include/BBTrackContainer.h +++ b/include/BBTrackContainer.h @@ -27,7 +27,7 @@ #define BB_TRACK_CONTAINER_H #include "TrackContainer.h" -#include "ComboBox.h" +#include "ComboBoxModel.h" class EXPORT BBTrackContainer : public TrackContainer diff --git a/include/BandLimitedWave.h b/include/BandLimitedWave.h index 1c81e0606..d8f1eae13 100644 --- a/include/BandLimitedWave.h +++ b/include/BandLimitedWave.h @@ -26,11 +26,9 @@ #ifndef BANDLIMITEDWAVE_H #define BANDLIMITEDWAVE_H -#include -#include -#include +class QDataStream; +class QString; -#include "ConfigManager.h" #include "export.h" #include "interpolation.h" #include "lmms_basics.h" diff --git a/include/BufferManager.h b/include/BufferManager.h index c2a0a987c..b40b43143 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -22,17 +22,14 @@ * Boston, MA 02110-1301 USA. * */ - + #ifndef BUFFER_MANAGER_H #define BUFFER_MANAGER_H -#include "MemoryManager.h" +#include "export.h" #include "lmms_basics.h" -#include "Engine.h" -#include "Mixer.h" -#include -#include +class QAtomicInt; const int BM_INITIAL_BUFFERS = 512; //const int BM_INCREMENT = 64; @@ -45,11 +42,11 @@ public: static void release( sampleFrame * buf ); static void refresh(); // static void extend( int c ); - + private: static sampleFrame ** s_available; static QAtomicInt s_availableIndex; - + static sampleFrame ** s_released; static QAtomicInt s_releasedIndex; // static QReadWriteLock s_mutex; diff --git a/include/ComboBoxModel.h b/include/ComboBoxModel.h index 8c1e64c83..5af4355f0 100644 --- a/include/ComboBoxModel.h +++ b/include/ComboBoxModel.h @@ -29,7 +29,6 @@ #include #include "AutomatableModel.h" -#include "templates.h" class PixmapLoader; diff --git a/include/DataFile.h b/include/DataFile.h index 57db8905f..1d5f71f78 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -28,12 +28,12 @@ #define DATA_FILE_H #include -#include #include "export.h" -#include "lmms_basics.h" #include "MemoryManager.h" +class QTextStream; + class EXPORT DataFile : public QDomDocument { MM_OPERATORS diff --git a/include/DrumSynth.h b/include/DrumSynth.h index e57499038..e29c4bc2c 100644 --- a/include/DrumSynth.h +++ b/include/DrumSynth.h @@ -3,7 +3,7 @@ * * Copyright (c) 1998-2000 Paul Kellett (mda-vst.com) * Copyright (c) 2007 Paul Giblock - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -42,11 +42,11 @@ class DrumSynth { void GetEnv(int env, const char *sec, const char *key, const char *ini); float waveform(float ph, int form); - + int GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, const char *file); int GetPrivateProfileInt(const char *sec, const char *key, int def, const char *file); float GetPrivateProfileFloat(const char *sec, const char *key, float def, const char *file); }; -#endif +#endif diff --git a/include/Engine.h b/include/Engine.h index 55dd9021e..ad7abe399 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -26,28 +26,17 @@ #ifndef ENGINE_H #define ENGINE_H -#include "lmmsconfig.h" -#include "MemoryManager.h" - #include #include "export.h" -class AutomationEditorWindow; -class BBEditor; class BBTrackContainer; class DummyTrackContainer; class FxMixer; -class FxMixerView; class ProjectJournal; -class MainWindow; class Mixer; -class PianoRollWindow; -class ProjectNotes; class Song; -class SongEditorWindow; class Ladspa2LMMS; -class ControllerRackView; class EXPORT Engine diff --git a/include/Instrument.h b/include/Instrument.h index 70831b0ea..fdacce603 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -26,17 +26,18 @@ #ifndef INSTRUMENT_H #define INSTRUMENT_H -#include - +#include +#include +#include "export.h" +#include "lmms_basics.h" +#include "MemoryManager.h" +#include "MidiTime.h" #include "Plugin.h" -#include "Mixer.h" // forward-declarations class InstrumentTrack; -class InstrumentView; class MidiEvent; -class MidiTime; class NotePlayHandle; class Track; diff --git a/include/MemoryManager.h b/include/MemoryManager.h index 44ef58c60..559e90869 100644 --- a/include/MemoryManager.h +++ b/include/MemoryManager.h @@ -28,11 +28,12 @@ #include #include -#include #include #include "MemoryHelper.h" #include "export.h" +class QReadWriteLock; + const int MM_CHUNK_SIZE = 64; // granularity of managed memory const int MM_INITIAL_CHUNKS = 1024 * 1024; // how many chunks to allocate at startup - TODO: make configurable const int MM_INCREMENT_CHUNKS = 16 * 1024; // min. amount of chunks to increment at a time diff --git a/include/MixerWorkerThread.h b/include/MixerWorkerThread.h index 5f5c18c84..e95c13a3b 100644 --- a/include/MixerWorkerThread.h +++ b/include/MixerWorkerThread.h @@ -28,15 +28,9 @@ #include #include -#include "ThreadableJob.h" -#include "Mixer.h" - -#ifdef __SSE__ -#include -#endif -#ifdef __SSE3__ -#include -#endif +class QWaitCondition; +class Mixer; +class ThreadableJob; class MixerWorkerThread : public QThread { diff --git a/include/Model.h b/include/Model.h index 9f0590e25..c62c52ebd 100644 --- a/include/Model.h +++ b/include/Model.h @@ -25,8 +25,8 @@ #ifndef MODEL_H #define MODEL_H +#include #include -#include #include "export.h" diff --git a/include/ModelView.h b/include/ModelView.h index 9e323a947..866546061 100644 --- a/include/ModelView.h +++ b/include/ModelView.h @@ -25,6 +25,7 @@ #ifndef MODEL_VIEW_H #define MODEL_VIEW_H +#include #include "Model.h" diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index d2cf1c0fc..9cabdc346 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -26,14 +26,13 @@ #ifndef NOTE_PLAY_HANDLE_H #define NOTE_PLAY_HANDLE_H -#include "lmmsconfig.h" #include "Note.h" #include "PlayHandle.h" #include "Track.h" #include "MemoryManager.h" -#include -#include +class QAtomicInt; +class QReadWriteLock; class InstrumentTrack; class NotePlayHandle; @@ -59,7 +58,7 @@ public: OriginCount }; typedef Origins Origin; - + NotePlayHandle( InstrumentTrack* instrumentTrack, const f_cnt_t offset, const f_cnt_t frames, @@ -83,9 +82,9 @@ public: { return m_midiChannel; } - + /*! convenience function that returns offset for the first period and zero otherwise, - used by instruments to handle the offset: instruments have to check this property and + used by instruments to handle the offset: instruments have to check this property and add the correct number of empty frames in the beginning of the period */ f_cnt_t noteOffset() const { diff --git a/include/Oscillator.h b/include/Oscillator.h index de7aee66b..e146b5af0 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -36,8 +36,6 @@ #include "SampleBuffer.h" #include "lmms_constants.h" - -class SampleBuffer; class IntModel; diff --git a/include/fft_helpers.h b/include/fft_helpers.h index 1fafb6b81..59805c400 100644 --- a/include/fft_helpers.h +++ b/include/fft_helpers.h @@ -26,7 +26,6 @@ #ifndef FFT_HELPERS_H #define FFT_HELPERS_H -#include "lmmsconfig.h" #include "export.h" #include diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 9549f5ad1..6c7501c8b 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -22,9 +22,8 @@ * */ -#include - #include "AutomatableModel.h" + #include "AutomationPattern.h" #include "ControllerConnection.h" #include "lmms_math.h" @@ -75,7 +74,7 @@ AutomatableModel::~AutomatableModel() { delete m_controllerConnection; } - + m_valueBuffer.clear(); emit destroyed( id() ); @@ -171,7 +170,7 @@ void AutomatableModel::loadSettings( const QDomElement& element, const QString& //m_controllerConnection->setTargetName( displayName() ); } } - + // models can be stored as elements (port00) or attributes (port10): // // @@ -566,7 +565,7 @@ ValueBuffer * AutomatableModel::valueBuffer() } } AutomatableModel* lm = NULL; - if( m_hasLinkedModels ) + if( m_hasLinkedModels ) { lm = m_linkedModels.first(); } @@ -583,7 +582,7 @@ ValueBuffer * AutomatableModel::valueBuffer() m_hasSampleExactData = true; return &m_valueBuffer; } - + if( m_oldValue != val ) { m_valueBuffer.interpolate( m_oldValue, val ); @@ -592,7 +591,7 @@ ValueBuffer * AutomatableModel::valueBuffer() m_hasSampleExactData = true; return &m_valueBuffer; } - + // if we have no sample-exact source for a ValueBuffer, return NULL to signify that no data is available at the moment // in which case the recipient knows to use the static value() instead m_lastUpdatedPeriod = s_periodCounter; @@ -667,11 +666,11 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) { int s = ( *it )->startPosition(); int e = ( *it )->endPosition(); - if( s <= time && e >= time ) { patternsInRange += ( *it ); } + if( s <= time && e >= time ) { patternsInRange += ( *it ); } } - + AutomationPattern * latestPattern = NULL; - + if( ! patternsInRange.isEmpty() ) { // if there are more than one overlapping patterns, just use the first one because @@ -682,7 +681,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) // if we find no patterns at the exact miditime, we need to search for the last pattern before time and use that { int latestPosition = 0; - + for( QVector::ConstIterator it = patterns.begin(); it != patterns.end(); it++ ) { int e = ( *it )->endPosition(); @@ -693,7 +692,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) } } } - + if( latestPattern ) { // scale/fit the value appropriately and return it @@ -701,7 +700,7 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) const float scaled_value = scaledValue( value ); return fittedValue( scaled_value ); } - // if we still find no pattern, the value at that time is undefined so + // if we still find no pattern, the value at that time is undefined so // just return current value as the best we can do else return m_value; } diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index beb11bd2d..4c8791ee3 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -24,9 +24,8 @@ * */ -#include - #include "AutomationPattern.h" + #include "AutomationPatternView.h" #include "AutomationTrack.h" #include "ProjectJournal.h" @@ -192,7 +191,7 @@ const AutomatableModel * AutomationPattern::firstObject() const MidiTime AutomationPattern::length() const { if( m_timeMap.isEmpty() ) return 0; - timeMap::const_iterator it = m_timeMap.end(); + timeMap::const_iterator it = m_timeMap.end(); return MidiTime( qMax( MidiTime( (it-1).key() ).getTact() + 1, 1 ), 0 ); } @@ -412,7 +411,7 @@ void AutomationPattern::flipY( int min, int max ) { numPoints++; } - + for( int i = 0; i <= numPoints; i++ ) { @@ -501,7 +500,7 @@ void AutomationPattern::flipX( int length ) tempMap[newTime] = tempValue; } } - + m_timeMap.clear(); m_timeMap = tempMap; @@ -617,7 +616,7 @@ void AutomationPattern::processMidiTime( const MidiTime & time ) ( *it )->setAutomatedValue( val ); } - } + } } } else @@ -625,7 +624,7 @@ void AutomationPattern::processMidiTime( const MidiTime & time ) if( time >= 0 && ! m_objects.isEmpty() ) { const float value = static_cast( firstObject()->value() ); - if( value != m_lastRecordedValue ) + if( value != m_lastRecordedValue ) { putValue( time, value, true ); m_lastRecordedValue = value; @@ -692,7 +691,7 @@ QVector AutomationPattern::patternsForModel( const Automata l += Engine::getSong()->tracks(); l += Engine::getBBTrackContainer()->tracks(); l += Engine::getSong()->globalAutomationTrack(); - + // go through all tracks... for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) { diff --git a/src/core/BBTrackContainer.cpp b/src/core/BBTrackContainer.cpp index 839e40994..d38cfdc00 100644 --- a/src/core/BBTrackContainer.cpp +++ b/src/core/BBTrackContainer.cpp @@ -2,7 +2,7 @@ * BBTrackContainer.cpp - model-component of BB-Editor * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -25,8 +25,6 @@ #include "BBTrackContainer.h" #include "BBTrack.h" -#include "ComboBox.h" -#include "embed.h" #include "Engine.h" #include "Song.h" diff --git a/src/core/BandLimitedWave.cpp b/src/core/BandLimitedWave.cpp index 11b3790a5..de608ba1d 100644 --- a/src/core/BandLimitedWave.cpp +++ b/src/core/BandLimitedWave.cpp @@ -25,6 +25,7 @@ #include "BandLimitedWave.h" +#include "ConfigManager.h" WaveMipMap BandLimitedWave::s_waveforms[4] = { }; bool BandLimitedWave::s_wavesGenerated = false; @@ -62,7 +63,7 @@ void BandLimitedWave::generateWaves() { // don't generate if they already exist if( s_wavesGenerated ) return; - + int i; // set wavetable directory @@ -90,7 +91,7 @@ void BandLimitedWave::generateWaves() const int len = TLENS[i]; //const double om = 1.0 / len; double max = 0.0; - + for( int ph = 0; ph < len; ph++ ) { int harm = 1; @@ -115,7 +116,7 @@ void BandLimitedWave::generateWaves() } } } - + // square wave - BLSquare // check for file and use it if exists if( sqr_file.exists() ) @@ -132,7 +133,7 @@ void BandLimitedWave::generateWaves() const int len = TLENS[i]; //const double om = 1.0 / len; double max = 0.0; - + for( int ph = 0; ph < len; ph++ ) { int harm = 1; @@ -173,7 +174,7 @@ void BandLimitedWave::generateWaves() const int len = TLENS[i]; //const double om = 1.0 / len; double max = 0.0; - + for( int ph = 0; ph < len; ph++ ) { int harm = 1; @@ -184,7 +185,7 @@ void BandLimitedWave::generateWaves() hlen = static_cast( len ) / static_cast( harm ); const double amp = 1.0 / static_cast( harm * harm ); //const double a2 = cos( om * harm * F_2PI ); - s += amp * /*a2 **/ sin( ( static_cast( ph * harm ) / static_cast( len ) + + s += amp * /*a2 **/ sin( ( static_cast( ph * harm ) / static_cast( len ) + ( ( harm + 1 ) % 4 == 0 ? 0.5 : 0.0 ) ) * F_2PI ); harm += 2; } while( hlen > 2.0 ); @@ -199,7 +200,7 @@ void BandLimitedWave::generateWaves() } } } - + // moog saw wave - BLMoog // basically, just add in triangle + 270-phase saw if( moog_file.exists() ) @@ -214,7 +215,7 @@ void BandLimitedWave::generateWaves() for( i = 0; i <= MAXTBL; i++ ) { const int len = TLENS[i]; - + for( int ph = 0; ph < len; ph++ ) { const int sawph = ( ph + static_cast( len * 0.75 ) ) % len; @@ -224,7 +225,7 @@ void BandLimitedWave::generateWaves() } } } - + // set the generated flag so we don't load/generate them again needlessly s_wavesGenerated = true; @@ -232,14 +233,14 @@ void BandLimitedWave::generateWaves() // generate files, serialize mipmaps as QDataStreams and save them on disk // // normally these are now provided with LMMS as pre-generated so we don't have to do this, -// but I'm leaving the code here in case it's needed in the future +// but I'm leaving the code here in case it's needed in the future // (maybe we add more waveforms or change the generation code or mipmap format, etc.) /* -// if you want to generate the files, you need to set the filenames and paths here - +// if you want to generate the files, you need to set the filenames and paths here - // can't use the usual wavetable directory here as it can require permissions on -// some systems... +// some systems... QFile sawfile( "path-to-wavetables/saw.bin" ); QFile sqrfile( "path-to-wavetables/sqr.bin" ); diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index cb38d45e9..1f535443e 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -25,6 +25,10 @@ #include "BufferManager.h" +#include +#include + +#include "MemoryManager.h" sampleFrame ** BufferManager::s_available; QAtomicInt BufferManager::s_availableIndex = 0; @@ -41,7 +45,7 @@ void BufferManager::init( fpp_t framesPerPeriod ) int c = framesPerPeriod * BM_INITIAL_BUFFERS; sampleFrame * b = MM_ALLOC( sampleFrame, c ); - + for( int i = 0; i < BM_INITIAL_BUFFERS; ++i ) { s_available[ i ] = b; @@ -58,10 +62,10 @@ sampleFrame * BufferManager::acquire() { qFatal( "BufferManager: out of buffers" ); } - + int i = s_availableIndex.fetchAndAddOrdered( -1 ); sampleFrame * b = s_available[ i ]; - + //qDebug( "acquired buffer: %p - index %d", b, i ); return b; } @@ -79,7 +83,7 @@ void BufferManager::refresh() // non-threadsafe, hence it's called periodically { if( s_releasedIndex == 0 ) return; //qDebug( "refresh: %d buffers", int( s_releasedIndex ) ); - + int j = s_availableIndex; for( int i = 0; i < s_releasedIndex; ++i ) { @@ -101,7 +105,7 @@ void BufferManager::extend( int c ) int cc = c * Engine::mixer()->framesPerPeriod(); sampleFrame * b = MM_ALLOC( sampleFrame, cc ); - + for( int i = 0; i < c; ++i ) { s_available[ s_availableIndex.fetchAndAddOrdered( 1 ) + 1 ] = b; diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 3c0266ab6..8b7040b50 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -1,5 +1,5 @@ /* - * ControllerConnection.cpp - implementation of class controller connection + * ControllerConnection.cpp - implementation of class controller connection * which handles the link between AutomatableModels and controllers * * Copyright (c) 2008 Paul Giblock @@ -26,12 +26,10 @@ #include #include -#include #include "Song.h" #include "Engine.h" -#include "Mixer.h" #include "ControllerConnection.h" @@ -123,7 +121,7 @@ void ControllerConnection::setController( Controller * _controller ) this, SIGNAL( valueChanged() ) ); } - m_ownsController = + m_ownsController = ( _controller->type() == Controller::MidiController ); // If we don't own the controller, allow deletion of controller @@ -150,8 +148,8 @@ inline void ControllerConnection::setTargetName( const QString & _name ) /* * A connection may not be finalized. This means, the connection should exist, * but the controller does not yet exist. This happens when loading. Even - * loading connections last won't help, since there can be connections BETWEEN - * controllers. So, we remember the controller-ID and use a dummyController + * loading connections last won't help, since there can be connections BETWEEN + * controllers. So, we remember the controller-ID and use a dummyController * instead. Once the song is loaded, finalizeConnections() connects to the proper controllers */ void ControllerConnection::finalizeConnections() diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 7bf47ed67..0cd7a5703 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -42,9 +42,6 @@ #include "lmmsversion.h" #include "base64.h" -// bbTCO::defaultColor() -#include "BBTrack.h" - DataFile::typeDescStruct @@ -628,7 +625,7 @@ void DataFile::upgrade() el.setAttribute( "lp1pos", el.attribute( "lp1pos" ).toInt()*3 ); } - + } if( version < "0.4.0-20080607" ) diff --git a/src/core/DrumSynth.cpp b/src/core/DrumSynth.cpp index 305ed5ae1..8c732bb7d 100644 --- a/src/core/DrumSynth.cpp +++ b/src/core/DrumSynth.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1998-2000 Paul Kellett (mda-vst.com) * Copyright (c) 2007 Paul Giblock - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -25,7 +25,6 @@ #include "DrumSynth.h" -#include "lmmsconfig.h" #include #include @@ -71,13 +70,13 @@ float mem_t=1.0f, mem_o=1.0f, mem_n=1.0f, mem_b=1.0f, mem_tune=1.0f, mem_time=1. int DrumSynth::LongestEnv(void) { long e, eon, p; - float l=0.f; - + float l=0.f; + for(e=1; e<7; e++) //3 { eon = e - 1; if(eon>2) eon=eon-1; p = 0; - while (envpts[e][0][p + 1] >= 0.f) p++; + while (envpts[e][0][p + 1] >= 0.f) p++; envData[e][MAX] = envpts[e][0][p] * timestretch; if(chkOn[eon]==1) if(envData[e][MAX]>l) l=envData[e][MAX]; } @@ -88,7 +87,7 @@ int DrumSynth::LongestEnv(void) float DrumSynth::LoudestEnv(void) -{ +{ float loudest=0.f; int i=0; @@ -102,9 +101,9 @@ float DrumSynth::LoudestEnv(void) void DrumSynth::UpdateEnv(int e, long t) -{ +{ float endEnv, dT; - //0.2's added + //0.2's added envData[e][NEXTT] = envpts[e][0][(long)(envData[e][PNT] + 1.f)] * timestretch; //get next point if(envData[e][NEXTT] < 0) envData[e][NEXTT] = 442000 * timestretch; //if end point, hold envData[e][ENV] = envpts[e][1][(long)(envData[e][PNT] + 0.f)] * 0.01f; //this level @@ -122,14 +121,14 @@ void DrumSynth::GetEnv(int env, const char *sec, const char *key, const char *in int i=0, o=0, ep=0; GetPrivateProfileString(sec, key, "0,0 100,0", en, sizeof(en), ini); en[255]=0; //be safe! - + while(en[i]!=0) { - if(en[i] == ',') + if(en[i] == ',') { if(sscanf(s, "%f", &envpts[env][0][ep])==0) envpts[env][0][ep] = 0.f; o=0; - } + } else if(en[i] == ' ') { if(sscanf(s, "%f", &envpts[env][1][ep])==0) envpts[env][1][ep] = 0.f; @@ -148,7 +147,7 @@ void DrumSynth::GetEnv(int env, const char *sec, const char *key, const char *in float DrumSynth::waveform(float ph, int form) { float w; - + switch (form) { case 0: w = (float)sin(fmod(ph,TwoPi)); break; //sine @@ -157,15 +156,15 @@ float DrumSynth::waveform(float ph, int form) w = 0.6366197f * (float)fmod(ph,TwoPi) - 1.f; //tri if(w>1.f) w=2.f-w; break; case 3: w = ph - TwoPi * (float)(int)(ph / TwoPi); //saw - w = (0.3183098f * w) - 1.f; break; + w = (0.3183098f * w) - 1.f; break; default: w = (sin(fmod(ph,TwoPi))>0.0)? 1.f: -1.f; break; //square - } - + } + return w; } -int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, const char *file) +int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const char *def, char *buffer, int size, const char *file) { ifstream is; bool inSection = false; @@ -190,12 +189,12 @@ int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const c } else if (!is.eof()) { is.getline(line, 200); - if (line[0] == '[') + if (line[0] == '[') break; k = strtok(line, " \t="); b = strtok(NULL, "\n\r\0"); - + if (k != 0 && strcasecmp(k, key)==0) { if (b==0) { len = 0; @@ -203,7 +202,7 @@ int DrumSynth::GetPrivateProfileString(const char *sec, const char *key, const c } else { k = (char *)(b + strlen(b)-1); - while ( (k>=b) && (*k==' ' || *k=='\t') ) + while ( (k>=b) && (*k==' ' || *k=='\t') ) --k; *(k+1) = '\0'; @@ -233,9 +232,9 @@ int DrumSynth::GetPrivateProfileInt(const char *sec, const char *key, int def, c int i=0; GetPrivateProfileString(sec, key, "", tmp, sizeof(tmp), file); - sscanf(tmp, "%d", &i); if(tmp[0]==0) i=def; - - return i; + sscanf(tmp, "%d", &i); if(tmp[0]==0) i=def; + + return i; } float DrumSynth::GetPrivateProfileFloat(const char *sec, const char *key, float def, const char *file) @@ -244,9 +243,9 @@ float DrumSynth::GetPrivateProfileFloat(const char *sec, const char *key, float float f=0.f; GetPrivateProfileString(sec, key, "", tmp, sizeof(tmp), file); - sscanf(tmp, "%f", &f); if(tmp[0]==0) f=def; + sscanf(tmp, "%f", &f); if(tmp[0]==0) f=def; - return f; + return f; } @@ -259,7 +258,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels { //input file char sec[32]; - char ver[32]; + char ver[32]; char comment[256]; int commentLen=0; @@ -268,11 +267,11 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels float x[3] = {0.f, 0.f, 0.f}; float MasterTune, randmax, randmax2; int MainFilter, HighPass; - + long NON, NT, TON, DiON, TDroop=0, DStep; float a, b=0.f, c=0.f, d=0.f, g, TT=0.f, TL, NL, F1, F2; float TphiStart=0.f, Tphi, TDroopRate, ddF, DAtten, DGain; - + long BON, BON2, BFStep, BFStep2, botmp; float BdF=0.f, BdF2=0.f, BPhi, BPhi2, BF, BF2, BQ, BQ2, BL, BL2; @@ -282,7 +281,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels float Oc0=0.0f, Oc1=0.0f, Oc2=0.0f; float MFfb, MFtmp, MFres, MFin=0.f, MFout=0.f; - float DownAve; + float DownAve; long DownStart, DownEnd, jj; @@ -297,22 +296,22 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels } //try to read version from input file - strcpy(sec, "General"); + strcpy(sec, "General"); GetPrivateProfileString(sec,"Version","",ver,sizeof(ver),dsfile); - ver[9]=0; + ver[9]=0; if(strcasecmp(ver, "DrumSynth") != 0) {return 0;} //input fail if(ver[11] != '1' && ver[11] != '2') {return 0;} //version fail - + //read master parameters GetPrivateProfileString(sec,"Comment","",comment,sizeof(comment),dsfile); while((comment[commentLen]!=0) && (commentLen<254)) commentLen++; if(commentLen==0) { comment[0]=32; comment[1]=0; commentLen=1;} comment[commentLen+1]=0; commentLen++; - if((commentLen % 2)==1) commentLen++; - + if((commentLen % 2)==1) commentLen++; + timestretch = .01f * mem_time * GetPrivateProfileFloat(sec,"Stretch",100.0,dsfile); - if(timestretch<0.2f) timestretch=0.2f; + if(timestretch<0.2f) timestretch=0.2f; if(timestretch>10.f) timestretch=10.f; DGain = 1.0f; //leave this here! @@ -320,35 +319,35 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels MasterTune = GetPrivateProfileFloat(sec,"Tuning",0.0,dsfile); MasterTune = (float)powf(1.0594631f, MasterTune + mem_tune); - MainFilter = 2 * GetPrivateProfileInt(sec,"Filter",0,dsfile); + MainFilter = 2 * GetPrivateProfileInt(sec,"Filter",0,dsfile); MFres = 0.0101f * GetPrivateProfileFloat(sec,"Resonance",0.0,dsfile); MFres = (float)powf(MFres, 0.5f); - + HighPass = GetPrivateProfileInt(sec,"HighPass",0,dsfile); GetEnv(7, sec, "FilterEnv", dsfile); - + //read noise parameters strcpy(sec, "Noise"); chkOn[1] = GetPrivateProfileInt(sec,"On",0,dsfile); - sliLev[1] = GetPrivateProfileInt(sec,"Level",0,dsfile); - NT = GetPrivateProfileInt(sec,"Slope",0,dsfile); + sliLev[1] = GetPrivateProfileInt(sec,"Level",0,dsfile); + NT = GetPrivateProfileInt(sec,"Slope",0,dsfile); GetEnv(2, sec, "Envelope", dsfile); - NON = chkOn[1]; + NON = chkOn[1]; NL = (float)(sliLev[1] * sliLev[1]) * mem_n; if(NT<0) { a = 1.f + (NT / 105.f); d = -NT / 105.f; g = (1.f + 0.0005f * NT * NT) * NL; } else { a = 1.f; b = -NT / 50.f; c = (float)fabs((float)NT) / 100.f; g = NL; } - - //if(GetPrivateProfileInt(sec,"FixedSeq",0,dsfile)!=0) + + //if(GetPrivateProfileInt(sec,"FixedSeq",0,dsfile)!=0) //srand(1); //fixed random sequence - + //read tone parameters strcpy(sec, "Tone"); chkOn[0] = GetPrivateProfileInt(sec,"On",0,dsfile); TON = chkOn[0]; - sliLev[0] = GetPrivateProfileInt(sec,"Level",128,dsfile); + sliLev[0] = GetPrivateProfileInt(sec,"Level",128,dsfile); TL = (float)(sliLev[0] * sliLev[0]) * mem_t; GetEnv(1, sec, "Envelope", dsfile); F1 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F1",200.0,dsfile) / Fs; @@ -364,13 +363,13 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels ddF = F1 - F2; } else ddF = F2-F1; - + Tphi = GetPrivateProfileFloat(sec,"Phase",90.f,dsfile) / 57.29578f; //degrees>radians //read overtone parameters strcpy(sec, "Overtones"); chkOn[2] = GetPrivateProfileInt(sec,"On",0,dsfile); OON = chkOn[2]; - sliLev[2] = GetPrivateProfileInt(sec,"Level",128,dsfile); + sliLev[2] = GetPrivateProfileInt(sec,"Level",128,dsfile); OL = (float)(sliLev[2] * sliLev[2]) * mem_o; GetEnv(3, sec, "Envelope1", dsfile); GetEnv(4, sec, "Envelope2", dsfile); @@ -381,11 +380,11 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels OW2 = GetPrivateProfileInt(sec,"Wave2",0,dsfile); OBal2 = (float)GetPrivateProfileInt(sec,"Param",50,dsfile); ODrive = (float)powf(OBal2, 3.0f) / (float)powf(50.0f, 3.0f); - OBal2 *= 0.01f; + OBal2 *= 0.01f; OBal1 = 1.f - OBal2; - Ophi1 = Tphi; + Ophi1 = Tphi; Ophi2 = Tphi; - if(MainFilter==0) + if(MainFilter==0) MainFilter = GetPrivateProfileInt(sec,"Filter",0,dsfile); if((GetPrivateProfileInt(sec,"Track1",0,dsfile)==1) && (TON==1)) { OF1Sync = 1; OF1 = OF1 / F1; } @@ -403,28 +402,28 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels //read noise band parameters strcpy(sec, "NoiseBand"); chkOn[3] = GetPrivateProfileInt(sec,"On",0,dsfile); BON = chkOn[3]; - sliLev[3] = GetPrivateProfileInt(sec,"Level",128,dsfile); + sliLev[3] = GetPrivateProfileInt(sec,"Level",128,dsfile); BL = (float)(sliLev[3] * sliLev[3]) * mem_b; BF = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F",1000.0,dsfile) / Fs; BPhi = TwoPi / 8.f; GetEnv(5, sec, "Envelope", dsfile); - BFStep = GetPrivateProfileInt(sec,"dF",50,dsfile); - BQ = (float)BFStep; + BFStep = GetPrivateProfileInt(sec,"dF",50,dsfile); + BQ = (float)BFStep; BQ = BQ * BQ / (10000.f-6600.f*((float)sqrt(BF)-0.19f)); BFStep = 1 + (int)((40.f - (BFStep / 2.5f)) / (BQ + 1.f + (1.f * BF))); strcpy(sec, "NoiseBand2"); chkOn[4] = GetPrivateProfileInt(sec,"On",0,dsfile); BON2 = chkOn[4]; - sliLev[4] = GetPrivateProfileInt(sec,"Level",128,dsfile); + sliLev[4] = GetPrivateProfileInt(sec,"Level",128,dsfile); BL2 = (float)(sliLev[4] * sliLev[4]) * mem_b; BF2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec,"F",1000.0,dsfile) / Fs; BPhi2 = TwoPi / 8.f; GetEnv(6, sec, "Envelope", dsfile); - BFStep2 = GetPrivateProfileInt(sec,"dF",50,dsfile); + BFStep2 = GetPrivateProfileInt(sec,"dF",50,dsfile); BQ2 = (float)BFStep2; BQ2 = BQ2 * BQ2 / (10000.f-6600.f*((float)sqrt(BF2)-0.19f)); BFStep2 = 1 + (int)((40 - (BFStep2 / 2.5)) / (BQ2 + 1 + (1 * BF2))); - + //read distortion parameters strcpy(sec, "Distortion"); chkOn[5] = GetPrivateProfileInt(sec,"On",0,dsfile); DiON = chkOn[5]; @@ -434,14 +433,14 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels clippoint = 32700; DAtten = 1.0f; - if(DiON==1) + if(DiON==1) { - DAtten = DGain * (short)LoudestEnv(); - if(DAtten>32700) clippoint=32700; else clippoint=(short)DAtten; + DAtten = DGain * (short)LoudestEnv(); + if(DAtten>32700) clippoint=32700; else clippoint=(short)DAtten; DAtten = (float)powf(2.0, 2.0 * GetPrivateProfileInt(sec,"Bits",0,dsfile)); DGain = DAtten * DGain * (float)powf(10.0, 0.05 * GetPrivateProfileInt(sec,"Clipping",0,dsfile)); } - + //prepare envelopes randmax = 1.f / RAND_MAX; randmax2 = 2.f * randmax; for (i=1;i<8;i++) { envData[i][NEXTT]=0; envData[i][PNT]=0; } @@ -473,7 +472,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels //write WAV header WH.riff = 0x46464952; - WH.riffLength = 36 + (2 * Length) + 44 + commentLen; + WH.riffLength = 36 + (2 * Length) + 44 + commentLen; WH.wave = 0x45564157; WH.fmt = 0x20746D66; WH.waveLength = 16; @@ -503,7 +502,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels else UpdateEnv(2, t); x[2] = x[1]; x[1] = x[0]; - x[0] = (randmax2 * (float)rand()) - 1.f; + x[0] = (randmax2 * (float)rand()) - 1.f; TT = a * x[0] + b * x[1] + c * x[2] + d * TT; DF[t - tpos] = TT * g * envData[2][ENV]; } @@ -512,7 +511,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels else { for(j=0; j<1200; j++) DF[j]=0.f; } - + if(TON==1) //tone { TphiStart = Tphi; @@ -520,16 +519,16 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels { for(t=tpos; t<=tplus; t++) phi[t - tpos] = F2 + (ddF * (float)exp(t * TDroopRate)); - } + } else { for(t=tpos; t<=tplus; t++) phi[t - tpos] = F1 + (t / envData[1][MAX]) * ddF; - } + } for(t=tpos; t<=tplus; t++) { totmp = t - tpos; - if(t < envData[1][NEXTT]) + if(t < envData[1][NEXTT]) envData[1][ENV] = envData[1][ENV] + envData[1][dENV]; else UpdateEnv(1, t); Tphi = Tphi + phi[totmp]; @@ -538,7 +537,7 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels if(t>=envData[1][MAX]) TON=0; } else for(j=0; j<1200; j++) phi[j]=F2; //for overtone sync - + if(BON==1) //noise band 1 { for(t=tpos; t<=tplus; t++) @@ -580,8 +579,8 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels { if(t>=envData[3][MAX]) //wait for OT2 { - envData[3][ENV] = 0; - envData[3][dENV] = 0; + envData[3][ENV] = 0; + envData[3][dENV] = 0; envData[3][NEXTT] = 999999; } else UpdateEnv(3, t); @@ -610,12 +609,12 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels Ot = OBal1 * envData[3][ENV] * waveform(Ophi1, OW1); Ot = OL * (Ot + OBal2 * envData[4][ENV] * waveform(Ophi2, OW2)); break; - + case 1: //FM Ot = ODrive * envData[4][ENV] * waveform(Ophi2, OW2); Ot = OL * envData[3][ENV] * waveform(Ophi1 + Ot, OW1); break; - + case 2: //RM Ot = (1 - ODrive / 8) + (((ODrive / 8) * envData[4][ENV]) * waveform(Ophi2, OW2)); Ot = OL * envData[3][ENV] * waveform(Ophi1, OW1) * Ot; @@ -625,10 +624,10 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels for(j=0; j<6; j++) { Oc[j][0] += 1.0f; - + if(Oc[j][0]>Oc[j][1]) - { - Oc[j][0] -= Oc[j][1]; + { + Oc[j][0] -= Oc[j][1]; Ot = OL * envData[3][ENV]; } } @@ -639,8 +638,8 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels Ot = Oc1; break; } - } - + } + if(MainFilter==1) //filter overtones { if(t0.2f) MFfb = 1.001f - (float)powf(10.0f, MFtmp - 1); else - MFfb = 0.999f - 0.7824f * MFtmp; - - MFtmp = Ot + MFres * (1.f + (1.f/MFfb)) * (MFin - MFout); + MFfb = 0.999f - 0.7824f * MFtmp; + + MFtmp = Ot + MFres * (1.f + (1.f/MFfb)) * (MFin - MFout); MFin = MFfb * (MFin - MFtmp) + MFtmp; MFout = MFfb * (MFout - MFin) + MFin; @@ -669,48 +668,48 @@ int DrumSynth::GetDSFileSamples(const char *dsfile, int16_t *&wave, int channels if(MFtmp >0.2f) MFfb = 1.001f - (float)powf(10.0f, MFtmp - 1); else - MFfb = 0.999f - 0.7824f * MFtmp; - - MFtmp = DF[t - tpos] + Ot + MFres * (1.f + (1.f/MFfb)) * (MFin - MFout); + MFfb = 0.999f - 0.7824f * MFtmp; + + MFtmp = DF[t - tpos] + Ot + MFres * (1.f + (1.f/MFfb)) * (MFin - MFout); MFin = MFfb * (MFin - MFtmp) + MFtmp; MFout = MFfb * (MFout - MFin) + MFin; - + DF[t - tpos] = MFout - (HighPass * (DF[t - tpos] + Ot)); } // PG: Ot is uninitialized else DF[t - tpos] = DF[t - tpos] + Ot; //no filter } - + if(DiON==1) //bit resolution { for(j=0; j<1200; j++) DF[j] = DGain * (int)(DF[j] / DAtten); - + for(j=0; j<1200; j+=DStep) //downsampling { DownAve = 0; DownStart = j; DownEnd = j + DStep - 1; - for(jj = DownStart; jj<=DownEnd; jj++) + for(jj = DownStart; jj<=DownEnd; jj++) DownAve = DownAve + DF[jj]; DownAve = DownAve / DStep; - for(jj = DownStart; jj<=DownEnd; jj++) + for(jj = DownStart; jj<=DownEnd; jj++) DF[jj] = DownAve; - } + } } else for(j=0; j<1200; j++) DF[j] *= DGain; - + for(j = 0; j<1200; j++) //clipping + output { if(DF[j] > clippoint) wave[wavewords++] = clippoint; - else if(DF[j] < -clippoint) + else if(DF[j] < -clippoint) wave[wavewords++] = -clippoint; - else + else wave[wavewords++] = (short)DF[j]; for (int c = 1; c < channels; c++) { - wave[wavewords] = wave[wavewords-1]; + wave[wavewords] = wave[wavewords-1]; wavewords++; } } diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index 5890566a3..f310f94dc 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -29,7 +29,6 @@ #include "EffectChain.h" #include "Effect.h" #include "Engine.h" -#include "debug.h" #include "DummyEffect.h" #include "MixHelpers.h" #include "Song.h" @@ -148,7 +147,7 @@ void EffectChain::moveDown( Effect * _effect ) if( _effect != m_effects.last() ) { int i = 0; - for( EffectList::Iterator it = m_effects.begin(); + for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); it++, i++ ) { if( *it == _effect ) @@ -156,10 +155,10 @@ void EffectChain::moveDown( Effect * _effect ) break; } } - + Effect * temp = m_effects[i + 1]; m_effects[i + 1] = _effect; - m_effects[i] = temp; + m_effects[i] = temp; } } @@ -171,7 +170,7 @@ void EffectChain::moveUp( Effect * _effect ) if( _effect != m_effects.first() ) { int i = 0; - for( EffectList::Iterator it = m_effects.begin(); + for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); it++, i++ ) { if( *it == _effect ) @@ -179,10 +178,10 @@ void EffectChain::moveUp( Effect * _effect ) break; } } - + Effect * temp = m_effects[i - 1]; m_effects[i - 1] = _effect; - m_effects[i] = temp; + m_effects[i] = temp; } } @@ -240,8 +239,8 @@ void EffectChain::startRunning() { return; } - - for( EffectList::Iterator it = m_effects.begin(); + + for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); it++ ) { ( *it )->startRunning(); diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index b11ad1e47..5730e977e 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -27,13 +27,10 @@ #include "BBTrackContainer.h" #include "ConfigManager.h" #include "FxMixer.h" -#include "InstrumentTrack.h" #include "Ladspa2LMMS.h" #include "Mixer.h" -#include "Pattern.h" #include "PresetPreviewPlayHandle.h" #include "ProjectJournal.h" -#include "ProjectNotes.h" #include "Plugin.h" #include "Song.h" #include "BandLimitedWave.h" diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 90f6747f0..271bfd6f4 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -25,7 +25,6 @@ #include #include "EnvelopeAndLfoParameters.h" -#include "debug.h" #include "Engine.h" #include "Mixer.h" #include "Oscillator.h" @@ -379,7 +378,7 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this ) with 4.15 file format*/ if( _this.hasAttribute( "sus" ) ) - { + { m_sustainModel.loadSettings( _this, "sus" ); m_sustainModel.setValue( 1.0 - m_sustainModel.value() ); } @@ -392,7 +391,7 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this ) ( TempoSyncKnob::TtempoSyncMode ) _this.attribute( "lfosyncmode" ).toInt() ); }*/ - + m_userWave.setAudioFile( _this.attribute( "userwavefile" ) ); updateSampleVars(); diff --git a/src/core/FxMixer.cpp b/src/core/FxMixer.cpp index e6d1767ff..00143b2ee 100644 --- a/src/core/FxMixer.cpp +++ b/src/core/FxMixer.cpp @@ -27,7 +27,6 @@ #include "FxMixer.h" #include "MixerWorkerThread.h" #include "MixHelpers.h" -#include "Effect.h" #include "Song.h" #include "InstrumentTrack.h" diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index f8b04fdb5..b4bf40bd1 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -26,7 +26,6 @@ #include "InstrumentTrack.h" #include "DummyInstrument.h" #include "NotePlayHandle.h" -#include "embed.h" #include "Engine.h" diff --git a/src/core/JournallingObject.cpp b/src/core/JournallingObject.cpp index 804483580..4c3163f0c 100644 --- a/src/core/JournallingObject.cpp +++ b/src/core/JournallingObject.cpp @@ -29,7 +29,6 @@ #include "JournallingObject.h" #include "AutomatableModel.h" #include "ProjectJournal.h" -#include "base64.h" #include "Engine.h" @@ -70,7 +69,7 @@ void JournallingObject::addJournalCheckPoint() QDomElement JournallingObject::saveState( QDomDocument & _doc, QDomElement & _parent ) { - if( isJournalling() ) + if( isJournalling() ) { QDomElement _this = SerializingObject::saveState( _doc, _parent ); diff --git a/src/core/LfoController.cpp b/src/core/LfoController.cpp index 5d77ce06a..f7c65a752 100644 --- a/src/core/LfoController.cpp +++ b/src/core/LfoController.cpp @@ -23,17 +23,14 @@ * */ -#include #include #include -#include #include "Song.h" #include "Engine.h" #include "Mixer.h" #include "LfoController.h" -#include "ControllerDialog.h" #include "lmms_math.h" @@ -47,7 +44,7 @@ LfoController::LfoController( Model * _parent ) : this, tr( "Oscillator waveform" ) ), m_multiplierModel( 0, 0, 2, this, tr( "Frequency Multiplier" ) ), m_duration( 1000 ), - m_phaseOffset( 0 ), + m_phaseOffset( 0 ), m_currentPhase( 0 ), m_sampleFunction( &Oscillator::sinSample ), m_userDefSampleBuffer( new SampleBuffer ) @@ -55,19 +52,19 @@ LfoController::LfoController( Model * _parent ) : setSampleExact( true ); connect( &m_waveModel, SIGNAL( dataChanged() ), this, SLOT( updateSampleFunction() ) ); - + connect( &m_speedModel, SIGNAL( dataChanged() ), this, SLOT( updateDuration() ) ); connect( &m_multiplierModel, SIGNAL( dataChanged() ), this, SLOT( updateDuration() ) ); - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), + connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateDuration() ) ); - + connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( updatePhase() ) ); connect( Engine::getSong(), SIGNAL( playbackPositionChanged() ), this, SLOT( updatePhase() ) ); - + updateDuration(); } @@ -88,12 +85,12 @@ LfoController::~LfoController() void LfoController::updateValueBuffer() { - m_phaseOffset = m_phaseModel.value() / 360.0; - float * values = m_valueBuffer.values(); + m_phaseOffset = m_phaseModel.value() / 360.0; + float * values = m_valueBuffer.values(); float phase = m_currentPhase + m_phaseOffset; // roll phase up until we're in sync with period counter - m_bufferLastUpdated++; + m_bufferLastUpdated++; if( m_bufferLastUpdated < s_periods ) { int diff = s_periods - m_bufferLastUpdated; @@ -103,16 +100,16 @@ void LfoController::updateValueBuffer() for( int i = 0; i < m_valueBuffer.length(); i++ ) - { - const float currentSample = m_sampleFunction != NULL + { + const float currentSample = m_sampleFunction != NULL ? m_sampleFunction( phase ) : m_userDefSampleBuffer->userWaveSample( phase ); - + values[i] = qBound( 0.0f, m_baseModel.value() + ( m_amountModel.value() * currentSample / 2.0f ), 1.0f ); phase += 1.0 / m_duration; } - + m_currentPhase = absFraction( phase - m_phaseOffset ); } @@ -141,7 +138,7 @@ void LfoController::updateDuration() default: break; } - + m_duration = newDurationF; } diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp index 21cdf01ba..7366aa234 100644 --- a/src/core/MemoryManager.cpp +++ b/src/core/MemoryManager.cpp @@ -26,6 +26,7 @@ #include "MemoryManager.h" #include +#include #include diff --git a/src/core/MixHelpers.cpp b/src/core/MixHelpers.cpp index 513dd40d9..22065c967 100644 --- a/src/core/MixHelpers.cpp +++ b/src/core/MixHelpers.cpp @@ -22,8 +22,8 @@ * */ -#include "lmms_math.h" #include "MixHelpers.h" +#include "lmms_math.h" #include "ValueBuffer.h" diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index b6aff0446..ba8006ddd 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -22,18 +22,14 @@ * */ -#include - #include "Mixer.h" + +#include "AudioPort.h" #include "FxMixer.h" -#include "MixHelpers.h" #include "MixerWorkerThread.h" #include "Song.h" -#include "templates.h" #include "EnvelopeAndLfoParameters.h" #include "NotePlayHandle.h" -#include "InstrumentTrack.h" -#include "debug.h" #include "Engine.h" #include "ConfigManager.h" #include "SamplePlayHandle.h" @@ -292,7 +288,7 @@ void Mixer::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) f_cnt_t frames = m_inputBufferFrames[ m_inputBufferWrite ]; int size = m_inputBufferSize[ m_inputBufferWrite ]; sampleFrame * buf = m_inputBuffer[ m_inputBufferWrite ]; - + if( frames + _frames > size ) { size = qMax( size * 2, frames + _frames ); @@ -305,10 +301,10 @@ void Mixer::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) buf = ab; } - + memcpy( &buf[ frames ], _ab, _frames * sizeof( sampleFrame ) ); m_inputBufferFrames[ m_inputBufferWrite ] += _frames; - + unlockInputFrames(); } @@ -359,7 +355,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() if( it != m_playHandles.end() ) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } @@ -415,7 +411,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() if( ( *it )->isFinished() ) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } @@ -446,7 +442,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() EnvelopeAndLfoParameters::instances()->trigger(); Controller::triggerFrameCounter(); AutomatableModel::incrementPeriodCounter(); - + // refresh buffer pool BufferManager::refresh(); @@ -639,7 +635,7 @@ bool Mixer::addPlayHandle( PlayHandle* handle ) return true; } - if( handle->type() == PlayHandle::TypeNotePlayHandle ) + if( handle->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*)handle ); } @@ -664,7 +660,7 @@ void Mixer::removePlayHandle( PlayHandle * _ph ) if( it != m_playHandles.end() ) { m_playHandles.erase( it ); - if( _ph->type() == PlayHandle::TypeNotePlayHandle ) + if( _ph->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) _ph ); } @@ -690,7 +686,7 @@ void Mixer::removePlayHandles( Track * _track, bool removeIPHs ) if( ( *it )->isFromTrack( _track ) && ( removeIPHs || ( *it )->type() != PlayHandle::TypeInstrumentPlayHandle ) ) { ( *it )->audioPort()->removePlayHandle( ( *it ) ); - if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) + if( ( *it )->type() == PlayHandle::TypeNotePlayHandle ) { NotePlayHandleManager::release( (NotePlayHandle*) *it ); } @@ -942,8 +938,8 @@ void Mixer::fifoWriter::run() #ifdef __SSE__ /* FTZ flag */ _MM_SET_FLUSH_ZERO_MODE( _MM_FLUSH_ZERO_ON ); -#endif - +#endif + #if 0 #ifdef LMMS_BUILD_LINUX #ifdef LMMS_HAVE_SCHED_H diff --git a/src/core/MixerWorkerThread.cpp b/src/core/MixerWorkerThread.cpp index 5a9ca166c..ef011f55f 100644 --- a/src/core/MixerWorkerThread.cpp +++ b/src/core/MixerWorkerThread.cpp @@ -23,8 +23,18 @@ */ #include "MixerWorkerThread.h" -#include "Engine.h" +#include +#include +#include "ThreadableJob.h" +#include "Mixer.h" + +#ifdef __SSE__ +#include +#endif +#ifdef __SSE3__ +#include +#endif MixerWorkerThread::JobQueue MixerWorkerThread::globalJobQueue; QWaitCondition * MixerWorkerThread::queueReadyWaitCond = NULL; @@ -157,7 +167,7 @@ void MixerWorkerThread::run() #ifdef __SSE__ /* FTZ flag */ _MM_SET_FLUSH_ZERO_MODE( _MM_FLUSH_ZERO_ON ); -#endif +#endif QMutex m; while( m_quit == false ) { diff --git a/src/core/Note.cpp b/src/core/Note.cpp index 937f52ac8..fb76a491c 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -2,7 +2,7 @@ * note.cpp - implementation of class note * * Copyright (c) 2004-2014 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -29,8 +29,6 @@ #include "Note.h" #include "DetuningHelper.h" -#include "templates.h" - @@ -68,7 +66,7 @@ Note::Note( const Note & _note ) : m_selected( _note.m_selected ), m_oldKey( _note.m_oldKey ), m_oldPos( _note.m_oldPos ), - m_oldLength( _note.m_oldLength ), + m_oldLength( _note.m_oldLength ), m_isPlaying( _note.m_isPlaying ), m_key( _note.m_key), m_volume( _note.m_volume ), diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 19ec0517a..be5a38295 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -25,7 +25,6 @@ #include "NotePlayHandle.h" #include "BasicFilters.h" -#include "ConfigManager.h" #include "DetuningHelper.h" #include "InstrumentSoundShaping.h" #include "InstrumentTrack.h" @@ -93,14 +92,14 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, parent->m_hadChildren = true; m_bbTrack = parent->m_bbTrack; - + parent->setUsesBuffer( false ); } updateFrequency(); setFrames( _frames ); - + // inform attached components about new MIDI note (used for recording in Piano Roll) if( m_origin == OriginMidiInput ) { @@ -114,7 +113,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, // send MidiNoteOn event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), - MidiTime::fromFrames( offset(), Engine::framesPerTick() ), + MidiTime::fromFrames( offset(), Engine::framesPerTick() ), offset() ); } @@ -122,9 +121,9 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, { setUsesBuffer( false ); } - + setAudioPort( instrumentTrack->audioPort() ); - + unlock(); } @@ -133,7 +132,7 @@ void NotePlayHandle::done() { lock(); noteOff( 0 ); - + if( hasParent() == false ) { delete m_baseDetuning; @@ -157,7 +156,7 @@ void NotePlayHandle::done() m_subNotes.clear(); delete m_filter; - + if( buffer() ) releaseBuffer(); unlock(); @@ -212,7 +211,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) setOffset( offset() - Engine::mixer()->framesPerPeriod() ); return; } - + lock(); if( m_frequencyNeedsUpdate ) { @@ -220,7 +219,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) } // number of frames that can be played this period - f_cnt_t framesThisPeriod = m_totalFramesPlayed == 0 + f_cnt_t framesThisPeriod = m_totalFramesPlayed == 0 ? Engine::mixer()->framesPerPeriod() - offset() : Engine::mixer()->framesPerPeriod(); @@ -386,7 +385,7 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) // send MidiNoteOff event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOff, midiChannel(), midiKey(), 0 ), - MidiTime::fromFrames( _s, Engine::framesPerTick() ), + MidiTime::fromFrames( _s, Engine::framesPerTick() ), _s ); } @@ -597,7 +596,7 @@ NotePlayHandle * NotePlayHandleManager::acquire( InstrumentTrack* instrumentTrac s_mutex.lockForRead(); NotePlayHandle * nph = s_available[ s_availableIndex.fetchAndAddOrdered( -1 ) ]; s_mutex.unlock(); - + new( (void*)nph ) NotePlayHandle( instrumentTrack, offset, frames, noteToPlay, parent, midiEventChannel, origin ); return nph; } @@ -618,7 +617,7 @@ void NotePlayHandleManager::extend( int c ) NotePlayHandle ** tmp = MM_ALLOC( NotePlayHandle*, s_size ); MM_FREE( s_available ); s_available = tmp; - + NotePlayHandle * n = MM_ALLOC( NotePlayHandle, c ); for( int i=0; i < c; ++i ) diff --git a/src/core/PeakController.cpp b/src/core/PeakController.cpp index c8702f937..2d92cff05 100644 --- a/src/core/PeakController.cpp +++ b/src/core/PeakController.cpp @@ -23,24 +23,20 @@ * */ +#include "PeakController.h" + #include #include #include -#include #include - -#include "Song.h" #include "Engine.h" #include "Mixer.h" -#include "PeakController.h" #include "EffectChain.h" -#include "ControllerDialog.h" #include "plugins/peak_controller_effect/peak_controller_effect.h" #include "PresetPreviewPlayHandle.h" -#include "lmms_math.h" -#include "interpolation.h" +class ControllerDialog; PeakControllerEffectVector PeakController::s_effects; int PeakController::m_getCount; @@ -48,7 +44,7 @@ int PeakController::m_loadCount; bool PeakController::m_buggedFile; -PeakController::PeakController( Model * _parent, +PeakController::PeakController( Model * _parent, PeakControllerEffect * _peak_effect ) : Controller( Controller::PeakController, _parent, tr( "Peak Controller" ) ), m_peakEffect( _peak_effect ), @@ -99,7 +95,7 @@ void PeakController::updateValueBuffer() { const f_cnt_t frames = Engine::mixer()->framesPerPeriod(); float * values = m_valueBuffer.values(); - + for( f_cnt_t f = 0; f < frames; ++f ) { const float diff = ( targetSample - m_currentSample ); diff --git a/src/core/base64.cpp b/src/core/base64.cpp index 08adc9d46..0479d468b 100644 --- a/src/core/base64.cpp +++ b/src/core/base64.cpp @@ -3,7 +3,7 @@ * to/from base64 * * Copyright (c) 2006-2008 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -26,7 +26,6 @@ #include "base64.h" -#include "lmms_basics.h" #include #include @@ -34,7 +33,7 @@ namespace base64 { - + QString encode( const QVariant & _data ) { QBuffer buf; diff --git a/src/core/fft_helpers.cpp b/src/core/fft_helpers.cpp index 71e84a8db..11f619c4a 100644 --- a/src/core/fft_helpers.cpp +++ b/src/core/fft_helpers.cpp @@ -2,7 +2,7 @@ * fft_helpers.cpp - some functions around FFT analysis * * Copyright (c) 2008-2012 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -25,8 +25,8 @@ #include "fft_helpers.h" -#include "lmms_math.h" - +#include +#include "lmms_constants.h" /* returns biggest value from abs_spectrum[spec_size] array @@ -36,10 +36,10 @@ float maximum(float *abs_spectrum, unsigned int spec_size) { float maxi=0; unsigned int i; - + if ( abs_spectrum==NULL ) return -1; - + if (spec_size<=0) return -1; @@ -48,7 +48,7 @@ float maximum(float *abs_spectrum, unsigned int spec_size) if ( abs_spectrum[i]>maxi ) maxi=abs_spectrum[i]; } - + return maxi; } @@ -60,21 +60,21 @@ int hanming(float *timebuffer, int length, WINDOWS type) { int i; float alpha; - + if ( (timebuffer==NULL)||(length<=0) ) return -1; - + switch (type) { case HAMMING: alpha=0.54; break; - case HANNING: + case HANNING: default: alpha=0.5; break; } - + for ( i=0; i num_new - + returns 0 on success, else -1 */ int compressbands(float *absspec_buffer, float *compressedband, int num_old, int num_new, int bottom, int top) { @@ -114,13 +114,13 @@ int compressbands(float *absspec_buffer, float *compressedband, int num_old, int int i, usefromold; float j; float j_min, j_max; - + if ( (absspec_buffer==NULL)||(compressedband==NULL) ) return -1; - + if ( num_old #endif -#include #include #include -#include #include #include #include -#include -#include #include -#include -#include +#include #ifdef LMMS_BUILD_WIN32 #include @@ -71,16 +66,13 @@ #include "MemoryManager.h" #include "ConfigManager.h" #include "NotePlayHandle.h" -#include "embed.h" #include "Engine.h" #include "GuiApplication.h" -#include "LmmsStyle.h" #include "ImportFilter.h" #include "MainWindow.h" #include "ProjectRenderer.h" #include "DataFile.h" #include "Song.h" -#include "LmmsPalette.h" static inline QString baseName( const QString & _file ) { diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index 02ea125de..db14eecf6 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -22,13 +22,15 @@ * */ +#include "BBEditor.h" + #include #include #include #include #include -#include "BBEditor.h" +#include "ComboBox.h" #include "BBTrackContainer.h" #include "embed.h" #include "MainWindow.h"