# HG changeset patch # User Chris Cannam # Date 1523957742 -3600 # Node ID a12fd0456f0c1ebf1c4c4b917860c7715aebb9b9 # Parent deabf9fd3d2877737e9dc652b400659bacb26073# Parent 48e9f538e6e9dc03ade551aeefe51dcc56f6d393 Merge from default branch diff -r deabf9fd3d28 -r a12fd0456f0c base/AudioLevel.cpp --- a/base/AudioLevel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/AudioLevel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -31,7 +31,7 @@ struct FaderDescription { FaderDescription(double _minDb, double _maxDb, double _zeroPoint) : - minDb(_minDb), maxDb(_maxDb), zeroPoint(_zeroPoint) { } + minDb(_minDb), maxDb(_maxDb), zeroPoint(_zeroPoint) { } double minDb; double maxDb; @@ -97,17 +97,17 @@ double db = 0.0f; if (def >= 50.0f) { - db = (def - 50.0f) / 2.5f - 20.0f; + db = (def - 50.0f) / 2.5f - 20.0f; } else if (def >= 30.0f) { - db = (def - 30.0f) / 2.0f - 30.0f; + db = (def - 30.0f) / 2.0f - 30.0f; } else if (def >= 15.0f) { - db = (def - 15.0f) / 1.5f - 40.0f; + db = (def - 15.0f) / 1.5f - 40.0f; } else if (def >= 7.5f) { - db = (def - 7.5f) / 0.75f - 50.0f; + db = (def - 7.5f) / 0.75f - 50.0f; } else if (def >= 2.5f) { - db = (def - 2.5f) / 0.5f - 60.0f; + db = (def - 2.5f) / 0.5f - 60.0f; } else { - db = (def / 0.25f) - 70.0f; + db = (def / 0.25f) - 70.0f; } return db; @@ -120,32 +120,32 @@ if (type == IEC268Meter || type == IEC268LongMeter) { - double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); - double percent = double(level) * maxPercent / double(maxLevel); - double dB = iec_fader_to_dB(percent); - return dB; + double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); + double percent = double(level) * maxPercent / double(maxLevel); + double dB = iec_fader_to_dB(percent); + return dB; } else { // scale proportional to sqrt(fabs(dB)) - int zeroLevel = int(maxLevel * faderTypes[type].zeroPoint); + int zeroLevel = int(maxLevel * faderTypes[type].zeroPoint); - if (level >= zeroLevel) { - - double value = level - zeroLevel; - double scale = (maxLevel - zeroLevel) / - sqrt(faderTypes[type].maxDb); - value /= scale; - double dB = pow(value, 2.); - return dB; - - } else { - - double value = zeroLevel - level; - double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); - value /= scale; - double dB = pow(value, 2.); - return 0. - dB; - } + if (level >= zeroLevel) { + + double value = level - zeroLevel; + double scale = (maxLevel - zeroLevel) / + sqrt(faderTypes[type].maxDb); + value /= scale; + double dB = pow(value, 2.); + return dB; + + } else { + + double value = zeroLevel - level; + double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); + value /= scale; + double dB = pow(value, 2.); + return 0. - dB; + } } } @@ -157,25 +157,25 @@ if (type == IEC268Meter || type == IEC268LongMeter) { - // The IEC scale gives a "percentage travel" for a given dB - // level, but it reaches 100% at 0dB. So we want to treat the - // result not as a percentage, but as a scale between 0 and - // whatever the "percentage" for our (possibly >0dB) max dB is. - - double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); - double percent = iec_dB_to_fader(dB); - int faderLevel = int((maxLevel * percent) / maxPercent + 0.01f); - - if (faderLevel < 0) faderLevel = 0; - if (faderLevel > maxLevel) faderLevel = maxLevel; - return faderLevel; + // The IEC scale gives a "percentage travel" for a given dB + // level, but it reaches 100% at 0dB. So we want to treat the + // result not as a percentage, but as a scale between 0 and + // whatever the "percentage" for our (possibly >0dB) max dB is. + + double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); + double percent = iec_dB_to_fader(dB); + int faderLevel = int((maxLevel * percent) / maxPercent + 0.01f); + + if (faderLevel < 0) faderLevel = 0; + if (faderLevel > maxLevel) faderLevel = maxLevel; + return faderLevel; } else { - int zeroLevel = int(maxLevel * faderTypes[type].zeroPoint); + int zeroLevel = int(maxLevel * faderTypes[type].zeroPoint); - if (dB >= 0.) { - + if (dB >= 0.) { + if (faderTypes[type].maxDb <= 0.) { return maxLevel; @@ -189,21 +189,21 @@ if (level > maxLevel) level = maxLevel; return level; } - - } else { + + } else { - dB = 0. - dB; - double value = sqrt(dB); - double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); - value *= scale; - int level = zeroLevel - int(value + 0.01f); - if (level < 0) level = 0; - return level; - } + dB = 0. - dB; + double value = sqrt(dB); + double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); + value *= scale; + int level = zeroLevel - int(value + 0.01f); + if (level < 0) level = 0; + return level; + } } } - + double AudioLevel::fader_to_multiplier(int level, int maxLevel, FaderType type) { @@ -226,12 +226,12 @@ { LevelList &ll = previewLevelCache[levels]; if (ll.empty()) { - for (int i = 0; i <= levels; ++i) { - double m = AudioLevel::fader_to_multiplier - (i + levels/4, levels + levels/4, AudioLevel::PreviewLevel); - if (levels == 1) m /= 100; // noise - ll.push_back(m); - } + for (int i = 0; i <= levels; ++i) { + double m = AudioLevel::fader_to_multiplier + (i + levels/4, levels + levels/4, AudioLevel::PreviewLevel); + if (levels == 1) m /= 100; // noise + ll.push_back(m); + } } return ll; } @@ -255,23 +255,23 @@ // binary search int level = -1; while (result < 0) { - int newlevel = (lo + hi) / 2; - if (newlevel == level || - newlevel == 0 || - newlevel == levels) { - result = newlevel; - break; - } - level = newlevel; - if (ll[level] >= m) { - hi = level; - } else if (ll[level+1] >= m) { - result = level; - } else { - lo = level; - } + int newlevel = (lo + hi) / 2; + if (newlevel == level || + newlevel == 0 || + newlevel == levels) { + result = newlevel; + break; + } + level = newlevel; + if (ll[level] >= m) { + hi = level; + } else if (ll[level+1] >= m) { + result = level; + } else { + lo = level; + } } - + return result; */ @@ -288,5 +288,5 @@ return ll[level]; */ } - + diff -r deabf9fd3d28 -r a12fd0456f0c base/AudioLevel.h --- a/base/AudioLevel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/AudioLevel.h Tue Apr 17 10:35:42 2018 +0100 @@ -38,11 +38,11 @@ static const double DB_FLOOR; enum FaderType { - ShortFader = 0, // -40 -> +6 dB + ShortFader = 0, // -40 -> +6 dB LongFader = 1, // -70 -> +10 dB IEC268Meter = 2, // -70 -> 0 dB IEC268LongMeter = 3, // -70 -> +10 dB (0dB aligns with LongFader) - PreviewLevel = 4 + PreviewLevel = 4 }; static double multiplier_to_dB(double multiplier); @@ -53,7 +53,7 @@ static double fader_to_multiplier(int level, int maxLevel, FaderType type); static int multiplier_to_fader(double multiplier, int maxFaderLevel, - FaderType type); + FaderType type); // fast if "levels" doesn't change often -- for audio segment previews static int multiplier_to_preview(double multiplier, int levels); diff -r deabf9fd3d28 -r a12fd0456f0c base/BaseTypes.h --- a/base/BaseTypes.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/BaseTypes.h Tue Apr 17 10:35:42 2018 +0100 @@ -38,9 +38,9 @@ { if (i < 0) return false; if (sizeof(T) > sizeof(typename C::size_type)) { - return i < static_cast(container.size()); + return i < static_cast(container.size()); } else { - return static_cast(i) < container.size(); + return static_cast(i) < container.size(); } } diff -r deabf9fd3d28 -r a12fd0456f0c base/ColumnOp.h --- a/base/ColumnOp.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/ColumnOp.h Tue Apr 17 10:35:42 2018 +0100 @@ -60,10 +60,10 @@ */ static Column applyGain(const Column &in, double gain) { if (gain == 1.0) return in; - Column out; - out.reserve(in.size()); - for (auto v: in) out.push_back(float(v * gain)); - return out; + Column out; + out.reserve(in.size()); + for (auto v: in) out.push_back(float(v * gain)); + return out; } /** @@ -71,10 +71,10 @@ */ static Column applyShift(const Column &in, float offset) { if (offset == 0.f) return in; - Column out; - out.reserve(in.size()); - for (auto v: in) out.push_back(v + offset); - return out; + Column out; + out.reserve(in.size()); + for (auto v: in) out.push_back(v + offset); + return out; } /** @@ -95,13 +95,13 @@ if (!in_range_for(in, ix+1)) { return in[ix] > in[ix-1]; } - if (in[ix] < in[ix+1]) { + if (in[ix] < in[ix+1]) { return false; } - if (in[ix] <= in[ix-1]) { + if (in[ix] <= in[ix-1]) { return false; } - return true; + return true; } /** @@ -130,10 +130,10 @@ * with the bin of index minbin. */ static Column distribute(const Column &in, - int h, - const std::vector &binfory, - int minbin, - bool interpolate); + int h, + const std::vector &binfory, + int minbin, + bool interpolate); }; diff -r deabf9fd3d28 -r a12fd0456f0c base/Command.cpp --- a/base/Command.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Command.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -24,7 +24,7 @@ MacroCommand::~MacroCommand() { for (size_t i = 0; i < m_commands.size(); ++i) { - delete m_commands[i]; + delete m_commands[i]; } } @@ -38,13 +38,13 @@ MacroCommand::deleteCommand(Command *command) { for (std::vector::iterator i = m_commands.begin(); - i != m_commands.end(); ++i) { + i != m_commands.end(); ++i) { - if (*i == command) { - m_commands.erase(i); - delete command; - return; - } + if (*i == command) { + m_commands.erase(i); + delete command; + return; + } } } @@ -58,7 +58,7 @@ MacroCommand::execute() { for (size_t i = 0; i < m_commands.size(); ++i) { - m_commands[i]->execute(); + m_commands[i]->execute(); } } @@ -66,7 +66,7 @@ MacroCommand::unexecute() { for (size_t i = 0; i < m_commands.size(); ++i) { - m_commands[m_commands.size() - i - 1]->unexecute(); + m_commands[m_commands.size() - i - 1]->unexecute(); } } diff -r deabf9fd3d28 -r a12fd0456f0c base/HitCount.h --- a/base/HitCount.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/HitCount.h Tue Apr 17 10:35:42 2018 +0100 @@ -25,34 +25,34 @@ { public: HitCount(std::string name) : - m_name(name), - m_hit(0), - m_partial(0), - m_miss(0) + m_name(name), + m_hit(0), + m_partial(0), + m_miss(0) { } ~HitCount() { #ifndef NO_HIT_COUNTS - using namespace std; - int total = m_hit + m_partial + m_miss; - cerr << "Hit count: " << m_name << ": "; - if (m_partial > 0) { - cerr << m_hit << " hits, " << m_partial << " partial, " - << m_miss << " misses"; - } else { - cerr << m_hit << " hits, " << m_miss << " misses"; - } - if (total > 0) { - if (m_partial > 0) { - cerr << " (" << ((m_hit * 100.0) / total) << "%, " - << ((m_partial * 100.0) / total) << "%, " - << ((m_miss * 100.0) / total) << "%)"; - } else { - cerr << " (" << ((m_hit * 100.0) / total) << "%, " - << ((m_miss * 100.0) / total) << "%)"; - } - } - cerr << endl; + using namespace std; + int total = m_hit + m_partial + m_miss; + cerr << "Hit count: " << m_name << ": "; + if (m_partial > 0) { + cerr << m_hit << " hits, " << m_partial << " partial, " + << m_miss << " misses"; + } else { + cerr << m_hit << " hits, " << m_miss << " misses"; + } + if (total > 0) { + if (m_partial > 0) { + cerr << " (" << ((m_hit * 100.0) / total) << "%, " + << ((m_partial * 100.0) / total) << "%, " + << ((m_miss * 100.0) / total) << "%)"; + } else { + cerr << " (" << ((m_hit * 100.0) / total) << "%, " + << ((m_miss * 100.0) / total) << "%)"; + } + } + cerr << endl; #endif } diff -r deabf9fd3d28 -r a12fd0456f0c base/MagnitudeRange.h --- a/base/MagnitudeRange.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/MagnitudeRange.h Tue Apr 17 10:35:42 2018 +0100 @@ -29,7 +29,7 @@ MagnitudeRange(float min, float max) : m_min(min), m_max(max) { } bool operator==(const MagnitudeRange &r) { - return r.m_min == m_min && r.m_max == m_max; + return r.m_min == m_min && r.m_max == m_max; } bool operator!=(const MagnitudeRange &r) { return !(*this == r); @@ -37,20 +37,20 @@ bool isSet() const { return (m_min != 0.f || m_max != 0.f); } void set(float min, float max) { - m_min = min; - m_max = max; - if (m_max < m_min) m_max = m_min; + m_min = min; + m_max = max; + if (m_max < m_min) m_max = m_min; } bool sample(float f) { - bool changed = false; - if (isSet()) { - if (f < m_min) { m_min = f; changed = true; } - if (f > m_max) { m_max = f; changed = true; } - } else { - m_max = m_min = f; - changed = true; - } - return changed; + bool changed = false; + if (isSet()) { + if (f < m_min) { m_min = f; changed = true; } + if (f > m_max) { m_max = f; changed = true; } + } else { + m_max = m_min = f; + changed = true; + } + return changed; } bool sample(const std::vector &ff) { bool changed = false; @@ -62,16 +62,16 @@ return changed; } bool sample(const MagnitudeRange &r) { - bool changed = false; - if (isSet()) { - if (r.m_min < m_min) { m_min = r.m_min; changed = true; } - if (r.m_max > m_max) { m_max = r.m_max; changed = true; } - } else { - m_min = r.m_min; - m_max = r.m_max; - changed = true; - } - return changed; + bool changed = false; + if (isSet()) { + if (r.m_min < m_min) { m_min = r.m_min; changed = true; } + if (r.m_max > m_max) { m_max = r.m_max; changed = true; } + } else { + m_min = r.m_min; + m_max = r.m_max; + changed = true; + } + return changed; } float getMin() const { return m_min; } float getMax() const { return m_max; } diff -r deabf9fd3d28 -r a12fd0456f0c base/Pitch.cpp --- a/base/Pitch.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Pitch.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -21,8 +21,8 @@ double Pitch::getFrequencyForPitch(int midiPitch, - double centsOffset, - double concertA) + double centsOffset, + double concertA) { if (concertA <= 0.0) { concertA = Preferences::getInstance()->getTuningFrequency(); @@ -33,8 +33,8 @@ int Pitch::getPitchForFrequency(double frequency, - double *centsOffsetReturn, - double concertA) + double *centsOffsetReturn, + double concertA) { if (concertA <= 0.0) { concertA = Preferences::getInstance()->getTuningFrequency(); @@ -45,12 +45,12 @@ double centsOffset = (p - midiPitch) * 100.0; if (centsOffset >= 50.0) { - midiPitch = midiPitch + 1; - centsOffset = -(100.0 - centsOffset); + midiPitch = midiPitch + 1; + centsOffset = -(100.0 - centsOffset); } if (centsOffset < -50.0) { - midiPitch = midiPitch - 1; - centsOffset = (100.0 + centsOffset); + midiPitch = midiPitch - 1; + centsOffset = (100.0 + centsOffset); } if (centsOffsetReturn) *centsOffsetReturn = centsOffset; @@ -80,8 +80,8 @@ double centsOffset = (p - midiPitch) * 100.0; if (centsOffset >= 50.0) { - midiPitch = midiPitch + 1; - centsOffset = -(100.0 - centsOffset); + midiPitch = midiPitch + 1; + centsOffset = -(100.0 - centsOffset); } if (centsOffsetReturn) *centsOffsetReturn = centsOffset; @@ -120,12 +120,12 @@ // spelled from a MIDI pitch + flats flag in isolation. if (midiPitch < 0) { - while (midiPitch < 0) { - midiPitch += 12; - --octave; - } + while (midiPitch < 0) { + midiPitch += 12; + --octave; + } } else { - octave = midiPitch / 12 + baseOctave; + octave = midiPitch / 12 + baseOctave; } note = midiPitch % 12; @@ -133,8 +133,8 @@ QString Pitch::getPitchLabel(int midiPitch, - double centsOffset, - bool useFlats) + double centsOffset, + bool useFlats) { int note, octave; getNoteAndOctaveForPitch(midiPitch, note, octave); @@ -149,8 +149,8 @@ QString Pitch::getPitchLabelForFrequency(double frequency, - double concertA, - bool useFlats) + double concertA, + bool useFlats) { if (concertA <= 0.0) { concertA = Preferences::getInstance()->getTuningFrequency(); diff -r deabf9fd3d28 -r a12fd0456f0c base/Pitch.h --- a/base/Pitch.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Pitch.h Tue Apr 17 10:35:42 2018 +0100 @@ -31,8 +31,8 @@ * specified in the application preferences (default 440Hz). */ static double getFrequencyForPitch(int midiPitch, - double centsOffset = 0, - double concertA = 0.0); + double centsOffset = 0, + double concertA = 0.0); /** * Return the nearest MIDI pitch to the given frequency. @@ -47,16 +47,16 @@ * specified in the application preferences (default 440Hz). */ static int getPitchForFrequency(double frequency, - double *centsOffsetReturn = 0, - double concertA = 0.0); + double *centsOffsetReturn = 0, + double concertA = 0.0); /** * Compatibility version of getPitchForFrequency accepting float * pointer argument. */ static int getPitchForFrequency(double frequency, - float *centsOffsetReturn, - double concertA = 0.0) { + float *centsOffsetReturn, + double concertA = 0.0) { double c; int p = getPitchForFrequency(frequency, &c, concertA); if (centsOffsetReturn) *centsOffsetReturn = float(c); @@ -127,8 +127,8 @@ * e.g. Bb3 instead of A#3. */ static QString getPitchLabel(int midiPitch, - double centsOffset = 0, - bool useFlats = false); + double centsOffset = 0, + bool useFlats = false); /** * Return a string describing the nearest MIDI pitch to the given @@ -142,8 +142,8 @@ * e.g. Bb3 instead of A#3. */ static QString getPitchLabelForFrequency(double frequency, - double concertA = 0.0, - bool useFlats = false); + double concertA = 0.0, + bool useFlats = false); /** * Return a string describing the given pitch range in octaves, diff -r deabf9fd3d28 -r a12fd0456f0c base/PlayParameterRepository.cpp --- a/base/PlayParameterRepository.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/PlayParameterRepository.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -39,8 +39,8 @@ if (!getPlayParameters(playable)) { - // Give all playables the same type of play parameters for the - // moment + // Give all playables the same type of play parameters for the + // moment // cerr << "PlayParameterRepository:addPlayable: Adding play parameters for " << playable << endl; @@ -121,8 +121,8 @@ { // cerr << "PlayParameterRepository: PlayParameterRepository::clear" << endl; while (!m_playParameters.empty()) { - delete m_playParameters.begin()->second; - m_playParameters.erase(m_playParameters.begin()); + delete m_playParameters.begin()->second; + m_playParameters.erase(m_playParameters.begin()); } } diff -r deabf9fd3d28 -r a12fd0456f0c base/Profiler.cpp --- a/base/Profiler.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Profiler.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -100,7 +100,7 @@ fprintf(stderr, "\tCPU: \t%.9g ms/call \t[%d ms total]\n", (((double)pp.second.first * 1000.0 / - (double)pp.first) / CLOCKS_PER_SEC), + (double)pp.first) / CLOCKS_PER_SEC), int((double(pp.second.first) * 1000.0) / CLOCKS_PER_SEC)); fprintf(stderr, "\tReal: \t%s ms \t[%s ms total]\n", @@ -192,8 +192,8 @@ RealTime elapsedTime = RealTime::fromTimeval(tv) - m_startTime; cerr << "Profiler : id = " << m_c - << " - elapsed so far = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) - << "ms CPU, " << elapsedTime << " real" << endl; + << " - elapsed so far = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) + << "ms CPU, " << elapsedTime << " real" << endl; } Profiler::~Profiler() @@ -215,7 +215,7 @@ if (m_showOnDestruct) cerr << "Profiler : id = " << m_c << " - elapsed = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) - << "ms CPU, " << elapsedTime << " real" << endl; + << "ms CPU, " << elapsedTime << " real" << endl; m_ended = true; } diff -r deabf9fd3d28 -r a12fd0456f0c base/ProgressReporter.cpp --- a/base/ProgressReporter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/ProgressReporter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -16,7 +16,7 @@ #include "ProgressReporter.h" ProgressReporter::ProgressReporter(QObject *parent) : - QObject(parent) + QObject(parent) { } diff -r deabf9fd3d28 -r a12fd0456f0c base/PropertyContainer.cpp --- a/base/PropertyContainer.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/PropertyContainer.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -223,8 +223,8 @@ } PropertyContainer::SetPropertyCommand::SetPropertyCommand(PropertyContainer *pc, - const PropertyName &pn, - int value) : + const PropertyName &pn, + int value) : m_pc(pc), m_pn(pn), m_value(value), diff -r deabf9fd3d28 -r a12fd0456f0c base/PropertyContainer.h --- a/base/PropertyContainer.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/PropertyContainer.h Tue Apr 17 10:35:42 2018 +0100 @@ -36,13 +36,13 @@ typedef std::vector PropertyList; enum PropertyType { - ToggleProperty, // on or off - RangeProperty, // range of integers - ValueProperty, // range of integers given string labels - ColourProperty, // colours, get/set as ColourDatabase indices + ToggleProperty, // on or off + RangeProperty, // range of integers + ValueProperty, // range of integers given string labels + ColourProperty, // colours, get/set as ColourDatabase indices ColourMapProperty, // colour maps, get/set as ColourMapper::StandardMap enum UnitsProperty, // unit from UnitDatabase, get/set unit id - InvalidProperty, // property not found! + InvalidProperty, // property not found! }; /** @@ -82,14 +82,14 @@ * passed as NULL if their values are not required. */ virtual int getPropertyRangeAndValue(const PropertyName &, - int *min, int *max, int *deflt) const; + int *min, int *max, int *deflt) const; /** * If the given property is a ValueProperty, return the display * label to be used for the given value for that property. */ virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; /** * If the given property is a ValueProperty, return the icon to be @@ -159,18 +159,18 @@ class SetPropertyCommand : public Command { public: - SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int); - virtual ~SetPropertyCommand() { } + SetPropertyCommand(PropertyContainer *pc, const PropertyName &pn, int); + virtual ~SetPropertyCommand() { } - virtual void execute(); - virtual void unexecute(); - virtual QString getName() const; + virtual void execute(); + virtual void unexecute(); + virtual QString getName() const; protected: - PropertyContainer *m_pc; - PropertyName m_pn; - int m_value; - int m_oldValue; + PropertyContainer *m_pc; + PropertyName m_pn; + int m_value; + int m_oldValue; }; virtual bool convertPropertyStrings(QString nameString, QString valueString, diff -r deabf9fd3d28 -r a12fd0456f0c base/RangeMapper.cpp --- a/base/RangeMapper.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/RangeMapper.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -22,7 +22,7 @@ #include LinearRangeMapper::LinearRangeMapper(int minpos, int maxpos, - double minval, double maxval, + double minval, double maxval, QString unit, bool inverted, std::map labels) : m_minpos(minpos), diff -r deabf9fd3d28 -r a12fd0456f0c base/RealTime.h --- a/base/RealTime.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/RealTime.h Tue Apr 17 10:35:42 2018 +0100 @@ -51,10 +51,10 @@ RealTime(int s, int n); RealTime(const RealTime &r) : - sec(r.sec), nsec(r.nsec) { } + sec(r.sec), nsec(r.nsec) { } RealTime(const Vamp::RealTime &r) : - sec(r.sec), nsec(r.nsec) { } + sec(r.sec), nsec(r.nsec) { } static RealTime fromSeconds(double sec); static RealTime fromMilliseconds(int msec); @@ -65,27 +65,27 @@ Vamp::RealTime toVampRealTime() const { return Vamp::RealTime(sec, nsec); } RealTime &operator=(const RealTime &r) { - sec = r.sec; nsec = r.nsec; return *this; + sec = r.sec; nsec = r.nsec; return *this; } RealTime operator+(const RealTime &r) const { - return RealTime(sec + r.sec, nsec + r.nsec); + return RealTime(sec + r.sec, nsec + r.nsec); } RealTime operator-(const RealTime &r) const { - return RealTime(sec - r.sec, nsec - r.nsec); + return RealTime(sec - r.sec, nsec - r.nsec); } RealTime operator-() const { - return RealTime(-sec, -nsec); + return RealTime(-sec, -nsec); } bool operator <(const RealTime &r) const { - if (sec == r.sec) return nsec < r.nsec; - else return sec < r.sec; + if (sec == r.sec) return nsec < r.nsec; + else return sec < r.sec; } bool operator >(const RealTime &r) const { - if (sec == r.sec) return nsec > r.nsec; - else return sec > r.sec; + if (sec == r.sec) return nsec > r.nsec; + else return sec > r.sec; } bool operator==(const RealTime &r) const { diff -r deabf9fd3d28 -r a12fd0456f0c base/RealTimeSV.cpp --- a/base/RealTimeSV.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/RealTimeSV.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -19,6 +19,7 @@ */ #include +#include #include #include @@ -43,16 +44,10 @@ RealTime::RealTime(int s, int n) : sec(s), nsec(n) { - if (sec == 0) { - while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; } - while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; } - } else if (sec < 0) { - while (nsec <= -ONE_BILLION) { nsec += ONE_BILLION; --sec; } - while (nsec > 0 && sec < 0) { nsec -= ONE_BILLION; ++sec; } - } else { - while (nsec >= ONE_BILLION) { nsec -= ONE_BILLION; ++sec; } - while (nsec < 0 && sec > 0) { nsec += ONE_BILLION; --sec; } - } + while (nsec <= -ONE_BILLION && sec > INT_MIN) { nsec += ONE_BILLION; --sec; } + while (nsec >= ONE_BILLION && sec < INT_MAX) { nsec -= ONE_BILLION; ++sec; } + while (nsec > 0 && sec < 0) { nsec -= ONE_BILLION; ++sec; } + while (nsec < 0 && sec > 0) { nsec += ONE_BILLION; --sec; } } RealTime @@ -174,9 +169,9 @@ std::ostream &operator<<(std::ostream &out, const RealTime &rt) { if (rt < RealTime::zeroTime) { - out << "-"; + out << "-"; } else { - out << " "; + out << " "; } int s = (rt.sec < 0 ? -rt.sec : rt.sec); @@ -187,8 +182,8 @@ int nn(n); if (nn == 0) out << "00000000"; else while (nn < (ONE_BILLION / 10)) { - out << "0"; - nn *= 10; + out << "0"; + nn *= 10; } out << n << "R"; @@ -319,24 +314,24 @@ int ms = msec(); if (ms != 0) { - out << "."; - out << (ms / 100); - ms = ms % 100; - if (ms != 0) { - out << (ms / 10); - ms = ms % 10; - } else if (fixedDp) { - out << "0"; - } - if (ms != 0) { - out << ms; - } else if (fixedDp) { - out << "0"; - } + out << "."; + out << (ms / 100); + ms = ms % 100; + if (ms != 0) { + out << (ms / 10); + ms = ms % 10; + } else if (fixedDp) { + out << "0"; + } + if (ms != 0) { + out << ms; + } else if (fixedDp) { + out << "0"; + } } else if (fixedDp) { - out << ".000"; + out << ".000"; } - + std::string s = out.str(); return s; @@ -371,7 +366,7 @@ out << d; div /= 10; } - + std::string s = out.str(); // cerr << "converted " << toString() << " to " << s << endl; diff -r deabf9fd3d28 -r a12fd0456f0c base/ResourceFinder.h --- a/base/ResourceFinder.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/ResourceFinder.h Tue Apr 17 10:35:42 2018 +0100 @@ -25,7 +25,7 @@ #include #include "Debug.h" - + class ResourceFinder { public: diff -r deabf9fd3d28 -r a12fd0456f0c base/RingBuffer.h --- a/base/RingBuffer.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/RingBuffer.h Tue Apr 17 10:35:42 2018 +0100 @@ -210,7 +210,7 @@ delete[] m_readers; if (m_mlocked) { - MUNLOCK((void *)m_buffer, m_size * sizeof(T)); + MUNLOCK((void *)m_buffer, m_size * sizeof(T)); } delete[] m_buffer; } @@ -293,15 +293,15 @@ { int space = 0; for (int i = 0; i < N; ++i) { - int here = (m_readers[i] + m_size - m_writer - 1) % m_size; - if (i == 0 || here < space) space = here; + int here = (m_readers[i] + m_size - m_writer - 1) % m_size; + if (i == 0 || here < space) space = here; } #ifdef DEBUG_RINGBUFFER int rs(getReadSpace()), rp(m_readers[0]); std::cerr << "RingBuffer: write space " << space << ", read space " - << rs << ", total " << (space + rs) << ", m_size " << m_size << std::endl; + << rs << ", total " << (space + rs) << ", m_size " << m_size << std::endl; std::cerr << "RingBuffer: reader " << rp << ", writer " << m_writer << std::endl; #endif @@ -323,20 +323,20 @@ int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only " << available << " samples available" - << std::endl; + std::cerr << "WARNING: Only " << available << " samples available" + << std::endl; #endif - memset(destination + available, 0, (n - available) * sizeof(T)); - n = available; + memset(destination + available, 0, (n - available) * sizeof(T)); + n = available; } if (n == 0) return n; int here = m_size - m_readers[R]; if (here >= n) { - memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); + memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); } else { - memcpy(destination, m_buffer + m_readers[R], here * sizeof(T)); - memcpy(destination + here, m_buffer, (n - here) * sizeof(T)); + memcpy(destination, m_buffer + m_readers[R], here * sizeof(T)); + memcpy(destination + here, m_buffer, (n - here) * sizeof(T)); } MBARRIER(); @@ -360,26 +360,26 @@ int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only " << available << " samples available" - << std::endl; + std::cerr << "WARNING: Only " << available << " samples available" + << std::endl; #endif - n = available; + n = available; } if (n == 0) return n; int here = m_size - m_readers[R]; if (here >= n) { - for (int i = 0; i < n; ++i) { - destination[i] += (m_buffer + m_readers[R])[i]; - } + for (int i = 0; i < n; ++i) { + destination[i] += (m_buffer + m_readers[R])[i]; + } } else { - for (int i = 0; i < here; ++i) { - destination[i] += (m_buffer + m_readers[R])[i]; - } - for (int i = 0; i < (n - here); ++i) { - destination[i + here] += m_buffer[i]; - } + for (int i = 0; i < here; ++i) { + destination[i] += (m_buffer + m_readers[R])[i]; + } + for (int i = 0; i < (n - here); ++i) { + destination[i + here] += m_buffer[i]; + } } MBARRIER(); @@ -397,12 +397,12 @@ if (m_writer == m_readers[R]) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: No sample available" - << std::endl; + std::cerr << "WARNING: No sample available" + << std::endl; #endif - T t; - memset(&t, 0, sizeof(T)); - return t; + T t; + memset(&t, 0, sizeof(T)); + return t; } T value = m_buffer[m_readers[R]]; MBARRIER(); @@ -421,20 +421,20 @@ int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only " << available << " samples available" - << std::endl; + std::cerr << "WARNING: Only " << available << " samples available" + << std::endl; #endif - memset(destination + available, 0, (n - available) * sizeof(T)); - n = available; + memset(destination + available, 0, (n - available) * sizeof(T)); + n = available; } if (n == 0) return n; int here = m_size - m_readers[R]; if (here >= n) { - memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); + memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); } else { - memcpy(destination, m_buffer + m_readers[R], here * sizeof(T)); - memcpy(destination + here, m_buffer, (n - here) * sizeof(T)); + memcpy(destination, m_buffer + m_readers[R], here * sizeof(T)); + memcpy(destination + here, m_buffer, (n - here) * sizeof(T)); } #ifdef DEBUG_RINGBUFFER @@ -454,12 +454,12 @@ if (m_writer == m_readers[R]) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: No sample available" - << std::endl; + std::cerr << "WARNING: No sample available" + << std::endl; #endif - T t; - memset(&t, 0, sizeof(T)); - return t; + T t; + memset(&t, 0, sizeof(T)); + return t; } T value = m_buffer[m_readers[R]]; return value; @@ -476,10 +476,10 @@ int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only " << available << " samples available" - << std::endl; + std::cerr << "WARNING: Only " << available << " samples available" + << std::endl; #endif - n = available; + n = available; } if (n == 0) return n; m_readers[R] = (m_readers[R] + n) % m_size; @@ -497,19 +497,19 @@ int available = getWriteSpace(); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only room for " << available << " samples" - << std::endl; + std::cerr << "WARNING: Only room for " << available << " samples" + << std::endl; #endif - n = available; + n = available; } if (n == 0) return n; int here = m_size - m_writer; if (here >= n) { - memcpy(m_buffer + m_writer, source, n * sizeof(T)); + memcpy(m_buffer + m_writer, source, n * sizeof(T)); } else { - memcpy(m_buffer + m_writer, source, here * sizeof(T)); - memcpy(m_buffer, source + here, (n - here) * sizeof(T)); + memcpy(m_buffer + m_writer, source, here * sizeof(T)); + memcpy(m_buffer, source + here, (n - here) * sizeof(T)); } MBARRIER(); @@ -533,19 +533,19 @@ int available = getWriteSpace(); if (n > available) { #ifdef DEBUG_RINGBUFFER - std::cerr << "WARNING: Only room for " << available << " samples" - << std::endl; + std::cerr << "WARNING: Only room for " << available << " samples" + << std::endl; #endif - n = available; + n = available; } if (n == 0) return n; int here = m_size - m_writer; if (here >= n) { - memset(m_buffer + m_writer, 0, n * sizeof(T)); + memset(m_buffer + m_writer, 0, n * sizeof(T)); } else { - memset(m_buffer + m_writer, 0, here * sizeof(T)); - memset(m_buffer, 0, (n - here) * sizeof(T)); + memset(m_buffer + m_writer, 0, here * sizeof(T)); + memset(m_buffer, 0, (n - here) * sizeof(T)); } MBARRIER(); diff -r deabf9fd3d28 -r a12fd0456f0c base/ScaleTickIntervals.h --- a/base/ScaleTickIntervals.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/ScaleTickIntervals.h Tue Apr 17 10:35:42 2018 +0100 @@ -30,14 +30,14 @@ { public: struct Range { - double min; // start of value range - double max; // end of value range - int n; // number of divisions (approximate only) + double min; // start of value range + double max; // end of value range + int n; // number of divisions (approximate only) }; struct Tick { - double value; // value this tick represents - std::string label; // value as written + double value; // value this tick represents + std::string label; // value as written }; typedef std::vector Ticks; @@ -79,12 +79,12 @@ }; struct Instruction { - double initial; // value of first tick + double initial; // value of first tick double limit; // max from original range - double spacing; // increment between ticks - double roundTo; // what all displayed values should be rounded to - Display display; // whether to use fixed precision (%e, %f, or %g) - int precision; // number of dp (%f) or sf (%e) + double spacing; // increment between ticks + double roundTo; // what all displayed values should be rounded to + Display display; // whether to use fixed precision (%e, %f, or %g) + int precision; // number of dp (%f) or sf (%e) bool logUnmap; // true if values represent logs of display values }; @@ -92,21 +92,21 @@ { Display display = Auto; - if (r.max < r.min) { - return linearInstruction({ r.max, r.min, r.n }); - } - if (r.n < 1 || r.max == r.min) { + if (r.max < r.min) { + return linearInstruction({ r.max, r.min, r.n }); + } + if (r.n < 1 || r.max == r.min) { return { r.min, r.min, 1.0, r.min, display, 1, false }; } - - double inc = (r.max - r.min) / r.n; + + double inc = (r.max - r.min) / r.n; double digInc = log10(inc); double digMax = log10(fabs(r.max)); double digMin = log10(fabs(r.min)); int precInc = int(floor(digInc)); - double roundTo = pow(10.0, precInc); + double roundTo = pow(10.0, precInc); if (precInc > -4 && precInc < 4) { display = Fixed; @@ -182,21 +182,21 @@ { Display display = Auto; - if (r.n < 1) { - return {}; - } - if (r.max < r.min) { - return logInstruction({ r.max, r.min, r.n }); - } + if (r.n < 1) { + return {}; + } + if (r.max < r.min) { + return logInstruction({ r.max, r.min, r.n }); + } if (r.max == r.min) { return { r.min, r.max, 1.0, r.min, display, 1, true }; } - - double inc = (r.max - r.min) / r.n; + + double inc = (r.max - r.min) / r.n; double digInc = log10(inc); int precInc = int(floor(digInc)); - double roundTo = pow(10.0, precInc); + double roundTo = pow(10.0, precInc); if (roundTo != 0.0) { inc = round(inc / roundTo) * roundTo; @@ -237,7 +237,7 @@ SVDEBUG << "ScaleTickIntervals: roundTo = " << roundTo << endl; #endif - double min = r.min; + double min = r.min; if (inc != 0.0) { min = ceil(r.min / inc) * inc; if (min > r.max) min = r.max; @@ -275,7 +275,7 @@ static Ticks explode(Instruction instruction) { #ifdef DEBUG_SCALE_TICK_INTERVALS - SVDEBUG << "ScaleTickIntervals::explode:" << endl + SVDEBUG << "ScaleTickIntervals::explode:" << endl << "initial = " << instruction.initial << ", limit = " << instruction.limit << ", spacing = " << instruction.spacing @@ -311,11 +311,11 @@ if (instruction.roundTo != 0.0) { value = instruction.roundTo * round(value / instruction.roundTo); } - ticks.push_back(makeTick(instruction.display, + ticks.push_back(makeTick(instruction.display, instruction.precision, value)); ++n; - } + } return ticks; } diff -r deabf9fd3d28 -r a12fd0456f0c base/Scavenger.h --- a/base/Scavenger.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Scavenger.h Tue Apr 17 10:35:42 2018 +0100 @@ -106,15 +106,15 @@ Scavenger::~Scavenger() { if (m_scavenged < m_claimed) { - for (size_t i = 0; i < m_objects.size(); ++i) { - ObjectTimePair &pair = m_objects[i]; - if (pair.first != 0) { - T *ot = pair.first; - pair.first = 0; - delete ot; - ++m_scavenged; - } - } + for (size_t i = 0; i < m_objects.size(); ++i) { + ObjectTimePair &pair = m_objects[i]; + if (pair.first != 0) { + T *ot = pair.first; + pair.first = 0; + delete ot; + ++m_scavenged; + } + } } clearExcess(0); @@ -131,17 +131,17 @@ time_t sec = tv.tv_sec; for (size_t i = 0; i < m_objects.size(); ++i) { - ObjectTimePair &pair = m_objects[i]; - if (pair.first == 0) { - pair.second = sec; - pair.first = t; - ++m_claimed; - return; - } + ObjectTimePair &pair = m_objects[i]; + if (pair.first == 0) { + pair.second = sec; + pair.first = t; + ++m_claimed; + return; + } } std::cerr << "WARNING: Scavenger::claim(" << t << "): run out of slots, " - << "using non-RT-safe method" << std::endl; + << "using non-RT-safe method" << std::endl; pushExcess(t); } @@ -158,14 +158,14 @@ time_t sec = tv.tv_sec; for (size_t i = 0; i < m_objects.size(); ++i) { - ObjectTimePair &pair = m_objects[i]; - if (clearNow || - (pair.first != 0 && pair.second + m_sec < sec)) { - T *ot = pair.first; - pair.first = 0; - delete ot; - ++m_scavenged; - } + ObjectTimePair &pair = m_objects[i]; + if (clearNow || + (pair.first != 0 && pair.second + m_sec < sec)) { + T *ot = pair.first; + pair.first = 0; + delete ot; + ++m_scavenged; + } } if (sec > m_lastExcess + m_sec) { @@ -191,8 +191,8 @@ { m_excessMutex.lock(); for (typename ObjectList::iterator i = m_excess.begin(); - i != m_excess.end(); ++i) { - delete *i; + i != m_excess.end(); ++i) { + delete *i; } m_excess.clear(); m_lastExcess = sec; diff -r deabf9fd3d28 -r a12fd0456f0c base/Selection.cpp --- a/base/Selection.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Selection.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -27,9 +27,9 @@ m_endFrame(endFrame) { if (m_startFrame > m_endFrame) { - sv_frame_t tmp = m_endFrame; - m_endFrame = m_startFrame; - m_startFrame = tmp; + sv_frame_t tmp = m_endFrame; + m_endFrame = m_startFrame; + m_startFrame = tmp; } } @@ -43,8 +43,8 @@ Selection::operator=(const Selection &s) { if (this != &s) { - m_startFrame = s.m_startFrame; - m_endFrame = s.m_endFrame; + m_startFrame = s.m_startFrame; + m_endFrame = s.m_endFrame; } return *this; } @@ -81,11 +81,11 @@ Selection::operator<(const Selection &s) const { if (isEmpty()) { - if (s.isEmpty()) return false; - else return true; + if (s.isEmpty()) return false; + else return true; } else { - if (s.isEmpty()) return false; - else return (m_startFrame < s.m_startFrame); + if (s.isEmpty()) return false; + else return (m_startFrame < s.m_startFrame); } } @@ -95,7 +95,7 @@ if (isEmpty()) return s.isEmpty(); return (m_startFrame == s.m_startFrame && - m_endFrame == s.m_endFrame); + m_endFrame == s.m_endFrame); } @@ -134,21 +134,21 @@ // this is not just a frill. for (SelectionList::iterator i = m_selections.begin(); - i != m_selections.end(); ) { - - SelectionList::iterator j = i; - if (++j == m_selections.end()) break; + i != m_selections.end(); ) { + + SelectionList::iterator j = i; + if (++j == m_selections.end()) break; - if (i->getEndFrame() >= j->getStartFrame()) { - Selection merged(i->getStartFrame(), - std::max(i->getEndFrame(), j->getEndFrame())); - m_selections.erase(i); - m_selections.erase(j); - m_selections.insert(merged); - i = m_selections.begin(); - } else { - ++i; - } + if (i->getEndFrame() >= j->getStartFrame()) { + Selection merged(i->getStartFrame(), + std::max(i->getEndFrame(), j->getEndFrame())); + m_selections.erase(i); + m_selections.erase(j); + m_selections.insert(merged); + i = m_selections.begin(); + } else { + ++i; + } } } @@ -161,7 +161,7 @@ //appropriately) if (m_selections.find(selection) != m_selections.end()) { - m_selections.erase(selection); + m_selections.erase(selection); } } @@ -169,7 +169,7 @@ MultiSelection::clearSelections() { if (!m_selections.empty()) { - m_selections.clear(); + m_selections.clear(); } } @@ -180,7 +180,7 @@ endFrame = 0; for (SelectionList::const_iterator i = m_selections.begin(); - i != m_selections.end(); ++i) { + i != m_selections.end(); ++i) { if (i == m_selections.begin() || i->getStartFrame() < startFrame) { startFrame = i->getStartFrame(); @@ -200,14 +200,14 @@ // scalable method, and I think that may be what we need for (SelectionList::const_iterator i = m_selections.begin(); - i != m_selections.end(); ++i) { + i != m_selections.end(); ++i) { - if (i->contains(frame)) return *i; + if (i->contains(frame)) return *i; - if (i->getStartFrame() > frame) { - if (defaultToFollowing) return *i; - else return Selection(); - } + if (i->getStartFrame() > frame) { + if (defaultToFollowing) return *i; + else return Selection(); + } } return Selection(); @@ -219,10 +219,10 @@ { stream << indent << QString("\n").arg(extraAttributes); for (SelectionList::iterator i = m_selections.begin(); - i != m_selections.end(); ++i) { - stream << indent + i != m_selections.end(); ++i) { + stream << indent << QString(" \n") - .arg(i->getStartFrame()).arg(i->getEndFrame()); + .arg(i->getStartFrame()).arg(i->getEndFrame()); } stream << indent << "\n"; } diff -r deabf9fd3d28 -r a12fd0456f0c base/StorageAdviser.cpp --- a/base/StorageAdviser.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/StorageAdviser.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -65,8 +65,8 @@ StorageAdviser::Recommendation StorageAdviser::recommend(Criteria criteria, - size_t minimumSize, - size_t maximumSize) + size_t minimumSize, + size_t maximumSize) { SVDEBUG << "StorageAdviser::recommend: criteria " << criteria << " (" + criteriaToString(criteria) + ")" diff -r deabf9fd3d28 -r a12fd0456f0c base/StringBits.cpp --- a/base/StringBits.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/StringBits.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -42,7 +42,7 @@ while (i < len) { - QChar c = s[i]; + QChar c = s[i]; if (c.isDigit()) { @@ -85,45 +85,45 @@ enum { sep, unq, q1, q2 } mode = sep; for (int i = 0; i < s.length(); ++i) { - - QChar c = s[i]; + + QChar c = s[i]; - if (c == '\'') { - switch (mode) { - case sep: mode = q1; break; - case unq: case q2: tok += c; break; - case q1: mode = unq; break; - } + if (c == '\'') { + switch (mode) { + case sep: mode = q1; break; + case unq: case q2: tok += c; break; + case q1: mode = unq; break; + } - } else if (c == '"') { - switch (mode) { - case sep: mode = q2; break; - case unq: case q1: tok += c; break; - case q2: mode = unq; break; - } + } else if (c == '"') { + switch (mode) { + case sep: mode = q2; break; + case unq: case q1: tok += c; break; + case q2: mode = unq; break; + } - } else if (c == separator || (separator == ' ' && c.isSpace())) { - switch (mode) { - case sep: if (separator != ' ') tokens << ""; break; - case unq: mode = sep; tokens << tok; tok = ""; break; - case q1: case q2: tok += c; break; - } + } else if (c == separator || (separator == ' ' && c.isSpace())) { + switch (mode) { + case sep: if (separator != ' ') tokens << ""; break; + case unq: mode = sep; tokens << tok; tok = ""; break; + case q1: case q2: tok += c; break; + } - } else if (c == '\\') { - if (++i < s.length()) { - c = s[i]; - switch (mode) { - case sep: mode = unq; tok += c; break; + } else if (c == '\\') { + if (++i < s.length()) { + c = s[i]; + switch (mode) { + case sep: mode = unq; tok += c; break; case unq: case q1: case q2: tok += c; break; - } - } + } + } - } else { - switch (mode) { - case sep: mode = unq; tok += c; break; + } else { + switch (mode) { + case sep: mode = unq; tok += c; break; case unq: case q1: case q2: tok += c; break; - } - } + } + } } if (tok != "" || mode != sep) { diff -r deabf9fd3d28 -r a12fd0456f0c base/TempWriteFile.cpp --- a/base/TempWriteFile.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/TempWriteFile.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -27,8 +27,8 @@ temp.setAutoRemove(false); temp.open(); // creates the file and opens it atomically if (temp.error()) { - SVCERR << "TempWriteFile: Failed to create temporary file in directory of " << m_target << ": " << temp.errorString() << endl; - throw FileOperationFailed(temp.fileName(), "creation"); + SVCERR << "TempWriteFile: Failed to create temporary file in directory of " << m_target << ": " << temp.errorString() << endl; + throw FileOperationFailed(temp.fileName(), "creation"); } m_temp = temp.fileName(); @@ -38,8 +38,8 @@ TempWriteFile::~TempWriteFile() { if (m_temp != "") { - QDir dir(QFileInfo(m_temp).dir()); - dir.remove(m_temp); + QDir dir(QFileInfo(m_temp).dir()); + dir.remove(m_temp); } } @@ -65,7 +65,7 @@ if (!tempFile.rename(m_target)) { SVCERR << "TempWriteFile: Failed to rename temporary file " << m_temp << " to target " << m_target << endl; - throw FileOperationFailed(m_temp, "rename"); + throw FileOperationFailed(m_temp, "rename"); } m_temp = ""; diff -r deabf9fd3d28 -r a12fd0456f0c base/TextMatcher.cpp --- a/base/TextMatcher.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/TextMatcher.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -25,7 +25,7 @@ void TextMatcher::test(Match &match, QStringList keywords, QString text, - QString textType, int score) + QString textType, int score) { /* if (text.toLower() == keyword.toLower()) { diff -r deabf9fd3d28 -r a12fd0456f0c base/Window.h --- a/base/Window.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/Window.h Tue Apr 17 10:35:42 2018 +0100 @@ -57,11 +57,11 @@ encache(); } Window &operator=(const Window &w) { - if (&w == this) return *this; - m_type = w.m_type; - m_size = w.m_size; - encache(); - return *this; + if (&w == this) return *this; + m_type = w.m_type; + m_size = w.m_size; + encache(); + return *this; } virtual ~Window() { breakfastquay::deallocate(m_cache); @@ -107,38 +107,38 @@ int i; switch (m_type) { - + case RectangularWindow: - for (i = 0; i < n; ++i) { - m_cache[i] *= T(0.5); - } - break; - + for (i = 0; i < n; ++i) { + m_cache[i] *= T(0.5); + } + break; + case BartlettWindow: - for (i = 0; i < n/2; ++i) { - m_cache[i] *= T(i) / T(n/2); - m_cache[i + n/2] *= T(1.0) - T(i) / T(n/2); - } - break; - + for (i = 0; i < n/2; ++i) { + m_cache[i] *= T(i) / T(n/2); + m_cache[i + n/2] *= T(1.0) - T(i) / T(n/2); + } + break; + case HammingWindow: cosinewin(m_cache, 0.54, 0.46, 0.0, 0.0); - break; - + break; + case HanningWindow: cosinewin(m_cache, 0.50, 0.50, 0.0, 0.0); - break; - + break; + case BlackmanWindow: cosinewin(m_cache, 0.42, 0.50, 0.08, 0.0); - break; - + break; + case GaussianWindow: - for (i = 0; i < n; ++i) { + for (i = 0; i < n; ++i) { m_cache[i] *= T(pow(2, - pow((i - (n-1)/2.0) / ((n-1)/2.0 / 3), 2))); - } - break; - + } + break; + case ParzenWindow: { int N = n-1; @@ -158,13 +158,13 @@ case NuttallWindow: cosinewin(m_cache, 0.3635819, 0.4891775, 0.1365995, 0.0106411); - break; + break; case BlackmanHarrisWindow: cosinewin(m_cache, 0.35875, 0.48829, 0.14128, 0.01168); break; } - + m_area = 0; for (int i = 0; i < n; ++i) { m_area += m_cache[i]; diff -r deabf9fd3d28 -r a12fd0456f0c base/XmlExportable.cpp --- a/base/XmlExportable.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/XmlExportable.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -41,11 +41,11 @@ XmlExportable::encodeEntities(QString s) { s - .replace("&", "&") - .replace("<", "<") - .replace(">", ">") - .replace("\"", """) - .replace("'", "'"); + .replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """) + .replace("'", "'"); return s; } @@ -77,7 +77,7 @@ static int maxId = 0; if (idMap.find(object) == idMap.end()) { - idMap[object] = maxId++; + idMap[object] = maxId++; } return idMap[object]; diff -r deabf9fd3d28 -r a12fd0456f0c base/XmlExportable.h --- a/base/XmlExportable.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/XmlExportable.h Tue Apr 17 10:35:42 2018 +0100 @@ -40,7 +40,7 @@ * Do not override this unless you really know what you're doing. */ virtual QString toXmlString(QString indent = "", - QString extraAttributes = "") const; + QString extraAttributes = "") const; static QString encodeEntities(QString); diff -r deabf9fd3d28 -r a12fd0456f0c base/ZoomConstraint.h --- a/base/ZoomConstraint.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/ZoomConstraint.h Tue Apr 17 10:35:42 2018 +0100 @@ -33,9 +33,9 @@ virtual ~ZoomConstraint() { } enum RoundingDirection { - RoundDown, - RoundUp, - RoundNearest + RoundDown, + RoundUp, + RoundNearest }; /** @@ -49,11 +49,11 @@ * depending on the rounding direction supplied. */ virtual int getNearestBlockSize(int requestedBlockSize, - RoundingDirection = RoundNearest) - const + RoundingDirection = RoundNearest) + const { - if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel(); - else return requestedBlockSize; + if (requestedBlockSize > getMaxZoomLevel()) return getMaxZoomLevel(); + else return requestedBlockSize; } /** diff -r deabf9fd3d28 -r a12fd0456f0c base/test/TestOurRealTime.h --- a/base/test/TestOurRealTime.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/test/TestOurRealTime.h Tue Apr 17 10:35:42 2018 +0100 @@ -70,6 +70,11 @@ QCOMPARE(RealTime(-2, ONE_BILLION*2), RealTime(0, 0)); QCOMPARE(RealTime(-2, ONE_BILLION/2), RealTime(-1, -ONE_BILLION/2)); + + QCOMPARE(RealTime(1, -ONE_BILLION/2).sec, 0); + QCOMPARE(RealTime(1, -ONE_BILLION/2).nsec, ONE_BILLION/2); + QCOMPARE(RealTime(-1, ONE_BILLION/2).sec, 0); + QCOMPARE(RealTime(-1, ONE_BILLION/2).nsec, -ONE_BILLION/2); QCOMPARE(RealTime(0, 1).sec, 0); QCOMPARE(RealTime(0, 1).nsec, 1); diff -r deabf9fd3d28 -r a12fd0456f0c base/test/TestPitch.h --- a/base/test/TestPitch.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/test/TestPitch.h Tue Apr 17 10:35:42 2018 +0100 @@ -32,76 +32,76 @@ private slots: void init() { - Preferences::getInstance()->setOctaveOfMiddleC(4); - Preferences::getInstance()->setTuningFrequency(440); + Preferences::getInstance()->setOctaveOfMiddleC(4); + Preferences::getInstance()->setTuningFrequency(440); } void pitchLabel() { - QCOMPARE(Pitch::getPitchLabel(60, 0, false), QString("C4")); - QCOMPARE(Pitch::getPitchLabel(69, 0, false), QString("A4")); - QCOMPARE(Pitch::getPitchLabel(61, 0, false), QString("C#4")); - QCOMPARE(Pitch::getPitchLabel(61, 0, true), QString("Db4")); - QCOMPARE(Pitch::getPitchLabel(59, 0, false), QString("B3")); - QCOMPARE(Pitch::getPitchLabel(59, 0, true), QString("B3")); - QCOMPARE(Pitch::getPitchLabel(0, 0, false), QString("C-1")); + QCOMPARE(Pitch::getPitchLabel(60, 0, false), QString("C4")); + QCOMPARE(Pitch::getPitchLabel(69, 0, false), QString("A4")); + QCOMPARE(Pitch::getPitchLabel(61, 0, false), QString("C#4")); + QCOMPARE(Pitch::getPitchLabel(61, 0, true), QString("Db4")); + QCOMPARE(Pitch::getPitchLabel(59, 0, false), QString("B3")); + QCOMPARE(Pitch::getPitchLabel(59, 0, true), QString("B3")); + QCOMPARE(Pitch::getPitchLabel(0, 0, false), QString("C-1")); - QCOMPARE(Pitch::getPitchLabel(60, -40, false), QString("C4-40c")); - QCOMPARE(Pitch::getPitchLabel(60, 40, false), QString("C4+40c")); - QCOMPARE(Pitch::getPitchLabel(58, 4, false), QString("A#3+4c")); + QCOMPARE(Pitch::getPitchLabel(60, -40, false), QString("C4-40c")); + QCOMPARE(Pitch::getPitchLabel(60, 40, false), QString("C4+40c")); + QCOMPARE(Pitch::getPitchLabel(58, 4, false), QString("A#3+4c")); - Preferences::getInstance()->setOctaveOfMiddleC(3); + Preferences::getInstance()->setOctaveOfMiddleC(3); - QCOMPARE(Pitch::getPitchLabel(60, 0, false), QString("C3")); - QCOMPARE(Pitch::getPitchLabel(69, 0, false), QString("A3")); - QCOMPARE(Pitch::getPitchLabel(61, 0, false), QString("C#3")); - QCOMPARE(Pitch::getPitchLabel(61, 0, true), QString("Db3")); - QCOMPARE(Pitch::getPitchLabel(59, 0, false), QString("B2")); - QCOMPARE(Pitch::getPitchLabel(59, 0, true), QString("B2")); - QCOMPARE(Pitch::getPitchLabel(0, 0, false), QString("C-2")); + QCOMPARE(Pitch::getPitchLabel(60, 0, false), QString("C3")); + QCOMPARE(Pitch::getPitchLabel(69, 0, false), QString("A3")); + QCOMPARE(Pitch::getPitchLabel(61, 0, false), QString("C#3")); + QCOMPARE(Pitch::getPitchLabel(61, 0, true), QString("Db3")); + QCOMPARE(Pitch::getPitchLabel(59, 0, false), QString("B2")); + QCOMPARE(Pitch::getPitchLabel(59, 0, true), QString("B2")); + QCOMPARE(Pitch::getPitchLabel(0, 0, false), QString("C-2")); - QCOMPARE(Pitch::getPitchLabel(60, -40, false), QString("C3-40c")); - QCOMPARE(Pitch::getPitchLabel(60, 40, false), QString("C3+40c")); - QCOMPARE(Pitch::getPitchLabel(58, 4, false), QString("A#2+4c")); + QCOMPARE(Pitch::getPitchLabel(60, -40, false), QString("C3-40c")); + QCOMPARE(Pitch::getPitchLabel(60, 40, false), QString("C3+40c")); + QCOMPARE(Pitch::getPitchLabel(58, 4, false), QString("A#2+4c")); } void pitchLabelForFrequency() { - QCOMPARE(Pitch::getPitchLabelForFrequency(440, 440, false), QString("A4")); - QCOMPARE(Pitch::getPitchLabelForFrequency(440, 220, false), QString("A5")); - QCOMPARE(Pitch::getPitchLabelForFrequency(261.63, 440, false), QString("C4")); + QCOMPARE(Pitch::getPitchLabelForFrequency(440, 440, false), QString("A4")); + QCOMPARE(Pitch::getPitchLabelForFrequency(440, 220, false), QString("A5")); + QCOMPARE(Pitch::getPitchLabelForFrequency(261.63, 440, false), QString("C4")); } #define MIDDLE_C 261.6255653005986 void frequencyForPitch() { - QCOMPARE(Pitch::getFrequencyForPitch(60, 0), MIDDLE_C); - QCOMPARE(Pitch::getFrequencyForPitch(69, 0), 440.0); - QCOMPARE(Pitch::getFrequencyForPitch(60, 0, 220), MIDDLE_C / 2.0); - QCOMPARE(Pitch::getFrequencyForPitch(69, 0, 220), 220.0); + QCOMPARE(Pitch::getFrequencyForPitch(60, 0), MIDDLE_C); + QCOMPARE(Pitch::getFrequencyForPitch(69, 0), 440.0); + QCOMPARE(Pitch::getFrequencyForPitch(60, 0, 220), MIDDLE_C / 2.0); + QCOMPARE(Pitch::getFrequencyForPitch(69, 0, 220), 220.0); } void pitchForFrequency() { - double centsOffset = 0.0; - QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); - QCOMPARE(centsOffset + 1.0, 1.0); // avoid ineffective fuzzy-compare to 0 - QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); - QCOMPARE(int(centsOffset), -4); - QCOMPARE(Pitch::getPitchForFrequency(440.0, ¢sOffset), 69); - QCOMPARE(centsOffset + 1.0, 1.0); + double centsOffset = 0.0; + QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); + QCOMPARE(centsOffset + 1.0, 1.0); // avoid ineffective fuzzy-compare to 0 + QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); + QCOMPARE(int(centsOffset), -4); + QCOMPARE(Pitch::getPitchForFrequency(440.0, ¢sOffset), 69); + QCOMPARE(centsOffset + 1.0, 1.0); } void pitchForFrequencyF() { - float centsOffset = 0.f; - QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); - QCOMPARE(centsOffset + 1.f, 1.f); // avoid ineffective fuzzy-compare to 0 - QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); - QCOMPARE(int(centsOffset), -4); - QCOMPARE(Pitch::getPitchForFrequency(440.0, ¢sOffset), 69); - QCOMPARE(centsOffset + 1.f, 1.f); + float centsOffset = 0.f; + QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, ¢sOffset), 60); + QCOMPARE(centsOffset + 1.f, 1.f); // avoid ineffective fuzzy-compare to 0 + QCOMPARE(Pitch::getPitchForFrequency(261.0, ¢sOffset), 60); + QCOMPARE(int(centsOffset), -4); + QCOMPARE(Pitch::getPitchForFrequency(440.0, ¢sOffset), 69); + QCOMPARE(centsOffset + 1.f, 1.f); } }; diff -r deabf9fd3d28 -r a12fd0456f0c base/test/TestRangeMapper.h --- a/base/test/TestRangeMapper.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/test/TestRangeMapper.h Tue Apr 17 10:35:42 2018 +0100 @@ -32,250 +32,250 @@ private slots: void linearUpForward() { - LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", false); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getPositionForValue(0.5), 1); - QCOMPARE(rm.getPositionForValue(4.0), 8); - QCOMPARE(rm.getPositionForValue(3.0), 6); - QCOMPARE(rm.getPositionForValue(3.1), 6); - QCOMPARE(rm.getPositionForValue(3.4), 7); - QCOMPARE(rm.getPositionForValue(0.2), 1); - QCOMPARE(rm.getPositionForValue(-12), 1); - QCOMPARE(rm.getPositionForValue(6.1), 8); - QCOMPARE(rm.getPositionForValueUnclamped(3.0), 6); - QCOMPARE(rm.getPositionForValueUnclamped(0.2), 0); - QCOMPARE(rm.getPositionForValueUnclamped(-12), -24); - QCOMPARE(rm.getPositionForValueUnclamped(6.1), 12); + LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", false); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getPositionForValue(0.5), 1); + QCOMPARE(rm.getPositionForValue(4.0), 8); + QCOMPARE(rm.getPositionForValue(3.0), 6); + QCOMPARE(rm.getPositionForValue(3.1), 6); + QCOMPARE(rm.getPositionForValue(3.4), 7); + QCOMPARE(rm.getPositionForValue(0.2), 1); + QCOMPARE(rm.getPositionForValue(-12), 1); + QCOMPARE(rm.getPositionForValue(6.1), 8); + QCOMPARE(rm.getPositionForValueUnclamped(3.0), 6); + QCOMPARE(rm.getPositionForValueUnclamped(0.2), 0); + QCOMPARE(rm.getPositionForValueUnclamped(-12), -24); + QCOMPARE(rm.getPositionForValueUnclamped(6.1), 12); } void linearDownForward() { - LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", true); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getPositionForValue(0.5), 8); - QCOMPARE(rm.getPositionForValue(4.0), 1); - QCOMPARE(rm.getPositionForValue(3.0), 3); - QCOMPARE(rm.getPositionForValue(3.1), 3); - QCOMPARE(rm.getPositionForValue(3.4), 2); - QCOMPARE(rm.getPositionForValue(0.2), 8); - QCOMPARE(rm.getPositionForValue(-12), 8); - QCOMPARE(rm.getPositionForValue(6.1), 1); - QCOMPARE(rm.getPositionForValueUnclamped(3.0), 3); - QCOMPARE(rm.getPositionForValueUnclamped(0.2), 9); - QCOMPARE(rm.getPositionForValueUnclamped(-12), 33); - QCOMPARE(rm.getPositionForValueUnclamped(6.1), -3); + LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", true); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getPositionForValue(0.5), 8); + QCOMPARE(rm.getPositionForValue(4.0), 1); + QCOMPARE(rm.getPositionForValue(3.0), 3); + QCOMPARE(rm.getPositionForValue(3.1), 3); + QCOMPARE(rm.getPositionForValue(3.4), 2); + QCOMPARE(rm.getPositionForValue(0.2), 8); + QCOMPARE(rm.getPositionForValue(-12), 8); + QCOMPARE(rm.getPositionForValue(6.1), 1); + QCOMPARE(rm.getPositionForValueUnclamped(3.0), 3); + QCOMPARE(rm.getPositionForValueUnclamped(0.2), 9); + QCOMPARE(rm.getPositionForValueUnclamped(-12), 33); + QCOMPARE(rm.getPositionForValueUnclamped(6.1), -3); } void linearUpBackward() { - LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", false); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getValueForPosition(1), 0.5); - QCOMPARE(rm.getValueForPosition(8), 4.0); - QCOMPARE(rm.getValueForPosition(6), 3.0); - QCOMPARE(rm.getValueForPosition(7), 3.5); - QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(1)); - QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(8)); - QCOMPARE(rm.getValueForPositionUnclamped(6), 3.0); - QCOMPARE(rm.getValueForPositionUnclamped(0) + 1.0, 0.0 + 1.0); - QCOMPARE(rm.getValueForPositionUnclamped(-24), -12.0); - QCOMPARE(rm.getValueForPositionUnclamped(12), 6.0); + LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", false); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getValueForPosition(1), 0.5); + QCOMPARE(rm.getValueForPosition(8), 4.0); + QCOMPARE(rm.getValueForPosition(6), 3.0); + QCOMPARE(rm.getValueForPosition(7), 3.5); + QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(1)); + QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(8)); + QCOMPARE(rm.getValueForPositionUnclamped(6), 3.0); + QCOMPARE(rm.getValueForPositionUnclamped(0) + 1.0, 0.0 + 1.0); + QCOMPARE(rm.getValueForPositionUnclamped(-24), -12.0); + QCOMPARE(rm.getValueForPositionUnclamped(12), 6.0); } void linearDownBackward() { - LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", true); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getValueForPosition(8), 0.5); - QCOMPARE(rm.getValueForPosition(1), 4.0); - QCOMPARE(rm.getValueForPosition(3), 3.0); - QCOMPARE(rm.getValueForPosition(2), 3.5); - QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(1)); - QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(8)); - QCOMPARE(rm.getValueForPositionUnclamped(3), 3.0); - QCOMPARE(rm.getValueForPositionUnclamped(9) + 1.0, 0.0 + 1.0); - QCOMPARE(rm.getValueForPositionUnclamped(33), -12.0); - QCOMPARE(rm.getValueForPositionUnclamped(-3), 6.0); + LinearRangeMapper rm(1, 8, 0.5, 4.0, "x", true); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getValueForPosition(8), 0.5); + QCOMPARE(rm.getValueForPosition(1), 4.0); + QCOMPARE(rm.getValueForPosition(3), 3.0); + QCOMPARE(rm.getValueForPosition(2), 3.5); + QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(1)); + QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(8)); + QCOMPARE(rm.getValueForPositionUnclamped(3), 3.0); + QCOMPARE(rm.getValueForPositionUnclamped(9) + 1.0, 0.0 + 1.0); + QCOMPARE(rm.getValueForPositionUnclamped(33), -12.0); + QCOMPARE(rm.getValueForPositionUnclamped(-3), 6.0); } void logUpForward() { - LogRangeMapper rm(3, 7, 10, 100000, "x", false); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getPositionForValue(10.0), 3); - QCOMPARE(rm.getPositionForValue(100000.0), 7); - QCOMPARE(rm.getPositionForValue(1.0), 3); - QCOMPARE(rm.getPositionForValue(1000000.0), 7); - QCOMPARE(rm.getPositionForValue(1000.0), 5); - QCOMPARE(rm.getPositionForValue(900.0), 5); - QCOMPARE(rm.getPositionForValue(20000), 6); - QCOMPARE(rm.getPositionForValueUnclamped(1.0), 2); - QCOMPARE(rm.getPositionForValueUnclamped(1000000.0), 8); - QCOMPARE(rm.getPositionForValueUnclamped(1000.0), 5); + LogRangeMapper rm(3, 7, 10, 100000, "x", false); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getPositionForValue(10.0), 3); + QCOMPARE(rm.getPositionForValue(100000.0), 7); + QCOMPARE(rm.getPositionForValue(1.0), 3); + QCOMPARE(rm.getPositionForValue(1000000.0), 7); + QCOMPARE(rm.getPositionForValue(1000.0), 5); + QCOMPARE(rm.getPositionForValue(900.0), 5); + QCOMPARE(rm.getPositionForValue(20000), 6); + QCOMPARE(rm.getPositionForValueUnclamped(1.0), 2); + QCOMPARE(rm.getPositionForValueUnclamped(1000000.0), 8); + QCOMPARE(rm.getPositionForValueUnclamped(1000.0), 5); } void logDownForward() { - LogRangeMapper rm(3, 7, 10, 100000, "x", true); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getPositionForValue(10.0), 7); - QCOMPARE(rm.getPositionForValue(100000.0), 3); - QCOMPARE(rm.getPositionForValue(1.0), 7); - QCOMPARE(rm.getPositionForValue(1000000.0), 3); - QCOMPARE(rm.getPositionForValue(1000.0), 5); - QCOMPARE(rm.getPositionForValue(900.0), 5); - QCOMPARE(rm.getPositionForValue(20000), 4); - QCOMPARE(rm.getPositionForValueUnclamped(1.0), 8); - QCOMPARE(rm.getPositionForValueUnclamped(1000000.0), 2); - QCOMPARE(rm.getPositionForValueUnclamped(1000.0), 5); + LogRangeMapper rm(3, 7, 10, 100000, "x", true); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getPositionForValue(10.0), 7); + QCOMPARE(rm.getPositionForValue(100000.0), 3); + QCOMPARE(rm.getPositionForValue(1.0), 7); + QCOMPARE(rm.getPositionForValue(1000000.0), 3); + QCOMPARE(rm.getPositionForValue(1000.0), 5); + QCOMPARE(rm.getPositionForValue(900.0), 5); + QCOMPARE(rm.getPositionForValue(20000), 4); + QCOMPARE(rm.getPositionForValueUnclamped(1.0), 8); + QCOMPARE(rm.getPositionForValueUnclamped(1000000.0), 2); + QCOMPARE(rm.getPositionForValueUnclamped(1000.0), 5); } void logUpBackward() { - LogRangeMapper rm(3, 7, 10, 100000, "x", false); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getValueForPosition(3), 10.0); - QCOMPARE(rm.getValueForPosition(7), 100000.0); - QCOMPARE(rm.getValueForPosition(5), 1000.0); - QCOMPARE(rm.getValueForPosition(6), 10000.0); - QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(3)); - QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(7)); - QCOMPARE(rm.getValueForPositionUnclamped(2), 1.0); + LogRangeMapper rm(3, 7, 10, 100000, "x", false); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getValueForPosition(3), 10.0); + QCOMPARE(rm.getValueForPosition(7), 100000.0); + QCOMPARE(rm.getValueForPosition(5), 1000.0); + QCOMPARE(rm.getValueForPosition(6), 10000.0); + QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(3)); + QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(7)); + QCOMPARE(rm.getValueForPositionUnclamped(2), 1.0); QCOMPARE(rm.getValueForPositionUnclamped(8), 1000000.0); QCOMPARE(rm.getValueForPositionUnclamped(5), 1000.0); } void logDownBackward() { - LogRangeMapper rm(3, 7, 10, 100000, "x", true); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getValueForPosition(7), 10.0); - QCOMPARE(rm.getValueForPosition(3), 100000.0); - QCOMPARE(rm.getValueForPosition(5), 1000.0); - QCOMPARE(rm.getValueForPosition(4), 10000.0); - QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(3)); - QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(7)); - QCOMPARE(rm.getValueForPositionUnclamped(8), 1.0); + LogRangeMapper rm(3, 7, 10, 100000, "x", true); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getValueForPosition(7), 10.0); + QCOMPARE(rm.getValueForPosition(3), 100000.0); + QCOMPARE(rm.getValueForPosition(5), 1000.0); + QCOMPARE(rm.getValueForPosition(4), 10000.0); + QCOMPARE(rm.getValueForPosition(0), rm.getValueForPosition(3)); + QCOMPARE(rm.getValueForPosition(9), rm.getValueForPosition(7)); + QCOMPARE(rm.getValueForPositionUnclamped(8), 1.0); QCOMPARE(rm.getValueForPositionUnclamped(2), 1000000.0); QCOMPARE(rm.getValueForPositionUnclamped(5), 1000.0); } void interpolatingForward() { - InterpolatingRangeMapper::CoordMap mappings; - mappings[1] = 10; - mappings[3] = 30; - mappings[5] = 70; - InterpolatingRangeMapper rm(mappings, "x"); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getPositionForValue(1.0), 10); - QCOMPARE(rm.getPositionForValue(0.0), 10); - QCOMPARE(rm.getPositionForValue(5.0), 70); - QCOMPARE(rm.getPositionForValue(6.0), 70); - QCOMPARE(rm.getPositionForValue(3.0), 30); - QCOMPARE(rm.getPositionForValue(2.5), 25); - QCOMPARE(rm.getPositionForValue(4.5), 60); - QCOMPARE(rm.getPositionForValueUnclamped(0.0), 0); - QCOMPARE(rm.getPositionForValueUnclamped(2.5), 25); - QCOMPARE(rm.getPositionForValueUnclamped(6.0), 90); + InterpolatingRangeMapper::CoordMap mappings; + mappings[1] = 10; + mappings[3] = 30; + mappings[5] = 70; + InterpolatingRangeMapper rm(mappings, "x"); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getPositionForValue(1.0), 10); + QCOMPARE(rm.getPositionForValue(0.0), 10); + QCOMPARE(rm.getPositionForValue(5.0), 70); + QCOMPARE(rm.getPositionForValue(6.0), 70); + QCOMPARE(rm.getPositionForValue(3.0), 30); + QCOMPARE(rm.getPositionForValue(2.5), 25); + QCOMPARE(rm.getPositionForValue(4.5), 60); + QCOMPARE(rm.getPositionForValueUnclamped(0.0), 0); + QCOMPARE(rm.getPositionForValueUnclamped(2.5), 25); + QCOMPARE(rm.getPositionForValueUnclamped(6.0), 90); } void interpolatingBackward() { - InterpolatingRangeMapper::CoordMap mappings; - mappings[1] = 10; - mappings[3] = 30; - mappings[5] = 70; - InterpolatingRangeMapper rm(mappings, "x"); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getValueForPosition(10), 1.0); - QCOMPARE(rm.getValueForPosition(9), 1.0); - QCOMPARE(rm.getValueForPosition(70), 5.0); - QCOMPARE(rm.getValueForPosition(80), 5.0); - QCOMPARE(rm.getValueForPosition(30), 3.0); - QCOMPARE(rm.getValueForPosition(25), 2.5); - QCOMPARE(rm.getValueForPosition(60), 4.5); + InterpolatingRangeMapper::CoordMap mappings; + mappings[1] = 10; + mappings[3] = 30; + mappings[5] = 70; + InterpolatingRangeMapper rm(mappings, "x"); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getValueForPosition(10), 1.0); + QCOMPARE(rm.getValueForPosition(9), 1.0); + QCOMPARE(rm.getValueForPosition(70), 5.0); + QCOMPARE(rm.getValueForPosition(80), 5.0); + QCOMPARE(rm.getValueForPosition(30), 3.0); + QCOMPARE(rm.getValueForPosition(25), 2.5); + QCOMPARE(rm.getValueForPosition(60), 4.5); } void autoLinearForward() { - AutoRangeMapper::CoordMap mappings; - mappings[0.5] = 1; - mappings[4.0] = 8; - AutoRangeMapper rm1(mappings, "x"); - QCOMPARE(rm1.getUnit(), QString("x")); - QCOMPARE(rm1.getType(), AutoRangeMapper::StraightLine); - QCOMPARE(rm1.getPositionForValue(0.1), 1); - QCOMPARE(rm1.getPositionForValue(0.5), 1); - QCOMPARE(rm1.getPositionForValue(4.0), 8); - QCOMPARE(rm1.getPositionForValue(4.5), 8); - QCOMPARE(rm1.getPositionForValue(3.0), 6); - QCOMPARE(rm1.getPositionForValue(3.1), 6); - QCOMPARE(rm1.getPositionForValueUnclamped(0.1), 0); - QCOMPARE(rm1.getPositionForValueUnclamped(3.1), 6); - QCOMPARE(rm1.getPositionForValueUnclamped(4.5), 9); - mappings[3.0] = 6; - mappings[3.5] = 7; - AutoRangeMapper rm2(mappings, "x"); - QCOMPARE(rm2.getUnit(), QString("x")); - QCOMPARE(rm2.getType(), AutoRangeMapper::StraightLine); - QCOMPARE(rm2.getPositionForValue(0.5), 1); - QCOMPARE(rm2.getPositionForValue(4.0), 8); - QCOMPARE(rm2.getPositionForValue(3.0), 6); - QCOMPARE(rm2.getPositionForValue(3.1), 6); + AutoRangeMapper::CoordMap mappings; + mappings[0.5] = 1; + mappings[4.0] = 8; + AutoRangeMapper rm1(mappings, "x"); + QCOMPARE(rm1.getUnit(), QString("x")); + QCOMPARE(rm1.getType(), AutoRangeMapper::StraightLine); + QCOMPARE(rm1.getPositionForValue(0.1), 1); + QCOMPARE(rm1.getPositionForValue(0.5), 1); + QCOMPARE(rm1.getPositionForValue(4.0), 8); + QCOMPARE(rm1.getPositionForValue(4.5), 8); + QCOMPARE(rm1.getPositionForValue(3.0), 6); + QCOMPARE(rm1.getPositionForValue(3.1), 6); + QCOMPARE(rm1.getPositionForValueUnclamped(0.1), 0); + QCOMPARE(rm1.getPositionForValueUnclamped(3.1), 6); + QCOMPARE(rm1.getPositionForValueUnclamped(4.5), 9); + mappings[3.0] = 6; + mappings[3.5] = 7; + AutoRangeMapper rm2(mappings, "x"); + QCOMPARE(rm2.getUnit(), QString("x")); + QCOMPARE(rm2.getType(), AutoRangeMapper::StraightLine); + QCOMPARE(rm2.getPositionForValue(0.5), 1); + QCOMPARE(rm2.getPositionForValue(4.0), 8); + QCOMPARE(rm2.getPositionForValue(3.0), 6); + QCOMPARE(rm2.getPositionForValue(3.1), 6); } void autoLogForward() { - AutoRangeMapper::CoordMap mappings; - mappings[10] = 3; - mappings[1000] = 5; - mappings[100000] = 7; - AutoRangeMapper rm1(mappings, "x"); - QCOMPARE(rm1.getUnit(), QString("x")); - QCOMPARE(rm1.getType(), AutoRangeMapper::Logarithmic); - QCOMPARE(rm1.getPositionForValue(10.0), 3); - QCOMPARE(rm1.getPositionForValue(100000.0), 7); - QCOMPARE(rm1.getPositionForValue(1.0), 3); - QCOMPARE(rm1.getPositionForValue(1000000.0), 7); - QCOMPARE(rm1.getPositionForValue(1000.0), 5); - QCOMPARE(rm1.getPositionForValue(900.0), 5); - QCOMPARE(rm1.getPositionForValue(20000), 6); - QCOMPARE(rm1.getPositionForValueUnclamped(1.0), 2); - QCOMPARE(rm1.getPositionForValueUnclamped(900.0), 5); - QCOMPARE(rm1.getPositionForValueUnclamped(1000000.0), 8); - mappings[100] = 4; - AutoRangeMapper rm2(mappings, "x"); - QCOMPARE(rm2.getUnit(), QString("x")); - QCOMPARE(rm2.getType(), AutoRangeMapper::Logarithmic); - QCOMPARE(rm2.getPositionForValue(10.0), 3); - QCOMPARE(rm2.getPositionForValue(100000.0), 7); - QCOMPARE(rm2.getPositionForValue(1.0), 3); - QCOMPARE(rm2.getPositionForValue(1000000.0), 7); - QCOMPARE(rm2.getPositionForValue(1000.0), 5); - QCOMPARE(rm2.getPositionForValue(900.0), 5); - QCOMPARE(rm2.getPositionForValue(20000), 6); + AutoRangeMapper::CoordMap mappings; + mappings[10] = 3; + mappings[1000] = 5; + mappings[100000] = 7; + AutoRangeMapper rm1(mappings, "x"); + QCOMPARE(rm1.getUnit(), QString("x")); + QCOMPARE(rm1.getType(), AutoRangeMapper::Logarithmic); + QCOMPARE(rm1.getPositionForValue(10.0), 3); + QCOMPARE(rm1.getPositionForValue(100000.0), 7); + QCOMPARE(rm1.getPositionForValue(1.0), 3); + QCOMPARE(rm1.getPositionForValue(1000000.0), 7); + QCOMPARE(rm1.getPositionForValue(1000.0), 5); + QCOMPARE(rm1.getPositionForValue(900.0), 5); + QCOMPARE(rm1.getPositionForValue(20000), 6); + QCOMPARE(rm1.getPositionForValueUnclamped(1.0), 2); + QCOMPARE(rm1.getPositionForValueUnclamped(900.0), 5); + QCOMPARE(rm1.getPositionForValueUnclamped(1000000.0), 8); + mappings[100] = 4; + AutoRangeMapper rm2(mappings, "x"); + QCOMPARE(rm2.getUnit(), QString("x")); + QCOMPARE(rm2.getType(), AutoRangeMapper::Logarithmic); + QCOMPARE(rm2.getPositionForValue(10.0), 3); + QCOMPARE(rm2.getPositionForValue(100000.0), 7); + QCOMPARE(rm2.getPositionForValue(1.0), 3); + QCOMPARE(rm2.getPositionForValue(1000000.0), 7); + QCOMPARE(rm2.getPositionForValue(1000.0), 5); + QCOMPARE(rm2.getPositionForValue(900.0), 5); + QCOMPARE(rm2.getPositionForValue(20000), 6); } void autoInterpolatingForward() { - AutoRangeMapper::CoordMap mappings; - mappings[1] = 10; - mappings[3] = 30; - mappings[5] = 70; - AutoRangeMapper rm(mappings, "x"); - QCOMPARE(rm.getUnit(), QString("x")); - QCOMPARE(rm.getType(), AutoRangeMapper::Interpolating); - QCOMPARE(rm.getPositionForValue(1.0), 10); - QCOMPARE(rm.getPositionForValue(0.0), 10); - QCOMPARE(rm.getPositionForValue(5.0), 70); - QCOMPARE(rm.getPositionForValue(6.0), 70); - QCOMPARE(rm.getPositionForValue(3.0), 30); - QCOMPARE(rm.getPositionForValue(2.5), 25); - QCOMPARE(rm.getPositionForValue(4.5), 60); - QCOMPARE(rm.getPositionForValueUnclamped(0.0), 0); - QCOMPARE(rm.getPositionForValueUnclamped(5.0), 70); - QCOMPARE(rm.getPositionForValueUnclamped(6.0), 90); + AutoRangeMapper::CoordMap mappings; + mappings[1] = 10; + mappings[3] = 30; + mappings[5] = 70; + AutoRangeMapper rm(mappings, "x"); + QCOMPARE(rm.getUnit(), QString("x")); + QCOMPARE(rm.getType(), AutoRangeMapper::Interpolating); + QCOMPARE(rm.getPositionForValue(1.0), 10); + QCOMPARE(rm.getPositionForValue(0.0), 10); + QCOMPARE(rm.getPositionForValue(5.0), 70); + QCOMPARE(rm.getPositionForValue(6.0), 70); + QCOMPARE(rm.getPositionForValue(3.0), 30); + QCOMPARE(rm.getPositionForValue(2.5), 25); + QCOMPARE(rm.getPositionForValue(4.5), 60); + QCOMPARE(rm.getPositionForValueUnclamped(0.0), 0); + QCOMPARE(rm.getPositionForValueUnclamped(5.0), 70); + QCOMPARE(rm.getPositionForValueUnclamped(6.0), 90); } }; diff -r deabf9fd3d28 -r a12fd0456f0c base/test/TestScaleTickIntervals.h --- a/base/test/TestScaleTickIntervals.h Tue Apr 17 10:03:51 2018 +0100 +++ b/base/test/TestScaleTickIntervals.h Tue Apr 17 10:35:42 2018 +0100 @@ -30,295 +30,295 @@ Q_OBJECT void printDiff(vector ticks, - vector expected) { + vector expected) { - cerr << "Have " << ticks.size() << " ticks, expected " - << expected.size() << endl; - for (int i = 0; i < int(ticks.size()); ++i) { - cerr << i << ": have " << ticks[i].value << " \"" + SVCERR << "Have " << ticks.size() << " ticks, expected " + << expected.size() << endl; + for (int i = 0; i < int(ticks.size()); ++i) { + SVCERR << i << ": have " << ticks[i].value << " \"" << ticks[i].label << "\", expected "; - if (i < int(expected.size())) { - cerr << expected[i].value << " \"" << expected[i].label - << "\"" << endl; + if (i < int(expected.size())) { + SVCERR << expected[i].value << " \"" << expected[i].label + << "\"" << endl; } else { - cerr << "(n/a)" << endl; - } - } + SVCERR << "(n/a)" << endl; + } + } } void compareTicks(ScaleTickIntervals::Ticks ticks, - ScaleTickIntervals::Ticks expected, + ScaleTickIntervals::Ticks expected, bool fuzzier = false) { double eps = 1e-7; - for (int i = 0; i < int(expected.size()); ++i) { - if (i < int(ticks.size())) { + for (int i = 0; i < int(expected.size()); ++i) { + if (i < int(ticks.size())) { bool pass = true; - if (ticks[i].label != expected[i].label) { + if (ticks[i].label != expected[i].label) { pass = false; } else if (!fuzzier) { - if (fabs(ticks[i].value - expected[i].value) > eps) { + if (fabs(ticks[i].value - expected[i].value) > eps) { pass = false; } } else { - if (fabs(ticks[i].value - expected[i].value) > + if (fabs(ticks[i].value - expected[i].value) > fabs(ticks[i].value) * 1e-5) { pass = false; } } if (!pass) { - printDiff(ticks, expected); + printDiff(ticks, expected); QCOMPARE(ticks[i].label, expected[i].label); QCOMPARE(ticks[i].value, expected[i].value); } - } - } + } + } if (ticks.size() != expected.size()) { printDiff(ticks, expected); } - QCOMPARE(ticks.size(), expected.size()); + QCOMPARE(ticks.size(), expected.size()); } private slots: void linear_0_1_10() { - auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 }); - ScaleTickIntervals::Ticks expected { - { 0.0, "0.0" }, - { 0.1, "0.1" }, - { 0.2, "0.2" }, - { 0.3, "0.3" }, - { 0.4, "0.4" }, - { 0.5, "0.5" }, - { 0.6, "0.6" }, - { 0.7, "0.7" }, - { 0.8, "0.8" }, - { 0.9, "0.9" }, - { 1.0, "1.0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 1, 10 }); + ScaleTickIntervals::Ticks expected { + { 0.0, "0.0" }, + { 0.1, "0.1" }, + { 0.2, "0.2" }, + { 0.3, "0.3" }, + { 0.4, "0.4" }, + { 0.5, "0.5" }, + { 0.6, "0.6" }, + { 0.7, "0.7" }, + { 0.8, "0.8" }, + { 0.9, "0.9" }, + { 1.0, "1.0" } + }; + compareTicks(ticks, expected); } void linear_0_5_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 }); - ScaleTickIntervals::Ticks expected { - { 0, "0" }, - { 1, "1" }, - { 2, "2" }, - { 3, "3" }, - { 4, "4" }, - { 5, "5" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 5, 5 }); + ScaleTickIntervals::Ticks expected { + { 0, "0" }, + { 1, "1" }, + { 2, "2" }, + { 3, "3" }, + { 4, "4" }, + { 5, "5" }, + }; + compareTicks(ticks, expected); } void linear_0_10_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 }); - ScaleTickIntervals::Ticks expected { - { 0, "0" }, - { 2, "2" }, - { 4, "4" }, - { 6, "6" }, - { 8, "8" }, - { 10, "10" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 10, 5 }); + ScaleTickIntervals::Ticks expected { + { 0, "0" }, + { 2, "2" }, + { 4, "4" }, + { 6, "6" }, + { 8, "8" }, + { 10, "10" } + }; + compareTicks(ticks, expected); } void linear_10_0_5() { - auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 }); - ScaleTickIntervals::Ticks expected { - { 0, "0" }, - { 2, "2" }, - { 4, "4" }, - { 6, "6" }, - { 8, "8" }, - { 10, "10" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 10, 0, 5 }); + ScaleTickIntervals::Ticks expected { + { 0, "0" }, + { 2, "2" }, + { 4, "4" }, + { 6, "6" }, + { 8, "8" }, + { 10, "10" } + }; + compareTicks(ticks, expected); } void linear_m10_0_5() { - auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 }); - ScaleTickIntervals::Ticks expected { - { -10, "-10" }, - { -8, "-8" }, - { -6, "-6" }, - { -4, "-4" }, - { -2, "-2" }, - { 0, "0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ -10, 0, 5 }); + ScaleTickIntervals::Ticks expected { + { -10, "-10" }, + { -8, "-8" }, + { -6, "-6" }, + { -4, "-4" }, + { -2, "-2" }, + { 0, "0" } + }; + compareTicks(ticks, expected); } void linear_0_m10_5() { - auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 }); - ScaleTickIntervals::Ticks expected { - { -10, "-10" }, - { -8, "-8" }, - { -6, "-6" }, - { -4, "-4" }, - { -2, "-2" }, - { 0, "0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, -10, 5 }); + ScaleTickIntervals::Ticks expected { + { -10, "-10" }, + { -8, "-8" }, + { -6, "-6" }, + { -4, "-4" }, + { -2, "-2" }, + { 0, "0" } + }; + compareTicks(ticks, expected); } void linear_0_0p1_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 }); - ScaleTickIntervals::Ticks expected { - { 0.00, "0.00" }, - { 0.02, "0.02" }, - { 0.04, "0.04" }, - { 0.06, "0.06" }, - { 0.08, "0.08" }, - { 0.10, "0.10" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 0.1, 5 }); + ScaleTickIntervals::Ticks expected { + { 0.00, "0.00" }, + { 0.02, "0.02" }, + { 0.04, "0.04" }, + { 0.06, "0.06" }, + { 0.08, "0.08" }, + { 0.10, "0.10" } + }; + compareTicks(ticks, expected); } void linear_0_0p01_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 }); - ScaleTickIntervals::Ticks expected { - { 0.000, "0.000" }, - { 0.002, "0.002" }, - { 0.004, "0.004" }, - { 0.006, "0.006" }, - { 0.008, "0.008" }, - { 0.010, "0.010" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 0.01, 5 }); + ScaleTickIntervals::Ticks expected { + { 0.000, "0.000" }, + { 0.002, "0.002" }, + { 0.004, "0.004" }, + { 0.006, "0.006" }, + { 0.008, "0.008" }, + { 0.010, "0.010" } + }; + compareTicks(ticks, expected); } void linear_0_0p005_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 }); - ScaleTickIntervals::Ticks expected { - { 0.000, "0.000" }, - { 0.001, "0.001" }, - { 0.002, "0.002" }, - { 0.003, "0.003" }, - { 0.004, "0.004" }, - { 0.005, "0.005" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 0.005, 5 }); + ScaleTickIntervals::Ticks expected { + { 0.000, "0.000" }, + { 0.001, "0.001" }, + { 0.002, "0.002" }, + { 0.003, "0.003" }, + { 0.004, "0.004" }, + { 0.005, "0.005" } + }; + compareTicks(ticks, expected); } void linear_0_0p001_5() { - auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 }); - ScaleTickIntervals::Ticks expected { - { 0.0000, "0.0e+00" }, - { 0.0002, "2.0e-04" }, - { 0.0004, "4.0e-04" }, - { 0.0006, "6.0e-04" }, - { 0.0008, "8.0e-04" }, - { 0.0010, "1.0e-03" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 0.001, 5 }); + ScaleTickIntervals::Ticks expected { + { 0.0000, "0.0e+00" }, + { 0.0002, "2.0e-04" }, + { 0.0004, "4.0e-04" }, + { 0.0006, "6.0e-04" }, + { 0.0008, "8.0e-04" }, + { 0.0010, "1.0e-03" } + }; + compareTicks(ticks, expected); } void linear_1_1p001_5() { - auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 }); - ScaleTickIntervals::Ticks expected { - { 1.0000, "1.0000" }, - { 1.0002, "1.0002" }, - { 1.0004, "1.0004" }, - { 1.0006, "1.0006" }, - { 1.0008, "1.0008" }, - { 1.0010, "1.0010" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 1, 1.001, 5 }); + ScaleTickIntervals::Ticks expected { + { 1.0000, "1.0000" }, + { 1.0002, "1.0002" }, + { 1.0004, "1.0004" }, + { 1.0006, "1.0006" }, + { 1.0008, "1.0008" }, + { 1.0010, "1.0010" } + }; + compareTicks(ticks, expected); } void linear_0p001_1_5() { - auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 }); - ScaleTickIntervals::Ticks expected { - { 0.1, "0.1" }, - { 0.3, "0.3" }, - { 0.5, "0.5" }, - { 0.7, "0.7" }, - { 0.9, "0.9" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0.001, 1, 5 }); + ScaleTickIntervals::Ticks expected { + { 0.1, "0.1" }, + { 0.3, "0.3" }, + { 0.5, "0.5" }, + { 0.7, "0.7" }, + { 0.9, "0.9" }, + }; + compareTicks(ticks, expected); } void linear_10000_10010_5() { - auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 }); - ScaleTickIntervals::Ticks expected { - { 10000, "10000" }, - { 10002, "10002" }, - { 10004, "10004" }, - { 10006, "10006" }, - { 10008, "10008" }, - { 10010, "10010" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 10000, 10010, 5 }); + ScaleTickIntervals::Ticks expected { + { 10000, "10000" }, + { 10002, "10002" }, + { 10004, "10004" }, + { 10006, "10006" }, + { 10008, "10008" }, + { 10010, "10010" }, + }; + compareTicks(ticks, expected); } void linear_10000_20000_5() { - auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 }); - ScaleTickIntervals::Ticks expected { - { 10000, "10000" }, - { 12000, "12000" }, - { 14000, "14000" }, - { 16000, "16000" }, - { 18000, "18000" }, - { 20000, "20000" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 10000, 20000, 5 }); + ScaleTickIntervals::Ticks expected { + { 10000, "10000" }, + { 12000, "12000" }, + { 14000, "14000" }, + { 16000, "16000" }, + { 18000, "18000" }, + { 20000, "20000" }, + }; + compareTicks(ticks, expected); } void linear_m1_1_10() { - auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 }); - ScaleTickIntervals::Ticks expected { - { -1.0, "-1.0" }, - { -0.8, "-0.8" }, - { -0.6, "-0.6" }, - { -0.4, "-0.4" }, - { -0.2, "-0.2" }, - { 0.0, "0.0" }, - { 0.2, "0.2" }, - { 0.4, "0.4" }, - { 0.6, "0.6" }, - { 0.8, "0.8" }, - { 1.0, "1.0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ -1, 1, 10 }); + ScaleTickIntervals::Ticks expected { + { -1.0, "-1.0" }, + { -0.8, "-0.8" }, + { -0.6, "-0.6" }, + { -0.4, "-0.4" }, + { -0.2, "-0.2" }, + { 0.0, "0.0" }, + { 0.2, "0.2" }, + { 0.4, "0.4" }, + { 0.6, "0.6" }, + { 0.8, "0.8" }, + { 1.0, "1.0" } + }; + compareTicks(ticks, expected); } void linear_221p23_623p7_57p4() { - auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 }); + auto ticks = ScaleTickIntervals::linear({ 221.23, 623.7, 4 }); // only 4 ticks, not 5, because none of the rounded tick // values lies on an end value - ScaleTickIntervals::Ticks expected { + ScaleTickIntervals::Ticks expected { { 300, "300" }, { 400, "400" }, { 500, "500" }, { 600, "600" }, - }; - compareTicks(ticks, expected); + }; + compareTicks(ticks, expected); } void linear_sqrt2_pi_7() { - auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 }); + auto ticks = ScaleTickIntervals::linear({ sqrt(2.0), M_PI, 7 }); // This would be better in steps of 0.25, but we only round to // integral powers of ten - ScaleTickIntervals::Ticks expected { + ScaleTickIntervals::Ticks expected { { 1.5, "1.5" }, { 1.7, "1.7" }, { 1.9, "1.9" }, @@ -328,14 +328,14 @@ { 2.7, "2.7" }, { 2.9, "2.9" }, { 3.1, "3.1" }, - }; - compareTicks(ticks, expected); + }; + compareTicks(ticks, expected); } void linear_pi_avogadro_7() { - auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 }); - ScaleTickIntervals::Ticks expected { + auto ticks = ScaleTickIntervals::linear({ M_PI, 6.022140857e23, 7 }); + ScaleTickIntervals::Ticks expected { // not perfect, but ok-ish { 0, "0.0e+00" }, { 9e+22, "9.0e+22" }, @@ -344,133 +344,133 @@ { 3.6e+23, "3.6e+23" }, { 4.5e+23, "4.5e+23" }, { 5.4e+23, "5.4e+23" }, - }; - compareTicks(ticks, expected); + }; + compareTicks(ticks, expected); } void linear_2_3_1() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 }); - ScaleTickIntervals::Ticks expected { - { 2.0, "2" }, - { 3.0, "3" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 1 }); + ScaleTickIntervals::Ticks expected { + { 2.0, "2" }, + { 3.0, "3" } + }; + compareTicks(ticks, expected); } void linear_2_3_2() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 }); - ScaleTickIntervals::Ticks expected { - { 2.0, "2.0" }, - { 2.5, "2.5" }, - { 3.0, "3.0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 2 }); + ScaleTickIntervals::Ticks expected { + { 2.0, "2.0" }, + { 2.5, "2.5" }, + { 3.0, "3.0" } + }; + compareTicks(ticks, expected); } void linear_2_3_3() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 }); - ScaleTickIntervals::Ticks expected { - { 2.0, "2.0" }, - { 2.3, "2.3" }, - { 2.6, "2.6" }, - { 2.9, "2.9" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 3 }); + ScaleTickIntervals::Ticks expected { + { 2.0, "2.0" }, + { 2.3, "2.3" }, + { 2.6, "2.6" }, + { 2.9, "2.9" } + }; + compareTicks(ticks, expected); } void linear_2_3_4() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 }); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 4 }); // This would be better in steps of 0.25, but we only round to // integral powers of ten - ScaleTickIntervals::Ticks expected { - { 2.0, "2.0" }, - { 2.3, "2.3" }, - { 2.6, "2.6" }, - { 2.9, "2.9" } - }; - compareTicks(ticks, expected); + ScaleTickIntervals::Ticks expected { + { 2.0, "2.0" }, + { 2.3, "2.3" }, + { 2.6, "2.6" }, + { 2.9, "2.9" } + }; + compareTicks(ticks, expected); } void linear_2_3_5() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 }); - ScaleTickIntervals::Ticks expected { - { 2.0, "2.0" }, - { 2.2, "2.2" }, - { 2.4, "2.4" }, - { 2.6, "2.6" }, - { 2.8, "2.8" }, - { 3.0, "3.0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 5 }); + ScaleTickIntervals::Ticks expected { + { 2.0, "2.0" }, + { 2.2, "2.2" }, + { 2.4, "2.4" }, + { 2.6, "2.6" }, + { 2.8, "2.8" }, + { 3.0, "3.0" } + }; + compareTicks(ticks, expected); } void linear_2_3_6() { - auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 }); - ScaleTickIntervals::Ticks expected { - { 2.0, "2.0" }, - { 2.2, "2.2" }, - { 2.4, "2.4" }, - { 2.6, "2.6" }, - { 2.8, "2.8" }, - { 3.0, "3.0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 2, 3, 6 }); + ScaleTickIntervals::Ticks expected { + { 2.0, "2.0" }, + { 2.2, "2.2" }, + { 2.4, "2.4" }, + { 2.6, "2.6" }, + { 2.8, "2.8" }, + { 3.0, "3.0" } + }; + compareTicks(ticks, expected); } void linear_1_1_10() { // pathological range - auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); - ScaleTickIntervals::Ticks expected { - { 1.0, "1" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 1, 1, 10 }); + ScaleTickIntervals::Ticks expected { + { 1.0, "1" } + }; + compareTicks(ticks, expected); } void linear_0_0_10() { // pathological range - auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 }); - ScaleTickIntervals::Ticks expected { - { 0.0, "0" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 0, 10 }); + ScaleTickIntervals::Ticks expected { + { 0.0, "0" } + }; + compareTicks(ticks, expected); } void linear_0_1_1() { - auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 }); - ScaleTickIntervals::Ticks expected { - { 0.0, "0" }, - { 1.0, "1" } - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 1, 1 }); + ScaleTickIntervals::Ticks expected { + { 0.0, "0" }, + { 1.0, "1" } + }; + compareTicks(ticks, expected); } void linear_0_1_0() { // senseless input - auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 }); - ScaleTickIntervals::Ticks expected { - { 0.0, "0" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 1, 0 }); + ScaleTickIntervals::Ticks expected { + { 0.0, "0" }, + }; + compareTicks(ticks, expected); } void linear_0_1_m1() { // senseless input - auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 }); - ScaleTickIntervals::Ticks expected { - { 0.0, "0" }, - }; - compareTicks(ticks, expected); + auto ticks = ScaleTickIntervals::linear({ 0, 1, -1 }); + ScaleTickIntervals::Ticks expected { + { 0.0, "0" }, + }; + compareTicks(ticks, expected); } void linear_0p465_778_10() @@ -496,28 +496,28 @@ void log_1_10_2() { auto ticks = ScaleTickIntervals::logarithmic({ 1, 10, 2 }); - ScaleTickIntervals::Ticks expected { + ScaleTickIntervals::Ticks expected { { 1.0, "1.0" }, { pow(10.0, 0.5), "3.2" }, { 10.0, "10.0" }, - }; - compareTicks(ticks, expected); + }; + compareTicks(ticks, expected); } void log_0_10_2() { auto ticks = ScaleTickIntervals::logarithmic({ 0, 10, 2 }); - ScaleTickIntervals::Ticks expected { + ScaleTickIntervals::Ticks expected { { 1e-6, "1e-06" }, { 1, "1" }, - }; - compareTicks(ticks, expected); + }; + compareTicks(ticks, expected); } void log_pi_avogadro_7() { - auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 }); - ScaleTickIntervals::Ticks expected { + auto ticks = ScaleTickIntervals::logarithmic({ M_PI, 6.022140857e23, 7 }); + ScaleTickIntervals::Ticks expected { { 1000, "1e+03" }, { 1e+06, "1e+06" }, { 1e+09, "1e+09" }, @@ -525,8 +525,8 @@ { 1e+15, "1e+15" }, { 1e+18, "1e+18" }, { 1e+21, "1e+21" }, - }; - compareTicks(ticks, expected, true); + }; + compareTicks(ticks, expected, true); } void log_0p465_778_10() diff -r deabf9fd3d28 -r a12fd0456f0c base/test/svcore-base-test.cpp --- a/base/test/svcore-base-test.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/base/test/svcore-base-test.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -33,51 +33,51 @@ app.setApplicationName("test-svcore-base"); { - TestRangeMapper t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestRangeMapper t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { - TestPitch t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestPitch t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { TestOurRealTime t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { TestVampRealTime t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { - TestStringBits t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestStringBits t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { - TestColumnOp t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestColumnOp t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { - TestLogRange t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestLogRange t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } { - TestScaleTickIntervals t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestScaleTickIntervals t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } if (bad > 0) { - cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl; - return 1; + SVCERR << "\n********* " << bad << " test suite(s) failed!\n" << endl; + return 1; } else { - cerr << "All tests passed" << endl; - return 0; + SVCERR << "All tests passed" << endl; + return 0; } } diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/BZipFileDevice.cpp --- a/data/fileio/BZipFileDevice.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/BZipFileDevice.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -189,7 +189,7 @@ if (openMode() & WriteOnly) { unsigned int in = 0, out = 0; BZ2_bzWriteClose(&bzError, m_bzFile, 0, &in, &out); -// cerr << "Wrote bzip2 stream (in=" << in << ", out=" << out << ")" << endl; +// cerr << "Wrote bzip2 stream (in=" << in << ", out=" << out << ")" << endl; if (bzError != BZ_OK) { setErrorString(tr("bzip2 stream write close error")); } diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/CSVFileReader.cpp --- a/data/fileio/CSVFileReader.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/CSVFileReader.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -34,6 +34,7 @@ #include #include +#include using namespace std; @@ -49,18 +50,18 @@ bool good = false; if (!file->exists()) { - m_error = QFile::tr("File \"%1\" does not exist").arg(path); + m_error = QFile::tr("File \"%1\" does not exist").arg(path); } else if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { - m_error = QFile::tr("Failed to open file \"%1\"").arg(path); + m_error = QFile::tr("Failed to open file \"%1\"").arg(path); } else { - good = true; + good = true; } if (good) { m_device = file; m_filename = QFileInfo(path).fileName(); } else { - delete file; + delete file; } } @@ -137,12 +138,12 @@ if (!ok) { if (m_warnings < warnLimit) { - cerr << "WARNING: CSVFileReader::load: " + SVCERR << "WARNING: CSVFileReader::load: " << "Bad time format (\"" << s << "\") in data line " << lineno+1 << endl; } else if (m_warnings == warnLimit) { - cerr << "WARNING: Too many warnings" << endl; + SVCERR << "WARNING: Too many warnings" << endl; } ++m_warnings; } @@ -172,10 +173,10 @@ } else { windowSize = 1; } - if (timeUnits == CSVFormat::TimeSeconds || + if (timeUnits == CSVFormat::TimeSeconds || timeUnits == CSVFormat::TimeMilliseconds) { - sampleRate = m_mainModelSampleRate; - } + sampleRate = m_mainModelSampleRate; + } } SparseOneDimensionalModel *model1 = 0; @@ -243,22 +244,22 @@ model1 = new SparseOneDimensionalModel(sampleRate, windowSize); model = model1; break; - + case CSVFormat::TwoDimensionalModel: model2 = new SparseTimeValueModel(sampleRate, windowSize, false); model = model2; break; - + case CSVFormat::TwoDimensionalModelWithDuration: model2a = new RegionModel(sampleRate, windowSize, false); model = model2a; break; - + case CSVFormat::TwoDimensionalModelWithDurationAndPitch: model2b = new NoteModel(sampleRate, windowSize, false); model = model2b; break; - + case CSVFormat::ThreeDimensionalModel: model3 = new EditableDenseThreeDimensionalModel (sampleRate, @@ -334,7 +335,7 @@ } if (modelType == CSVFormat::OneDimensionalModel) { - + SparseOneDimensionalModel::Point point(frameNo, label); model1->addPoint(point); @@ -368,7 +369,7 @@ float value = list[i].toFloat(&ok); values.push_back(value); - + if (firstEverValue || value < min) min = value; if (firstEverValue || value > max) max = value; @@ -384,19 +385,19 @@ if (!ok) { if (warnings < warnLimit) { - cerr << "WARNING: CSVFileReader::load: " + SVCERR << "WARNING: CSVFileReader::load: " << "Non-numeric value \"" << list[i] << "\" in data line " << lineno+1 << ":" << endl; - cerr << line << endl; + SVCERR << line << endl; ++warnings; } else if (warnings == warnLimit) { -// cerr << "WARNING: Too many warnings" << endl; +// SVCERR << "WARNING: Too many warnings" << endl; } } } - + // SVDEBUG << "Setting bin values for count " << lineno << ", frame " // << frameNo << ", time " << RealTime::frame2RealTime(frameNo, sampleRate) << endl; @@ -426,11 +427,11 @@ for (map >::iterator i = countLabelValueMap.end(); i != countLabelValueMap.begin(); ) { --i; - cerr << "count -> " << i->first << endl; + SVCERR << "count -> " << i->first << endl; for (map::iterator j = i->second.begin(); j != i->second.end(); ++j) { j->second = v; - cerr << "label -> " << j->first << ", value " << v << endl; + SVCERR << "label -> " << j->first << ", value " << v << endl; v = v + 1.f; } } @@ -443,7 +444,7 @@ RegionModel::Point p(*i); int count = labelCountMap[p.label]; v = countLabelValueMap[count][p.label]; - cerr << "mapping from label \"" << p.label << "\" (count " << count << ") to value " << v << endl; + // SVCERR << "mapping from label \"" << p.label << "\" (count " << count << ") to value " << v << endl; RegionModel::Point pp(p.frame, v, p.duration, p.label); pointMap[p] = pp; } @@ -474,8 +475,8 @@ } if (model3) { - model3->setMinimumLevel(min); - model3->setMaximumLevel(max); + model3->setMinimumLevel(min); + model3->setMaximumLevel(max); } return model; diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/CSVFormat.cpp --- a/data/fileio/CSVFormat.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/CSVFormat.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -114,7 +114,7 @@ ColumnNumeric | ColumnIntegral | ColumnIncreasing | ColumnNearEmpty; for (int i = 0; i < cols; ++i) { - + while (m_columnQualities.size() <= i) { m_columnQualities.push_back(defaultQualities); m_prevValues.push_back(0.f); @@ -197,7 +197,7 @@ { m_timingType = CSVFormat::ImplicitTiming; m_timeUnits = CSVFormat::TimeWindows; - + int timingColumnCount = 0; // if our first column has zero or one entries in it and the rest diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/CSVFormat.h Tue Apr 17 10:35:42 2018 +0100 @@ -25,23 +25,23 @@ { public: enum ModelType { - OneDimensionalModel, - TwoDimensionalModel, + OneDimensionalModel, + TwoDimensionalModel, TwoDimensionalModelWithDuration, TwoDimensionalModelWithDurationAndPitch, - ThreeDimensionalModel + ThreeDimensionalModel }; enum TimingType { - ExplicitTiming, - ImplicitTiming + ExplicitTiming, + ImplicitTiming }; enum TimeUnits { - TimeSeconds, + TimeSeconds, TimeMilliseconds, - TimeAudioFrames, - TimeWindows, + TimeAudioFrames, + TimeWindows, }; enum ColumnPurpose { @@ -121,7 +121,7 @@ // read-only; only valid if format has been guessed: QList getExample() const { return m_example; } int getMaxExampleCols() const { return m_maxExampleCols; } - + protected: ModelType m_modelType; TimingType m_timingType; diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/DataFileReaderFactory.h --- a/data/fileio/DataFileReaderFactory.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/DataFileReaderFactory.h Tue Apr 17 10:35:42 2018 +0100 @@ -48,7 +48,7 @@ */ static DataFileReader *createReader(QString path, MIDIFileImportPreferenceAcquirer *, - sv_samplerate_t mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); /** * Read the given path, if a suitable reader is available. @@ -83,7 +83,7 @@ static DataFileReader *createReader(QString path, bool csv, MIDIFileImportPreferenceAcquirer *, CSVFormat format, - sv_samplerate_t mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); }; #endif diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/MIDIFileReader.cpp --- a/data/fileio/MIDIFileReader.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/MIDIFileReader.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -58,7 +58,7 @@ MIDIFileReader::MIDIFileReader(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - sv_samplerate_t mainModelSampleRate) : + sv_samplerate_t mainModelSampleRate) : m_smpte(false), m_timingDivision(0), m_fps(0), @@ -74,21 +74,21 @@ m_acquirer(acquirer) { if (parseFile()) { - m_error = ""; + m_error = ""; } } MIDIFileReader::~MIDIFileReader() { for (MIDIComposition::iterator i = m_midiComposition.begin(); - i != m_midiComposition.end(); ++i) { - - for (MIDITrack::iterator j = i->second.begin(); - j != i->second.end(); ++j) { - delete *j; - } + i != m_midiComposition.end(); ++i) { + + for (MIDITrack::iterator j = i->second.begin(); + j != i->second.end(); ++j) { + delete *j; + } - i->second.clear(); + i->second.clear(); } m_midiComposition.clear(); @@ -110,7 +110,7 @@ MIDIFileReader::midiBytesToLong(const string& bytes) { if (bytes.length() != 4) { - throw MIDIException(tr("Wrong length for long data in MIDI stream (%1, should be %2)").arg(bytes.length()).arg(4)); + throw MIDIException(tr("Wrong length for long data in MIDI stream (%1, should be %2)").arg(bytes.length()).arg(4)); } long longRet = ((long)(((MIDIByte)bytes[0]) << 24)) | @@ -125,7 +125,7 @@ MIDIFileReader::midiBytesToInt(const string& bytes) { if (bytes.length() != 2) { - throw MIDIException(tr("Wrong length for int data in MIDI stream (%1, should be %2)").arg(bytes.length()).arg(2)); + throw MIDIException(tr("Wrong length for int data in MIDI stream (%1, should be %2)").arg(bytes.length()).arg(2)); } int intRet = ((int)(((MIDIByte)bytes[0]) << 8)) | @@ -142,7 +142,7 @@ MIDIFileReader::getMIDIByte() { if (!m_midiFile) { - throw MIDIException(tr("getMIDIByte called but no MIDI file open")); + throw MIDIException(tr("getMIDIByte called but no MIDI file open")); } if (m_midiFile->eof()) { @@ -155,8 +155,8 @@ char byte; if (m_midiFile->read(&byte, 1)) { - --m_trackByteCount; - return (MIDIByte)byte; + --m_trackByteCount; + return (MIDIByte)byte; } throw MIDIException(tr("Attempt to read past MIDI file end")); @@ -171,7 +171,7 @@ MIDIFileReader::getMIDIBytes(unsigned long numberOfBytes) { if (!m_midiFile) { - throw MIDIException(tr("getMIDIBytes called but no MIDI file open")); + throw MIDIException(tr("getMIDIBytes called but no MIDI file open")); } if (m_midiFile->eof()) { @@ -212,27 +212,27 @@ MIDIFileReader::getNumberFromMIDIBytes(int firstByte) { if (!m_midiFile) { - throw MIDIException(tr("getNumberFromMIDIBytes called but no MIDI file open")); + throw MIDIException(tr("getNumberFromMIDIBytes called but no MIDI file open")); } long longRet = 0; MIDIByte midiByte; if (firstByte >= 0) { - midiByte = (MIDIByte)firstByte; + midiByte = (MIDIByte)firstByte; } else if (m_midiFile->eof()) { - return longRet; + return longRet; } else { - midiByte = getMIDIByte(); + midiByte = getMIDIByte(); } longRet = midiByte; if (midiByte & 0x80) { - longRet &= 0x7F; - do { - midiByte = getMIDIByte(); - longRet = (longRet << 7) + (midiByte & 0x7F); - } while (!m_midiFile->eof() && (midiByte & 0x80)); + longRet &= 0x7F; + do { + midiByte = getMIDIByte(); + longRet = (longRet << 7) + (midiByte & 0x7F); + } while (!m_midiFile->eof() && (midiByte & 0x80)); } return longRet; @@ -246,7 +246,7 @@ MIDIFileReader::skipToNextTrack() { if (!m_midiFile) { - throw MIDIException(tr("skipToNextTrack called but no MIDI file open")); + throw MIDIException(tr("skipToNextTrack called but no MIDI file open")); } string buffer, buffer2; @@ -255,10 +255,10 @@ while (!m_midiFile->eof() && (m_decrementCount == false)) { buffer = getMIDIBytes(4); - if (buffer.compare(0, 4, MIDI_TRACK_HEADER) == 0) { - m_trackByteCount = midiBytesToLong(getMIDIBytes(4)); - m_decrementCount = true; - } + if (buffer.compare(0, 4, MIDI_TRACK_HEADER) == 0) { + m_trackByteCount = midiBytesToLong(getMIDIBytes(4)); + m_decrementCount = true; + } } if (m_trackByteCount == -1) { // we haven't found a track @@ -284,77 +284,77 @@ // Open the file m_midiFile = new ifstream(m_path.toLocal8Bit().data(), - ios::in | ios::binary); + ios::in | ios::binary); if (!*m_midiFile) { - m_error = "File not found or not readable."; - m_format = MIDI_FILE_BAD_FORMAT; - delete m_midiFile; + m_error = "File not found or not readable."; + m_format = MIDI_FILE_BAD_FORMAT; + delete m_midiFile; m_midiFile = 0; - return false; + return false; } bool retval = false; try { - // Set file size so we can count it off - // - m_midiFile->seekg(0, ios::end); + // Set file size so we can count it off + // + m_midiFile->seekg(0, ios::end); std::streamoff off = m_midiFile->tellg(); - m_fileSize = 0; + m_fileSize = 0; if (off > 0) m_fileSize = off; - m_midiFile->seekg(0, ios::beg); + m_midiFile->seekg(0, ios::beg); - // Parse the MIDI header first. The first 14 bytes of the file. - if (!parseHeader(getMIDIBytes(14))) { - m_format = MIDI_FILE_BAD_FORMAT; - m_error = "Not a MIDI file."; - goto done; - } + // Parse the MIDI header first. The first 14 bytes of the file. + if (!parseHeader(getMIDIBytes(14))) { + m_format = MIDI_FILE_BAD_FORMAT; + m_error = "Not a MIDI file."; + goto done; + } - unsigned int i = 0; + unsigned int i = 0; - for (unsigned int j = 0; j < m_numberOfTracks; ++j) { + for (unsigned int j = 0; j < m_numberOfTracks; ++j) { #ifdef MIDI_DEBUG - SVDEBUG << "Parsing Track " << j << endl; + SVDEBUG << "Parsing Track " << j << endl; #endif - if (!skipToNextTrack()) { + if (!skipToNextTrack()) { #ifdef MIDI_DEBUG - SVDEBUG << "Couldn't find Track " << j << endl; + SVDEBUG << "Couldn't find Track " << j << endl; #endif - m_error = "File corrupted or in non-standard format?"; - m_format = MIDI_FILE_BAD_FORMAT; - goto done; - } + m_error = "File corrupted or in non-standard format?"; + m_format = MIDI_FILE_BAD_FORMAT; + goto done; + } #ifdef MIDI_DEBUG - SVDEBUG << "Track has " << m_trackByteCount << " bytes" << endl; + SVDEBUG << "Track has " << m_trackByteCount << " bytes" << endl; #endif - // Run through the events taking them into our internal - // representation. - if (!parseTrack(i)) { + // Run through the events taking them into our internal + // representation. + if (!parseTrack(i)) { #ifdef MIDI_DEBUG - SVDEBUG << "Track " << j << " parsing failed" << endl; + SVDEBUG << "Track " << j << " parsing failed" << endl; #endif - m_error = "File corrupted or in non-standard format?"; - m_format = MIDI_FILE_BAD_FORMAT; - goto done; - } + m_error = "File corrupted or in non-standard format?"; + m_format = MIDI_FILE_BAD_FORMAT; + goto done; + } - ++i; // j is the source track number, i the destination - } - - m_numberOfTracks = i; - retval = true; + ++i; // j is the source track number, i the destination + } + + m_numberOfTracks = i; + retval = true; } catch (MIDIException e) { SVDEBUG << "MIDIFileReader::open() - caught exception - " << e.what() << endl; - m_error = e.what(); + m_error = e.what(); } done: @@ -367,7 +367,7 @@ // start. The addTime method returns the sum of the current // MIDI Event delta time plus the argument. - unsigned long acc = 0; + unsigned long acc = 0; for (MIDITrack::iterator i = m_midiComposition[track].begin(); i != m_midiComposition[track].end(); ++i) { @@ -375,8 +375,8 @@ } if (consolidateNoteOffEvents(track)) { // returns true if some notes exist - m_loadableTracks.insert(track); - } + m_loadableTracks.insert(track); + } } for (unsigned int track = 0; track < m_numberOfTracks; ++track) { @@ -402,18 +402,18 @@ if (midiHeader.compare(0, 4, MIDI_FILE_HEADER) != 0) { #ifdef MIDI_DEBUG - SVDEBUG << "MIDIFileReader::parseHeader()" - << "- file header not found or malformed" - << endl; + SVDEBUG << "MIDIFileReader::parseHeader()" + << "- file header not found or malformed" + << endl; #endif - return false; + return false; } if (midiBytesToLong(midiHeader.substr(4,4)) != 6L) { #ifdef MIDI_DEBUG SVDEBUG << "MIDIFileReader::parseHeader()" - << " - header length incorrect" - << endl; + << " - header length incorrect" + << endl; #endif return false; } @@ -474,18 +474,18 @@ while (!m_midiFile->eof() && (m_trackByteCount > 0)) { - if (eventCode < 0x80) { + if (eventCode < 0x80) { #ifdef MIDI_DEBUG - SVDEBUG << "WARNING: Invalid event code " << eventCode - << " in MIDI file" << endl; + SVDEBUG << "WARNING: Invalid event code " << eventCode + << " in MIDI file" << endl; #endif - throw MIDIException(tr("Invalid event code %1 found").arg(int(eventCode))); - } + throw MIDIException(tr("Invalid event code %1 found").arg(int(eventCode))); + } deltaTime = getNumberFromMIDIBytes(); #ifdef MIDI_DEBUG - SVDEBUG << "read delta time " << deltaTime << endl; + SVDEBUG << "read delta time " << deltaTime << endl; #endif // Get a single byte @@ -493,72 +493,72 @@ if (!(midiByte & MIDI_STATUS_BYTE_MASK)) { - if (runningStatus < 0) { - throw MIDIException(tr("Running status used for first event in track")); - } + if (runningStatus < 0) { + throw MIDIException(tr("Running status used for first event in track")); + } - eventCode = (MIDIByte)runningStatus; - data1 = midiByte; + eventCode = (MIDIByte)runningStatus; + data1 = midiByte; #ifdef MIDI_DEBUG - SVDEBUG << "using running status (byte " << int(midiByte) << " found)" << endl; + SVDEBUG << "using running status (byte " << int(midiByte) << " found)" << endl; #endif } else { #ifdef MIDI_DEBUG - SVDEBUG << "have new event code " << int(midiByte) << endl; + SVDEBUG << "have new event code " << int(midiByte) << endl; #endif eventCode = midiByte; - data1 = getMIDIByte(); - } + data1 = getMIDIByte(); + } if (eventCode == MIDI_FILE_META_EVENT) { - metaEventCode = data1; + metaEventCode = data1; messageLength = getNumberFromMIDIBytes(); //#ifdef MIDI_DEBUG - SVDEBUG << "Meta event of type " << int(metaEventCode) << " and " << messageLength << " bytes found, putting on track " << metaTrack << endl; + SVDEBUG << "Meta event of type " << int(metaEventCode) << " and " << messageLength << " bytes found, putting on track " << metaTrack << endl; //#endif metaMessage = getMIDIBytes(messageLength); - long gap = accumulatedTime - trackTimeMap[metaTrack]; - accumulatedTime += deltaTime; - deltaTime += gap; - trackTimeMap[metaTrack] = accumulatedTime; + long gap = accumulatedTime - trackTimeMap[metaTrack]; + accumulatedTime += deltaTime; + deltaTime += gap; + trackTimeMap[metaTrack] = accumulatedTime; MIDIEvent *e = new MIDIEvent(deltaTime, MIDI_FILE_META_EVENT, metaEventCode, metaMessage); - m_midiComposition[metaTrack].push_back(e); + m_midiComposition[metaTrack].push_back(e); - if (metaEventCode == MIDI_TRACK_NAME) { - m_trackNames[metaTrack] = metaMessage.c_str(); - } + if (metaEventCode == MIDI_TRACK_NAME) { + m_trackNames[metaTrack] = metaMessage.c_str(); + } } else { // non-meta events - runningStatus = eventCode; + runningStatus = eventCode; MIDIEvent *midiEvent; - int channel = (eventCode & MIDI_CHANNEL_NUM_MASK); - if (channelTrackMap[channel] == -1) { - if (!firstTrack) ++lastTrackNum; - else firstTrack = false; - channelTrackMap[channel] = lastTrackNum; - } + int channel = (eventCode & MIDI_CHANNEL_NUM_MASK); + if (channelTrackMap[channel] == -1) { + if (!firstTrack) ++lastTrackNum; + else firstTrack = false; + channelTrackMap[channel] = lastTrackNum; + } - unsigned int trackNum = channelTrackMap[channel]; - - // accumulatedTime is abs time of last event on any track; - // trackTimeMap[trackNum] is that of last event on this track - - long gap = accumulatedTime - trackTimeMap[trackNum]; - accumulatedTime += deltaTime; - deltaTime += gap; - trackTimeMap[trackNum] = accumulatedTime; + unsigned int trackNum = channelTrackMap[channel]; + + // accumulatedTime is abs time of last event on any track; + // trackTimeMap[trackNum] is that of last event on this track + + long gap = accumulatedTime - trackTimeMap[trackNum]; + accumulatedTime += deltaTime; + deltaTime += gap; + trackTimeMap[trackNum] = accumulatedTime; switch (eventCode & MIDI_MESSAGE_TYPE_MASK) { @@ -572,17 +572,17 @@ midiEvent = new MIDIEvent(deltaTime, eventCode, data1, data2); /* - SVDEBUG << "MIDI event for channel " << channel << " (track " - << trackNum << ")" << endl; - midiEvent->print(); + SVDEBUG << "MIDI event for channel " << channel << " (track " + << trackNum << ")" << endl; + midiEvent->print(); */ m_midiComposition[trackNum].push_back(midiEvent); - if (midiEvent->getChannelNumber() == MIDI_PERCUSSION_CHANNEL) { - m_percussionTracks.insert(trackNum); - } + if (midiEvent->getChannelNumber() == MIDI_PERCUSSION_CHANNEL) { + m_percussionTracks.insert(trackNum); + } break; @@ -605,7 +605,7 @@ messageLength = getNumberFromMIDIBytes(data1); #ifdef MIDI_DEBUG - SVDEBUG << "SysEx of " << messageLength << " bytes found" << endl; + SVDEBUG << "SysEx of " << messageLength << " bytes found" << endl; #endif metaMessage= getMIDIBytes(messageLength); @@ -644,10 +644,10 @@ } if (lastTrackNum > metaTrack) { - for (unsigned int track = metaTrack + 1; track <= lastTrackNum; ++track) { - m_trackNames[track] = QString("%1 <%2>") - .arg(m_trackNames[metaTrack]).arg(track - metaTrack + 1); - } + for (unsigned int track = metaTrack + 1; track <= lastTrackNum; ++track) { + m_trackNames[track] = QString("%1 <%2>") + .arg(m_trackNames[metaTrack]).arg(track - metaTrack + 1); + } } return true; @@ -664,18 +664,18 @@ bool noteOffFound; for (MIDITrack::iterator i = m_midiComposition[track].begin(); - i != m_midiComposition[track].end(); i++) { + i != m_midiComposition[track].end(); i++) { if ((*i)->getMessageType() == MIDI_NOTE_ON && (*i)->getVelocity() > 0) { - notesOnTrack = true; + notesOnTrack = true; noteOffFound = false; for (MIDITrack::iterator j = i; - j != m_midiComposition[track].end(); j++) { + j != m_midiComposition[track].end(); j++) { if (((*j)->getChannelNumber() == (*i)->getChannelNumber()) && - ((*j)->getPitch() == (*i)->getPitch()) && + ((*j)->getPitch() == (*i)->getPitch()) && ((*j)->getMessageType() == MIDI_NOTE_OFF || ((*j)->getMessageType() == MIDI_NOTE_ON && (*j)->getVelocity() == 0x00))) { @@ -694,10 +694,10 @@ // Event duration to length of track // if (!noteOffFound) { - MIDITrack::iterator j = m_midiComposition[track].end(); - --j; + MIDITrack::iterator j = m_midiComposition[track].end(); + --j; (*i)->setDuration((*j)->getTime() - (*i)->getTime()); - } + } } } @@ -712,24 +712,24 @@ SVDEBUG << "updateTempoMap for track " << track << " (" << m_midiComposition[track].size() << " events)" << endl; for (MIDITrack::iterator i = m_midiComposition[track].begin(); - i != m_midiComposition[track].end(); ++i) { + i != m_midiComposition[track].end(); ++i) { if ((*i)->isMeta() && - (*i)->getMetaEventCode() == MIDI_SET_TEMPO) { + (*i)->getMetaEventCode() == MIDI_SET_TEMPO) { - MIDIByte m0 = (*i)->getMetaMessage()[0]; - MIDIByte m1 = (*i)->getMetaMessage()[1]; - MIDIByte m2 = (*i)->getMetaMessage()[2]; - - long tempo = (((m0 << 8) + m1) << 8) + m2; + MIDIByte m0 = (*i)->getMetaMessage()[0]; + MIDIByte m1 = (*i)->getMetaMessage()[1]; + MIDIByte m2 = (*i)->getMetaMessage()[2]; + + long tempo = (((m0 << 8) + m1) << 8) + m2; - SVDEBUG << "updateTempoMap: have tempo, it's " << tempo << " at " << (*i)->getTime() << endl; + SVDEBUG << "updateTempoMap: have tempo, it's " << tempo << " at " << (*i)->getTime() << endl; - if (tempo != 0) { - double qpm = 60000000.0 / double(tempo); - m_tempoMap[(*i)->getTime()] = - TempoChange(RealTime::zeroTime, qpm); - } + if (tempo != 0) { + double qpm = 60000000.0 / double(tempo); + m_tempoMap[(*i)->getTime()] = + TempoChange(RealTime::zeroTime, qpm); + } } } } @@ -744,19 +744,19 @@ if (td == 0) td = 96; for (TempoMap::iterator i = m_tempoMap.begin(); i != m_tempoMap.end(); ++i) { - - unsigned long mtime = i->first; - unsigned long melapsed = mtime - lastMIDITime; - double quarters = double(melapsed) / double(td); - double seconds = (60.0 * quarters) / tempo; + + unsigned long mtime = i->first; + unsigned long melapsed = mtime - lastMIDITime; + double quarters = double(melapsed) / double(td); + double seconds = (60.0 * quarters) / tempo; - RealTime t = lastRealTime + RealTime::fromSeconds(seconds); + RealTime t = lastRealTime + RealTime::fromSeconds(seconds); - i->second.first = t; + i->second.first = t; - lastRealTime = t; - lastMIDITime = mtime; - tempo = i->second.second; + lastRealTime = t; + lastMIDITime = mtime; + tempo = i->second.second; } } @@ -769,10 +769,10 @@ TempoMap::const_iterator i = m_tempoMap.lower_bound(midiTime); if (i != m_tempoMap.begin()) { - --i; - tempoMIDITime = i->first; - tempoRealTime = i->second.first; - tempo = i->second.second; + --i; + tempoMIDITime = i->first; + tempoRealTime = i->second.first; + tempo = i->second.second; } int td = m_timingDivision; @@ -784,10 +784,10 @@ /* SVDEBUG << "MIDIFileReader::getTimeForMIDITime(" << midiTime << ")" - << endl; + << endl; SVDEBUG << "timing division = " << td << endl; SVDEBUG << "nearest tempo event (of " << m_tempoMap.size() << ") is at " << tempoMIDITime << " (" - << tempoRealTime << ")" << endl; + << tempoRealTime << ")" << endl; SVDEBUG << "quarters since then = " << quarters << endl; SVDEBUG << "tempo = " << tempo << " quarters per minute" << endl; SVDEBUG << "seconds since then = " << seconds << endl; @@ -807,40 +807,40 @@ m_acquirer->showError (tr("MIDI file \"%1\" has no notes in any track").arg(m_path)); } - return 0; + return 0; } std::set tracksToLoad; if (m_loadableTracks.size() == 1) { - tracksToLoad.insert(*m_loadableTracks.begin()); + tracksToLoad.insert(*m_loadableTracks.begin()); } else { QStringList displayNames; - for (set::iterator i = m_loadableTracks.begin(); - i != m_loadableTracks.end(); ++i) { + for (set::iterator i = m_loadableTracks.begin(); + i != m_loadableTracks.end(); ++i) { - unsigned int trackNo = *i; - QString label; + unsigned int trackNo = *i; + QString label; - QString perc; - if (m_percussionTracks.find(trackNo) != m_percussionTracks.end()) { - perc = tr(" - uses GM percussion channel"); - } + QString perc; + if (m_percussionTracks.find(trackNo) != m_percussionTracks.end()) { + perc = tr(" - uses GM percussion channel"); + } - if (m_trackNames.find(trackNo) != m_trackNames.end()) { - label = tr("Track %1 (%2)%3") - .arg(trackNo).arg(m_trackNames.find(trackNo)->second) - .arg(perc); - } else { - label = tr("Track %1 (untitled)%3").arg(trackNo).arg(perc); - } + if (m_trackNames.find(trackNo) != m_trackNames.end()) { + label = tr("Track %1 (%2)%3") + .arg(trackNo).arg(m_trackNames.find(trackNo)->second) + .arg(perc); + } else { + label = tr("Track %1 (untitled)%3").arg(trackNo).arg(perc); + } displayNames << label; - } + } QString singleTrack; @@ -866,28 +866,28 @@ for (set::iterator i = m_loadableTracks.begin(); i != m_loadableTracks.end(); ++i) { - if (pref == MIDIFileImportPreferenceAcquirer::MergeAllTracks || - m_percussionTracks.find(*i) == m_percussionTracks.end()) { + if (pref == MIDIFileImportPreferenceAcquirer::MergeAllTracks || + m_percussionTracks.find(*i) == m_percussionTracks.end()) { - tracksToLoad.insert(*i); - } - } + tracksToLoad.insert(*i); + } + } - } else { - - int j = 0; + } else { + + int j = 0; - for (set::iterator i = m_loadableTracks.begin(); - i != m_loadableTracks.end(); ++i) { - - if (singleTrack == displayNames[j]) { - tracksToLoad.insert(*i); - break; - } - - ++j; - } - } + for (set::iterator i = m_loadableTracks.begin(); + i != m_loadableTracks.end(); ++i) { + + if (singleTrack == displayNames[j]) { + tracksToLoad.insert(*i); + break; + } + + ++j; + } + } } if (tracksToLoad.empty()) return 0; @@ -896,18 +896,18 @@ Model *model = 0; for (std::set::iterator i = tracksToLoad.begin(); - i != tracksToLoad.end(); ++i) { + i != tracksToLoad.end(); ++i) { - int minProgress = (100 * count) / n; - int progressAmount = 100 / n; + int minProgress = (100 * count) / n; + int progressAmount = 100 / n; - model = loadTrack(*i, model, minProgress, progressAmount); + model = loadTrack(*i, model, minProgress, progressAmount); - ++count; + ++count; } if (dynamic_cast(model)) { - dynamic_cast(model)->setCompletion(100); + dynamic_cast(model)->setCompletion(100); } return model; @@ -915,26 +915,26 @@ Model * MIDIFileReader::loadTrack(unsigned int trackToLoad, - Model *existingModel, - int minProgress, - int progressAmount) const + Model *existingModel, + int minProgress, + int progressAmount) const { if (m_midiComposition.find(trackToLoad) == m_midiComposition.end()) { - return 0; + return 0; } NoteModel *model = 0; if (existingModel) { - model = dynamic_cast(existingModel); - if (!model) { - SVDEBUG << "WARNING: MIDIFileReader::loadTrack: Existing model given, but it isn't a NoteModel -- ignoring it" << endl; - } + model = dynamic_cast(existingModel); + if (!model) { + SVDEBUG << "WARNING: MIDIFileReader::loadTrack: Existing model given, but it isn't a NoteModel -- ignoring it" << endl; + } } if (!model) { - model = new NoteModel(m_mainModelSampleRate, 1, 0.0, 0.0, false); - model->setValueQuantization(1.0); + model = new NoteModel(m_mainModelSampleRate, 1, 0.0, 0.0, false); + model->setValueQuantization(1.0); model->setObjectName(QFileInfo(m_path).fileName()); } @@ -956,54 +956,54 @@ rt = getTimeForMIDITime(midiTime); } - // We ignore most of these event types for now, though in - // theory some of the text ones could usefully be incorporated + // We ignore most of these event types for now, though in + // theory some of the text ones could usefully be incorporated - if ((*i)->isMeta()) { + if ((*i)->isMeta()) { - switch((*i)->getMetaEventCode()) { + switch((*i)->getMetaEventCode()) { - case MIDI_KEY_SIGNATURE: - // minorKey = (int((*i)->getMetaMessage()[1]) != 0); - sharpKey = (int((*i)->getMetaMessage()[0]) >= 0); - break; + case MIDI_KEY_SIGNATURE: + // minorKey = (int((*i)->getMetaMessage()[1]) != 0); + sharpKey = (int((*i)->getMetaMessage()[0]) >= 0); + break; - case MIDI_TEXT_EVENT: - case MIDI_LYRIC: - case MIDI_TEXT_MARKER: - case MIDI_COPYRIGHT_NOTICE: - case MIDI_TRACK_NAME: - // The text events that we could potentially use - break; + case MIDI_TEXT_EVENT: + case MIDI_LYRIC: + case MIDI_TEXT_MARKER: + case MIDI_COPYRIGHT_NOTICE: + case MIDI_TRACK_NAME: + // The text events that we could potentially use + break; - case MIDI_SET_TEMPO: - // Already dealt with in a separate pass previously - break; + case MIDI_SET_TEMPO: + // Already dealt with in a separate pass previously + break; - case MIDI_TIME_SIGNATURE: - // Not yet! - break; + case MIDI_TIME_SIGNATURE: + // Not yet! + break; - case MIDI_SEQUENCE_NUMBER: - case MIDI_CHANNEL_PREFIX_OR_PORT: - case MIDI_INSTRUMENT_NAME: - case MIDI_CUE_POINT: - case MIDI_CHANNEL_PREFIX: - case MIDI_SEQUENCER_SPECIFIC: - case MIDI_SMPTE_OFFSET: - default: - break; - } + case MIDI_SEQUENCE_NUMBER: + case MIDI_CHANNEL_PREFIX_OR_PORT: + case MIDI_INSTRUMENT_NAME: + case MIDI_CUE_POINT: + case MIDI_CHANNEL_PREFIX: + case MIDI_SEQUENCER_SPECIFIC: + case MIDI_SMPTE_OFFSET: + default: + break; + } - } else { + } else { - switch ((*i)->getMessageType()) { + switch ((*i)->getMessageType()) { - case MIDI_NOTE_ON: + case MIDI_NOTE_ON: if ((*i)->getVelocity() == 0) break; // effective note-off - else { - RealTime endRT; + else { + RealTime endRT; unsigned long endMidiTime = (*i)->getTime() + (*i)->getDuration(); if (m_smpte) { endRT = RealTime::frame2RealTime(endMidiTime, m_fps * m_subframes); @@ -1011,32 +1011,32 @@ endRT = getTimeForMIDITime(endMidiTime); } - long startFrame = RealTime::realTime2Frame - (rt, model->getSampleRate()); + long startFrame = RealTime::realTime2Frame + (rt, model->getSampleRate()); - long endFrame = RealTime::realTime2Frame - (endRT, model->getSampleRate()); + long endFrame = RealTime::realTime2Frame + (endRT, model->getSampleRate()); - QString pitchLabel = Pitch::getPitchLabel((*i)->getPitch(), - 0, - !sharpKey); + QString pitchLabel = Pitch::getPitchLabel((*i)->getPitch(), + 0, + !sharpKey); - QString noteLabel = tr("%1 - vel %2") - .arg(pitchLabel).arg(int((*i)->getVelocity())); + QString noteLabel = tr("%1 - vel %2") + .arg(pitchLabel).arg(int((*i)->getVelocity())); float level = float((*i)->getVelocity()) / 128.f; - Note note(startFrame, (*i)->getPitch(), - endFrame - startFrame, level, noteLabel); + Note note(startFrame, (*i)->getPitch(), + endFrame - startFrame, level, noteLabel); -// SVDEBUG << "Adding note " << startFrame << "," << (endFrame-startFrame) << " : " << int((*i)->getPitch()) << endl; +// SVDEBUG << "Adding note " << startFrame << "," << (endFrame-startFrame) << " : " << int((*i)->getPitch()) << endl; - model->addPoint(note); - break; - } + model->addPoint(note); + break; + } case MIDI_PITCH_BEND: - // I guess we could make some use of this... + // I guess we could make some use of this... break; case MIDI_NOTE_OFF: @@ -1050,11 +1050,11 @@ default: break; } - } + } - model->setCompletion(minProgress + - (count * progressAmount) / totalEvents); - ++count; + model->setCompletion(minProgress + + (count * progressAmount) / totalEvents); + ++count; } return model; diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/MIDIFileReader.h --- a/data/fileio/MIDIFileReader.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/MIDIFileReader.h Tue Apr 17 10:35:42 2018 +0100 @@ -75,10 +75,10 @@ typedef std::map TempoMap; // key is MIDI time typedef enum { - MIDI_SINGLE_TRACK_FILE = 0x00, - MIDI_SIMULTANEOUS_TRACK_FILE = 0x01, - MIDI_SEQUENTIAL_TRACK_FILE = 0x02, - MIDI_FILE_BAD_FORMAT = 0xFF + MIDI_SINGLE_TRACK_FILE = 0x00, + MIDI_SIMULTANEOUS_TRACK_FILE = 0x01, + MIDI_SEQUENTIAL_TRACK_FILE = 0x02, + MIDI_FILE_BAD_FORMAT = 0xFF } MIDIFileFormatType; bool parseFile(); @@ -86,9 +86,9 @@ bool parseTrack(unsigned int &trackNum); Model *loadTrack(unsigned int trackNum, - Model *existingModel = 0, - int minProgress = 0, - int progressAmount = 100) const; + Model *existingModel = 0, + int minProgress = 0, + int progressAmount = 100) const; bool consolidateNoteOffEvents(unsigned int track); void updateTempoMap(unsigned int track); diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/MIDIFileWriter.cpp --- a/data/fileio/MIDIFileWriter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/MIDIFileWriter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -56,14 +56,14 @@ MIDIFileWriter::~MIDIFileWriter() { for (MIDIComposition::iterator i = m_midiComposition.begin(); - i != m_midiComposition.end(); ++i) { - - for (MIDITrack::iterator j = i->second.begin(); - j != i->second.end(); ++j) { - delete *j; - } + i != m_midiComposition.end(); ++i) { + + for (MIDITrack::iterator j = i->second.begin(); + j != i->second.end(); ++j) { + delete *j; + } - i->second.clear(); + i->second.clear(); } m_midiComposition.clear(); diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/MIDIFileWriter.h --- a/data/fileio/MIDIFileWriter.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/MIDIFileWriter.h Tue Apr 17 10:35:42 2018 +0100 @@ -60,10 +60,10 @@ typedef std::map MIDIComposition; typedef enum { - MIDI_SINGLE_TRACK_FILE = 0x00, - MIDI_SIMULTANEOUS_TRACK_FILE = 0x01, - MIDI_SEQUENTIAL_TRACK_FILE = 0x02, - MIDI_FILE_BAD_FORMAT = 0xFF + MIDI_SINGLE_TRACK_FILE = 0x00, + MIDI_SIMULTANEOUS_TRACK_FILE = 0x01, + MIDI_SEQUENTIAL_TRACK_FILE = 0x02, + MIDI_FILE_BAD_FORMAT = 0xFF } MIDIFileFormatType; std::string intToMIDIBytes(int number) const; diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/MP3FileReader.h --- a/data/fileio/MP3FileReader.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/MP3FileReader.h Tue Apr 17 10:35:42 2018 +0100 @@ -122,10 +122,10 @@ bool m_decodeErrorShown; struct DecoderData { - unsigned char const *start; - sv_frame_t length; + unsigned char const *start; + sv_frame_t length; bool finished; - MP3FileReader *reader; + MP3FileReader *reader; }; bool decode(void *mm, sv_frame_t sz); diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/PlaylistFileReader.cpp --- a/data/fileio/PlaylistFileReader.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/PlaylistFileReader.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -66,13 +66,13 @@ bool good = false; if (!m_file->exists()) { - m_error = QFile::tr("File \"%1\" does not exist") + m_error = QFile::tr("File \"%1\" does not exist") .arg(m_source.getLocation()); } else if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) { - m_error = QFile::tr("Failed to open file \"%1\"") + m_error = QFile::tr("Failed to open file \"%1\"") .arg(m_source.getLocation()); } else { - good = true; + good = true; } if (good) { @@ -82,8 +82,8 @@ } if (!good) { - delete m_file; - m_file = 0; + delete m_file; + m_file = 0; } } diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/WavFileWriter.cpp --- a/data/fileio/WavFileWriter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/WavFileWriter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -19,11 +19,13 @@ #include "base/Selection.h" #include "base/TempWriteFile.h" #include "base/Exceptions.h" +#include "base/Debug.h" #include #include #include +#include using namespace std; @@ -41,7 +43,7 @@ int fileRate = int(round(m_sampleRate)); if (m_sampleRate != sv_samplerate_t(fileRate)) { - cerr << "WavFileWriter: WARNING: Non-integer sample rate " + SVCERR << "WavFileWriter: WARNING: Non-integer sample rate " << m_sampleRate << " presented, rounding to " << fileRate << endl; } @@ -61,7 +63,7 @@ m_file = sf_open(writePath.toLocal8Bit(), SFM_WRITE, &fileInfo); #endif if (!m_file) { - cerr << "WavFileWriter: Failed to open file (" + SVCERR << "WavFileWriter: Failed to open file (" << sf_strerror(m_file) << ")" << endl; m_error = QString("Failed to open audio file '%1' for writing") .arg(writePath); @@ -132,11 +134,11 @@ for (MultiSelection::SelectionList::iterator i = selection->getSelections().begin(); i != selection->getSelections().end(); ++i) { - + sv_frame_t f0(i->getStartFrame()), f1(i->getEndFrame()); for (sv_frame_t f = f0; f < f1; f += bs) { - + sv_frame_t n = min(bs, f1 - f); floatvec_t interleaved(n * m_channels, 0.f); @@ -161,7 +163,7 @@ return isOK(); } - + bool WavFileWriter::writeSamples(const float *const *samples, sv_frame_t count) { diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/AudioFileReaderTest.h --- a/data/fileio/test/AudioFileReaderTest.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/AudioFileReaderTest.h Tue Apr 17 10:35:42 2018 +0100 @@ -188,11 +188,11 @@ { if (!QDir(audioDir).exists()) { QString cwd = QDir::currentPath(); - cerr << "ERROR: Audio test file directory \"" << audioDir << "\" does not exist (cwd = " << cwd << ")" << endl; + SVCERR << "ERROR: Audio test file directory \"" << audioDir << "\" does not exist (cwd = " << cwd << ")" << endl; QVERIFY2(QDir(audioDir).exists(), "Audio test file directory not found"); } if (!QDir(diffDir).exists() && !QDir().mkpath(diffDir)) { - cerr << "ERROR: Audio diff directory \"" << diffDir << "\" does not exist and could not be created" << endl; + SVCERR << "ERROR: Audio diff directory \"" << diffDir << "\" does not exist and could not be created" << endl; QVERIFY2(QDir(diffDir).exists(), "Audio diff directory not found and could not be created"); } } @@ -254,17 +254,17 @@ AudioFileReaderFactory::GaplessMode::Gapless : AudioFileReaderFactory::GaplessMode::Gappy); - AudioFileReader *reader = - AudioFileReaderFactory::createReader - (audioDir + "/" + format + "/" + audiofile, params); + AudioFileReader *reader = + AudioFileReaderFactory::createReader + (audioDir + "/" + format + "/" + audiofile, params); - if (!reader) { + if (!reader) { #if ( QT_VERSION >= 0x050000 ) - QSKIP("Unsupported file, skipping"); + QSKIP("Unsupported file, skipping"); #else - QSKIP("Unsupported file, skipping", SkipSingle); + QSKIP("Unsupported file, skipping", SkipSingle); #endif - } + } QString extension; sv_samplerate_t fileRate; @@ -276,22 +276,22 @@ QCOMPARE(reader->getNativeRate(), fileRate); QCOMPARE(reader->getSampleRate(), readRate); - AudioTestData tdata(readRate, channels); - - float *reference = tdata.getInterleavedData(); + AudioTestData tdata(readRate, channels); + + float *reference = tdata.getInterleavedData(); sv_frame_t refFrames = tdata.getFrameCount(); - - // The reader should give us exactly the expected number of - // frames, except for mp3/aac files. We ask for quite a lot - // more, though, so we can (a) check that we only get the - // expected number back (if this is not mp3/aac) or (b) take - // into account silence at beginning and end (if it is). - floatvec_t test = reader->getInterleavedFrames(0, refFrames + 5000); + + // The reader should give us exactly the expected number of + // frames, except for mp3/aac files. We ask for quite a lot + // more, though, so we can (a) check that we only get the + // expected number back (if this is not mp3/aac) or (b) take + // into account silence at beginning and end (if it is). + floatvec_t test = reader->getInterleavedFrames(0, refFrames + 5000); delete reader; reader = 0; - sv_frame_t read = test.size() / channels; + sv_frame_t read = test.size() / channels; bool perceptual = (extension == "mp3" || extension == "aac" || @@ -426,7 +426,7 @@ for (int i = 0; i < refFrames; ++i) { int ix = i + offset; if (ix >= read) { - cerr << "ERROR: audiofile " << audiofile << " reads truncated (read-rate reference frames " << i << " onward, of " << refFrames << ", are lost)" << endl; + SVCERR << "ERROR: audiofile " << audiofile << " reads truncated (read-rate reference frames " << i << " onward, of " << refFrames << ", are lost)" << endl; QVERIFY(ix < read); } @@ -461,15 +461,15 @@ /* cerr << "channel " << c << ": mean diff " << meanDiff << endl; - cerr << "channel " << c << ": rms diff " << rmsDiff << endl; - cerr << "channel " << c << ": max diff " << maxDiff << " at " << maxIndex << endl; + cerr << "channel " << c << ": rms diff " << rmsDiff << endl; + cerr << "channel " << c << ": max diff " << maxDiff << " at " << maxIndex << endl; */ if (rmsDiff >= rmsLimit) { - cerr << "ERROR: for audiofile " << audiofile << ": RMS diff = " << rmsDiff << " for channel " << c << " (limit = " << rmsLimit << ")" << endl; + SVCERR << "ERROR: for audiofile " << audiofile << ": RMS diff = " << rmsDiff << " for channel " << c << " (limit = " << rmsLimit << ")" << endl; QVERIFY(rmsDiff < rmsLimit); } if (maxDiff >= maxLimit) { - cerr << "ERROR: for audiofile " << audiofile << ": max diff = " << maxDiff << " at frame " << maxIndex << " of " << read << " on channel " << c << " (limit = " << maxLimit << ", edge limit = " << edgeLimit << ", mean diff = " << meanDiff << ", rms = " << rmsDiff << ")" << endl; + SVCERR << "ERROR: for audiofile " << audiofile << ": max diff = " << maxDiff << " at frame " << maxIndex << " of " << read << " on channel " << c << " (limit = " << maxLimit << ", edge limit = " << edgeLimit << ", mean diff = " << meanDiff << ", rms = " << rmsDiff << ")" << endl; QVERIFY(maxDiff < maxLimit); } @@ -480,11 +480,11 @@ float quiet = 0.1f; //!!! allow some ringing - but let's come back to this, it should tail off float mag = fabsf(test[ix * channels + c]); if (mag > quiet) { - cerr << "ERROR: audiofile " << audiofile << " contains spurious data after end of reference (found sample " << test[ix * channels + c] << " at index " << ix << " of channel " << c << " after reference+offset ended at " << refFrames+offset << ")" << endl; + SVCERR << "ERROR: audiofile " << audiofile << " contains spurious data after end of reference (found sample " << test[ix * channels + c] << " at index " << ix << " of channel " << c << " after reference+offset ended at " << refFrames+offset << ")" << endl; QVERIFY(mag < quiet); } } - } + } } }; diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/AudioFileWriterTest.h --- a/data/fileio/test/AudioFileWriterTest.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/AudioFileWriterTest.h Tue Apr 17 10:35:42 2018 +0100 @@ -69,7 +69,7 @@ void init() { if (!QDir(outDir).exists() && !QDir().mkpath(outDir)) { - cerr << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl; + SVCERR << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl; QVERIFY2(QDir(outDir).exists(), "Audio out directory not found and could not be created"); } } diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/AudioTestData.h --- a/data/fileio/test/AudioTestData.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/AudioTestData.h Tue Apr 17 10:35:42 2018 +0100 @@ -38,74 +38,74 @@ { public: AudioTestData(double rate, int channels) : - m_channelCount(channels), - m_duration(2.0), - m_sampleRate(rate), - m_sinFreq(600.0), - m_pulseFreq(2) + m_channelCount(channels), + m_duration(2.0), + m_sampleRate(rate), + m_sinFreq(600.0), + m_pulseFreq(2) { - m_frameCount = lrint(m_duration * m_sampleRate); - m_data = new float[m_frameCount * m_channelCount]; - m_pulseWidth = 0.01 * m_sampleRate; - generate(); + m_frameCount = lrint(m_duration * m_sampleRate); + m_data = new float[m_frameCount * m_channelCount]; + m_pulseWidth = 0.01 * m_sampleRate; + generate(); } ~AudioTestData() { - delete[] m_data; + delete[] m_data; } void generate() { - double hpw = m_pulseWidth / 2.0; + double hpw = m_pulseWidth / 2.0; - for (int i = 0; i < m_frameCount; ++i) { - for (int c = 0; c < m_channelCount; ++c) { + for (int i = 0; i < m_frameCount; ++i) { + for (int c = 0; c < m_channelCount; ++c) { - double s = 0.0; + double s = 0.0; - if (c == 0) { + if (c == 0) { - double phase = (i * m_sinFreq * 2.0 * M_PI) / m_sampleRate; - s = sin(phase); + double phase = (i * m_sinFreq * 2.0 * M_PI) / m_sampleRate; + s = sin(phase); - } else if (c == 1) { + } else if (c == 1) { - int pulseNo = int((i * m_pulseFreq) / m_sampleRate); - int index = int(round((i * m_pulseFreq) - + int pulseNo = int((i * m_pulseFreq) / m_sampleRate); + int index = int(round((i * m_pulseFreq) - (m_sampleRate * pulseNo))); - if (index < m_pulseWidth) { - s = 1.0 - fabs(hpw - index) / hpw; - if (pulseNo % 2) s = -s; - } + if (index < m_pulseWidth) { + s = 1.0 - fabs(hpw - index) / hpw; + if (pulseNo % 2) s = -s; + } - } else { + } else { - s = c / 20.0; - } + s = c / 20.0; + } - m_data[i * m_channelCount + c] = float(s); - } - } + m_data[i * m_channelCount + c] = float(s); + } + } } float *getInterleavedData() const { - return m_data; + return m_data; } sv_frame_t getFrameCount() const { - return m_frameCount; + return m_frameCount; } int getChannelCount() const { - return m_channelCount; + return m_channelCount; } sv_samplerate_t getSampleRate () const { - return m_sampleRate; + return m_sampleRate; } double getDuration() const { // seconds - return m_duration; + return m_duration; } private: diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/EncodingTest.h --- a/data/fileio/test/EncodingTest.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/EncodingTest.h Tue Apr 17 10:35:42 2018 +0100 @@ -82,11 +82,11 @@ void init() { if (!QDir(encodingDir).exists()) { - cerr << "ERROR: Audio encoding file directory \"" << encodingDir << "\" does not exist" << endl; + SVCERR << "ERROR: Audio encoding file directory \"" << encodingDir << "\" does not exist" << endl; QVERIFY2(QDir(encodingDir).exists(), "Audio encoding file directory not found"); } if (!QDir(outDir).exists() && !QDir().mkpath(outDir)) { - cerr << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl; + SVCERR << "ERROR: Audio out directory \"" << outDir << "\" does not exist and could not be created" << endl; QVERIFY2(QDir(outDir).exists(), "Audio out directory not found and could not be created"); } } @@ -161,17 +161,17 @@ found = true; QString expected = QString::fromUtf8(mapping[m][1]); if (title != expected) { - cerr << "Title does not match expected: codepoints are" << endl; - cerr << "Title (" << title.length() << "ch): "; + SVCERR << "Title does not match expected: codepoints are" << endl; + SVCERR << "Title (" << title.length() << "ch): "; for (int i = 0; i < title.length(); ++i) { - cerr << title[i].unicode() << " "; + SVCERR << title[i].unicode() << " "; } - cerr << endl; - cerr << "Expected (" << expected.length() << "ch): "; + SVCERR << endl; + SVCERR << "Expected (" << expected.length() << "ch): "; for (int i = 0; i < expected.length(); ++i) { - cerr << expected[i].unicode() << " "; + SVCERR << expected[i].unicode() << " "; } - cerr << endl; + SVCERR << endl; } QCOMPARE(title, expected); break; @@ -185,7 +185,7 @@ // the expected UTF-16. We check this properly in // readWriteAudio below, by saving out the file to a // name matching the metadata - cerr << "Couldn't find filename \"" + SVCERR << "Couldn't find filename \"" << file << "\" in title mapping array" << endl; QSKIP("Couldn't find filename in title mapping array"); } diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/MIDIFileReaderTest.h --- a/data/fileio/test/MIDIFileReaderTest.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/MIDIFileReaderTest.h Tue Apr 17 10:35:42 2018 +0100 @@ -55,7 +55,7 @@ void init() { if (!QDir(midiDir).exists()) { - cerr << "ERROR: MIDI file directory \"" << midiDir << "\" does not exist" << endl; + SVCERR << "ERROR: MIDI file directory \"" << midiDir << "\" does not exist" << endl; QVERIFY2(QDir(midiDir).exists(), "MIDI file directory not found"); } } @@ -76,7 +76,7 @@ MIDIFileReader reader(path, nullptr, 44100); Model *m = reader.load(); if (!m) { - cerr << "MIDI load failed for path: \"" << path << "\"" << endl; + SVCERR << "MIDI load failed for path: \"" << path << "\"" << endl; } QVERIFY(m != nullptr); //!!! Ah, now here we could do something a bit more informative diff -r deabf9fd3d28 -r a12fd0456f0c data/fileio/test/svcore-data-fileio-test.cpp --- a/data/fileio/test/svcore-data-fileio-test.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/fileio/test/svcore-data-fileio-test.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -35,12 +35,12 @@ #endif if (argc > 1) { - cerr << "argc = " << argc << endl; + SVCERR << "argc = " << argc << endl; testDir = argv[1]; } if (testDir != "") { - cerr << "Setting test directory base path to \"" << testDir << "\"" << endl; + SVCERR << "Setting test directory base path to \"" << testDir << "\"" << endl; } QCoreApplication app(argc, argv); @@ -78,10 +78,10 @@ } if (bad > 0) { - cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl; - return 1; + SVCERR << "\n********* " << bad << " test suite(s) failed!\n" << endl; + return 1; } else { - cerr << "All tests passed" << endl; - return 0; + SVCERR << "All tests passed" << endl; + return 0; } } diff -r deabf9fd3d28 -r a12fd0456f0c data/midi/MIDIEvent.h --- a/data/midi/MIDIEvent.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/midi/MIDIEvent.h Tue Apr 17 10:35:42 2018 +0100 @@ -123,9 +123,9 @@ int eventCode, int data1 = 0, int data2 = 0) : - m_deltaTime(deltaTime), - m_duration(0), - m_metaEventCode(0) + m_deltaTime(deltaTime), + m_duration(0), + m_metaEventCode(0) { if (eventCode < 0 || eventCode > 0xff || data1 < 0 || data1 > 0xff || @@ -141,25 +141,25 @@ MIDIByte eventCode, MIDIByte metaEventCode, const std::string &metaMessage) : - m_deltaTime(deltaTime), - m_duration(0), - m_eventCode(eventCode), - m_data1(0), - m_data2(0), - m_metaEventCode(metaEventCode), - m_metaMessage(metaMessage) + m_deltaTime(deltaTime), + m_duration(0), + m_eventCode(eventCode), + m_data1(0), + m_data2(0), + m_metaEventCode(metaEventCode), + m_metaMessage(metaMessage) { } MIDIEvent(unsigned long deltaTime, MIDIByte eventCode, const std::string &sysEx) : - m_deltaTime(deltaTime), - m_duration(0), - m_eventCode(eventCode), - m_data1(0), - m_data2(0), - m_metaEventCode(0), - m_metaMessage(sysEx) + m_deltaTime(deltaTime), + m_duration(0), + m_eventCode(eventCode), + m_data1(0), + m_data2(0), + m_metaEventCode(0), + m_metaMessage(sysEx) { } ~MIDIEvent() { } @@ -167,8 +167,8 @@ void setTime(const unsigned long &time) { m_deltaTime = time; } void setDuration(const unsigned long& duration) { m_duration = duration;} unsigned long addTime(const unsigned long &time) { - m_deltaTime += time; - return m_deltaTime; + m_deltaTime += time; + return m_deltaTime; } MIDIByte getMessageType() const @@ -222,12 +222,12 @@ public: MIDIException(QString message) throw() : m_message(message) { std::cerr << "WARNING: MIDI exception: " - << message.toLocal8Bit().data() << std::endl; + << message.toLocal8Bit().data() << std::endl; } virtual ~MIDIException() throw() { } virtual const char *what() const throw() { - return m_message.toLocal8Bit().data(); + return m_message.toLocal8Bit().data(); } protected: diff -r deabf9fd3d28 -r a12fd0456f0c data/midi/rtmidi/RtMidi.cpp --- a/data/midi/rtmidi/RtMidi.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/midi/rtmidi/RtMidi.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -1226,7 +1226,7 @@ if ( !( data->ignoreFlags & 0x04 ) ) doDecode = true; break; - case SND_SEQ_EVENT_SYSEX: + case SND_SEQ_EVENT_SYSEX: if ( (data->ignoreFlags & 0x01) ) break; if ( ev->data.ext.len > apiData->bufferSize ) { apiData->bufferSize = ev->data.ext.len; @@ -1238,6 +1238,8 @@ break; } } + doDecode = true; + break; default: doDecode = true; @@ -1573,11 +1575,11 @@ snd_seq_port_info_t *pinfo; snd_seq_port_info_alloca( &pinfo ); snd_seq_port_info_set_capability( pinfo, - SND_SEQ_PORT_CAP_WRITE | - SND_SEQ_PORT_CAP_SUBS_WRITE ); + SND_SEQ_PORT_CAP_WRITE | + SND_SEQ_PORT_CAP_SUBS_WRITE ); snd_seq_port_info_set_type( pinfo, - SND_SEQ_PORT_TYPE_MIDI_GENERIC | - SND_SEQ_PORT_TYPE_APPLICATION ); + SND_SEQ_PORT_TYPE_MIDI_GENERIC | + SND_SEQ_PORT_TYPE_APPLICATION ); snd_seq_port_info_set_midi_channels(pinfo, 16); #ifndef AVOID_TIMESTAMPING snd_seq_port_info_set_timestamping(pinfo, 1); @@ -1689,7 +1691,7 @@ errorString_ = "MidiOutAlsa::initialize: error creating ALSA sequencer client object."; error( RtMidiError::DRIVER_ERROR, errorString_ ); return; - } + } // Set client name. snd_seq_set_client_name( seq, clientName.c_str() ); @@ -1722,8 +1724,8 @@ unsigned int MidiOutAlsa :: getPortCount() { - snd_seq_port_info_t *pinfo; - snd_seq_port_info_alloca( &pinfo ); + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca( &pinfo ); AlsaMidiData *data = static_cast (apiData_); return portInfo( data->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, -1 ); @@ -1772,8 +1774,8 @@ return; } - snd_seq_port_info_t *pinfo; - snd_seq_port_info_alloca( &pinfo ); + snd_seq_port_info_t *pinfo; + snd_seq_port_info_alloca( &pinfo ); AlsaMidiData *data = static_cast (apiData_); if ( portInfo( data->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, (int) portNumber ) == 0 ) { std::ostringstream ost; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/AlignmentModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -22,7 +22,7 @@ AlignmentModel::AlignmentModel(Model *reference, Model *aligned, Model *inputModel, - SparseTimeValueModel *path) : + SparseTimeValueModel *path) : m_reference(reference), m_aligned(aligned), m_inputModel(inputModel), diff -r deabf9fd3d28 -r a12fd0456f0c data/model/Dense3DModelPeakCache.cpp --- a/data/model/Dense3DModelPeakCache.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/Dense3DModelPeakCache.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -20,7 +20,7 @@ #include "base/HitCount.h" Dense3DModelPeakCache::Dense3DModelPeakCache(const DenseThreeDimensionalModel *source, - int columnsPerPeak) : + int columnsPerPeak) : m_source(source), m_columnsPerPeak(columnsPerPeak) { diff -r deabf9fd3d28 -r a12fd0456f0c data/model/DenseTimeValueModel.cpp --- a/data/model/DenseTimeValueModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/DenseTimeValueModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -27,7 +27,7 @@ { PlayParameterRepository::getInstance()->removePlayable(this); } - + QString DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { diff -r deabf9fd3d28 -r a12fd0456f0c data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -321,7 +321,7 @@ QWriteLocker locker(&m_lock); while (index >= int(m_data.size())) { - m_data.push_back(Column()); + m_data.push_back(Column()); m_trunc.push_back(0); } @@ -332,14 +332,14 @@ if (ISNAN(value) || ISINF(value)) { continue; } - if (!m_haveExtents || value < m_minimum) { - m_minimum = value; - allChange = true; - } - if (!m_haveExtents || value > m_maximum) { - m_maximum = value; - allChange = true; - } + if (!m_haveExtents || value < m_minimum) { + m_minimum = value; + allChange = true; + } + if (!m_haveExtents || value > m_maximum) { + m_maximum = value; + allChange = true; + } m_haveExtents = true; } @@ -351,26 +351,26 @@ windowStart *= m_resolution; if (m_notifyOnAdd) { - if (allChange) { - emit modelChanged(); - } else { - emit modelChangedWithin(windowStart, windowStart + m_resolution); - } + if (allChange) { + emit modelChanged(); + } else { + emit modelChangedWithin(windowStart, windowStart + m_resolution); + } } else { - if (allChange) { - m_sinceLastNotifyMin = -1; - m_sinceLastNotifyMax = -1; - emit modelChanged(); - } else { - if (m_sinceLastNotifyMin == -1 || - windowStart < m_sinceLastNotifyMin) { - m_sinceLastNotifyMin = windowStart; - } - if (m_sinceLastNotifyMax == -1 || - windowStart > m_sinceLastNotifyMax) { - m_sinceLastNotifyMax = windowStart; - } - } + if (allChange) { + m_sinceLastNotifyMin = -1; + m_sinceLastNotifyMax = -1; + emit modelChanged(); + } else { + if (m_sinceLastNotifyMin == -1 || + windowStart < m_sinceLastNotifyMin) { + m_sinceLastNotifyMin = windowStart; + } + if (m_sinceLastNotifyMax == -1 || + windowStart > m_sinceLastNotifyMax) { + m_sinceLastNotifyMax = windowStart; + } + } } } @@ -462,27 +462,27 @@ EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update) { if (m_completion != completion) { - m_completion = completion; + m_completion = completion; - if (completion == 100) { + if (completion == 100) { - m_notifyOnAdd = true; // henceforth - emit modelChanged(); + m_notifyOnAdd = true; // henceforth + emit modelChanged(); - } else if (!m_notifyOnAdd) { + } else if (!m_notifyOnAdd) { - if (update && + if (update && m_sinceLastNotifyMin >= 0 && - m_sinceLastNotifyMax >= 0) { - emit modelChangedWithin(m_sinceLastNotifyMin, + m_sinceLastNotifyMax >= 0) { + emit modelChangedWithin(m_sinceLastNotifyMin, m_sinceLastNotifyMax + m_resolution); - m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; - } else { - emit completionChanged(); - } - } else { - emit completionChanged(); - } + m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; + } else { + emit completionChanged(); + } + } else { + emit completionChanged(); + } } } @@ -493,7 +493,7 @@ QString s; for (int i = 0; in_range_for(m_data, i); ++i) { QStringList list; - for (int j = 0; in_range_for(m_data.at(i), j); ++j) { + for (int j = 0; in_range_for(m_data.at(i), j); ++j) { list << QString("%1").arg(m_data.at(i).at(j)); } s += list.join(delimiter) + "\n"; @@ -531,36 +531,36 @@ SVDEBUG << "EditableDenseThreeDimensionalModel::toXml" << endl; Model::toXml - (out, indent, + (out, indent, QString("type=\"dense\" dimensions=\"3\" windowSize=\"%1\" yBinCount=\"%2\" minimum=\"%3\" maximum=\"%4\" dataset=\"%5\" startFrame=\"%6\" %7") - .arg(m_resolution) - .arg(m_yBinCount) - .arg(m_minimum) - .arg(m_maximum) - .arg(getObjectExportId(&m_data)) + .arg(m_resolution) + .arg(m_yBinCount) + .arg(m_minimum) + .arg(m_maximum) + .arg(getObjectExportId(&m_data)) .arg(m_startFrame) - .arg(extraAttributes)); + .arg(extraAttributes)); out << indent; out << QString("\n") - .arg(getObjectExportId(&m_data)); + .arg(getObjectExportId(&m_data)); for (int i = 0; i < (int)m_binNames.size(); ++i) { - if (m_binNames[i] != "") { - out << indent + " "; - out << QString("\n") - .arg(i).arg(m_binNames[i]); - } + if (m_binNames[i] != "") { + out << indent + " "; + out << QString("\n") + .arg(i).arg(m_binNames[i]); + } } for (int i = 0; i < (int)m_data.size(); ++i) { - out << indent + " "; - out << QString("").arg(i); - for (int j = 0; j < (int)m_data.at(i).size(); ++j) { - if (j > 0) out << " "; - out << m_data.at(i).at(j); - } - out << QString("\n"); + out << indent + " "; + out << QString("").arg(i); + for (int j = 0; j < (int)m_data.at(i).size(); ++j) { + if (j > 0) out << " "; + out << m_data.at(i).at(j); + } + out << QString("\n"); out.flush(); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/EditableDenseThreeDimensionalModel.h --- a/data/model/EditableDenseThreeDimensionalModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -43,10 +43,10 @@ }; EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, - int resolution, - int height, + int resolution, + int height, CompressionType compression, - bool notifyOnAdd = true); + bool notifyOnAdd = true); virtual bool isOK() const; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/FFTModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -19,6 +19,7 @@ #include "base/Profiler.h" #include "base/Pitch.h" #include "base/HitCount.h" +#include "base/Debug.h" #include @@ -52,8 +53,8 @@ } if (m_windowSize > m_fftSize) { - cerr << "ERROR: FFTModel::FFTModel: window size (" << m_windowSize - << ") must be at least FFT size (" << m_fftSize << ")" << endl; + SVCERR << "ERROR: FFTModel::FFTModel: window size (" << m_windowSize + << ") must be at least FFT size (" << m_fftSize << ")" << endl; throw invalid_argument("FFTModel window size must be at least FFT size"); } @@ -72,7 +73,7 @@ FFTModel::sourceModelAboutToBeDeleted() { if (m_model) { - cerr << "FFTModel[" << this << "]::sourceModelAboutToBeDeleted(" << m_model << ")" << endl; + SVDEBUG << "FFTModel[" << this << "]::sourceModelAboutToBeDeleted(" << m_model << ")" << endl; m_model = 0; } } @@ -287,15 +288,15 @@ } if (m_channel == -1) { - int channels = m_model->getChannelCount(); - if (channels > 1) { + int channels = m_model->getChannelCount(); + if (channels > 1) { int n = int(data.size()); float factor = 1.f / float(channels); // use mean instead of sum for fft model input - for (int i = 0; i < n; ++i) { - data[i] *= factor; - } - } + for (int i = 0; i < n; ++i) { + data[i] *= factor; + } + } } return data; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/FlexiNoteModel.h --- a/data/model/FlexiNoteModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/FlexiNoteModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -44,7 +44,7 @@ public: FlexiNote(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } FlexiNote(sv_frame_t _frame, float _value, sv_frame_t _duration, float _level, QString _label) : - frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } + frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } int getDimensions() const { return 3; } @@ -60,9 +60,9 @@ QString indent = "", QString extraAttributes = "") const { - stream << + stream << QString("%1\n") - .arg(indent).arg(frame).arg(value).arg(duration).arg(level) + .arg(indent).arg(frame).arg(value).arg(duration).arg(level) .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } @@ -80,21 +80,21 @@ } struct Comparator { - bool operator()(const FlexiNote &p1, - const FlexiNote &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - if (p1.value != p2.value) return p1.value < p2.value; - if (p1.duration != p2.duration) return p1.duration < p2.duration; + bool operator()(const FlexiNote &p1, + const FlexiNote &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + if (p1.value != p2.value) return p1.value < p2.value; + if (p1.duration != p2.duration) return p1.duration < p2.duration; if (p1.level != p2.level) return p1.level < p2.level; - return p1.label < p2.label; - } + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const FlexiNote &p1, - const FlexiNote &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const FlexiNote &p1, + const FlexiNote &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -106,21 +106,21 @@ public: FlexiNoteModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, notifyOnAdd), - m_valueQuantization(0) + IntervalModel(sampleRate, resolution, notifyOnAdd), + m_valueQuantization(0) { - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } FlexiNoteModel(sv_samplerate_t sampleRate, int resolution, - float valueMinimum, float valueMaximum, - bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, + float valueMinimum, float valueMaximum, + bool notifyOnAdd = true) : + IntervalModel(sampleRate, resolution, valueMinimum, valueMaximum, notifyOnAdd), - m_valueQuantization(0) + m_valueQuantization(0) { - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } virtual ~FlexiNoteModel() @@ -150,10 +150,10 @@ << extraAttributes.toStdString() << std::endl; IntervalModel::toXml - (out, + (out, indent, - QString("%1 subtype=\"flexinote\" valueQuantization=\"%2\"") - .arg(extraAttributes).arg(m_valueQuantization)); + QString("%1 subtype=\"flexinote\" valueQuantization=\"%2\"") + .arg(extraAttributes).arg(m_valueQuantization)); } /** @@ -235,10 +235,10 @@ NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const { - PointList points = getPoints(startFrame, endFrame); + PointList points = getPoints(startFrame, endFrame); NoteList notes; for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { - sv_frame_t duration = pli->duration; + sv_frame_t duration = pli->duration; if (duration == 0 || duration == 1) { duration = sv_frame_t(getSampleRate() / 20); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/ImageModel.h --- a/data/model/ImageModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/ImageModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -47,9 +47,9 @@ QString indent = "", QString extraAttributes = "") const { - stream << + stream << QString("%1\n") - .arg(indent).arg(frame) + .arg(indent).arg(frame) .arg(encodeEntities(image)) .arg(encodeEntities(label)) .arg(extraAttributes); @@ -65,19 +65,19 @@ } struct Comparator { - bool operator()(const ImagePoint &p1, - const ImagePoint &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; + bool operator()(const ImagePoint &p1, + const ImagePoint &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; if (p1.label != p2.label) return p1.label < p2.label; - return p1.image < p2.image; - } + return p1.image < p2.image; + } }; struct OrderComparator { - bool operator()(const ImagePoint &p1, - const ImagePoint &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const ImagePoint &p1, + const ImagePoint &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -90,7 +90,7 @@ public: ImageModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : - SparseModel(sampleRate, resolution, notifyOnAdd) + SparseModel(sampleRate, resolution, notifyOnAdd) { } QString getTypeName() const { return tr("Image"); } @@ -100,10 +100,10 @@ QString extraAttributes = "") const { SparseModel::toXml - (out, + (out, indent, - QString("%1 subtype=\"image\"") - .arg(extraAttributes)); + QString("%1 subtype=\"image\"") + .arg(extraAttributes)); } /** @@ -116,25 +116,25 @@ const ImagePoint &point, QString newImage, QString newLabel) : - m_model(model), m_oldPoint(point), m_newPoint(point) { - m_newPoint.image = newImage; + m_model(model), m_oldPoint(point), m_newPoint(point) { + m_newPoint.image = newImage; m_newPoint.label = newLabel; - } + } - virtual QString getName() const { return tr("Edit Image"); } + virtual QString getName() const { return tr("Edit Image"); } - virtual void execute() { - m_model->deletePoint(m_oldPoint); - m_model->addPoint(m_newPoint); - std::swap(m_oldPoint, m_newPoint); - } + virtual void execute() { + m_model->deletePoint(m_oldPoint); + m_model->addPoint(m_newPoint); + std::swap(m_oldPoint, m_newPoint); + } - virtual void unexecute() { execute(); } + virtual void unexecute() { execute(); } private: - ImageModel *m_model; - ImagePoint m_oldPoint; - ImagePoint m_newPoint; + ImageModel *m_model; + ImagePoint m_oldPoint; + ImagePoint m_newPoint; }; /** diff -r deabf9fd3d28 -r a12fd0456f0c data/model/IntervalModel.h --- a/data/model/IntervalModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/IntervalModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -31,13 +31,13 @@ public: IntervalModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : - SparseValueModel(sampleRate, resolution, notifyOnAdd) + SparseValueModel(sampleRate, resolution, notifyOnAdd) { } IntervalModel(sv_samplerate_t sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : - SparseValueModel(sampleRate, resolution, + SparseValueModel(sampleRate, resolution, valueMinimum, valueMaximum, notifyOnAdd) { } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/Model.cpp --- a/data/model/Model.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/Model.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -185,12 +185,12 @@ { stream << indent; stream << QString("\n") - .arg(getObjectExportId(this)) - .arg(encodeEntities(objectName())) - .arg(getSampleRate()) - .arg(getStartFrame()) - .arg(getEndFrame()) - .arg(extraAttributes); + .arg(getObjectExportId(this)) + .arg(encodeEntities(objectName())) + .arg(getSampleRate()) + .arg(getStartFrame()) + .arg(getEndFrame()) + .arg(extraAttributes); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/Model.h --- a/data/model/Model.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/Model.h Tue Apr 17 10:35:42 2018 +0100 @@ -33,7 +33,7 @@ */ class Model : public QObject, - public XmlExportable, + public XmlExportable, public Playable { Q_OBJECT @@ -125,9 +125,9 @@ * getCompletion(). */ virtual bool isReady(int *completion = 0) const { - bool ok = isOK(); - if (completion) *completion = (ok ? 100 : 0); - return ok; + bool ok = isOK(); + if (completion) *completion = (ok ? 100 : 0); + return ok; } static const int COMPLETION_UNKNOWN; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/NoteData.h --- a/data/model/NoteData.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/NoteData.h Tue Apr 17 10:35:42 2018 +0100 @@ -22,8 +22,8 @@ struct NoteData { NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) : - start(_start), duration(_dur), midiPitch(_mp), frequency(0), - isMidiPitchQuantized(true), velocity(_vel), channel(0) { }; + start(_start), duration(_dur), midiPitch(_mp), frequency(0), + isMidiPitchQuantized(true), velocity(_vel), channel(0) { }; sv_frame_t start; // audio sample frame sv_frame_t duration; // in audio sample frames diff -r deabf9fd3d28 -r a12fd0456f0c data/model/NoteModel.h --- a/data/model/NoteModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/NoteModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -40,7 +40,7 @@ public: Note(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } Note(sv_frame_t _frame, float _value, sv_frame_t _duration, float _level, QString _label) : - frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } + frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } int getDimensions() const { return 3; } @@ -56,9 +56,9 @@ QString indent = "", QString extraAttributes = "") const { - stream << + stream << QString("%1\n") - .arg(indent).arg(frame).arg(value).arg(duration).arg(level) + .arg(indent).arg(frame).arg(value).arg(duration).arg(level) .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } @@ -75,21 +75,21 @@ } struct Comparator { - bool operator()(const Note &p1, - const Note &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - if (p1.value != p2.value) return p1.value < p2.value; - if (p1.duration != p2.duration) return p1.duration < p2.duration; + bool operator()(const Note &p1, + const Note &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + if (p1.value != p2.value) return p1.value < p2.value; + if (p1.duration != p2.duration) return p1.duration < p2.duration; if (p1.level != p2.level) return p1.level < p2.level; - return p1.label < p2.label; - } + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const Note &p1, - const Note &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const Note &p1, + const Note &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -100,22 +100,22 @@ public: NoteModel(sv_samplerate_t sampleRate, int resolution, - bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, notifyOnAdd), - m_valueQuantization(0) + bool notifyOnAdd = true) : + IntervalModel(sampleRate, resolution, notifyOnAdd), + m_valueQuantization(0) { - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } NoteModel(sv_samplerate_t sampleRate, int resolution, - float valueMinimum, float valueMaximum, - bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, + float valueMinimum, float valueMaximum, + bool notifyOnAdd = true) : + IntervalModel(sampleRate, resolution, valueMinimum, valueMaximum, notifyOnAdd), - m_valueQuantization(0) + m_valueQuantization(0) { - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } virtual ~NoteModel() @@ -143,10 +143,10 @@ << extraAttributes.toStdString() << std::endl; IntervalModel::toXml - (out, + (out, indent, - QString("%1 subtype=\"note\" valueQuantization=\"%2\"") - .arg(extraAttributes).arg(m_valueQuantization)); + QString("%1 subtype=\"note\" valueQuantization=\"%2\"") + .arg(extraAttributes).arg(m_valueQuantization)); } /** @@ -227,13 +227,13 @@ NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const { - PointList points = getPoints(startFrame, endFrame); + PointList points = getPoints(startFrame, endFrame); NoteList notes; for (PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { + points.begin(); pli != points.end(); ++pli) { - sv_frame_t duration = pli->duration; + sv_frame_t duration = pli->duration; if (duration == 0 || duration == 1) { duration = sv_frame_t(getSampleRate() / 20); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/PowerOfSqrtTwoZoomConstraint.cpp --- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -21,7 +21,7 @@ int PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(int blockSize, - RoundingDirection dir) const + RoundingDirection dir) const { int type, power; int rv = getNearestBlockSize(blockSize, type, power, dir); @@ -30,30 +30,30 @@ int PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(int blockSize, - int &type, - int &power, - RoundingDirection dir) const + int &type, + int &power, + RoundingDirection dir) const { // cerr << "given " << blockSize << endl; int minCachePower = getMinCachePower(); if (blockSize < (1 << minCachePower)) { - type = -1; - power = 0; - float val = 1.0, prevVal = 1.0; - while (val + 0.01 < blockSize) { - prevVal = val; - val *= sqrtf(2.f); - } - int rval; - if (dir == RoundUp) rval = int(val + 0.01f); - else if (dir == RoundDown) rval = int(prevVal + 0.01f); - else if (val - float(blockSize) < + type = -1; + power = 0; + float val = 1.0, prevVal = 1.0; + while (val + 0.01 < blockSize) { + prevVal = val; + val *= sqrtf(2.f); + } + int rval; + if (dir == RoundUp) rval = int(val + 0.01f); + else if (dir == RoundDown) rval = int(prevVal + 0.01f); + else if (val - float(blockSize) < float(blockSize) - prevVal) rval = int(val + 0.01f); - else rval = int(prevVal + 0.01); -// SVDEBUG << "returning " << rval << endl; - return rval; + else rval = int(prevVal + 0.01); +// SVDEBUG << "returning " << rval << endl; + return rval; } int prevBase = (1 << minCachePower); @@ -64,46 +64,46 @@ for (unsigned int i = 0; ; ++i) { - power = minCachePower + i/2; - type = i % 2; + power = minCachePower + i/2; + type = i % 2; - int base; - if (type == 0) { - base = (1 << power); - } else { - base = (((unsigned int)((1 << minCachePower) * sqrt(2.) + 0.01)) - << (power - minCachePower)); - } + int base; + if (type == 0) { + base = (1 << power); + } else { + base = (((unsigned int)((1 << minCachePower) * sqrt(2.) + 0.01)) + << (power - minCachePower)); + } -// SVDEBUG << "Testing base " << base << endl; +// SVDEBUG << "Testing base " << base << endl; if (base == blockSize) { result = base; break; } - if (base > blockSize) { - if (dir == RoundNearest) { - if (base - blockSize < blockSize - prevBase) { - dir = RoundUp; - } else { - dir = RoundDown; - } - } - if (dir == RoundUp) { - result = base; - break; - } else { - type = prevType; - power = prevPower; - result = prevBase; - break; - } - } + if (base > blockSize) { + if (dir == RoundNearest) { + if (base - blockSize < blockSize - prevBase) { + dir = RoundUp; + } else { + dir = RoundDown; + } + } + if (dir == RoundUp) { + result = base; + break; + } else { + type = prevType; + power = prevPower; + result = prevBase; + break; + } + } - prevType = type; - prevPower = power; - prevBase = base; + prevType = type; + prevPower = power; + prevBase = base; } if (result > getMaxZoomLevel()) result = getMaxZoomLevel(); diff -r deabf9fd3d28 -r a12fd0456f0c data/model/PowerOfSqrtTwoZoomConstraint.h --- a/data/model/PowerOfSqrtTwoZoomConstraint.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.h Tue Apr 17 10:35:42 2018 +0100 @@ -22,15 +22,15 @@ { public: virtual int getNearestBlockSize(int requestedBlockSize, - RoundingDirection dir = RoundNearest) - const; + RoundingDirection dir = RoundNearest) + const; virtual int getNearestBlockSize(int requestedBlockSize, - int &type, - int &power, - RoundingDirection dir = RoundNearest) - const; - + int &type, + int &power, + RoundingDirection dir = RoundNearest) + const; + virtual int getMinCachePower() const { return 6; } }; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/PowerOfTwoZoomConstraint.cpp --- a/data/model/PowerOfTwoZoomConstraint.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/PowerOfTwoZoomConstraint.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -17,28 +17,28 @@ int PowerOfTwoZoomConstraint::getNearestBlockSize(int req, - RoundingDirection dir) const + RoundingDirection dir) const { int result = 0; for (int bs = 1; ; bs *= 2) { - if (bs >= req) { - if (dir == RoundNearest) { - if (bs - req < req - bs/2) { - result = bs; - break; - } else { - result = bs/2; - break; - } - } else if (dir == RoundDown) { - result = bs/2; - break; - } else { - result = bs; - break; - } - } + if (bs >= req) { + if (dir == RoundNearest) { + if (bs - req < req - bs/2) { + result = bs; + break; + } else { + result = bs/2; + break; + } + } else if (dir == RoundDown) { + result = bs/2; + break; + } else { + result = bs; + break; + } + } } if (result > getMaxZoomLevel()) result = getMaxZoomLevel(); diff -r deabf9fd3d28 -r a12fd0456f0c data/model/PowerOfTwoZoomConstraint.h --- a/data/model/PowerOfTwoZoomConstraint.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/PowerOfTwoZoomConstraint.h Tue Apr 17 10:35:42 2018 +0100 @@ -22,8 +22,8 @@ { public: virtual int getNearestBlockSize(int requestedBlockSize, - RoundingDirection dir = RoundNearest) - const; + RoundingDirection dir = RoundNearest) + const; }; #endif diff -r deabf9fd3d28 -r a12fd0456f0c data/model/ReadOnlyWaveFileModel.cpp --- a/data/model/ReadOnlyWaveFileModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/ReadOnlyWaveFileModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -219,7 +219,7 @@ int channels = getChannelCount(); if (channel >= channels) { - cerr << "ERROR: WaveFileModel::getData: channel (" + SVCERR << "ERROR: WaveFileModel::getData: channel (" << channel << ") >= channel count (" << channels << ")" << endl; return {}; @@ -278,14 +278,14 @@ int channels = getChannelCount(); if (fromchannel > tochannel) { - cerr << "ERROR: ReadOnlyWaveFileModel::getData: fromchannel (" + SVCERR << "ERROR: ReadOnlyWaveFileModel::getData: fromchannel (" << fromchannel << ") > tochannel (" << tochannel << ")" << endl; return {}; } if (tochannel >= channels) { - cerr << "ERROR: ReadOnlyWaveFileModel::getData: tochannel (" + SVCERR << "ERROR: ReadOnlyWaveFileModel::getData: tochannel (" << tochannel << ") >= channel count (" << channels << ")" << endl; return {}; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/RegionModel.h --- a/data/model/RegionModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/RegionModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -39,7 +39,7 @@ RegionRec() : frame(0), value(0.f), duration(0) { } RegionRec(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0) { } RegionRec(sv_frame_t _frame, float _value, sv_frame_t _duration, QString _label) : - frame(_frame), value(_value), duration(_duration), label(_label) { } + frame(_frame), value(_value), duration(_duration), label(_label) { } int getDimensions() const { return 3; } @@ -54,9 +54,9 @@ QString indent = "", QString extraAttributes = "") const { - stream << + stream << QString("%1\n") - .arg(indent).arg(frame).arg(value).arg(duration) + .arg(indent).arg(frame).arg(value).arg(duration) .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } @@ -71,20 +71,20 @@ } struct Comparator { - bool operator()(const RegionRec &p1, - const RegionRec &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - if (p1.value != p2.value) return p1.value < p2.value; - if (p1.duration != p2.duration) return p1.duration < p2.duration; - return p1.label < p2.label; - } + bool operator()(const RegionRec &p1, + const RegionRec &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + if (p1.value != p2.value) return p1.value < p2.value; + if (p1.duration != p2.duration) return p1.duration < p2.duration; + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const RegionRec &p1, - const RegionRec &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const RegionRec &p1, + const RegionRec &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -96,8 +96,8 @@ public: RegionModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, notifyOnAdd), - m_valueQuantization(0), + IntervalModel(sampleRate, resolution, notifyOnAdd), + m_valueQuantization(0), m_haveDistinctValues(false) { } @@ -105,10 +105,10 @@ RegionModel(sv_samplerate_t sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : - IntervalModel(sampleRate, resolution, + IntervalModel(sampleRate, resolution, valueMinimum, valueMaximum, notifyOnAdd), - m_valueQuantization(0), + m_valueQuantization(0), m_haveDistinctValues(false) { } @@ -132,10 +132,10 @@ << extraAttributes.toStdString() << std::endl; IntervalModel::toXml - (out, + (out, indent, - QString("%1 subtype=\"region\" valueQuantization=\"%2\"") - .arg(extraAttributes).arg(m_valueQuantization)); + QString("%1 subtype=\"region\" valueQuantization=\"%2\"") + .arg(extraAttributes).arg(m_valueQuantization)); } /** diff -r deabf9fd3d28 -r a12fd0456f0c data/model/SparseModel.h --- a/data/model/SparseModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/SparseModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -45,7 +45,7 @@ { public: SparseModel(sv_samplerate_t sampleRate, int resolution, - bool notifyOnAdd = true); + bool notifyOnAdd = true); virtual ~SparseModel() { } virtual bool isOK() const { return true; } @@ -71,7 +71,7 @@ typedef PointType Point; typedef std::multiset PointList; + typename PointType::OrderComparator> PointList; typedef typename PointList::iterator PointListIterator; typedef typename PointList::const_iterator PointListConstIterator; @@ -196,23 +196,23 @@ class AddPointCommand : public Command { public: - AddPointCommand(SparseModel *model, - const PointType &point, + AddPointCommand(SparseModel *model, + const PointType &point, QString name = "") : - m_model(model), m_point(point), m_name(name) { } + m_model(model), m_point(point), m_name(name) { } - virtual QString getName() const { + virtual QString getName() const { return (m_name == "" ? tr("Add Point") : m_name); } - virtual void execute() { m_model->addPoint(m_point); } - virtual void unexecute() { m_model->deletePoint(m_point); } + virtual void execute() { m_model->addPoint(m_point); } + virtual void unexecute() { m_model->deletePoint(m_point); } - const PointType &getPoint() const { return m_point; } + const PointType &getPoint() const { return m_point; } private: - SparseModel *m_model; - PointType m_point; + SparseModel *m_model; + PointType m_point; QString m_name; }; @@ -223,20 +223,20 @@ class DeletePointCommand : public Command { public: - DeletePointCommand(SparseModel *model, - const PointType &point) : - m_model(model), m_point(point) { } + DeletePointCommand(SparseModel *model, + const PointType &point) : + m_model(model), m_point(point) { } - virtual QString getName() const { return tr("Delete Point"); } + virtual QString getName() const { return tr("Delete Point"); } - virtual void execute() { m_model->deletePoint(m_point); } - virtual void unexecute() { m_model->addPoint(m_point); } + virtual void execute() { m_model->deletePoint(m_point); } + virtual void unexecute() { m_model->addPoint(m_point); } - const PointType &getPoint() const { return m_point; } + const PointType &getPoint() const { return m_point; } private: - SparseModel *m_model; - PointType m_point; + SparseModel *m_model; + PointType m_point; }; @@ -247,27 +247,27 @@ class EditCommand : public MacroCommand { public: - EditCommand(SparseModel *model, QString commandName); + EditCommand(SparseModel *model, QString commandName); - virtual void addPoint(const PointType &point); - virtual void deletePoint(const PointType &point); + virtual void addPoint(const PointType &point); + virtual void deletePoint(const PointType &point); - /** - * Stack an arbitrary other command in the same sequence. - */ - virtual void addCommand(Command *command) { addCommand(command, true); } + /** + * Stack an arbitrary other command in the same sequence. + */ + virtual void addCommand(Command *command) { addCommand(command, true); } - /** - * If any points have been added or deleted, return this - * command (so the caller can add it to the command history). - * Otherwise delete the command and return NULL. - */ - virtual EditCommand *finish(); + /** + * If any points have been added or deleted, return this + * command (so the caller can add it to the command history). + * Otherwise delete the command and return NULL. + */ + virtual EditCommand *finish(); protected: - virtual void addCommand(Command *command, bool executeFirst); + virtual void addCommand(Command *command, bool executeFirst); - SparseModel *m_model; + SparseModel *m_model; }; @@ -277,27 +277,27 @@ class RelabelCommand : public Command { public: - RelabelCommand(SparseModel *model, - const PointType &point, - QString newLabel) : - m_model(model), m_oldPoint(point), m_newPoint(point) { - m_newPoint.label = newLabel; - } + RelabelCommand(SparseModel *model, + const PointType &point, + QString newLabel) : + m_model(model), m_oldPoint(point), m_newPoint(point) { + m_newPoint.label = newLabel; + } - virtual QString getName() const { return tr("Re-Label Point"); } + virtual QString getName() const { return tr("Re-Label Point"); } - virtual void execute() { - m_model->deletePoint(m_oldPoint); - m_model->addPoint(m_newPoint); - std::swap(m_oldPoint, m_newPoint); - } + virtual void execute() { + m_model->deletePoint(m_oldPoint); + m_model->addPoint(m_newPoint); + std::swap(m_oldPoint, m_newPoint); + } - virtual void unexecute() { execute(); } + virtual void unexecute() { execute(); } private: - SparseModel *m_model; - PointType m_oldPoint; - PointType m_newPoint; + SparseModel *m_model; + PointType m_oldPoint; + PointType m_newPoint; }; /** @@ -558,7 +558,7 @@ QMutexLocker locker(&m_mutex); sv_frame_t f = 0; if (!m_points.empty()) { - f = m_points.begin()->frame; + f = m_points.begin()->frame; } return f; } @@ -570,8 +570,8 @@ QMutexLocker locker(&m_mutex); sv_frame_t f = 0; if (!m_points.empty()) { - PointListConstIterator i(m_points.end()); - f = (--i)->frame; + PointListConstIterator i(m_points.end()); + f = (--i)->frame; } if (m_extendTo > f) return m_extendTo; else return f; @@ -618,7 +618,7 @@ PointList rv; for (PointListConstIterator i = startItr; i != endItr; ++i) { - rv.insert(*i); + rv.insert(*i); } return rv; @@ -634,7 +634,7 @@ PointList rv; for (PointListConstIterator i = startItr; i != endItr; ++i) { - rv.insert(*i); + rv.insert(*i); } return rv; @@ -704,9 +704,9 @@ --i; sv_frame_t frame = i->frame; while (i->frame == frame) { - rv.insert(*i); - if (i == m_points.begin()) break; - --i; + rv.insert(*i); + if (i == m_points.begin()) break; + --i; } return rv; @@ -726,8 +726,8 @@ sv_frame_t frame = i->frame; while (i != m_points.end() && i->frame == frame) { - rv.insert(*i); - ++i; + rv.insert(*i); + ++i; } return rv; @@ -738,8 +738,8 @@ SparseModel::setResolution(int resolution) { { - QMutexLocker locker(&m_mutex); - m_resolution = resolution; + QMutexLocker locker(&m_mutex); + m_resolution = resolution; m_rows.clear(); } emit modelChanged(); @@ -750,8 +750,8 @@ SparseModel::clear() { { - QMutexLocker locker(&m_mutex); - m_points.clear(); + QMutexLocker locker(&m_mutex); + m_points.clear(); m_pointCount = 0; m_rows.clear(); } @@ -776,16 +776,16 @@ if (m_notifyOnAdd) { m_rows.clear(); //!!! inefficient - emit modelChangedWithin(point.frame, point.frame + m_resolution); + emit modelChangedWithin(point.frame, point.frame + m_resolution); } else { - if (m_sinceLastNotifyMin == -1 || - point.frame < m_sinceLastNotifyMin) { - m_sinceLastNotifyMin = point.frame; - } - if (m_sinceLastNotifyMax == -1 || - point.frame > m_sinceLastNotifyMax) { - m_sinceLastNotifyMax = point.frame; - } + if (m_sinceLastNotifyMin == -1 || + point.frame < m_sinceLastNotifyMin) { + m_sinceLastNotifyMin = point.frame; + } + if (m_sinceLastNotifyMax == -1 || + point.frame > m_sinceLastNotifyMax) { + m_sinceLastNotifyMax = point.frame; + } } } @@ -822,12 +822,12 @@ m_points.erase(i); m_pointCount--; break; - } + } ++i; } // std::cout << "SparseOneDimensionalModel: emit modelChanged(" -// << point.frame << ")" << std::endl; +// << point.frame << ")" << std::endl; m_rows.clear(); //!!! inefficient emit modelChangedWithin(point.frame, point.frame + m_resolution); } @@ -841,32 +841,32 @@ QMutexLocker locker(&m_mutex); if (m_completion != completion) { - m_completion = completion; + m_completion = completion; - if (completion == 100) { + if (completion == 100) { if (!m_notifyOnAdd) { emit completionChanged(); } - m_notifyOnAdd = true; // henceforth + m_notifyOnAdd = true; // henceforth m_rows.clear(); //!!! inefficient - emit modelChanged(); + emit modelChanged(); - } else if (!m_notifyOnAdd) { + } else if (!m_notifyOnAdd) { - if (update && + if (update && m_sinceLastNotifyMin >= 0 && - m_sinceLastNotifyMax >= 0) { + m_sinceLastNotifyMax >= 0) { m_rows.clear(); //!!! inefficient - emit modelChangedWithin(m_sinceLastNotifyMin, m_sinceLastNotifyMax); - m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; - } else { - emit completionChanged(); - } - } else { - emit completionChanged(); - } + emit modelChangedWithin(m_sinceLastNotifyMin, m_sinceLastNotifyMax); + m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; + } else { + emit completionChanged(); + } + } else { + emit completionChanged(); + } } } @@ -882,20 +882,20 @@ QString type = getXmlOutputType(); Model::toXml - (out, + (out, indent, - QString("type=\"%1\" dimensions=\"%2\" resolution=\"%3\" notifyOnAdd=\"%4\" dataset=\"%5\" %6") + QString("type=\"%1\" dimensions=\"%2\" resolution=\"%3\" notifyOnAdd=\"%4\" dataset=\"%5\" %6") .arg(type) - .arg(PointType(0).getDimensions()) - .arg(m_resolution) - .arg(m_notifyOnAdd ? "true" : "false") - .arg(getObjectExportId(&m_points)) - .arg(extraAttributes)); + .arg(PointType(0).getDimensions()) + .arg(m_resolution) + .arg(m_notifyOnAdd ? "true" : "false") + .arg(getObjectExportId(&m_points)) + .arg(extraAttributes)); out << indent; out << QString("\n") - .arg(getObjectExportId(&m_points)) - .arg(PointType(0).getDimensions()); + .arg(getObjectExportId(&m_points)) + .arg(PointType(0).getDimensions()); for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { i->toXml(out, indent + " "); @@ -942,24 +942,24 @@ template void SparseModel::EditCommand::addCommand(Command *command, - bool executeFirst) + bool executeFirst) { if (executeFirst) command->execute(); if (!m_commands.empty()) { - DeletePointCommand *dpc = dynamic_cast(command); - if (dpc) { - AddPointCommand *apc = dynamic_cast - (m_commands[m_commands.size() - 1]); - typename PointType::Comparator comparator; - if (apc) { - if (!comparator(apc->getPoint(), dpc->getPoint()) && - !comparator(dpc->getPoint(), apc->getPoint())) { - deleteCommand(apc); - return; - } - } - } + DeletePointCommand *dpc = dynamic_cast(command); + if (dpc) { + AddPointCommand *apc = dynamic_cast + (m_commands[m_commands.size() - 1]); + typename PointType::Comparator comparator; + if (apc) { + if (!comparator(apc->getPoint(), dpc->getPoint()) && + !comparator(dpc->getPoint(), apc->getPoint())) { + deleteCommand(apc); + return; + } + } + } } MacroCommand::addCommand(command); diff -r deabf9fd3d28 -r a12fd0456f0c data/model/SparseOneDimensionalModel.h --- a/data/model/SparseOneDimensionalModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/SparseOneDimensionalModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -41,7 +41,7 @@ QString extraAttributes = "") const { stream << QString("%1\n") - .arg(indent).arg(frame).arg(XmlExportable::encodeEntities(label)) + .arg(indent).arg(frame).arg(XmlExportable::encodeEntities(label)) .arg(extraAttributes); } @@ -54,18 +54,18 @@ } struct Comparator { - bool operator()(const OneDimensionalPoint &p1, - const OneDimensionalPoint &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - return p1.label < p2.label; - } + bool operator()(const OneDimensionalPoint &p1, + const OneDimensionalPoint &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const OneDimensionalPoint &p1, - const OneDimensionalPoint &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const OneDimensionalPoint &p1, + const OneDimensionalPoint &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -77,10 +77,10 @@ public: SparseOneDimensionalModel(sv_samplerate_t sampleRate, int resolution, - bool notifyOnAdd = true) : - SparseModel(sampleRate, resolution, notifyOnAdd) + bool notifyOnAdd = true) : + SparseModel(sampleRate, resolution, notifyOnAdd) { - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } virtual ~SparseOneDimensionalModel() @@ -97,14 +97,14 @@ int getIndexOf(const Point &point) { - // slow - int i = 0; - Point::Comparator comparator; - for (PointList::const_iterator j = m_points.begin(); - j != m_points.end(); ++j, ++i) { - if (!comparator(*j, point) && !comparator(point, *j)) return i; - } - return -1; + // slow + int i = 0; + Point::Comparator comparator; + for (PointList::const_iterator j = m_points.begin(); + j != m_points.end(); ++j, ++i) { + if (!comparator(*j, point) && !comparator(point, *j)) return i; + } + return -1; } QString getTypeName() const { return tr("Sparse 1-D"); } @@ -189,11 +189,11 @@ NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const { - PointList points = getPoints(startFrame, endFrame); + PointList points = getPoints(startFrame, endFrame); NoteList notes; - for (PointList::iterator pli = - points.begin(); pli != points.end(); ++pli) { + for (PointList::iterator pli = + points.begin(); pli != points.end(); ++pli) { notes.push_back (NoteData(pli->frame, diff -r deabf9fd3d28 -r a12fd0456f0c data/model/SparseTimeValueModel.h --- a/data/model/SparseTimeValueModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/SparseTimeValueModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -31,7 +31,7 @@ public: TimeValuePoint(sv_frame_t _frame) : frame(_frame), value(0.0f) { } TimeValuePoint(sv_frame_t _frame, float _value, QString _label) : - frame(_frame), value(_value), label(_label) { } + frame(_frame), value(_value), label(_label) { } int getDimensions() const { return 2; } @@ -45,7 +45,7 @@ QString extraAttributes = "") const { stream << QString("%1\n") - .arg(indent).arg(frame).arg(value).arg(XmlExportable::encodeEntities(label)) + .arg(indent).arg(frame).arg(value).arg(XmlExportable::encodeEntities(label)) .arg(extraAttributes); } @@ -59,19 +59,19 @@ } struct Comparator { - bool operator()(const TimeValuePoint &p1, - const TimeValuePoint &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - if (p1.value != p2.value) return p1.value < p2.value; - return p1.label < p2.label; - } + bool operator()(const TimeValuePoint &p1, + const TimeValuePoint &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + if (p1.value != p2.value) return p1.value < p2.value; + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const TimeValuePoint &p1, - const TimeValuePoint &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const TimeValuePoint &p1, + const TimeValuePoint &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -82,30 +82,30 @@ public: SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution, - bool notifyOnAdd = true) : - SparseValueModel(sampleRate, resolution, - notifyOnAdd) + bool notifyOnAdd = true) : + SparseValueModel(sampleRate, resolution, + notifyOnAdd) { // Model is playable, but may not sound (if units not Hz or // range unsuitable) - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution, - float valueMinimum, float valueMaximum, - bool notifyOnAdd = true) : - SparseValueModel(sampleRate, resolution, - valueMinimum, valueMaximum, - notifyOnAdd) + float valueMinimum, float valueMaximum, + bool notifyOnAdd = true) : + SparseValueModel(sampleRate, resolution, + valueMinimum, valueMaximum, + notifyOnAdd) { // Model is playable, but may not sound (if units not Hz or // range unsuitable) - PlayParameterRepository::getInstance()->addPlayable(this); + PlayParameterRepository::getInstance()->addPlayable(this); } virtual ~SparseTimeValueModel() { - PlayParameterRepository::getInstance()->removePlayable(this); + PlayParameterRepository::getInstance()->removePlayable(this); } QString getTypeName() const { return tr("Sparse Time-Value"); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/SparseValueModel.h --- a/data/model/SparseValueModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/SparseValueModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -32,19 +32,19 @@ { public: SparseValueModel(sv_samplerate_t sampleRate, int resolution, - bool notifyOnAdd = true) : - SparseModel(sampleRate, resolution, notifyOnAdd), - m_valueMinimum(0.f), - m_valueMaximum(0.f), + bool notifyOnAdd = true) : + SparseModel(sampleRate, resolution, notifyOnAdd), + m_valueMinimum(0.f), + m_valueMaximum(0.f), m_haveExtents(false) { } SparseValueModel(sv_samplerate_t sampleRate, int resolution, - float valueMinimum, float valueMaximum, - bool notifyOnAdd = true) : - SparseModel(sampleRate, resolution, notifyOnAdd), - m_valueMinimum(valueMinimum), - m_valueMaximum(valueMaximum), + float valueMinimum, float valueMaximum, + bool notifyOnAdd = true) : + SparseModel(sampleRate, resolution, notifyOnAdd), + m_valueMinimum(valueMinimum), + m_valueMaximum(valueMaximum), m_haveExtents(true) { } @@ -66,7 +66,7 @@ virtual void addPoint(const PointType &point) { - bool allChange = false; + bool allChange = false; if (!ISNAN(point.value) && !ISINF(point.value)) { if (!m_haveExtents || point.value < m_valueMinimum) { @@ -80,37 +80,37 @@ m_haveExtents = true; } - SparseModel::addPoint(point); - if (allChange) emit modelChanged(); + SparseModel::addPoint(point); + if (allChange) emit modelChanged(); } virtual void deletePoint(const PointType &point) { - SparseModel::deletePoint(point); + SparseModel::deletePoint(point); - if (point.value == m_valueMinimum || - point.value == m_valueMaximum) { + if (point.value == m_valueMinimum || + point.value == m_valueMaximum) { - float formerMin = m_valueMinimum, formerMax = m_valueMaximum; + float formerMin = m_valueMinimum, formerMax = m_valueMaximum; - for (typename SparseModel::PointList::const_iterator i - = m_points.begin(); - i != m_points.end(); ++i) { + for (typename SparseModel::PointList::const_iterator i + = m_points.begin(); + i != m_points.end(); ++i) { - if (i == m_points.begin() || i->value < m_valueMinimum) { - m_valueMinimum = i->value; + if (i == m_points.begin() || i->value < m_valueMinimum) { + m_valueMinimum = i->value; // std::cerr << "deletePoint: value min = " << m_valueMinimum << std::endl; - } - if (i == m_points.begin() || i->value > m_valueMaximum) { - m_valueMaximum = i->value; + } + if (i == m_points.begin() || i->value > m_valueMaximum) { + m_valueMaximum = i->value; // std::cerr << "deletePoint: value max = " << m_valueMaximum << std::endl; - } - } + } + } - if (formerMin != m_valueMinimum || formerMax != m_valueMaximum) { - emit modelChanged(); - } - } + if (formerMin != m_valueMinimum || formerMax != m_valueMaximum) { + emit modelChanged(); + } + } } virtual void toXml(QTextStream &stream, @@ -120,11 +120,11 @@ std::cerr << "SparseValueModel::toXml: extraAttributes = \"" << extraAttributes.toStdString() << std::endl; - SparseModel::toXml - (stream, + SparseModel::toXml + (stream, indent, - QString("%1 minimum=\"%2\" maximum=\"%3\" units=\"%4\"") - .arg(extraAttributes).arg(m_valueMinimum).arg(m_valueMaximum) + QString("%1 minimum=\"%2\" maximum=\"%3\" units=\"%4\"") + .arg(extraAttributes).arg(m_valueMinimum).arg(m_valueMaximum) .arg(this->encodeEntities(m_units))); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/TextModel.h --- a/data/model/TextModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/TextModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -33,7 +33,7 @@ public: TextPoint(sv_frame_t _frame) : frame(_frame), height(0.0f) { } TextPoint(sv_frame_t _frame, float _height, QString _label) : - frame(_frame), height(_height), label(_label) { } + frame(_frame), height(_height), label(_label) { } int getDimensions() const { return 2; } @@ -46,8 +46,8 @@ void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const { - stream << QString("%1\n") - .arg(indent).arg(frame).arg(height) + stream << QString("%1\n") + .arg(indent).arg(frame).arg(height) .arg(encodeEntities(label)).arg(extraAttributes); } @@ -61,19 +61,19 @@ } struct Comparator { - bool operator()(const TextPoint &p1, - const TextPoint &p2) const { - if (p1.frame != p2.frame) return p1.frame < p2.frame; - if (p1.height != p2.height) return p1.height < p2.height; - return p1.label < p2.label; - } + bool operator()(const TextPoint &p1, + const TextPoint &p2) const { + if (p1.frame != p2.frame) return p1.frame < p2.frame; + if (p1.height != p2.height) return p1.height < p2.height; + return p1.label < p2.label; + } }; struct OrderComparator { - bool operator()(const TextPoint &p1, - const TextPoint &p2) const { - return p1.frame < p2.frame; - } + bool operator()(const TextPoint &p1, + const TextPoint &p2) const { + return p1.frame < p2.frame; + } }; }; @@ -86,7 +86,7 @@ public: TextModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : - SparseModel(sampleRate, resolution, notifyOnAdd) + SparseModel(sampleRate, resolution, notifyOnAdd) { } virtual void toXml(QTextStream &out, @@ -94,10 +94,10 @@ QString extraAttributes = "") const { SparseModel::toXml - (out, + (out, indent, - QString("%1 subtype=\"text\"") - .arg(extraAttributes)); + QString("%1 subtype=\"text\"") + .arg(extraAttributes)); } QString getTypeName() const { return tr("Text"); } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/WritableWaveFileModel.cpp --- a/data/model/WritableWaveFileModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/WritableWaveFileModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -37,8 +37,8 @@ //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate, - int channels, - QString path) : + int channels, + QString path) : m_model(0), m_writer(0), m_reader(0), @@ -54,7 +54,7 @@ path = dir.filePath(QString("written_%1.wav") .arg((intptr_t)this)); } catch (DirectoryCreationFailed f) { - cerr << "WritableWaveFileModel: Failed to create temporary directory" << endl; + SVCERR << "WritableWaveFileModel: Failed to create temporary directory" << endl; return; } } @@ -64,7 +64,7 @@ m_writer = new WavFileWriter(path, sampleRate, channels, WavFileWriter::WriteToTarget); if (!m_writer->isOK()) { - cerr << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError() << endl; + SVCERR << "WritableWaveFileModel: Error in creating WAV file writer: " << m_writer->getError() << endl; delete m_writer; m_writer = 0; return; @@ -74,7 +74,7 @@ m_reader = new WavFileReader(source, true); if (!m_reader->getError().isEmpty()) { - cerr << "WritableWaveFileModel: Error in creating wave file reader" << endl; + SVCERR << "WritableWaveFileModel: Error in creating wave file reader" << endl; delete m_reader; m_reader = 0; return; @@ -82,7 +82,7 @@ m_model = new ReadOnlyWaveFileModel(source, m_reader); if (!m_model->isOK()) { - cerr << "WritableWaveFileModel: Error in creating wave file model" << endl; + SVCERR << "WritableWaveFileModel: Error in creating wave file model" << endl; delete m_model; m_model = 0; delete m_reader; diff -r deabf9fd3d28 -r a12fd0456f0c data/model/test/Compares.h --- a/data/model/test/Compares.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/test/Compares.h Tue Apr 17 10:35:42 2018 +0100 @@ -24,12 +24,12 @@ COMPARE_FUZZIER(a[cmp_i], n); \ } -#define COMPARE_ALL(a, b) \ +#define COMPARE_ALL(a, b) \ for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \ COMPARE_FUZZIER(a[cmp_i], b[cmp_i]); \ } -#define COMPARE_SCALED(a, b, s) \ +#define COMPARE_SCALED(a, b, s) \ for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \ COMPARE_FUZZIER(a[cmp_i] / s, b[cmp_i]); \ } @@ -39,12 +39,12 @@ COMPARE_FUZZIER_F(a[cmp_i], n); \ } -#define COMPARE_ALL_F(a, b) \ +#define COMPARE_ALL_F(a, b) \ for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \ COMPARE_FUZZIER_F(a[cmp_i], b[cmp_i]); \ } -#define COMPARE_SCALED_F(a, b, s) \ +#define COMPARE_SCALED_F(a, b, s) \ for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \ COMPARE_FUZZIER_F(a[cmp_i] / s, b[cmp_i]); \ } diff -r deabf9fd3d28 -r a12fd0456f0c data/model/test/MockWaveModel.cpp --- a/data/model/test/MockWaveModel.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/test/MockWaveModel.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -22,7 +22,7 @@ MockWaveModel::MockWaveModel(vector sorts, int length, int pad) { for (auto sort: sorts) { - m_data.push_back(generate(sort, length, pad)); + m_data.push_back(generate(sort, length, pad)); } } @@ -36,11 +36,11 @@ floatvec_t data; while (i < count) { - sv_frame_t idx = start + i; - if (!in_range_for(m_data[channel], idx)) break; - data.push_back(m_data[channel][idx]); -// cerr << data[i] << " "; - ++i; + sv_frame_t idx = start + i; + if (!in_range_for(m_data[channel], idx)) break; + data.push_back(m_data[channel][idx]); +// cerr << data[i] << " "; + ++i; } // cerr << endl; @@ -50,7 +50,7 @@ vector MockWaveModel::getMultiChannelData(int fromchannel, int tochannel, - sv_frame_t start, sv_frame_t count) const + sv_frame_t start, sv_frame_t count) const { vector data(tochannel - fromchannel + 1); @@ -72,17 +72,17 @@ for (int i = 0; i < length; ++i) { - double v = 0.0; - - switch (sort) { - case DC: v = 1.0; break; - case Sine: v = sin((2.0 * M_PI / 8.0) * i); break; - case Cosine: v = cos((2.0 * M_PI / 8.0) * i); break; - case Nyquist: v = (i % 2) * 2 - 1; break; - case Dirac: v = (i == 0) ? 1.0 : 0.0; break; - } + double v = 0.0; + + switch (sort) { + case DC: v = 1.0; break; + case Sine: v = sin((2.0 * M_PI / 8.0) * i); break; + case Cosine: v = cos((2.0 * M_PI / 8.0) * i); break; + case Nyquist: v = (i % 2) * 2 - 1; break; + case Dirac: v = (i == 0) ? 1.0 : 0.0; break; + } - data.push_back(float(v)); + data.push_back(float(v)); } for (int i = 0; i < pad; ++i) { diff -r deabf9fd3d28 -r a12fd0456f0c data/model/test/TestFFTModel.h --- a/data/model/test/TestFFTModel.h Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/test/TestFFTModel.h Tue Apr 17 10:35:42 2018 +0100 @@ -66,18 +66,18 @@ float thresh = 1e-5f; if (abs(reals[i] - eRe) > thresh || abs(imags[i] - eIm) > thresh) { - cerr << "ERROR: output is not as expected for column " + SVCERR << "ERROR: output is not as expected for column " << i << " in channel " << ch << " (stepThrough = " << stepThrough << ")" << endl; - cerr << "expected : "; + SVCERR << "expected : "; for (int j = 0; j < hs1; ++j) { - cerr << expectedValues[ch][j] << " "; + SVCERR << expectedValues[ch][j] << " "; } - cerr << "\nactual : "; + SVCERR << "\nactual : "; for (int j = 0; j < hs1; ++j) { - cerr << complex(reals[j], imags[j]) << " "; + SVCERR << complex(reals[j], imags[j]) << " "; } - cerr << endl; + SVCERR << endl; } COMPARE_FUZZIER_F(reals[i], eRe); COMPARE_FUZZIER_F(imags[i], eIm); @@ -101,7 +101,7 @@ // are those of our expected signal. void dc_simple_rect() { - MockWaveModel mwm({ DC }, 16, 4); + MockWaveModel mwm({ DC }, 16, 4); test(&mwm, RectangularWindow, 8, 8, 8, 0, { { {}, {}, {}, {}, {} } }, 4); test(&mwm, RectangularWindow, 8, 8, 8, 1, @@ -115,7 +115,7 @@ void dc_simple_hann() { // The Hann window function is a simple sinusoid with period // equal to twice the window size, and it halves the DC energy - MockWaveModel mwm({ DC }, 16, 4); + MockWaveModel mwm({ DC }, 16, 4); test(&mwm, HanningWindow, 8, 8, 8, 0, { { {}, {}, {}, {}, {} } }, 4); test(&mwm, HanningWindow, 8, 8, 8, 1, @@ -127,7 +127,7 @@ } void dc_simple_hann_halfoverlap() { - MockWaveModel mwm({ DC }, 16, 4); + MockWaveModel mwm({ DC }, 16, 4); test(&mwm, HanningWindow, 8, 4, 8, 0, { { {}, {}, {}, {}, {} } }, 7); test(&mwm, HanningWindow, 8, 4, 8, 2, @@ -139,7 +139,7 @@ } void sine_simple_rect() { - MockWaveModel mwm({ Sine }, 16, 4); + MockWaveModel mwm({ Sine }, 16, 4); // Sine: output is purely imaginary. Note the sign is flipped // (normally the first half of the output would have negative // sign for a sine starting at 0) because the model does an @@ -155,7 +155,7 @@ } void cosine_simple_rect() { - MockWaveModel mwm({ Cosine }, 16, 4); + MockWaveModel mwm({ Cosine }, 16, 4); // Cosine: output is purely real. Note the sign is flipped // because the model does an FFT shift to centre the phase test(&mwm, RectangularWindow, 8, 8, 8, 0, @@ -169,7 +169,7 @@ } void twochan_simple_rect() { - MockWaveModel mwm({ Sine, Cosine }, 16, 4); + MockWaveModel mwm({ Sine, Cosine }, 16, 4); // Test that the two channels are read and converted separately test(&mwm, RectangularWindow, 8, 8, 8, 0, { @@ -194,7 +194,7 @@ } void nyquist_simple_rect() { - MockWaveModel mwm({ Nyquist }, 16, 4); + MockWaveModel mwm({ Nyquist }, 16, 4); // Again, the sign is flipped. This has the same amount of // energy as the DC example test(&mwm, RectangularWindow, 8, 8, 8, 0, @@ -208,7 +208,7 @@ } void dirac_simple_rect() { - MockWaveModel mwm({ Dirac }, 16, 4); + MockWaveModel mwm({ Dirac }, 16, 4); // The window scales by 0.5 and some signs are flipped. Only // column 1 has any data (the single impulse). test(&mwm, RectangularWindow, 8, 8, 8, 0, @@ -222,7 +222,7 @@ } void dirac_simple_rect_2() { - MockWaveModel mwm({ Dirac }, 16, 8); + MockWaveModel mwm({ Dirac }, 16, 8); // With 8 samples padding, the FFT shift places the first // Dirac impulse at the start of column 1, thus giving all // positive values @@ -239,7 +239,7 @@ } void dirac_simple_rect_halfoverlap() { - MockWaveModel mwm({ Dirac }, 16, 4); + MockWaveModel mwm({ Dirac }, 16, 4); test(&mwm, RectangularWindow, 8, 4, 8, 0, { { {}, {}, {}, {}, {} } }, 7); test(&mwm, RectangularWindow, 8, 4, 8, 1, diff -r deabf9fd3d28 -r a12fd0456f0c data/model/test/svcore-data-model-test.cpp --- a/data/model/test/svcore-data-model-test.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/model/test/svcore-data-model-test.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -28,17 +28,17 @@ app.setApplicationName("test-model"); { - TestFFTModel t; - if (QTest::qExec(&t, argc, argv) == 0) ++good; - else ++bad; + TestFFTModel t; + if (QTest::qExec(&t, argc, argv) == 0) ++good; + else ++bad; } if (bad > 0) { - cerr << "\n********* " << bad << " test suite(s) failed!\n" << endl; - return 1; + SVCERR << "\n********* " << bad << " test suite(s) failed!\n" << endl; + return 1; } else { - cerr << "All tests passed" << endl; - return 0; + SVCERR << "All tests passed" << endl; + return 0; } } diff -r deabf9fd3d28 -r a12fd0456f0c data/osc/OSCQueue.cpp --- a/data/osc/OSCQueue.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/data/osc/OSCQueue.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -34,7 +34,7 @@ OSCQueue::oscError(int num, const char *msg, const char *path) { cerr << "ERROR: OSCQueue::oscError: liblo server error " << num - << " in path " << path << ": " << msg << endl; + << " in path " << path << ": " << msg << endl; } int @@ -48,7 +48,7 @@ QString method; if (!queue->parseOSCPath(path, target, targetData, method)) { - return 1; + return 1; } OSCMessage message; @@ -80,7 +80,7 @@ break; } - ++i; + ++i; } queue->postMessage(message); @@ -190,7 +190,7 @@ QString &method) { while (path.startsWith("/")) { - path = path.right(path.length()-1); + path = path.right(path.length()-1); } int i = 0; diff -r deabf9fd3d28 -r a12fd0456f0c plugin/DSSIPluginFactory.cpp --- a/plugin/DSSIPluginFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/DSSIPluginFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -61,61 +61,61 @@ Profiler profiler("DSSIPluginFactory::enumeratePlugins"); for (std::vector::iterator i = m_identifiers.begin(); - i != m_identifiers.end(); ++i) { + i != m_identifiers.end(); ++i) { - const DSSI_Descriptor *ddesc = getDSSIDescriptor(*i); - if (!ddesc) continue; + const DSSI_Descriptor *ddesc = getDSSIDescriptor(*i); + if (!ddesc) continue; - const LADSPA_Descriptor *descriptor = ddesc->LADSPA_Plugin; - if (!descriptor) continue; - -// SVDEBUG << "DSSIPluginFactory::enumeratePlugins: Name " << (descriptor->Name ? descriptor->Name : "NONE" ) << endl; + const LADSPA_Descriptor *descriptor = ddesc->LADSPA_Plugin; + if (!descriptor) continue; + +// SVDEBUG << "DSSIPluginFactory::enumeratePlugins: Name " << (descriptor->Name ? descriptor->Name : "NONE" ) << endl; - list.push_back(*i); - list.push_back(descriptor->Name); - list.push_back(QString("%1").arg(descriptor->UniqueID)); - list.push_back(descriptor->Label); - list.push_back(descriptor->Maker); - list.push_back(descriptor->Copyright); - list.push_back((ddesc->run_synth || ddesc->run_multiple_synths) ? "true" : "false"); - list.push_back(ddesc->run_multiple_synths ? "true" : "false"); - list.push_back(m_taxonomy[*i]); - list.push_back(QString("%1").arg(descriptor->PortCount)); + list.push_back(*i); + list.push_back(descriptor->Name); + list.push_back(QString("%1").arg(descriptor->UniqueID)); + list.push_back(descriptor->Label); + list.push_back(descriptor->Maker); + list.push_back(descriptor->Copyright); + list.push_back((ddesc->run_synth || ddesc->run_multiple_synths) ? "true" : "false"); + list.push_back(ddesc->run_multiple_synths ? "true" : "false"); + list.push_back(m_taxonomy[*i]); + list.push_back(QString("%1").arg(descriptor->PortCount)); - for (int p = 0; p < (int)descriptor->PortCount; ++p) { + for (int p = 0; p < (int)descriptor->PortCount; ++p) { - int type = 0; - if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { - type |= PortType::Control; - } else { - type |= PortType::Audio; - } - if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) { - type |= PortType::Input; - } else { - type |= PortType::Output; - } + int type = 0; + if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { + type |= PortType::Control; + } else { + type |= PortType::Audio; + } + if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) { + type |= PortType::Input; + } else { + type |= PortType::Output; + } - list.push_back(QString("%1").arg(p)); - list.push_back(descriptor->PortNames[p]); - list.push_back(QString("%1").arg(type)); - list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p))); - list.push_back(QString("%1").arg(getPortMinimum(descriptor, p))); - list.push_back(QString("%1").arg(getPortMaximum(descriptor, p))); - list.push_back(QString("%1").arg(getPortDefault(descriptor, p))); - } + list.push_back(QString("%1").arg(p)); + list.push_back(descriptor->PortNames[p]); + list.push_back(QString("%1").arg(type)); + list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p))); + list.push_back(QString("%1").arg(getPortMinimum(descriptor, p))); + list.push_back(QString("%1").arg(getPortMaximum(descriptor, p))); + list.push_back(QString("%1").arg(getPortDefault(descriptor, p))); + } } unloadUnusedLibraries(); } - + RealTimePluginInstance * DSSIPluginFactory::instantiatePlugin(QString identifier, - int instrument, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int channels) + int instrument, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int channels) { Profiler profiler("DSSIPluginFactory::instantiatePlugin"); @@ -123,14 +123,14 @@ if (descriptor) { - DSSIPluginInstance *instance = - new DSSIPluginInstance - (this, instrument, identifier, position, sampleRate, blockSize, channels, - descriptor); + DSSIPluginInstance *instance = + new DSSIPluginInstance + (this, instrument, identifier, position, sampleRate, blockSize, channels, + descriptor); - m_instances.insert(instance); + m_instances.insert(instance); - return instance; + return instance; } return 0; @@ -143,49 +143,49 @@ PluginIdentifier::parseIdentifier(identifier, type, soname, label); if (soname == PluginIdentifier::BUILTIN_PLUGIN_SONAME) { - if (label == "sample_player") { - const DSSI_Descriptor *descriptor = SamplePlayer::getDescriptor(0); - if (descriptor) { - descriptor->receive_host_descriptor(&m_hostDescriptor); - } - return descriptor; - } else { - return 0; - } + if (label == "sample_player") { + const DSSI_Descriptor *descriptor = SamplePlayer::getDescriptor(0); + if (descriptor) { + descriptor->receive_host_descriptor(&m_hostDescriptor); + } + return descriptor; + } else { + return 0; + } } bool firstInLibrary = false; if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { - loadLibrary(soname); - if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { - cerr << "WARNING: DSSIPluginFactory::getDSSIDescriptor: loadLibrary failed for " << soname << endl; - return 0; - } - firstInLibrary = true; + loadLibrary(soname); + if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { + cerr << "WARNING: DSSIPluginFactory::getDSSIDescriptor: loadLibrary failed for " << soname << endl; + return 0; + } + firstInLibrary = true; } void *libraryHandle = m_libraryHandles[soname]; DSSI_Descriptor_Function fn = (DSSI_Descriptor_Function) - DLSYM(libraryHandle, "dssi_descriptor"); + DLSYM(libraryHandle, "dssi_descriptor"); if (!fn) { - cerr << "WARNING: DSSIPluginFactory::getDSSIDescriptor: No descriptor function in library " << soname << endl; - return 0; + cerr << "WARNING: DSSIPluginFactory::getDSSIDescriptor: No descriptor function in library " << soname << endl; + return 0; } const DSSI_Descriptor *descriptor = 0; int index = 0; while ((descriptor = fn(index))) { - if (descriptor->LADSPA_Plugin->Label == label) { - if (firstInLibrary && (descriptor->DSSI_API_Version >= 2)) { - descriptor->receive_host_descriptor(&m_hostDescriptor); - } - return descriptor; - } - ++index; + if (descriptor->LADSPA_Plugin->Label == label) { + if (firstInLibrary && (descriptor->DSSI_API_Version >= 2)) { + descriptor->receive_host_descriptor(&m_hostDescriptor); + } + return descriptor; + } + ++index; } cerr << "WARNING: DSSIPluginFactory::getDSSIDescriptor: No such plugin as " << label << " in library " << soname << endl; @@ -215,8 +215,8 @@ path = DEFAULT_DSSI_PATH; - char *home = getenv("HOME"); - if (home) { + char *home = getenv("HOME"); + if (home) { std::string::size_type f; while ((f = path.find("$HOME")) != std::string::npos && f < path.length()) { @@ -240,8 +240,8 @@ std::string::size_type index = 0, newindex = 0; while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) { - pathList.push_back(path.substr(index, newindex - index).c_str()); - index = newindex + 1; + pathList.push_back(path.substr(index, newindex - index).c_str()); + index = newindex + 1; } pathList.push_back(path.substr(index).c_str()); @@ -265,8 +265,8 @@ lrdfPaths.push_back("/usr/share/ladspa/rdf"); for (std::vector::iterator i = pathList.begin(); - i != pathList.end(); ++i) { - lrdfPaths.push_back(*i + "/rdf"); + i != pathList.end(); ++i) { + lrdfPaths.push_back(*i + "/rdf"); } #ifdef DSSI_BASE @@ -300,11 +300,11 @@ } DSSI_Descriptor_Function fn = (DSSI_Descriptor_Function) - DLSYM(libraryHandle, "dssi_descriptor"); + DLSYM(libraryHandle, "dssi_descriptor"); if (!fn) { - cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No descriptor function in " << soname << endl; - return; + cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No descriptor function in " << soname << endl; + return; } const DSSI_Descriptor *descriptor = 0; @@ -312,12 +312,12 @@ int index = 0; while ((descriptor = fn(index))) { - const LADSPA_Descriptor *ladspaDescriptor = descriptor->LADSPA_Plugin; - if (!ladspaDescriptor) { - cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No LADSPA descriptor for plugin " << index << " in " << soname << endl; - ++index; - continue; - } + const LADSPA_Descriptor *ladspaDescriptor = descriptor->LADSPA_Plugin; + if (!ladspaDescriptor) { + cerr << "WARNING: DSSIPluginFactory::discoverPlugins: No LADSPA descriptor for plugin " << index << " in " << soname << endl; + ++index; + continue; + } RealTimePluginDescriptor *rtd = new RealTimePluginDescriptor; rtd->name = ladspaDescriptor->Name; @@ -332,71 +332,71 @@ rtd->audioOutputPortCount = 0; rtd->controlOutputPortCount = 0; - QString identifier = PluginIdentifier::createIdentifier - ("dssi", soname, ladspaDescriptor->Label); + QString identifier = PluginIdentifier::createIdentifier + ("dssi", soname, ladspaDescriptor->Label); #ifdef HAVE_LRDF - char *def_uri = 0; - lrdf_defaults *defs = 0; - - QString category = m_taxonomy[identifier]; + char *def_uri = 0; + lrdf_defaults *defs = 0; + + QString category = m_taxonomy[identifier]; if (category == "" && m_lrdfTaxonomy[ladspaDescriptor->UniqueID] != "") { m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID]; category = m_taxonomy[identifier]; } - if (category == "") { - std::string name = rtd->name; - if (name.length() > 4 && - name.substr(name.length() - 4) == " VST") { - if (descriptor->run_synth || descriptor->run_multiple_synths) { - category = "VST instruments"; - } else { - category = "VST effects"; - } - m_taxonomy[identifier] = category; - } - } + if (category == "") { + std::string name = rtd->name; + if (name.length() > 4 && + name.substr(name.length() - 4) == " VST") { + if (descriptor->run_synth || descriptor->run_multiple_synths) { + category = "VST instruments"; + } else { + category = "VST effects"; + } + m_taxonomy[identifier] = category; + } + } rtd->category = category.toStdString(); - -// cerr << "Plugin id is " << ladspaDescriptor->UniqueID + +// cerr << "Plugin id is " << ladspaDescriptor->UniqueID // << ", identifier is \"" << identifier -// << "\", category is \"" << category -// << "\", name is " << ladspaDescriptor->Name -// << ", label is " << ladspaDescriptor->Label -// << endl; - - def_uri = lrdf_get_default_uri(ladspaDescriptor->UniqueID); - if (def_uri) { - defs = lrdf_get_setting_values(def_uri); - } - - unsigned int controlPortNumber = 1; - - for (int i = 0; i < (int)ladspaDescriptor->PortCount; i++) { - - if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { - - if (def_uri && defs) { - - for (int j = 0; j < (int)defs->count; j++) { - if (defs->items[j].pid == controlPortNumber) { -// cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << ladspaDescriptor->PortNames[i] << endl; - m_portDefaults[ladspaDescriptor->UniqueID][i] = - defs->items[j].value; - } - } - } - - ++controlPortNumber; - } - } +// << "\", category is \"" << category +// << "\", name is " << ladspaDescriptor->Name +// << ", label is " << ladspaDescriptor->Label +// << endl; + + def_uri = lrdf_get_default_uri(ladspaDescriptor->UniqueID); + if (def_uri) { + defs = lrdf_get_setting_values(def_uri); + } + + unsigned int controlPortNumber = 1; + + for (int i = 0; i < (int)ladspaDescriptor->PortCount; i++) { + + if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { + + if (def_uri && defs) { + + for (int j = 0; j < (int)defs->count; j++) { + if (defs->items[j].pid == controlPortNumber) { +// cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << ladspaDescriptor->PortNames[i] << endl; + m_portDefaults[ladspaDescriptor->UniqueID][i] = + defs->items[j].value; + } + } + } + + ++controlPortNumber; + } + } #endif // HAVE_LRDF - for (unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) { - if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { + for (unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) { + if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { ++rtd->parameterCount; } else { @@ -416,11 +416,11 @@ } } - m_identifiers.push_back(identifier); + m_identifiers.push_back(identifier); m_rtDescriptors[identifier] = rtd; - ++index; + ++index; } if (DLCLOSE(libraryHandle) != 0) { diff -r deabf9fd3d28 -r a12fd0456f0c plugin/DSSIPluginFactory.h --- a/plugin/DSSIPluginFactory.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/DSSIPluginFactory.h Tue Apr 17 10:35:42 2018 +0100 @@ -38,11 +38,11 @@ virtual void enumeratePlugins(std::vector &list); virtual RealTimePluginInstance *instantiatePlugin(QString identifier, - int clientId, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int channels); + int clientId, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int channels); protected: DSSIPluginFactory(); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/DSSIPluginInstance.cpp --- a/plugin/DSSIPluginInstance.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/DSSIPluginInstance.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -54,13 +54,13 @@ DSSIPluginInstance::DSSIPluginInstance(RealTimePluginFactory *factory, - int clientId, - QString identifier, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int idealChannelCount, - const DSSI_Descriptor* descriptor) : + int clientId, + QString identifier, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int idealChannelCount, + const DSSI_Descriptor* descriptor) : RealTimePluginInstance(factory, identifier), m_client(clientId), m_position(position), @@ -79,7 +79,7 @@ { #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")" - << endl; + << endl; #endif init(); @@ -88,10 +88,10 @@ m_outputBuffers = new sample_t*[m_outputBufferCount]; for (size_t i = 0; i < m_audioPortsIn.size(); ++i) { - m_inputBuffers[i] = new sample_t[blockSize]; + m_inputBuffers[i] = new sample_t[blockSize]; } for (int i = 0; i < m_outputBufferCount; ++i) { - m_outputBuffers[i] = new sample_t[blockSize]; + m_outputBuffers[i] = new sample_t[blockSize]; } m_ownBuffers = true; @@ -100,9 +100,9 @@ instantiate(sampleRate); if (isOK()) { - connectPorts(); - activate(); - initialiseGroupMembership(); + connectPorts(); + activate(); + initialiseGroupMembership(); } } @@ -229,34 +229,34 @@ { if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { m_audioPortsIn.push_back(i); - } else { + } else { m_audioPortsOut.push_back(i); - } + } } else if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { - if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { + if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { - LADSPA_Data *data = new LADSPA_Data(0.0); + LADSPA_Data *data = new LADSPA_Data(0.0); - m_controlPortsIn.push_back(std::pair - (i, data)); + m_controlPortsIn.push_back(std::pair + (i, data)); - m_backupControlPortsIn.push_back(0.0); + m_backupControlPortsIn.push_back(0.0); - } else { - LADSPA_Data *data = new LADSPA_Data(0.0); - m_controlPortsOut.push_back( + } else { + LADSPA_Data *data = new LADSPA_Data(0.0); + m_controlPortsOut.push_back( std::pair(i, data)); - if (!strcmp(descriptor->PortNames[i], "latency") || - !strcmp(descriptor->PortNames[i], "_latency")) { + if (!strcmp(descriptor->PortNames[i], "latency") || + !strcmp(descriptor->PortNames[i], "_latency")) { #ifdef DEBUG_DSSI - cerr << "Wooo! We have a latency port!" << endl; + cerr << "Wooo! We have a latency port!" << endl; #endif - m_latencyPort = data; - } - } + m_latencyPort = data; + } + } } #ifdef DEBUG_DSSI else @@ -279,7 +279,7 @@ #endif if (m_latencyPort) { - if (!m_run) { + if (!m_run) { for (int i = 0; i < getAudioInputCount(); ++i) { for (int j = 0; j < m_blockSize; ++j) { m_inputBuffers[i][j] = 0.f; @@ -287,7 +287,7 @@ } run(Vamp::RealTime::zeroTime); } - latency = (sv_frame_t)(*m_latencyPort + 0.1); + latency = (sv_frame_t)(*m_latencyPort + 0.1); } #ifdef DEBUG_DSSI_PROCESS @@ -301,8 +301,8 @@ DSSIPluginInstance::silence() { if (m_instanceHandle != 0) { - deactivate(); - activate(); + deactivate(); + activate(); } } @@ -317,41 +317,41 @@ { #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::setIdealChannelCount: channel count " - << channels << " (was " << m_idealChannelCount << ")" << endl; + << channels << " (was " << m_idealChannelCount << ")" << endl; #endif if (channels == m_idealChannelCount) { - silence(); - return; + silence(); + return; } if (m_instanceHandle != 0) { - deactivate(); + deactivate(); } m_idealChannelCount = channels; if (channels > m_outputBufferCount) { - for (int i = 0; i < m_outputBufferCount; ++i) { - delete[] m_outputBuffers[i]; - } + for (int i = 0; i < m_outputBufferCount; ++i) { + delete[] m_outputBuffers[i]; + } - delete[] m_outputBuffers; + delete[] m_outputBuffers; - m_outputBufferCount = channels; + m_outputBufferCount = channels; - m_outputBuffers = new sample_t*[m_outputBufferCount]; + m_outputBuffers = new sample_t*[m_outputBufferCount]; - for (int i = 0; i < m_outputBufferCount; ++i) { - m_outputBuffers[i] = new sample_t[m_blockSize]; - } + for (int i = 0; i < m_outputBufferCount; ++i) { + m_outputBuffers[i] = new sample_t[m_blockSize]; + } - connectPorts(); + connectPorts(); } if (m_instanceHandle != 0) { - activate(); + activate(); } } @@ -367,8 +367,8 @@ DSSIPluginInstance::initialiseGroupMembership() { if (!m_descriptor->run_multiple_synths) { - m_grouped = false; - return; + m_grouped = false; + return; } //!!! GroupMap is not actually thread-safe. @@ -377,24 +377,24 @@ if (++pluginsInGroup > m_groupLocalEventBufferCount) { - size_t nextBufferCount = pluginsInGroup * 2; + size_t nextBufferCount = pluginsInGroup * 2; - snd_seq_event_t **eventLocalBuffers = new snd_seq_event_t *[nextBufferCount]; + snd_seq_event_t **eventLocalBuffers = new snd_seq_event_t *[nextBufferCount]; - for (size_t i = 0; i < m_groupLocalEventBufferCount; ++i) { - eventLocalBuffers[i] = m_groupLocalEventBuffers[i]; - } - for (size_t i = m_groupLocalEventBufferCount; i < nextBufferCount; ++i) { - eventLocalBuffers[i] = new snd_seq_event_t[EVENT_BUFFER_SIZE]; - } + for (size_t i = 0; i < m_groupLocalEventBufferCount; ++i) { + eventLocalBuffers[i] = m_groupLocalEventBuffers[i]; + } + for (size_t i = m_groupLocalEventBufferCount; i < nextBufferCount; ++i) { + eventLocalBuffers[i] = new snd_seq_event_t[EVENT_BUFFER_SIZE]; + } - if (m_groupLocalEventBuffers) { - m_bufferScavenger.claim(new ScavengerArrayWrapper - (m_groupLocalEventBuffers)); - } + if (m_groupLocalEventBuffers) { + m_bufferScavenger.claim(new ScavengerArrayWrapper + (m_groupLocalEventBuffers)); + } - m_groupLocalEventBuffers = eventLocalBuffers; - m_groupLocalEventBufferCount = nextBufferCount; + m_groupLocalEventBuffers = eventLocalBuffers; + m_groupLocalEventBufferCount = nextBufferCount; } m_grouped = true; @@ -409,22 +409,22 @@ if (m_threads.find(m_instanceHandle) != m_threads.end()) { - for (std::set::iterator i = - m_threads[m_instanceHandle].begin(); - i != m_threads[m_instanceHandle].end(); ++i) { + for (std::set::iterator i = + m_threads[m_instanceHandle].begin(); + i != m_threads[m_instanceHandle].end(); ++i) { - (*i)->setExiting(); - (*i)->wait(); - delete *i; - } + (*i)->setExiting(); + (*i)->wait(); + delete *i; + } - m_threads.erase(m_instanceHandle); + m_threads.erase(m_instanceHandle); } detachFromGroup(); if (m_instanceHandle != 0) { - deactivate(); + deactivate(); } cleanup(); @@ -439,15 +439,15 @@ m_controlPortsOut.clear(); if (m_ownBuffers) { - for (int i = 0; i < getAudioInputCount(); ++i) { - delete[] m_inputBuffers[i]; - } - for (int i = 0; i < m_outputBufferCount; ++i) { - delete[] m_outputBuffers[i]; - } + for (int i = 0; i < getAudioInputCount(); ++i) { + delete[] m_inputBuffers[i]; + } + for (int i = 0; i < m_outputBufferCount; ++i) { + delete[] m_outputBuffers[i]; + } - delete[] m_inputBuffers; - delete[] m_outputBuffers; + delete[] m_inputBuffers; + delete[] m_outputBuffers; } m_audioPortsIn.clear(); @@ -467,10 +467,10 @@ const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin; if (!descriptor->instantiate) { - cerr << "Bad plugin: plugin id " << descriptor->UniqueID - << ":" << descriptor->Label - << " has no instantiate method!" << endl; - return; + cerr << "Bad plugin: plugin id " << descriptor->UniqueID + << ":" << descriptor->Label + << " has no instantiate method!" << endl; + return; } unsigned long pluginRate = (unsigned long)(sampleRate); @@ -483,24 +483,24 @@ if (m_instanceHandle) { - if (m_descriptor->get_midi_controller_for_port) { + if (m_descriptor->get_midi_controller_for_port) { - for (int i = 0; i < (int)descriptor->PortCount; ++i) { + for (int i = 0; i < (int)descriptor->PortCount; ++i) { - if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i]) && - LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { + if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i]) && + LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { - int controller = m_descriptor->get_midi_controller_for_port - (m_instanceHandle, i); + int controller = m_descriptor->get_midi_controller_for_port + (m_instanceHandle, i); - if (controller != 0 && controller != 32 && - DSSI_IS_CC(controller)) { + if (controller != 0 && controller != 32 && + DSSI_IS_CC(controller)) { - m_controllerMap[DSSI_CC_NUMBER(controller)] = i; - } - } - } - } + m_controllerMap[DSSI_CC_NUMBER(controller)] = i; + } + } + } + } } } @@ -515,19 +515,19 @@ #endif if (!m_descriptor || !m_descriptor->get_program) { - m_programCacheValid = true; - return; + m_programCacheValid = true; + return; } int index = 0; const DSSI_Program_Descriptor *programDescriptor; while ((programDescriptor = m_descriptor->get_program(m_instanceHandle, index))) { - ++index; - ProgramDescriptor d; - d.bank = (int)programDescriptor->Bank; - d.program = (int)programDescriptor->Program; - d.name = programDescriptor->Name; - m_cachedPrograms.push_back(d); + ++index; + ProgramDescriptor d; + d.bank = (int)programDescriptor->Bank; + d.program = (int)programDescriptor->Program; + d.name = programDescriptor->Name; + m_cachedPrograms.push_back(d); } #ifdef DEBUG_DSSI @@ -551,8 +551,8 @@ ProgramList programs; for (std::vector::iterator i = m_cachedPrograms.begin(); - i != m_cachedPrograms.end(); ++i) { - programs.push_back(i->name); + i != m_cachedPrograms.end(); ++i) { + programs.push_back(i->name); } return programs; @@ -570,8 +570,8 @@ checkProgramCache(); for (std::vector::iterator i = m_cachedPrograms.begin(); - i != m_cachedPrograms.end(); ++i) { - if (i->bank == bank && i->program == program) return i->name; + i != m_cachedPrograms.end(); ++i) { + if (i->bank == bank && i->program == program) return i->name; } return std::string(); @@ -591,12 +591,12 @@ int rv; for (std::vector::iterator i = m_cachedPrograms.begin(); - i != m_cachedPrograms.end(); ++i) { - if (i->name == name) { - rv = i->bank; - rv = (rv << 16) + i->program; - return rv; - } + i != m_cachedPrograms.end(); ++i) { + if (i->name == name) { + rv = i->bank; + rv = (rv << 16) + i->program; + return rv; + } } return 0; @@ -631,20 +631,20 @@ int bankNo = 0, programNo = 0; for (std::vector::iterator i = m_cachedPrograms.begin(); - i != m_cachedPrograms.end(); ++i) { + i != m_cachedPrograms.end(); ++i) { - if (i->name == program) { + if (i->name == program) { - bankNo = i->bank; - programNo = i->program; - found = true; + bankNo = i->bank; + programNo = i->program; + found = true; #ifdef DEBUG_DSSI - SVDEBUG << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << endl; + SVDEBUG << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << endl; #endif - break; - } + break; + } } if (!found) return; @@ -660,9 +660,9 @@ #endif if (backupPortValues) { - for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { - m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; - } + for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { + m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; + } } } @@ -678,16 +678,16 @@ if (m_program != "") { #ifdef DEBUG_DSSI - SVDEBUG << "DSSIPluginInstance::activate: restoring program " << m_program << endl; + SVDEBUG << "DSSIPluginInstance::activate: restoring program " << m_program << endl; #endif - selectProgramAux(m_program, false); + selectProgramAux(m_program, false); } for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { #ifdef DEBUG_DSSI - SVDEBUG << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << endl; + SVDEBUG << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << endl; #endif - *m_controlPortsIn[i].second = m_backupControlPortsIn[i]; + *m_controlPortsIn[i].second = m_backupControlPortsIn[i]; } } @@ -697,8 +697,8 @@ if (!m_descriptor || !m_descriptor->LADSPA_Plugin->connect_port) return; #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::connectPorts: " << getAudioInputCount() - << " audio ports in, " << m_audioPortsOut.size() << " out, " - << m_outputBufferCount << " output buffers" << endl; + << " audio ports in, " << m_audioPortsOut.size() << " out, " + << m_outputBufferCount << " output buffers" << endl; #endif assert(sizeof(LADSPA_Data) == sizeof(float)); @@ -708,26 +708,26 @@ int inbuf = 0, outbuf = 0; for (int i = 0; i < getAudioInputCount(); ++i) { - m_descriptor->LADSPA_Plugin->connect_port - (m_instanceHandle, - m_audioPortsIn[i], - (LADSPA_Data *)m_inputBuffers[inbuf]); - ++inbuf; + m_descriptor->LADSPA_Plugin->connect_port + (m_instanceHandle, + m_audioPortsIn[i], + (LADSPA_Data *)m_inputBuffers[inbuf]); + ++inbuf; } for (size_t i = 0; i < m_audioPortsOut.size(); ++i) { - m_descriptor->LADSPA_Plugin->connect_port - (m_instanceHandle, - m_audioPortsOut[i], - (LADSPA_Data *)m_outputBuffers[outbuf]); - ++outbuf; + m_descriptor->LADSPA_Plugin->connect_port + (m_instanceHandle, + m_audioPortsOut[i], + (LADSPA_Data *)m_outputBuffers[outbuf]); + ++outbuf; } for (size_t i = 0; i < m_controlPortsIn.size(); ++i) { - m_descriptor->LADSPA_Plugin->connect_port - (m_instanceHandle, - m_controlPortsIn[i].first, - m_controlPortsIn[i].second); + m_descriptor->LADSPA_Plugin->connect_port + (m_instanceHandle, + m_controlPortsIn[i].first, + m_controlPortsIn[i].second); if (f) { float defaultValue = f->getPortDefault @@ -741,10 +741,10 @@ } for (size_t i = 0; i < m_controlPortsOut.size(); ++i) { - m_descriptor->LADSPA_Plugin->connect_port - (m_instanceHandle, - m_controlPortsOut[i].first, - m_controlPortsOut[i].second); + m_descriptor->LADSPA_Plugin->connect_port + (m_instanceHandle, + m_controlPortsOut[i].first, + m_controlPortsOut[i].second); } } @@ -766,12 +766,12 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - if (value < f->getPortMinimum(m_descriptor->LADSPA_Plugin, portNumber)) { - value = f->getPortMinimum(m_descriptor->LADSPA_Plugin, portNumber); - } - if (value > f->getPortMaximum(m_descriptor->LADSPA_Plugin, portNumber)) { - value = f->getPortMaximum(m_descriptor->LADSPA_Plugin, portNumber); - } + if (value < f->getPortMinimum(m_descriptor->LADSPA_Plugin, portNumber)) { + value = f->getPortMinimum(m_descriptor->LADSPA_Plugin, portNumber); + } + if (value > f->getPortMaximum(m_descriptor->LADSPA_Plugin, portNumber)) { + value = f->getPortMaximum(m_descriptor->LADSPA_Plugin, portNumber); + } } (*m_controlPortsIn[parameter].second) = value; @@ -793,27 +793,27 @@ float value = (float)cv; if (!LADSPA_IS_HINT_BOUNDED_BELOW(d)) { - if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { - /* unbounded: might as well leave the value alone. */ - } else { - /* bounded above only. just shift the range. */ - value = ub - 127.0f + value; - } + if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { + /* unbounded: might as well leave the value alone. */ + } else { + /* bounded above only. just shift the range. */ + value = ub - 127.0f + value; + } } else { - if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { - /* bounded below only. just shift the range. */ - value = lb + value; - } else { - /* bounded both ends. more interesting. */ - /* XXX !!! todo: fill in logarithmic, sample rate &c */ - value = lb + ((ub - lb) * value / 127.0f); - } + if (!LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { + /* bounded below only. just shift the range. */ + value = lb + value; + } else { + /* bounded both ends. more interesting. */ + /* XXX !!! todo: fill in logarithmic, sample rate &c */ + value = lb + ((ub - lb) * value / 127.0f); + } } for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) { - if (m_controlPortsIn[i].first == port) { - setParameterValue(i, value); - } + if (m_controlPortsIn[i].first == port) { + setParameterValue(i, value); + } } } @@ -841,10 +841,10 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - return f->getPortDefault(m_descriptor->LADSPA_Plugin, - m_controlPortsIn[parameter].first); + return f->getPortDefault(m_descriptor->LADSPA_Plugin, + m_controlPortsIn[parameter].first); } else { - return 0.0f; + return 0.0f; } } @@ -855,35 +855,35 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - return f->getPortDisplayHint(m_descriptor->LADSPA_Plugin, + return f->getPortDisplayHint(m_descriptor->LADSPA_Plugin, m_controlPortsIn[parameter].first); } else { - return PortHint::NoHint; + return PortHint::NoHint; } } std::string DSSIPluginInstance::configure(std::string key, - std::string value) + std::string value) { if (!m_descriptor || !m_descriptor->configure) return std::string(); if (key == PluginIdentifier::RESERVED_PROJECT_DIRECTORY_KEY.toStdString()) { #ifdef DSSI_PROJECT_DIRECTORY_KEY - key = DSSI_PROJECT_DIRECTORY_KEY; + key = DSSI_PROJECT_DIRECTORY_KEY; #else - return std::string(); + return std::string(); #endif } - + #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::configure(" << key << "," << value << ")" << endl; #endif char *message = m_descriptor->configure(m_instanceHandle, - key.c_str(), - value.c_str()); + key.c_str(), + value.c_str()); m_programCacheValid = false; @@ -895,16 +895,16 @@ // as project directory #ifdef DSSI_RESERVED_CONFIGURE_PREFIX if (QString(key.c_str()).startsWith(DSSI_RESERVED_CONFIGURE_PREFIX)) { - return qm; + return qm; } #endif if (message) { - if (m_descriptor->LADSPA_Plugin && m_descriptor->LADSPA_Plugin->Label) { - qm = std::string(m_descriptor->LADSPA_Plugin->Label) + ": "; - } - qm = qm + message; - free(message); + if (m_descriptor->LADSPA_Plugin && m_descriptor->LADSPA_Plugin->Label) { + qm = std::string(m_descriptor->LADSPA_Plugin->Label) + ": "; + } + qm = qm + message; + free(message); cerr << "DSSIPluginInstance::configure: warning: configure returned message: \"" << qm << "\"" << endl; } @@ -914,7 +914,7 @@ void DSSIPluginInstance::sendEvent(const RealTime &eventTime, - const void *e) + const void *e) { #ifdef DEBUG_DSSI_PROCESS SVDEBUG << "DSSIPluginInstance::sendEvent: last was " << m_lastEventSendTime << " (valid " << m_haveLastEventSendTime << "), this is " << eventTime << endl; @@ -925,12 +925,12 @@ // we will happily drop events here if we find the timeline going // backwards. if (m_haveLastEventSendTime && - m_lastEventSendTime > eventTime) { + m_lastEventSendTime > eventTime) { #ifdef DEBUG_DSSI_PROCESS - cerr << "... clearing down" << endl; + cerr << "... clearing down" << endl; #endif - m_haveLastEventSendTime = false; - clearEvents(); + m_haveLastEventSendTime = false; + clearEvents(); } snd_seq_event_t *event = (snd_seq_event_t *)e; @@ -968,21 +968,21 @@ #endif if (controller == 0) { // bank select MSB - - m_pending.msb = ev->data.control.value; + + m_pending.msb = ev->data.control.value; } else if (controller == 32) { // bank select LSB - m_pending.lsb = ev->data.control.value; + m_pending.lsb = ev->data.control.value; } else if (controller > 0 && controller < 128) { - - if (m_controllerMap.find(controller) != m_controllerMap.end()) { - int port = m_controllerMap[controller]; - setPortValueFromController(port, ev->data.control.value); - } else { - return true; // pass through to plugin - } + + if (m_controllerMap.find(controller) != m_controllerMap.end()) { + int port = m_controllerMap[controller]; + setPortValueFromController(port, ev->data.control.value); + } else { + return true; // pass through to plugin + } } return false; @@ -1000,32 +1000,32 @@ if (m_descriptor && m_descriptor->select_program) needLock = true; if (needLock) { - if (!m_processLock.tryLock()) { - for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { - memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); - } - return; - } + if (!m_processLock.tryLock()) { + for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { + memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); + } + return; + } } if (m_grouped) { - runGrouped(blockTime); - goto done; + runGrouped(blockTime); + goto done; } if (!m_descriptor || !m_descriptor->run_synth) { - m_eventBuffer.skip(m_eventBuffer.getReadSpace()); - m_haveLastEventSendTime = false; - if (m_descriptor && m_descriptor->LADSPA_Plugin->run) { - m_descriptor->LADSPA_Plugin->run(m_instanceHandle, count); - } else { - for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { - memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); - } - } - m_run = true; - if (needLock) m_processLock.unlock(); - return; + m_eventBuffer.skip(m_eventBuffer.getReadSpace()); + m_haveLastEventSendTime = false; + if (m_descriptor && m_descriptor->LADSPA_Plugin->run) { + m_descriptor->LADSPA_Plugin->run(m_instanceHandle, count); + } else { + for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { + memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); + } + } + m_run = true; + if (needLock) m_processLock.unlock(); + return; } #ifdef DEBUG_DSSI_PROCESS @@ -1034,65 +1034,65 @@ #ifdef DEBUG_DSSI_PROCESS if (m_eventBuffer.getReadSpace() > 0) { - SVDEBUG << "DSSIPluginInstance::run: event buffer has " - << m_eventBuffer.getReadSpace() << " event(s) in it" << endl; + SVDEBUG << "DSSIPluginInstance::run: event buffer has " + << m_eventBuffer.getReadSpace() << " event(s) in it" << endl; } #endif while (m_eventBuffer.getReadSpace() > 0) { - snd_seq_event_t *ev = localEventBuffer + evCount; - *ev = m_eventBuffer.peekOne(); - bool accept = true; + snd_seq_event_t *ev = localEventBuffer + evCount; + *ev = m_eventBuffer.peekOne(); + bool accept = true; - RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec); + RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec); sv_frame_t frameOffset = 0; - if (evTime > blockTime) { - frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); - } + if (evTime > blockTime) { + frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); + } #ifdef DEBUG_DSSI_PROCESS - SVDEBUG << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset - << ", blockSize " << m_blockSize << endl; - cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << endl; + SVDEBUG << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset + << ", blockSize " << m_blockSize << endl; + cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << endl; #endif - if (frameOffset >= (long)count) break; - if (frameOffset < 0) { - frameOffset = 0; - if (ev->type == SND_SEQ_EVENT_NOTEON) { - m_eventBuffer.skip(1); - continue; - } - } + if (frameOffset >= (long)count) break; + if (frameOffset < 0) { + frameOffset = 0; + if (ev->type == SND_SEQ_EVENT_NOTEON) { + m_eventBuffer.skip(1); + continue; + } + } - ev->time.tick = (snd_seq_tick_time_t)frameOffset; - m_eventBuffer.skip(1); + ev->time.tick = (snd_seq_tick_time_t)frameOffset; + m_eventBuffer.skip(1); - if (ev->type == SND_SEQ_EVENT_CONTROLLER) { - accept = handleController(ev); - } else if (ev->type == SND_SEQ_EVENT_PGMCHANGE) { - m_pending.program = ev->data.control.value; - accept = false; - } + if (ev->type == SND_SEQ_EVENT_CONTROLLER) { + accept = handleController(ev); + } else if (ev->type == SND_SEQ_EVENT_PGMCHANGE) { + m_pending.program = ev->data.control.value; + accept = false; + } - if (accept) { - if (++evCount >= EVENT_BUFFER_SIZE) break; - } + if (accept) { + if (++evCount >= EVENT_BUFFER_SIZE) break; + } } if (m_pending.program >= 0 && m_descriptor->select_program) { - int program = m_pending.program; - int bank = m_pending.lsb + 128 * m_pending.msb; + int program = m_pending.program; + int bank = m_pending.lsb + 128 * m_pending.msb; #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::run: making select_program(" << bank << "," << program << ") call" << endl; #endif - m_pending.lsb = m_pending.msb = m_pending.program = -1; - m_descriptor->select_program(m_instanceHandle, bank, program); + m_pending.lsb = m_pending.msb = m_pending.program = -1; + m_descriptor->select_program(m_instanceHandle, bank, program); #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::run: made select_program(" << bank << "," << program << ") call" << endl; @@ -1101,16 +1101,16 @@ #ifdef DEBUG_DSSI_PROCESS SVDEBUG << "DSSIPluginInstance::run: running with " << evCount << " events" - << endl; + << endl; #endif m_descriptor->run_synth(m_instanceHandle, count, - localEventBuffer, evCount); + localEventBuffer, evCount); #ifdef DEBUG_DSSI_PROCESS // for (int i = 0; i < count; ++i) { -// cout << m_outputBuffers[0][i] << " "; -// if (i % 8 == 0) cout << endl; +// cout << m_outputBuffers[0][i] << " "; +// if (i % 8 == 0) cout << endl; // } #endif @@ -1120,31 +1120,31 @@ int numAudioOuts = int(m_audioPortsOut.size()); if (numAudioOuts == 0) { - // copy inputs to outputs - for (int ch = 0; ch < m_idealChannelCount; ++ch) { - int sch = ch % getAudioInputCount(); - for (int i = 0; i < m_blockSize; ++i) { - m_outputBuffers[ch][i] = m_inputBuffers[sch][i]; - } - } + // copy inputs to outputs + for (int ch = 0; ch < m_idealChannelCount; ++ch) { + int sch = ch % getAudioInputCount(); + for (int i = 0; i < m_blockSize; ++i) { + m_outputBuffers[ch][i] = m_inputBuffers[sch][i]; + } + } } else if (m_idealChannelCount < numAudioOuts) { - if (m_idealChannelCount == 1) { - // mix down to mono - for (int ch = 1; ch < numAudioOuts; ++ch) { - for (int i = 0; i < m_blockSize; ++i) { - m_outputBuffers[0][i] += m_outputBuffers[ch][i]; - } - } - } + if (m_idealChannelCount == 1) { + // mix down to mono + for (int ch = 1; ch < numAudioOuts; ++ch) { + for (int i = 0; i < m_blockSize; ++i) { + m_outputBuffers[0][i] += m_outputBuffers[ch][i]; + } + } + } } else if (m_idealChannelCount > numAudioOuts) { - // duplicate - for (int ch = numAudioOuts; ch < m_idealChannelCount; ++ch) { - int sch = (ch - numAudioOuts) % numAudioOuts; - for (int i = 0; i < m_blockSize; ++i) { - m_outputBuffers[ch][i] = m_outputBuffers[sch][i]; - } - } - } + // duplicate + for (int ch = numAudioOuts; ch < m_idealChannelCount; ++ch) { + int sch = (ch - numAudioOuts) % numAudioOuts; + for (int i = 0; i < m_blockSize; ++i) { + m_outputBuffers[ch][i] = m_outputBuffers[sch][i]; + } + } + } m_lastRunTime = blockTime; m_run = true; @@ -1168,22 +1168,22 @@ #endif if (m_lastRunTime != blockTime) { - for (PluginSet::iterator i = s.begin(); i != s.end(); ++i) { - DSSIPluginInstance *instance = *i; - if (instance != this && instance->m_lastRunTime == blockTime) { + for (PluginSet::iterator i = s.begin(); i != s.end(); ++i) { + DSSIPluginInstance *instance = *i; + if (instance != this && instance->m_lastRunTime == blockTime) { #ifdef DEBUG_DSSI_PROCESS - SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << endl; + SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << endl; #endif - needRun = false; - } - } + needRun = false; + } + } } if (!needRun) { #ifdef DEBUG_DSSI_PROCESS - SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << endl; + SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << endl; #endif - return; + return; } #ifdef DEBUG_DSSI_PROCESS @@ -1192,81 +1192,81 @@ size_t index = 0; unsigned long *counts = (unsigned long *) - alloca(m_groupLocalEventBufferCount * sizeof(unsigned long)); + alloca(m_groupLocalEventBufferCount * sizeof(unsigned long)); LADSPA_Handle *instances = (LADSPA_Handle *) - alloca(m_groupLocalEventBufferCount * sizeof(LADSPA_Handle)); + alloca(m_groupLocalEventBufferCount * sizeof(LADSPA_Handle)); for (PluginSet::iterator i = s.begin(); i != s.end(); ++i) { - if (index >= m_groupLocalEventBufferCount) break; + if (index >= m_groupLocalEventBufferCount) break; - DSSIPluginInstance *instance = *i; - counts[index] = 0; - instances[index] = instance->m_instanceHandle; + DSSIPluginInstance *instance = *i; + counts[index] = 0; + instances[index] = instance->m_instanceHandle; #ifdef DEBUG_DSSI_PROCESS - SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << endl; + SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << endl; #endif - if (instance->m_pending.program >= 0 && - instance->m_descriptor->select_program) { - int program = instance->m_pending.program; - int bank = instance->m_pending.lsb + 128 * instance->m_pending.msb; - instance->m_pending.lsb = instance->m_pending.msb = instance->m_pending.program = -1; - instance->m_descriptor->select_program - (instance->m_instanceHandle, bank, program); - } + if (instance->m_pending.program >= 0 && + instance->m_descriptor->select_program) { + int program = instance->m_pending.program; + int bank = instance->m_pending.lsb + 128 * instance->m_pending.msb; + instance->m_pending.lsb = instance->m_pending.msb = instance->m_pending.program = -1; + instance->m_descriptor->select_program + (instance->m_instanceHandle, bank, program); + } - while (instance->m_eventBuffer.getReadSpace() > 0) { + while (instance->m_eventBuffer.getReadSpace() > 0) { - snd_seq_event_t *ev = m_groupLocalEventBuffers[index] + counts[index]; - *ev = instance->m_eventBuffer.peekOne(); - bool accept = true; + snd_seq_event_t *ev = m_groupLocalEventBuffers[index] + counts[index]; + *ev = instance->m_eventBuffer.peekOne(); + bool accept = true; - RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec); + RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec); - sv_frame_t frameOffset = 0; - if (evTime > blockTime) { - frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); - } + sv_frame_t frameOffset = 0; + if (evTime > blockTime) { + frameOffset = RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); + } #ifdef DEBUG_DSSI_PROCESS - SVDEBUG << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset - << ", block size " << m_blockSize << endl; + SVDEBUG << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset + << ", block size " << m_blockSize << endl; #endif - if (frameOffset >= int(m_blockSize)) break; - if (frameOffset < 0) frameOffset = 0; + if (frameOffset >= int(m_blockSize)) break; + if (frameOffset < 0) frameOffset = 0; - ev->time.tick = snd_seq_tick_time_t(frameOffset); - instance->m_eventBuffer.skip(1); + ev->time.tick = snd_seq_tick_time_t(frameOffset); + instance->m_eventBuffer.skip(1); - if (ev->type == SND_SEQ_EVENT_CONTROLLER) { - accept = instance->handleController(ev); - } else if (ev->type == SND_SEQ_EVENT_PGMCHANGE) { - instance->m_pending.program = ev->data.control.value; - accept = false; - } + if (ev->type == SND_SEQ_EVENT_CONTROLLER) { + accept = instance->handleController(ev); + } else if (ev->type == SND_SEQ_EVENT_PGMCHANGE) { + instance->m_pending.program = ev->data.control.value; + accept = false; + } - if (accept) { - if (++counts[index] >= EVENT_BUFFER_SIZE) break; - } - } + if (accept) { + if (++counts[index] >= EVENT_BUFFER_SIZE) break; + } + } - ++index; + ++index; } m_descriptor->run_multiple_synths(index, - instances, - m_blockSize, - m_groupLocalEventBuffers, - counts); + instances, + m_blockSize, + m_groupLocalEventBuffers, + counts); } int DSSIPluginInstance::requestMidiSend(LADSPA_Handle /* instance */, - unsigned char /* ports */, - unsigned char /* channels */) + unsigned char /* ports */, + unsigned char /* channels */) { // This is called from a non-RT context (during instantiate) @@ -1276,8 +1276,8 @@ void DSSIPluginInstance::midiSend(LADSPA_Handle /* instance */, - snd_seq_event_t * /* events */, - unsigned long /* eventCount */) + snd_seq_event_t * /* events */, + unsigned long /* eventCount */) { // This is likely to be called from an RT context @@ -1288,14 +1288,14 @@ DSSIPluginInstance::NonRTPluginThread::run() { while (!m_exiting) { - m_runFunction(m_handle); - usleep(100000); + m_runFunction(m_handle); + usleep(100000); } } int DSSIPluginInstance::requestNonRTThread(LADSPA_Handle instance, - void (*runFunction)(LADSPA_Handle)) + void (*runFunction)(LADSPA_Handle)) { NonRTPluginThread *thread = new NonRTPluginThread(instance, runFunction); m_threads[instance].insert(thread); @@ -1312,7 +1312,7 @@ if (!m_descriptor || !m_descriptor->LADSPA_Plugin->deactivate) return; for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { - m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; + m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; } m_descriptor->LADSPA_Plugin->deactivate(m_instanceHandle); @@ -1332,11 +1332,11 @@ if (!m_descriptor) return; if (!m_descriptor->LADSPA_Plugin->cleanup) { - cerr << "Bad plugin: plugin id " - << m_descriptor->LADSPA_Plugin->UniqueID - << ":" << m_descriptor->LADSPA_Plugin->Label - << " has no cleanup method!" << endl; - return; + cerr << "Bad plugin: plugin id " + << m_descriptor->LADSPA_Plugin->UniqueID + << ":" << m_descriptor->LADSPA_Plugin->Label + << " has no cleanup method!" << endl; + return; } m_descriptor->LADSPA_Plugin->cleanup(m_instanceHandle); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/DSSIPluginInstance.h --- a/plugin/DSSIPluginInstance.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/DSSIPluginInstance.h Tue Apr 17 10:35:42 2018 +0100 @@ -68,7 +68,7 @@ virtual std::string configure(std::string key, std::string value); virtual void sendEvent(const RealTime &eventTime, - const void *event); + const void *event); virtual void clearEvents(); virtual int getBufferSize() const { return m_blockSize; } @@ -107,13 +107,13 @@ // Constructor that creates the buffers internally // DSSIPluginInstance(RealTimePluginFactory *factory, - int client, - QString identifier, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int idealChannelCount, - const DSSI_Descriptor* descriptor); + int client, + QString identifier, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int idealChannelCount, + const DSSI_Descriptor* descriptor); void init(); void instantiate(sv_samplerate_t sampleRate); @@ -132,13 +132,13 @@ // For use in DSSIPluginFactory (set in the DSSI_Host_Descriptor): static int requestMidiSend(LADSPA_Handle instance, - unsigned char ports, - unsigned char channels); + unsigned char ports, + unsigned char channels); static void midiSend(LADSPA_Handle instance, - snd_seq_event_t *events, - unsigned long eventCount); + snd_seq_event_t *events, + unsigned long eventCount); static int requestNonRTThread(LADSPA_Handle instance, - void (*runFunction)(LADSPA_Handle)); + void (*runFunction)(LADSPA_Handle)); int m_client; int m_position; @@ -156,16 +156,16 @@ std::vector m_audioPortsOut; struct ProgramControl { - int msb; - int lsb; - int program; + int msb; + int lsb; + int program; }; ProgramControl m_pending; struct ProgramDescriptor { - int bank; - int program; - std::string name; + int bank; + int program; + std::string name; }; mutable std::vector m_cachedPrograms; mutable bool m_programCacheValid; @@ -203,19 +203,19 @@ class NonRTPluginThread : public Thread { public: - NonRTPluginThread(LADSPA_Handle handle, - void (*runFunction)(LADSPA_Handle)) : - m_handle(handle), - m_runFunction(runFunction), - m_exiting(false) { } + NonRTPluginThread(LADSPA_Handle handle, + void (*runFunction)(LADSPA_Handle)) : + m_handle(handle), + m_runFunction(runFunction), + m_exiting(false) { } - virtual void run(); - void setExiting() { m_exiting = true; } + virtual void run(); + void setExiting() { m_exiting = true; } protected: - LADSPA_Handle m_handle; - void (*m_runFunction)(LADSPA_Handle); - bool m_exiting; + LADSPA_Handle m_handle; + void (*m_runFunction)(LADSPA_Handle); + bool m_exiting; }; static std::map > m_threads; }; diff -r deabf9fd3d28 -r a12fd0456f0c plugin/LADSPAPluginFactory.cpp --- a/plugin/LADSPAPluginFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/LADSPAPluginFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -51,9 +51,9 @@ LADSPAPluginFactory::~LADSPAPluginFactory() { for (std::set::iterator i = m_instances.begin(); - i != m_instances.end(); ++i) { - (*i)->setFactory(0); - delete *i; + i != m_instances.end(); ++i) { + (*i)->setFactory(0); + delete *i; } m_instances.clear(); unloadUnusedLibraries(); @@ -75,62 +75,62 @@ Profiler profiler("LADSPAPluginFactory::enumeratePlugins"); for (std::vector::iterator i = m_identifiers.begin(); - i != m_identifiers.end(); ++i) { + i != m_identifiers.end(); ++i) { - const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i); + const LADSPA_Descriptor *descriptor = getLADSPADescriptor(*i); - if (!descriptor) { - cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << *i << endl; - continue; - } - - list.push_back(*i); - list.push_back(descriptor->Name); - list.push_back(QString("%1").arg(descriptor->UniqueID)); - list.push_back(descriptor->Label); - list.push_back(descriptor->Maker); - list.push_back(descriptor->Copyright); - list.push_back("false"); // is synth - list.push_back("false"); // is grouped + if (!descriptor) { + cerr << "WARNING: LADSPAPluginFactory::enumeratePlugins: couldn't get descriptor for identifier " << *i << endl; + continue; + } + + list.push_back(*i); + list.push_back(descriptor->Name); + list.push_back(QString("%1").arg(descriptor->UniqueID)); + list.push_back(descriptor->Label); + list.push_back(descriptor->Maker); + list.push_back(descriptor->Copyright); + list.push_back("false"); // is synth + list.push_back("false"); // is grouped - if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") { -// cerr << "LADSPAPluginFactory: cat for " << *i << " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << endl; - list.push_back(m_taxonomy[*i]); - } else { - list.push_back(""); -// cerr << "LADSPAPluginFactory: cat for " << *i << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << endl; - - } + if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") { +// cerr << "LADSPAPluginFactory: cat for " << *i << " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << endl; + list.push_back(m_taxonomy[*i]); + } else { + list.push_back(""); +// cerr << "LADSPAPluginFactory: cat for " << *i << " not found (despite having " << m_fallbackCategories.size() << " fallbacks)" << endl; + + } - list.push_back(QString("%1").arg(descriptor->PortCount)); + list.push_back(QString("%1").arg(descriptor->PortCount)); - for (int p = 0; p < (int)descriptor->PortCount; ++p) { + for (int p = 0; p < (int)descriptor->PortCount; ++p) { - int type = 0; - if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { - type |= PortType::Control; - } else { - type |= PortType::Audio; - } - if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) { - type |= PortType::Input; - } else { - type |= PortType::Output; - } + int type = 0; + if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { + type |= PortType::Control; + } else { + type |= PortType::Audio; + } + if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[p])) { + type |= PortType::Input; + } else { + type |= PortType::Output; + } - list.push_back(QString("%1").arg(p)); - list.push_back(descriptor->PortNames[p]); - list.push_back(QString("%1").arg(type)); - list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p))); - list.push_back(QString("%1").arg(getPortMinimum(descriptor, p))); - list.push_back(QString("%1").arg(getPortMaximum(descriptor, p))); - list.push_back(QString("%1").arg(getPortDefault(descriptor, p))); - } + list.push_back(QString("%1").arg(p)); + list.push_back(descriptor->PortNames[p]); + list.push_back(QString("%1").arg(type)); + list.push_back(QString("%1").arg(getPortDisplayHint(descriptor, p))); + list.push_back(QString("%1").arg(getPortMinimum(descriptor, p))); + list.push_back(QString("%1").arg(getPortMaximum(descriptor, p))); + list.push_back(QString("%1").arg(getPortDefault(descriptor, p))); + } } unloadUnusedLibraries(); } - + const RealTimePluginDescriptor * LADSPAPluginFactory::getPluginDescriptor(QString identifier) const { @@ -148,20 +148,20 @@ LADSPAPluginFactory::getPortMinimum(const LADSPA_Descriptor *descriptor, int port) { LADSPA_PortRangeHintDescriptor d = - descriptor->PortRangeHints[port].HintDescriptor; + descriptor->PortRangeHints[port].HintDescriptor; float minimum = 0.f; - + if (LADSPA_IS_HINT_BOUNDED_BELOW(d)) { - float lb = descriptor->PortRangeHints[port].LowerBound; - minimum = lb; + float lb = descriptor->PortRangeHints[port].LowerBound; + minimum = lb; } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { - float ub = descriptor->PortRangeHints[port].UpperBound; - minimum = std::min(0.f, ub - 1.f); + float ub = descriptor->PortRangeHints[port].UpperBound; + minimum = std::min(0.f, ub - 1.f); } if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { - minimum = float(minimum * m_sampleRate); + minimum = float(minimum * m_sampleRate); } if (LADSPA_IS_HINT_LOGARITHMIC(d)) { @@ -175,20 +175,20 @@ LADSPAPluginFactory::getPortMaximum(const LADSPA_Descriptor *descriptor, int port) { LADSPA_PortRangeHintDescriptor d = - descriptor->PortRangeHints[port].HintDescriptor; + descriptor->PortRangeHints[port].HintDescriptor; float maximum = 1.f; if (LADSPA_IS_HINT_BOUNDED_ABOVE(d)) { - float ub = descriptor->PortRangeHints[port].UpperBound; - maximum = ub; + float ub = descriptor->PortRangeHints[port].UpperBound; + maximum = ub; } else { - float lb = descriptor->PortRangeHints[port].LowerBound; - maximum = lb + 1.f; + float lb = descriptor->PortRangeHints[port].LowerBound; + maximum = lb + 1.f; } if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { - maximum = float(maximum * m_sampleRate); + maximum = float(maximum * m_sampleRate); } return maximum; @@ -202,19 +202,19 @@ float deft; if (m_portDefaults.find(descriptor->UniqueID) != - m_portDefaults.end()) { - if (m_portDefaults[descriptor->UniqueID].find(port) != - m_portDefaults[descriptor->UniqueID].end()) { + m_portDefaults.end()) { + if (m_portDefaults[descriptor->UniqueID].find(port) != + m_portDefaults[descriptor->UniqueID].end()) { - deft = m_portDefaults[descriptor->UniqueID][port]; - if (deft < minimum) deft = minimum; - if (deft > maximum) deft = maximum; - return deft; - } + deft = m_portDefaults[descriptor->UniqueID][port]; + if (deft < minimum) deft = minimum; + if (deft > maximum) deft = maximum; + return deft; + } } LADSPA_PortRangeHintDescriptor d = - descriptor->PortRangeHints[port].HintDescriptor; + descriptor->PortRangeHints[port].HintDescriptor; bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC(d); @@ -230,61 +230,61 @@ // SVDEBUG << "LADSPAPluginFactory::getPortDefault: hint = " << d << endl; if (!LADSPA_IS_HINT_HAS_DEFAULT(d)) { - - deft = minimum; - + + deft = minimum; + } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM(d)) { - - deft = minimum; - + + deft = minimum; + } else if (LADSPA_IS_HINT_DEFAULT_LOW(d)) { - - if (logarithmic) { - deft = powf(10, logmin * 0.75f + logmax * 0.25f); - } else { - deft = minimum * 0.75f + maximum * 0.25f; - } - + + if (logarithmic) { + deft = powf(10, logmin * 0.75f + logmax * 0.25f); + } else { + deft = minimum * 0.75f + maximum * 0.25f; + } + } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(d)) { - - if (logarithmic) { - deft = powf(10, logmin * 0.5f + logmax * 0.5f); - } else { - deft = minimum * 0.5f + maximum * 0.5f; - } - + + if (logarithmic) { + deft = powf(10, logmin * 0.5f + logmax * 0.5f); + } else { + deft = minimum * 0.5f + maximum * 0.5f; + } + } else if (LADSPA_IS_HINT_DEFAULT_HIGH(d)) { - - if (logarithmic) { - deft = powf(10, logmin * 0.25f + logmax * 0.75f); - } else { - deft = minimum * 0.25f + maximum * 0.75f; - } - + + if (logarithmic) { + deft = powf(10, logmin * 0.25f + logmax * 0.75f); + } else { + deft = minimum * 0.25f + maximum * 0.75f; + } + } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(d)) { - - deft = maximum; - + + deft = maximum; + } else if (LADSPA_IS_HINT_DEFAULT_0(d)) { - - deft = 0.0; - + + deft = 0.0; + } else if (LADSPA_IS_HINT_DEFAULT_1(d)) { - - deft = 1.0; - + + deft = 1.0; + } else if (LADSPA_IS_HINT_DEFAULT_100(d)) { - - deft = 100.0; - + + deft = 100.0; + } else if (LADSPA_IS_HINT_DEFAULT_440(d)) { - -// deft = 440.0; + +// deft = 440.0; deft = (float)Preferences::getInstance()->getTuningFrequency(); - + } else { - - deft = minimum; + + deft = minimum; } //!!! No -- the min and max have already been multiplied by the rate, @@ -292,7 +292,7 @@ //doesn't want to be multiplied by the rate either // if (LADSPA_IS_HINT_SAMPLE_RATE(d)) { -// deft *= m_sampleRate; +// deft *= m_sampleRate; // } return deft; @@ -316,7 +316,7 @@ LADSPAPluginFactory::getPortDisplayHint(const LADSPA_Descriptor *descriptor, int port) { LADSPA_PortRangeHintDescriptor d = - descriptor->PortRangeHints[port].HintDescriptor; + descriptor->PortRangeHints[port].HintDescriptor; int hint = PortHint::NoHint; if (LADSPA_IS_HINT_TOGGLED(d)) hint |= PortHint::Toggled; @@ -329,11 +329,11 @@ RealTimePluginInstance * LADSPAPluginFactory::instantiatePlugin(QString identifier, - int instrument, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int channels) + int instrument, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int channels) { Profiler profiler("LADSPAPluginFactory::instantiatePlugin"); @@ -341,19 +341,19 @@ if (descriptor) { - LADSPAPluginInstance *instance = - new LADSPAPluginInstance - (this, instrument, identifier, position, sampleRate, blockSize, channels, - descriptor); + LADSPAPluginInstance *instance = + new LADSPAPluginInstance + (this, instrument, identifier, position, sampleRate, blockSize, channels, + descriptor); - m_instances.insert(instance); + m_instances.insert(instance); #ifdef DEBUG_LADSPA_PLUGIN_FACTORY SVDEBUG << "LADSPAPluginFactory::instantiatePlugin(" << identifier << ": now have " << m_instances.size() << " instances" << endl; #endif - return instance; + return instance; } return 0; @@ -361,14 +361,14 @@ void LADSPAPluginFactory::releasePlugin(RealTimePluginInstance *instance, - QString identifier) + QString identifier) { Profiler profiler("LADSPAPluginFactory::releasePlugin"); if (m_instances.find(instance) == m_instances.end()) { - cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!" - << endl; - return; + cerr << "WARNING: LADSPAPluginFactory::releasePlugin: Not one of mine!" + << endl; + return; } QString type, soname, label; @@ -379,16 +379,16 @@ bool stillInUse = false; for (std::set::iterator ii = m_instances.begin(); - ii != m_instances.end(); ++ii) { - QString itype, isoname, ilabel; - PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); - if (isoname == soname) { + ii != m_instances.end(); ++ii) { + QString itype, isoname, ilabel; + PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); + if (isoname == soname) { #ifdef DEBUG_LADSPA_PLUGIN_FACTORY - SVDEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << endl; + SVDEBUG << "LADSPAPluginFactory::releasePlugin: dll " << soname << " is still in use for plugin " << ilabel << endl; #endif - stillInUse = true; - break; - } + stillInUse = true; + break; + } } if (!stillInUse) { @@ -413,29 +413,29 @@ PluginIdentifier::parseIdentifier(identifier, type, soname, label); if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { - loadLibrary(soname); - if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { - cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << endl; - return 0; - } + loadLibrary(soname); + if (m_libraryHandles.find(soname) == m_libraryHandles.end()) { + cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: loadLibrary failed for " << soname << endl; + return 0; + } } void *libraryHandle = m_libraryHandles[soname]; LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) - DLSYM(libraryHandle, "ladspa_descriptor"); + DLSYM(libraryHandle, "ladspa_descriptor"); if (!fn) { - cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << endl; - return 0; + cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No descriptor function in library " << soname << endl; + return 0; } const LADSPA_Descriptor *descriptor = 0; int index = 0; while ((descriptor = fn(index))) { - if (descriptor->Label == label) return descriptor; - ++index; + if (descriptor->Label == label) return descriptor; + ++index; } cerr << "WARNING: LADSPAPluginFactory::getLADSPADescriptor: No such plugin as " << label << " in library " << soname << endl; @@ -465,7 +465,7 @@ QString base = QFileInfo(soName).baseName(); for (std::vector::iterator i = pathList.begin(); - i != pathList.end(); ++i) { + i != pathList.end(); ++i) { #ifdef DEBUG_LADSPA_PLUGIN_FACTORY SVDEBUG << "Looking at: " << (*i) << endl; @@ -486,7 +486,7 @@ } } - for (unsigned int j = 0; j < dir.count(); ++j) { + for (unsigned int j = 0; j < dir.count(); ++j) { QString file = dir.filePath(dir[j]); if (QFileInfo(file).baseName() == base) { #ifdef DEBUG_LADSPA_PLUGIN_FACTORY @@ -509,9 +509,9 @@ { LibraryHandleMap::iterator li = m_libraryHandles.find(soName); if (li != m_libraryHandles.end()) { -// SVDEBUG << "unloading " << soname << endl; - DLCLOSE(m_libraryHandles[soName]); - m_libraryHandles.erase(li); +// SVDEBUG << "unloading " << soname << endl; + DLCLOSE(m_libraryHandles[soName]); + m_libraryHandles.erase(li); } } @@ -521,26 +521,26 @@ std::vector toUnload; for (LibraryHandleMap::iterator i = m_libraryHandles.begin(); - i != m_libraryHandles.end(); ++i) { + i != m_libraryHandles.end(); ++i) { - bool stillInUse = false; + bool stillInUse = false; - for (std::set::iterator ii = m_instances.begin(); - ii != m_instances.end(); ++ii) { + for (std::set::iterator ii = m_instances.begin(); + ii != m_instances.end(); ++ii) { - QString itype, isoname, ilabel; - PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); - if (isoname == i->first) { - stillInUse = true; - break; - } - } + QString itype, isoname, ilabel; + PluginIdentifier::parseIdentifier((*ii)->getPluginIdentifier(), itype, isoname, ilabel); + if (isoname == i->first) { + stillInUse = true; + break; + } + } - if (!stillInUse) toUnload.push_back(i->first); + if (!stillInUse) toUnload.push_back(i->first); } for (std::vector::iterator i = toUnload.begin(); - i != toUnload.end(); ++i) { + i != toUnload.end(); ++i) { if (*i != PluginIdentifier::BUILTIN_PLUGIN_SONAME) { unloadLibrary(*i); } @@ -569,8 +569,8 @@ path = DEFAULT_LADSPA_PATH; - char *home = getenv("HOME"); - if (home) { + char *home = getenv("HOME"); + if (home) { std::string::size_type f; while ((f = path.find("$HOME")) != std::string::npos && f < path.length()) { @@ -594,8 +594,8 @@ std::string::size_type index = 0, newindex = 0; while ((newindex = path.find(PATH_SEPARATOR, index)) < path.size()) { - pathList.push_back(path.substr(index, newindex - index).c_str()); - index = newindex + 1; + pathList.push_back(path.substr(index, newindex - index).c_str()); + index = newindex + 1; } pathList.push_back(path.substr(index).c_str()); @@ -616,8 +616,8 @@ lrdfPaths.push_back("/usr/share/ladspa/rdf"); for (std::vector::iterator i = pathList.begin(); - i != pathList.end(); ++i) { - lrdfPaths.push_back(*i + "/rdf"); + i != pathList.end(); ++i) { + lrdfPaths.push_back(*i + "/rdf"); } baseUri = LADSPA_BASE; @@ -636,10 +636,10 @@ std::vector pathList = getPluginPath(); // SVDEBUG << "LADSPAPluginFactory::discoverPlugins - " -// << "discovering plugins; path is "; +// << "discovering plugins; path is "; // for (std::vector::iterator i = pathList.begin(); -// i != pathList.end(); ++i) { -// SVDEBUG << "[" << i-<< "] "; +// i != pathList.end(); ++i) { +// SVDEBUG << "[" << i-<< "] "; // } // SVDEBUG << endl; @@ -652,17 +652,17 @@ bool haveSomething = false; for (size_t i = 0; i < lrdfPaths.size(); ++i) { - QDir dir(lrdfPaths[i], "*.rdf;*.rdfs"); - for (unsigned int j = 0; j < dir.count(); ++j) { - if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) { -// cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << endl; - haveSomething = true; - } - } + QDir dir(lrdfPaths[i], "*.rdf;*.rdfs"); + for (unsigned int j = 0; j < dir.count(); ++j) { + if (!lrdf_read_file(QString("file:" + lrdfPaths[i] + "/" + dir[j]).toStdString().c_str())) { +// cerr << "LADSPAPluginFactory: read RDF file " << (lrdfPaths[i] + "/" + dir[j]) << endl; + haveSomething = true; + } + } } if (haveSomething) { - generateTaxonomy(baseUri + "Plugin", ""); + generateTaxonomy(baseUri + "Plugin", ""); } #endif // HAVE_LRDF @@ -688,11 +688,11 @@ } LADSPA_Descriptor_Function fn = (LADSPA_Descriptor_Function) - DLSYM(libraryHandle, "ladspa_descriptor"); + DLSYM(libraryHandle, "ladspa_descriptor"); if (!fn) { - cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << endl; - return; + cerr << "WARNING: LADSPAPluginFactory::discoverPlugins: No descriptor function in " << soname << endl; + return; } const LADSPA_Descriptor *descriptor = 0; @@ -712,67 +712,67 @@ rtd->audioOutputPortCount = 0; rtd->controlOutputPortCount = 0; - QString identifier = PluginIdentifier::createIdentifier - ("ladspa", soname, descriptor->Label); + QString identifier = PluginIdentifier::createIdentifier + ("ladspa", soname, descriptor->Label); #ifdef HAVE_LRDF - char *def_uri = 0; - lrdf_defaults *defs = 0; - + char *def_uri = 0; + lrdf_defaults *defs = 0; + if (m_lrdfTaxonomy[descriptor->UniqueID] != "") { m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID]; // cerr << "set id \"" << identifier << "\" to cat \"" << m_taxonomy[identifier] << "\" from LRDF" << endl; // cout << identifier << "::" << m_taxonomy[identifier] << endl; } - QString category = m_taxonomy[identifier]; - - if (category == "") { - std::string name = rtd->name; - if (name.length() > 4 && - name.substr(name.length() - 4) == " VST") { - category = "VST effects"; - m_taxonomy[identifier] = category; - } - } - + QString category = m_taxonomy[identifier]; + + if (category == "") { + std::string name = rtd->name; + if (name.length() > 4 && + name.substr(name.length() - 4) == " VST") { + category = "VST effects"; + m_taxonomy[identifier] = category; + } + } + rtd->category = category.toStdString(); -// cerr << "Plugin id is " << descriptor->UniqueID -// << ", category is \"" << (category ? category : QString("(none)")) -// << "\", name is " << descriptor->Name -// << ", label is " << descriptor->Label -// << endl; - - def_uri = lrdf_get_default_uri(descriptor->UniqueID); - if (def_uri) { - defs = lrdf_get_setting_values(def_uri); - } +// cerr << "Plugin id is " << descriptor->UniqueID +// << ", category is \"" << (category ? category : QString("(none)")) +// << "\", name is " << descriptor->Name +// << ", label is " << descriptor->Label +// << endl; + + def_uri = lrdf_get_default_uri(descriptor->UniqueID); + if (def_uri) { + defs = lrdf_get_setting_values(def_uri); + } - unsigned int controlPortNumber = 1; - - for (int i = 0; i < (int)descriptor->PortCount; i++) { - - if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { - - if (def_uri && defs) { - - for (unsigned int j = 0; j < defs->count; j++) { - if (defs->items[j].pid == controlPortNumber) { -// cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << endl; - m_portDefaults[descriptor->UniqueID][i] = - defs->items[j].value; - } - } - } - - ++controlPortNumber; - } - } + unsigned int controlPortNumber = 1; + + for (int i = 0; i < (int)descriptor->PortCount; i++) { + + if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { + + if (def_uri && defs) { + + for (unsigned int j = 0; j < defs->count; j++) { + if (defs->items[j].pid == controlPortNumber) { +// cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << descriptor->PortNames[i] << endl; + m_portDefaults[descriptor->UniqueID][i] = + defs->items[j].value; + } + } + } + + ++controlPortNumber; + } + } #endif // HAVE_LRDF - for (int i = 0; i < (int)descriptor->PortCount; i++) { - if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { + for (int i = 0; i < (int)descriptor->PortCount; i++) { + if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i])) { if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { ++rtd->parameterCount; } else { @@ -792,11 +792,11 @@ } } - m_identifiers.push_back(identifier); + m_identifiers.push_back(identifier); m_rtDescriptors[identifier] = rtd; - ++index; + ++index; } if (DLCLOSE(libraryHandle) != 0) { @@ -812,44 +812,44 @@ std::vector path; for (size_t i = 0; i < pluginPath.size(); ++i) { - if (pluginPath[i].contains("/lib/")) { - QString p(pluginPath[i]); + if (pluginPath[i].contains("/lib/")) { + QString p(pluginPath[i]); path.push_back(p); - p.replace("/lib/", "/share/"); - path.push_back(p); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << endl; - } - path.push_back(pluginPath[i]); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << endl; + p.replace("/lib/", "/share/"); + path.push_back(p); +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << endl; + } + path.push_back(pluginPath[i]); +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << endl; } for (size_t i = 0; i < path.size(); ++i) { - QDir dir(path[i], "*.cat"); + QDir dir(path[i], "*.cat"); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; - for (unsigned int j = 0; j < dir.count(); ++j) { +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; + for (unsigned int j = 0; j < dir.count(); ++j) { - QFile file(path[i] + "/" + dir[j]); + QFile file(path[i] + "/" + dir[j]); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; - if (file.open(QIODevice::ReadOnly)) { -// cerr << "...opened" << endl; - QTextStream stream(&file); - QString line; + if (file.open(QIODevice::ReadOnly)) { +// cerr << "...opened" << endl; + QTextStream stream(&file); + QString line; - while (!stream.atEnd()) { - line = stream.readLine(); -// cerr << "line is: \"" << line << "\"" << endl; - QString id = PluginIdentifier::canonicalise + while (!stream.atEnd()) { + line = stream.readLine(); +// cerr << "line is: \"" << line << "\"" << endl; + QString id = PluginIdentifier::canonicalise (line.section("::", 0, 0)); - QString cat = line.section("::", 1, 1); - m_taxonomy[id] = cat; -// cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << endl; - } - } - } + QString cat = line.section("::", 1, 1); + m_taxonomy[id] = cat; +// cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << endl; + } + } + } } } @@ -860,21 +860,21 @@ lrdf_uris *uris = lrdf_get_instances(uri.toStdString().c_str()); if (uris != NULL) { - for (unsigned int i = 0; i < uris->count; ++i) { - m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base; - } - lrdf_free_uris(uris); + for (unsigned int i = 0; i < uris->count; ++i) { + m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base; + } + lrdf_free_uris(uris); } uris = lrdf_get_subclasses(uri.toStdString().c_str()); if (uris != NULL) { - for (unsigned int i = 0; i < uris->count; ++i) { - char *label = lrdf_get_label(uris->items[i]); - generateTaxonomy(uris->items[i], - base + (base.length() > 0 ? " > " : "") + label); - } - lrdf_free_uris(uris); + for (unsigned int i = 0; i < uris->count; ++i) { + char *label = lrdf_get_label(uris->items[i]); + generateTaxonomy(uris->items[i], + base + (base.length() > 0 ? " > " : "") + label); + } + lrdf_free_uris(uris); } #else // avoid unused parameter diff -r deabf9fd3d28 -r a12fd0456f0c plugin/LADSPAPluginFactory.h --- a/plugin/LADSPAPluginFactory.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/LADSPAPluginFactory.h Tue Apr 17 10:35:42 2018 +0100 @@ -47,11 +47,11 @@ virtual const RealTimePluginDescriptor *getPluginDescriptor(QString identifier) const; virtual RealTimePluginInstance *instantiatePlugin(QString identifier, - int clientId, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int channels); + int clientId, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int channels); virtual QString getPluginCategory(QString identifier); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/LADSPAPluginInstance.cpp --- a/plugin/LADSPAPluginInstance.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/LADSPAPluginInstance.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -34,12 +34,12 @@ LADSPAPluginInstance::LADSPAPluginInstance(RealTimePluginFactory *factory, - int clientId, - QString identifier, + int clientId, + QString identifier, int position, - sv_samplerate_t sampleRate, - int blockSize, - int idealChannelCount, + sv_samplerate_t sampleRate, + int blockSize, + int idealChannelCount, const LADSPA_Descriptor* descriptor) : RealTimePluginInstance(factory, identifier), m_client(clientId), @@ -67,18 +67,18 @@ } for (size_t i = 0; i < m_instanceCount * m_audioPortsIn.size(); ++i) { - m_inputBuffers[i] = new sample_t[blockSize]; + m_inputBuffers[i] = new sample_t[blockSize]; } for (size_t i = 0; i < m_instanceCount * m_audioPortsOut.size(); ++i) { - m_outputBuffers[i] = new sample_t[blockSize]; + m_outputBuffers[i] = new sample_t[blockSize]; } m_ownBuffers = true; instantiate(sampleRate); if (isOK()) { - connectPorts(); - activate(); + connectPorts(); + activate(); } } @@ -222,7 +222,7 @@ { #ifdef DEBUG_LADSPA SVDEBUG << "LADSPAPluginInstance::init(" << idealChannelCount << "): plugin has " - << m_descriptor->PortCount << " ports" << endl; + << m_descriptor->PortCount << " ports" << endl; #endif // Discover ports numbers and identities @@ -233,44 +233,44 @@ if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) { #ifdef DEBUG_LADSPA - SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is audio in" << endl; + SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is audio in" << endl; #endif m_audioPortsIn.push_back(i); - } else { + } else { #ifdef DEBUG_LADSPA - SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is audio out" << endl; + SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is audio out" << endl; #endif m_audioPortsOut.push_back(i); - } + } } else if (LADSPA_IS_PORT_CONTROL(m_descriptor->PortDescriptors[i])) { - if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) { + if (LADSPA_IS_PORT_INPUT(m_descriptor->PortDescriptors[i])) { #ifdef DEBUG_LADSPA - SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is control in" << endl; + SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is control in" << endl; #endif - LADSPA_Data *data = new LADSPA_Data(0.0); - m_controlPortsIn.push_back( + LADSPA_Data *data = new LADSPA_Data(0.0); + m_controlPortsIn.push_back( std::pair(i, data)); - } else { + } else { #ifdef DEBUG_LADSPA - SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is control out" << endl; + SVDEBUG << "LADSPAPluginInstance::init: port " << i << " is control out" << endl; #endif - LADSPA_Data *data = new LADSPA_Data(0.0); - m_controlPortsOut.push_back( + LADSPA_Data *data = new LADSPA_Data(0.0); + m_controlPortsOut.push_back( std::pair(i, data)); - if (!strcmp(m_descriptor->PortNames[i], "latency") || - !strcmp(m_descriptor->PortNames[i], "_latency")) { + if (!strcmp(m_descriptor->PortNames[i], "latency") || + !strcmp(m_descriptor->PortNames[i], "_latency")) { #ifdef DEBUG_LADSPA - cerr << "Wooo! We have a latency port!" << endl; + cerr << "Wooo! We have a latency port!" << endl; #endif - m_latencyPort = data; - } + m_latencyPort = data; + } - } + } } #ifdef DEBUG_LADSPA else @@ -282,10 +282,10 @@ m_instanceCount = 1; if (idealChannelCount > 0) { - if (m_audioPortsIn.size() == 1) { - // mono plugin: duplicate it if need be - m_instanceCount = idealChannelCount; - } + if (m_audioPortsIn.size() == 1) { + // mono plugin: duplicate it if need be + m_instanceCount = idealChannelCount; + } } } @@ -293,7 +293,7 @@ LADSPAPluginInstance::getLatency() { if (m_latencyPort) { - if (!m_run) { + if (!m_run) { for (int i = 0; i < getAudioInputCount(); ++i) { for (int j = 0; j < m_blockSize; ++j) { m_inputBuffers[i][j] = 0.f; @@ -301,7 +301,7 @@ } run(Vamp::RealTime::zeroTime); } - if (*m_latencyPort > 0) return (sv_frame_t)*m_latencyPort; + if (*m_latencyPort > 0) return (sv_frame_t)*m_latencyPort; } return 0; } @@ -310,8 +310,8 @@ LADSPAPluginInstance::silence() { if (isOK()) { - deactivate(); - activate(); + deactivate(); + activate(); } } @@ -319,12 +319,12 @@ LADSPAPluginInstance::setIdealChannelCount(int channels) { if (m_audioPortsIn.size() != 1 || channels == m_instanceCount) { - silence(); - return; + silence(); + return; } if (isOK()) { - deactivate(); + deactivate(); } //!!! don't we need to reallocate inputBuffers and outputBuffers? @@ -333,8 +333,8 @@ m_instanceCount = channels; instantiate(m_sampleRate); if (isOK()) { - connectPorts(); - activate(); + connectPorts(); + activate(); } } @@ -346,7 +346,7 @@ #endif if (m_instanceHandles.size() != 0) { // "isOK()" - deactivate(); + deactivate(); } cleanup(); @@ -361,15 +361,15 @@ m_controlPortsOut.clear(); if (m_ownBuffers) { - for (size_t i = 0; i < m_instanceCount * m_audioPortsIn.size(); ++i) { - delete[] m_inputBuffers[i]; - } - for (size_t i = 0; i < m_instanceCount * m_audioPortsOut.size(); ++i) { - delete[] m_outputBuffers[i]; - } + for (size_t i = 0; i < m_instanceCount * m_audioPortsIn.size(); ++i) { + delete[] m_inputBuffers[i]; + } + for (size_t i = 0; i < m_instanceCount * m_audioPortsOut.size(); ++i) { + delete[] m_outputBuffers[i]; + } - delete[] m_inputBuffers; - delete[] m_outputBuffers; + delete[] m_inputBuffers; + delete[] m_outputBuffers; } m_audioPortsIn.clear(); @@ -388,10 +388,10 @@ #endif if (!m_descriptor->instantiate) { - cerr << "Bad plugin: plugin id " << m_descriptor->UniqueID - << ":" << m_descriptor->Label - << " has no instantiate method!" << endl; - return; + cerr << "Bad plugin: plugin id " << m_descriptor->UniqueID + << ":" << m_descriptor->Label + << " has no instantiate method!" << endl; + return; } unsigned long pluginRate = (unsigned long)(sampleRate); @@ -402,8 +402,8 @@ } for (int i = 0; i < m_instanceCount; ++i) { - m_instanceHandles.push_back - (m_descriptor->instantiate(m_descriptor, pluginRate)); + m_instanceHandles.push_back + (m_descriptor->instantiate(m_descriptor, pluginRate)); } } @@ -413,8 +413,8 @@ if (!m_descriptor || !m_descriptor->activate) return; for (std::vector::iterator hi = m_instanceHandles.begin(); - hi != m_instanceHandles.end(); ++hi) { - m_descriptor->activate(*hi); + hi != m_instanceHandles.end(); ++hi) { + m_descriptor->activate(*hi); } } @@ -430,44 +430,44 @@ int inbuf = 0, outbuf = 0; for (std::vector::iterator hi = m_instanceHandles.begin(); - hi != m_instanceHandles.end(); ++hi) { + hi != m_instanceHandles.end(); ++hi) { - for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) { - m_descriptor->connect_port(*hi, - m_audioPortsIn[i], - (LADSPA_Data *)m_inputBuffers[inbuf]); - ++inbuf; - } + for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) { + m_descriptor->connect_port(*hi, + m_audioPortsIn[i], + (LADSPA_Data *)m_inputBuffers[inbuf]); + ++inbuf; + } - for (unsigned int i = 0; i < m_audioPortsOut.size(); ++i) { - m_descriptor->connect_port(*hi, - m_audioPortsOut[i], - (LADSPA_Data *)m_outputBuffers[outbuf]); - ++outbuf; - } + for (unsigned int i = 0; i < m_audioPortsOut.size(); ++i) { + m_descriptor->connect_port(*hi, + m_audioPortsOut[i], + (LADSPA_Data *)m_outputBuffers[outbuf]); + ++outbuf; + } - // If there is more than one instance, they all share the same - // control port ins (and outs, for the moment, because we - // don't actually do anything with the outs anyway -- but they - // do have to be connected as the plugin can't know if they're - // not and will write to them anyway). + // If there is more than one instance, they all share the same + // control port ins (and outs, for the moment, because we + // don't actually do anything with the outs anyway -- but they + // do have to be connected as the plugin can't know if they're + // not and will write to them anyway). - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { - m_descriptor->connect_port(*hi, - m_controlPortsIn[i].first, - m_controlPortsIn[i].second); + for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + m_descriptor->connect_port(*hi, + m_controlPortsIn[i].first, + m_controlPortsIn[i].second); if (f) { float defaultValue = f->getPortDefault (m_descriptor, m_controlPortsIn[i].first); *m_controlPortsIn[i].second = defaultValue; } - } + } - for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { - m_descriptor->connect_port(*hi, - m_controlPortsOut[i].first, - m_controlPortsOut[i].second); - } + for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { + m_descriptor->connect_port(*hi, + m_controlPortsOut[i].first, + m_controlPortsOut[i].second); + } } } @@ -486,12 +486,12 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - if (value < f->getPortMinimum(m_descriptor, portNumber)) { - value = f->getPortMinimum(m_descriptor, portNumber); - } - if (value > f->getPortMaximum(m_descriptor, portNumber)) { - value = f->getPortMaximum(m_descriptor, portNumber); - } + if (value < f->getPortMinimum(m_descriptor, portNumber)) { + value = f->getPortMinimum(m_descriptor, portNumber); + } + if (value > f->getPortMaximum(m_descriptor, portNumber)) { + value = f->getPortMaximum(m_descriptor, portNumber); + } } (*m_controlPortsIn[parameter].second) = value; @@ -518,9 +518,9 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - return f->getPortDefault(m_descriptor, m_controlPortsIn[parameter].first); + return f->getPortDefault(m_descriptor, m_controlPortsIn[parameter].first); } else { - return 0.0f; + return 0.0f; } } @@ -531,9 +531,9 @@ LADSPAPluginFactory *f = dynamic_cast(m_factory); if (f) { - return f->getPortDisplayHint(m_descriptor, m_controlPortsIn[parameter].first); + return f->getPortDisplayHint(m_descriptor, m_controlPortsIn[parameter].first); } else { - return PortHint::NoHint; + return PortHint::NoHint; } } @@ -545,7 +545,7 @@ if (count == 0) count = m_blockSize; for (std::vector::iterator hi = m_instanceHandles.begin(); - hi != m_instanceHandles.end(); ++hi) { + hi != m_instanceHandles.end(); ++hi) { m_descriptor->run(*hi, count); } @@ -559,7 +559,7 @@ if (!m_descriptor || !m_descriptor->deactivate) return; for (std::vector::iterator hi = m_instanceHandles.begin(); - hi != m_instanceHandles.end(); ++hi) { + hi != m_instanceHandles.end(); ++hi) { m_descriptor->deactivate(*hi); } } @@ -570,15 +570,15 @@ if (!m_descriptor) return; if (!m_descriptor->cleanup) { - cerr << "Bad plugin: plugin id " << m_descriptor->UniqueID - << ":" << m_descriptor->Label - << " has no cleanup method!" << endl; - return; + cerr << "Bad plugin: plugin id " << m_descriptor->UniqueID + << ":" << m_descriptor->Label + << " has no cleanup method!" << endl; + return; } for (std::vector::iterator hi = m_instanceHandles.begin(); - hi != m_instanceHandles.end(); ++hi) { - m_descriptor->cleanup(*hi); + hi != m_instanceHandles.end(); ++hi) { + m_descriptor->cleanup(*hi); } m_instanceHandles.clear(); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/LADSPAPluginInstance.h --- a/plugin/LADSPAPluginInstance.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/LADSPAPluginInstance.h Tue Apr 17 10:35:42 2018 +0100 @@ -89,12 +89,12 @@ // Constructor that creates the buffers internally // LADSPAPluginInstance(RealTimePluginFactory *factory, - int client, - QString identifier, + int client, + QString identifier, int position, - sv_samplerate_t sampleRate, - int blockSize, - int idealChannelCount, + sv_samplerate_t sampleRate, + int blockSize, + int idealChannelCount, const LADSPA_Descriptor* descriptor); void init(int idealChannelCount = 0); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/NativeVampPluginFactory.cpp --- a/plugin/NativeVampPluginFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/NativeVampPluginFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -231,7 +231,7 @@ return file; } - for (unsigned int j = 0; j < dir.count(); ++j) { + for (unsigned int j = 0; j < dir.count(); ++j) { file = dir.filePath(dir[j]); if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) { @@ -304,7 +304,7 @@ #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE cerr << "NativeVampPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; #endif - return 0; + return 0; } QString found = findPluginFile(soname); @@ -399,42 +399,42 @@ vector path; for (size_t i = 0; i < pluginPath.size(); ++i) { - if (pluginPath[i].contains("/lib/")) { - QString p(pluginPath[i]); + if (pluginPath[i].contains("/lib/")) { + QString p(pluginPath[i]); path.push_back(p); - p.replace("/lib/", "/share/"); - path.push_back(p); - } - path.push_back(pluginPath[i]); + p.replace("/lib/", "/share/"); + path.push_back(p); + } + path.push_back(pluginPath[i]); } for (size_t i = 0; i < path.size(); ++i) { - QDir dir(path[i], "*.cat"); + QDir dir(path[i], "*.cat"); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; - for (unsigned int j = 0; j < dir.count(); ++j) { +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << endl; + for (unsigned int j = 0; j < dir.count(); ++j) { - QFile file(path[i] + "/" + dir[j]); + QFile file(path[i] + "/" + dir[j]); -// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; +// SVDEBUG << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i]+ "/" + dir[j]) << endl; - if (file.open(QIODevice::ReadOnly)) { -// cerr << "...opened" << endl; - QTextStream stream(&file); - QString line; + if (file.open(QIODevice::ReadOnly)) { +// cerr << "...opened" << endl; + QTextStream stream(&file); + QString line; - while (!stream.atEnd()) { - line = stream.readLine(); -// cerr << "line is: \"" << line << "\"" << endl; - QString id = PluginIdentifier::canonicalise + while (!stream.atEnd()) { + line = stream.readLine(); +// cerr << "line is: \"" << line << "\"" << endl; + QString id = PluginIdentifier::canonicalise (line.section("::", 0, 0)); - QString cat = line.section("::", 1, 1); - m_taxonomy[id] = cat; -// cerr << "NativeVampPluginFactory: set id \"" << id << "\" to cat \"" << cat << "\"" << endl; - } - } - } + QString cat = line.section("::", 1, 1); + m_taxonomy[id] = cat; +// cerr << "NativeVampPluginFactory: set id \"" << id << "\" to cat \"" << cat << "\"" << endl; + } + } + } } } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/PiperVampPluginFactory.cpp --- a/plugin/PiperVampPluginFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/PiperVampPluginFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -113,8 +113,7 @@ Profiler profiler("PiperVampPluginFactory::instantiatePlugin"); if (m_origins.find(identifier) == m_origins.end()) { - cerr << "ERROR: No known server for identifier " << identifier << endl; - SVDEBUG << "ERROR: No known server for identifier " << identifier << endl; + SVCERR << "ERROR: No known server for identifier " << identifier << endl; return 0; } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/PluginIdentifier.cpp --- a/plugin/PluginIdentifier.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/PluginIdentifier.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -24,8 +24,8 @@ QString PluginIdentifier::createIdentifier(QString type, - QString soName, - QString label) + QString soName, + QString label) { QString identifier = type + ":" + QFileInfo(soName).baseName() + ":" + label; return identifier; @@ -41,9 +41,9 @@ void PluginIdentifier::parseIdentifier(QString identifier, - QString &type, - QString &soName, - QString &label) + QString &type, + QString &soName, + QString &label) { type = identifier.section(':', 0, 0); soName = identifier.section(':', 1, 1); @@ -61,7 +61,7 @@ if (type1 != type2 || label1 != label2) return false; bool similar = (soName1.section('/', -1).section('.', 0, 0) == - soName2.section('/', -1).section('.', 0, 0)); + soName2.section('/', -1).section('.', 0, 0)); return similar; } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/PluginIdentifier.h --- a/plugin/PluginIdentifier.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/PluginIdentifier.h Tue Apr 17 10:35:42 2018 +0100 @@ -36,7 +36,7 @@ static QString canonicalise(QString identifier); static void parseIdentifier(QString identifier, - QString &type, QString &soName, QString &label); + QString &type, QString &soName, QString &label); static bool areIdentifiersSimilar(QString id1, QString id2); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/PluginScan.cpp --- a/plugin/PluginScan.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/PluginScan.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -190,16 +190,16 @@ QMutexLocker locker(&m_mutex); if (!m_succeeded) { - return QObject::tr("Failed to scan for plugins" - "

Failed to scan for plugins at startup. Possibly " + return QObject::tr("Failed to scan for plugins" + "

Failed to scan for plugins at startup. Possibly " "the plugin checker program was not correctly " "installed alongside %1?

") .arg(QCoreApplication::applicationName()); } if (m_kp.empty()) { - return QObject::tr("Did not scan for plugins" - "

Apparently no scan for plugins was attempted " - "(internal error?)

"); + return QObject::tr("Did not scan for plugins" + "

Apparently no scan for plugins was attempted " + "(internal error?)

"); } QString report; @@ -207,12 +207,12 @@ report += QString::fromStdString(kp.second->getFailureReport()); } if (report == "") { - return report; + return report; } return QObject::tr("Failed to load plugins" - "

Failed to load one or more plugin libraries:

") - + report + "

Failed to load one or more plugin libraries:

") + + report + QObject::tr("

These plugins may be incompatible with the system, " "and will be ignored during this run of %1.

") .arg(QCoreApplication::applicationName()); diff -r deabf9fd3d28 -r a12fd0456f0c plugin/PluginScan.h --- a/plugin/PluginScan.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/PluginScan.h Tue Apr 17 10:35:42 2018 +0100 @@ -45,9 +45,9 @@ bool scanSucceeded() const; enum PluginType { - VampPlugin, - LADSPAPlugin, - DSSIPlugin + VampPlugin, + LADSPAPlugin, + DSSIPlugin }; struct Candidate { QString libraryPath; // full path, not just soname diff -r deabf9fd3d28 -r a12fd0456f0c plugin/RealTimePluginFactory.cpp --- a/plugin/RealTimePluginFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/RealTimePluginFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -43,21 +43,21 @@ RealTimePluginFactory::instance(QString pluginType) { if (pluginType == "ladspa") { - if (!_ladspaInstance) { -// SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new LADSPAPluginFactory" << endl; - _ladspaInstance = new LADSPAPluginFactory(); - _ladspaInstance->discoverPlugins(); - } - return _ladspaInstance; + if (!_ladspaInstance) { +// SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new LADSPAPluginFactory" << endl; + _ladspaInstance = new LADSPAPluginFactory(); + _ladspaInstance->discoverPlugins(); + } + return _ladspaInstance; } else if (pluginType == "dssi") { - if (!_dssiInstance) { -// SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new DSSIPluginFactory" << endl; - _dssiInstance = new DSSIPluginFactory(); - _dssiInstance->discoverPlugins(); - } - return _dssiInstance; + if (!_dssiInstance) { +// SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new DSSIPluginFactory" << endl; + _dssiInstance = new DSSIPluginFactory(); + _dssiInstance->discoverPlugins(); + } + return _dssiInstance; } - + else return 0; } @@ -86,18 +86,18 @@ factory = instance("dssi"); if (factory) { - const std::vector &tmp = factory->getPluginIdentifiers(); - for (size_t i = 0; i < tmp.size(); ++i) { - rv.push_back(tmp[i]); - } + const std::vector &tmp = factory->getPluginIdentifiers(); + for (size_t i = 0; i < tmp.size(); ++i) { + rv.push_back(tmp[i]); + } } factory = instance("ladspa"); if (factory) { - const std::vector &tmp = factory->getPluginIdentifiers(); - for (size_t i = 0; i < tmp.size(); ++i) { - rv.push_back(tmp[i]); - } + const std::vector &tmp = factory->getPluginIdentifiers(); + for (size_t i = 0; i < tmp.size(); ++i) { + rv.push_back(tmp[i]); + } } // Plugins can change the locale, revert it to default. diff -r deabf9fd3d28 -r a12fd0456f0c plugin/RealTimePluginFactory.h --- a/plugin/RealTimePluginFactory.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/RealTimePluginFactory.h Tue Apr 17 10:35:42 2018 +0100 @@ -86,11 +86,11 @@ * Instantiate a plugin. */ virtual RealTimePluginInstance *instantiatePlugin(QString identifier, - int clientId, - int position, - sv_samplerate_t sampleRate, - int blockSize, - int channels) = 0; + int clientId, + int position, + sv_samplerate_t sampleRate, + int blockSize, + int channels) = 0; /** * Get category metadata about a plugin (without instantiating it). diff -r deabf9fd3d28 -r a12fd0456f0c plugin/RealTimePluginInstance.cpp --- a/plugin/RealTimePluginInstance.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/RealTimePluginInstance.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -31,9 +31,9 @@ // SVDEBUG << "RealTimePluginInstance::~RealTimePluginInstance" << endl; if (m_factory) { -// SVDEBUG << "Asking factory to release " << m_identifier << endl; +// SVDEBUG << "Asking factory to release " << m_identifier << endl; - m_factory->releasePlugin(this, m_identifier); + m_factory->releasePlugin(this, m_identifier); } } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/RealTimePluginInstance.h --- a/plugin/RealTimePluginInstance.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/RealTimePluginInstance.h Tue Apr 17 10:35:42 2018 +0100 @@ -33,7 +33,7 @@ #include class RealTimePluginFactory; - + /** * RealTimePluginInstance is an interface that an audio process can * use to refer to an instance of a plugin without needing to know @@ -121,7 +121,7 @@ virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); } virtual void sendEvent(const RealTime & /* eventTime */, - const void * /* event */) { } + const void * /* event */) { } virtual void clearEvents() { } virtual bool isBypassed() const = 0; @@ -145,7 +145,7 @@ protected: RealTimePluginInstance(RealTimePluginFactory *factory, QString identifier) : - m_factory(factory), m_identifier(identifier) { } + m_factory(factory), m_identifier(identifier) { } RealTimePluginFactory *m_factory; QString m_identifier; diff -r deabf9fd3d28 -r a12fd0456f0c plugin/api/alsa/asoundef.h --- a/plugin/api/alsa/asoundef.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/api/alsa/asoundef.h Tue Apr 17 10:35:42 2018 +0100 @@ -44,8 +44,8 @@ * \{ */ -#define MIDI_CHANNELS 16 /**< Number of channels per port/cable. */ -#define MIDI_GM_DRUM_CHANNEL (10-1) /**< Channel number for GM drums. */ +#define MIDI_CHANNELS 16 /**< Number of channels per port/cable. */ +#define MIDI_GM_DRUM_CHANNEL (10-1) /**< Channel number for GM drums. */ /** * \defgroup MIDI_Commands MIDI Commands @@ -53,26 +53,26 @@ * \{ */ -#define MIDI_CMD_NOTE_OFF 0x80 /**< note off */ -#define MIDI_CMD_NOTE_ON 0x90 /**< note on */ -#define MIDI_CMD_NOTE_PRESSURE 0xa0 /**< key pressure */ -#define MIDI_CMD_CONTROL 0xb0 /**< control change */ -#define MIDI_CMD_PGM_CHANGE 0xc0 /**< program change */ -#define MIDI_CMD_CHANNEL_PRESSURE 0xd0 /**< channel pressure */ -#define MIDI_CMD_BENDER 0xe0 /**< pitch bender */ +#define MIDI_CMD_NOTE_OFF 0x80 /**< note off */ +#define MIDI_CMD_NOTE_ON 0x90 /**< note on */ +#define MIDI_CMD_NOTE_PRESSURE 0xa0 /**< key pressure */ +#define MIDI_CMD_CONTROL 0xb0 /**< control change */ +#define MIDI_CMD_PGM_CHANGE 0xc0 /**< program change */ +#define MIDI_CMD_CHANNEL_PRESSURE 0xd0 /**< channel pressure */ +#define MIDI_CMD_BENDER 0xe0 /**< pitch bender */ -#define MIDI_CMD_COMMON_SYSEX 0xf0 /**< sysex (system exclusive) begin */ -#define MIDI_CMD_COMMON_MTC_QUARTER 0xf1 /**< MTC quarter frame */ -#define MIDI_CMD_COMMON_SONG_POS 0xf2 /**< song position */ -#define MIDI_CMD_COMMON_SONG_SELECT 0xf3 /**< song select */ -#define MIDI_CMD_COMMON_TUNE_REQUEST 0xf6 /**< tune request */ -#define MIDI_CMD_COMMON_SYSEX_END 0xf7 /**< end of sysex */ -#define MIDI_CMD_COMMON_CLOCK 0xf8 /**< clock */ -#define MIDI_CMD_COMMON_START 0xfa /**< start */ -#define MIDI_CMD_COMMON_CONTINUE 0xfb /**< continue */ -#define MIDI_CMD_COMMON_STOP 0xfc /**< stop */ -#define MIDI_CMD_COMMON_SENSING 0xfe /**< active sensing */ -#define MIDI_CMD_COMMON_RESET 0xff /**< reset */ +#define MIDI_CMD_COMMON_SYSEX 0xf0 /**< sysex (system exclusive) begin */ +#define MIDI_CMD_COMMON_MTC_QUARTER 0xf1 /**< MTC quarter frame */ +#define MIDI_CMD_COMMON_SONG_POS 0xf2 /**< song position */ +#define MIDI_CMD_COMMON_SONG_SELECT 0xf3 /**< song select */ +#define MIDI_CMD_COMMON_TUNE_REQUEST 0xf6 /**< tune request */ +#define MIDI_CMD_COMMON_SYSEX_END 0xf7 /**< end of sysex */ +#define MIDI_CMD_COMMON_CLOCK 0xf8 /**< clock */ +#define MIDI_CMD_COMMON_START 0xfa /**< start */ +#define MIDI_CMD_COMMON_CONTINUE 0xfb /**< continue */ +#define MIDI_CMD_COMMON_STOP 0xfc /**< stop */ +#define MIDI_CMD_COMMON_SENSING 0xfe /**< active sensing */ +#define MIDI_CMD_COMMON_RESET 0xff /**< reset */ /** \} */ @@ -82,78 +82,78 @@ * \{ */ -#define MIDI_CTL_MSB_BANK 0x00 /**< Bank selection */ -#define MIDI_CTL_MSB_MODWHEEL 0x01 /**< Modulation */ -#define MIDI_CTL_MSB_BREATH 0x02 /**< Breath */ -#define MIDI_CTL_MSB_FOOT 0x04 /**< Foot */ -#define MIDI_CTL_MSB_PORTAMENTO_TIME 0x05 /**< Portamento time */ -#define MIDI_CTL_MSB_DATA_ENTRY 0x06 /**< Data entry */ -#define MIDI_CTL_MSB_MAIN_VOLUME 0x07 /**< Main volume */ -#define MIDI_CTL_MSB_BALANCE 0x08 /**< Balance */ -#define MIDI_CTL_MSB_PAN 0x0a /**< Panpot */ -#define MIDI_CTL_MSB_EXPRESSION 0x0b /**< Expression */ -#define MIDI_CTL_MSB_EFFECT1 0x0c /**< Effect1 */ -#define MIDI_CTL_MSB_EFFECT2 0x0d /**< Effect2 */ -#define MIDI_CTL_MSB_GENERAL_PURPOSE1 0x10 /**< General purpose 1 */ -#define MIDI_CTL_MSB_GENERAL_PURPOSE2 0x11 /**< General purpose 2 */ -#define MIDI_CTL_MSB_GENERAL_PURPOSE3 0x12 /**< General purpose 3 */ -#define MIDI_CTL_MSB_GENERAL_PURPOSE4 0x13 /**< General purpose 4 */ -#define MIDI_CTL_LSB_BANK 0x20 /**< Bank selection */ -#define MIDI_CTL_LSB_MODWHEEL 0x21 /**< Modulation */ -#define MIDI_CTL_LSB_BREATH 0x22 /**< Breath */ -#define MIDI_CTL_LSB_FOOT 0x24 /**< Foot */ -#define MIDI_CTL_LSB_PORTAMENTO_TIME 0x25 /**< Portamento time */ -#define MIDI_CTL_LSB_DATA_ENTRY 0x26 /**< Data entry */ -#define MIDI_CTL_LSB_MAIN_VOLUME 0x27 /**< Main volume */ -#define MIDI_CTL_LSB_BALANCE 0x28 /**< Balance */ -#define MIDI_CTL_LSB_PAN 0x2a /**< Panpot */ -#define MIDI_CTL_LSB_EXPRESSION 0x2b /**< Expression */ -#define MIDI_CTL_LSB_EFFECT1 0x2c /**< Effect1 */ -#define MIDI_CTL_LSB_EFFECT2 0x2d /**< Effect2 */ -#define MIDI_CTL_LSB_GENERAL_PURPOSE1 0x30 /**< General purpose 1 */ -#define MIDI_CTL_LSB_GENERAL_PURPOSE2 0x31 /**< General purpose 2 */ -#define MIDI_CTL_LSB_GENERAL_PURPOSE3 0x32 /**< General purpose 3 */ -#define MIDI_CTL_LSB_GENERAL_PURPOSE4 0x33 /**< General purpose 4 */ -#define MIDI_CTL_SUSTAIN 0x40 /**< Sustain pedal */ -#define MIDI_CTL_PORTAMENTO 0x41 /**< Portamento */ -#define MIDI_CTL_SUSTENUTO 0x42 /**< Sostenuto */ -#define MIDI_CTL_SOFT_PEDAL 0x43 /**< Soft pedal */ -#define MIDI_CTL_LEGATO_FOOTSWITCH 0x44 /**< Legato foot switch */ -#define MIDI_CTL_HOLD2 0x45 /**< Hold2 */ -#define MIDI_CTL_SC1_SOUND_VARIATION 0x46 /**< SC1 Sound Variation */ -#define MIDI_CTL_SC2_TIMBRE 0x47 /**< SC2 Timbre */ -#define MIDI_CTL_SC3_RELEASE_TIME 0x48 /**< SC3 Release Time */ -#define MIDI_CTL_SC4_ATTACK_TIME 0x49 /**< SC4 Attack Time */ -#define MIDI_CTL_SC5_BRIGHTNESS 0x4a /**< SC5 Brightness */ -#define MIDI_CTL_SC6 0x4b /**< SC6 */ -#define MIDI_CTL_SC7 0x4c /**< SC7 */ -#define MIDI_CTL_SC8 0x4d /**< SC8 */ -#define MIDI_CTL_SC9 0x4e /**< SC9 */ -#define MIDI_CTL_SC10 0x4f /**< SC10 */ -#define MIDI_CTL_GENERAL_PURPOSE5 0x50 /**< General purpose 5 */ -#define MIDI_CTL_GENERAL_PURPOSE6 0x51 /**< General purpose 6 */ -#define MIDI_CTL_GENERAL_PURPOSE7 0x52 /**< General purpose 7 */ -#define MIDI_CTL_GENERAL_PURPOSE8 0x53 /**< General purpose 8 */ -#define MIDI_CTL_PORTAMENTO_CONTROL 0x54 /**< Portamento control */ -#define MIDI_CTL_E1_REVERB_DEPTH 0x5b /**< E1 Reverb Depth */ -#define MIDI_CTL_E2_TREMOLO_DEPTH 0x5c /**< E2 Tremolo Depth */ -#define MIDI_CTL_E3_CHORUS_DEPTH 0x5d /**< E3 Chorus Depth */ -#define MIDI_CTL_E4_DETUNE_DEPTH 0x5e /**< E4 Detune Depth */ -#define MIDI_CTL_E5_PHASER_DEPTH 0x5f /**< E5 Phaser Depth */ -#define MIDI_CTL_DATA_INCREMENT 0x60 /**< Data Increment */ -#define MIDI_CTL_DATA_DECREMENT 0x61 /**< Data Decrement */ -#define MIDI_CTL_NONREG_PARM_NUM_LSB 0x62 /**< Non-registered parameter number */ -#define MIDI_CTL_NONREG_PARM_NUM_MSB 0x63 /**< Non-registered parameter number */ -#define MIDI_CTL_REGIST_PARM_NUM_LSB 0x64 /**< Registered parameter number */ -#define MIDI_CTL_REGIST_PARM_NUM_MSB 0x65 /**< Registered parameter number */ -#define MIDI_CTL_ALL_SOUNDS_OFF 0x78 /**< All sounds off */ -#define MIDI_CTL_RESET_CONTROLLERS 0x79 /**< Reset Controllers */ -#define MIDI_CTL_LOCAL_CONTROL_SWITCH 0x7a /**< Local control switch */ -#define MIDI_CTL_ALL_NOTES_OFF 0x7b /**< All notes off */ -#define MIDI_CTL_OMNI_OFF 0x7c /**< Omni off */ -#define MIDI_CTL_OMNI_ON 0x7d /**< Omni on */ -#define MIDI_CTL_MONO1 0x7e /**< Mono1 */ -#define MIDI_CTL_MONO2 0x7f /**< Mono2 */ +#define MIDI_CTL_MSB_BANK 0x00 /**< Bank selection */ +#define MIDI_CTL_MSB_MODWHEEL 0x01 /**< Modulation */ +#define MIDI_CTL_MSB_BREATH 0x02 /**< Breath */ +#define MIDI_CTL_MSB_FOOT 0x04 /**< Foot */ +#define MIDI_CTL_MSB_PORTAMENTO_TIME 0x05 /**< Portamento time */ +#define MIDI_CTL_MSB_DATA_ENTRY 0x06 /**< Data entry */ +#define MIDI_CTL_MSB_MAIN_VOLUME 0x07 /**< Main volume */ +#define MIDI_CTL_MSB_BALANCE 0x08 /**< Balance */ +#define MIDI_CTL_MSB_PAN 0x0a /**< Panpot */ +#define MIDI_CTL_MSB_EXPRESSION 0x0b /**< Expression */ +#define MIDI_CTL_MSB_EFFECT1 0x0c /**< Effect1 */ +#define MIDI_CTL_MSB_EFFECT2 0x0d /**< Effect2 */ +#define MIDI_CTL_MSB_GENERAL_PURPOSE1 0x10 /**< General purpose 1 */ +#define MIDI_CTL_MSB_GENERAL_PURPOSE2 0x11 /**< General purpose 2 */ +#define MIDI_CTL_MSB_GENERAL_PURPOSE3 0x12 /**< General purpose 3 */ +#define MIDI_CTL_MSB_GENERAL_PURPOSE4 0x13 /**< General purpose 4 */ +#define MIDI_CTL_LSB_BANK 0x20 /**< Bank selection */ +#define MIDI_CTL_LSB_MODWHEEL 0x21 /**< Modulation */ +#define MIDI_CTL_LSB_BREATH 0x22 /**< Breath */ +#define MIDI_CTL_LSB_FOOT 0x24 /**< Foot */ +#define MIDI_CTL_LSB_PORTAMENTO_TIME 0x25 /**< Portamento time */ +#define MIDI_CTL_LSB_DATA_ENTRY 0x26 /**< Data entry */ +#define MIDI_CTL_LSB_MAIN_VOLUME 0x27 /**< Main volume */ +#define MIDI_CTL_LSB_BALANCE 0x28 /**< Balance */ +#define MIDI_CTL_LSB_PAN 0x2a /**< Panpot */ +#define MIDI_CTL_LSB_EXPRESSION 0x2b /**< Expression */ +#define MIDI_CTL_LSB_EFFECT1 0x2c /**< Effect1 */ +#define MIDI_CTL_LSB_EFFECT2 0x2d /**< Effect2 */ +#define MIDI_CTL_LSB_GENERAL_PURPOSE1 0x30 /**< General purpose 1 */ +#define MIDI_CTL_LSB_GENERAL_PURPOSE2 0x31 /**< General purpose 2 */ +#define MIDI_CTL_LSB_GENERAL_PURPOSE3 0x32 /**< General purpose 3 */ +#define MIDI_CTL_LSB_GENERAL_PURPOSE4 0x33 /**< General purpose 4 */ +#define MIDI_CTL_SUSTAIN 0x40 /**< Sustain pedal */ +#define MIDI_CTL_PORTAMENTO 0x41 /**< Portamento */ +#define MIDI_CTL_SUSTENUTO 0x42 /**< Sostenuto */ +#define MIDI_CTL_SOFT_PEDAL 0x43 /**< Soft pedal */ +#define MIDI_CTL_LEGATO_FOOTSWITCH 0x44 /**< Legato foot switch */ +#define MIDI_CTL_HOLD2 0x45 /**< Hold2 */ +#define MIDI_CTL_SC1_SOUND_VARIATION 0x46 /**< SC1 Sound Variation */ +#define MIDI_CTL_SC2_TIMBRE 0x47 /**< SC2 Timbre */ +#define MIDI_CTL_SC3_RELEASE_TIME 0x48 /**< SC3 Release Time */ +#define MIDI_CTL_SC4_ATTACK_TIME 0x49 /**< SC4 Attack Time */ +#define MIDI_CTL_SC5_BRIGHTNESS 0x4a /**< SC5 Brightness */ +#define MIDI_CTL_SC6 0x4b /**< SC6 */ +#define MIDI_CTL_SC7 0x4c /**< SC7 */ +#define MIDI_CTL_SC8 0x4d /**< SC8 */ +#define MIDI_CTL_SC9 0x4e /**< SC9 */ +#define MIDI_CTL_SC10 0x4f /**< SC10 */ +#define MIDI_CTL_GENERAL_PURPOSE5 0x50 /**< General purpose 5 */ +#define MIDI_CTL_GENERAL_PURPOSE6 0x51 /**< General purpose 6 */ +#define MIDI_CTL_GENERAL_PURPOSE7 0x52 /**< General purpose 7 */ +#define MIDI_CTL_GENERAL_PURPOSE8 0x53 /**< General purpose 8 */ +#define MIDI_CTL_PORTAMENTO_CONTROL 0x54 /**< Portamento control */ +#define MIDI_CTL_E1_REVERB_DEPTH 0x5b /**< E1 Reverb Depth */ +#define MIDI_CTL_E2_TREMOLO_DEPTH 0x5c /**< E2 Tremolo Depth */ +#define MIDI_CTL_E3_CHORUS_DEPTH 0x5d /**< E3 Chorus Depth */ +#define MIDI_CTL_E4_DETUNE_DEPTH 0x5e /**< E4 Detune Depth */ +#define MIDI_CTL_E5_PHASER_DEPTH 0x5f /**< E5 Phaser Depth */ +#define MIDI_CTL_DATA_INCREMENT 0x60 /**< Data Increment */ +#define MIDI_CTL_DATA_DECREMENT 0x61 /**< Data Decrement */ +#define MIDI_CTL_NONREG_PARM_NUM_LSB 0x62 /**< Non-registered parameter number */ +#define MIDI_CTL_NONREG_PARM_NUM_MSB 0x63 /**< Non-registered parameter number */ +#define MIDI_CTL_REGIST_PARM_NUM_LSB 0x64 /**< Registered parameter number */ +#define MIDI_CTL_REGIST_PARM_NUM_MSB 0x65 /**< Registered parameter number */ +#define MIDI_CTL_ALL_SOUNDS_OFF 0x78 /**< All sounds off */ +#define MIDI_CTL_RESET_CONTROLLERS 0x79 /**< Reset Controllers */ +#define MIDI_CTL_LOCAL_CONTROL_SWITCH 0x7a /**< Local control switch */ +#define MIDI_CTL_ALL_NOTES_OFF 0x7b /**< All notes off */ +#define MIDI_CTL_OMNI_OFF 0x7c /**< Omni off */ +#define MIDI_CTL_OMNI_ON 0x7d /**< Omni on */ +#define MIDI_CTL_MONO1 0x7e /**< Mono1 */ +#define MIDI_CTL_MONO2 0x7f /**< Mono2 */ /** \} */ diff -r deabf9fd3d28 -r a12fd0456f0c plugin/api/alsa/seq.h --- a/plugin/api/alsa/seq.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/api/alsa/seq.h Tue Apr 17 10:35:42 2018 +0100 @@ -48,34 +48,34 @@ /* event type macros */ enum { - SND_SEQ_EVFLG_RESULT, - SND_SEQ_EVFLG_NOTE, - SND_SEQ_EVFLG_CONTROL, - SND_SEQ_EVFLG_QUEUE, - SND_SEQ_EVFLG_SYSTEM, - SND_SEQ_EVFLG_MESSAGE, - SND_SEQ_EVFLG_CONNECTION, - SND_SEQ_EVFLG_SAMPLE, - SND_SEQ_EVFLG_USERS, - SND_SEQ_EVFLG_INSTR, - SND_SEQ_EVFLG_QUOTE, - SND_SEQ_EVFLG_NONE, - SND_SEQ_EVFLG_RAW, - SND_SEQ_EVFLG_FIXED, - SND_SEQ_EVFLG_VARIABLE, - SND_SEQ_EVFLG_VARUSR + SND_SEQ_EVFLG_RESULT, + SND_SEQ_EVFLG_NOTE, + SND_SEQ_EVFLG_CONTROL, + SND_SEQ_EVFLG_QUEUE, + SND_SEQ_EVFLG_SYSTEM, + SND_SEQ_EVFLG_MESSAGE, + SND_SEQ_EVFLG_CONNECTION, + SND_SEQ_EVFLG_SAMPLE, + SND_SEQ_EVFLG_USERS, + SND_SEQ_EVFLG_INSTR, + SND_SEQ_EVFLG_QUOTE, + SND_SEQ_EVFLG_NONE, + SND_SEQ_EVFLG_RAW, + SND_SEQ_EVFLG_FIXED, + SND_SEQ_EVFLG_VARIABLE, + SND_SEQ_EVFLG_VARUSR }; enum { - SND_SEQ_EVFLG_NOTE_ONEARG, - SND_SEQ_EVFLG_NOTE_TWOARG + SND_SEQ_EVFLG_NOTE_ONEARG, + SND_SEQ_EVFLG_NOTE_TWOARG }; enum { - SND_SEQ_EVFLG_QUEUE_NOARG, - SND_SEQ_EVFLG_QUEUE_TICK, - SND_SEQ_EVFLG_QUEUE_TIME, - SND_SEQ_EVFLG_QUEUE_VALUE + SND_SEQ_EVFLG_QUEUE_NOARG, + SND_SEQ_EVFLG_QUEUE_TICK, + SND_SEQ_EVFLG_QUEUE_TIME, + SND_SEQ_EVFLG_QUEUE_VALUE }; /** @@ -85,99 +85,99 @@ */ extern const unsigned int snd_seq_event_types[]; -#define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */ -#define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */ +#define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */ +#define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */ /** check the event type */ #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x)) /** event type check: result events */ #define snd_seq_ev_is_result_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT) + snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT) /** event type check: note events */ #define snd_seq_ev_is_note_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE) + snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE) /** event type check: control events */ #define snd_seq_ev_is_control_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL) + snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL) /** event type check: channel specific events */ #define snd_seq_ev_is_channel_type(ev) \ - (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL))) + (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL))) /** event type check: queue control events */ #define snd_seq_ev_is_queue_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE) + snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE) /** event type check: system status messages */ #define snd_seq_ev_is_message_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE) + snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE) /** event type check: system status messages */ #define snd_seq_ev_is_subscribe_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION) + snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION) /** event type check: sample messages */ #define snd_seq_ev_is_sample_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE) + snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE) /** event type check: user-defined messages */ #define snd_seq_ev_is_user_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS) + snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS) /** event type check: instrument layer events */ #define snd_seq_ev_is_instr_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR) + snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR) /** event type check: fixed length events */ #define snd_seq_ev_is_fixed_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED) + snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED) /** event type check: variable length events */ -#define snd_seq_ev_is_variable_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE) +#define snd_seq_ev_is_variable_type(ev) \ + snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE) /** event type check: user pointer events */ #define snd_seq_ev_is_varusr_type(ev) \ - snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR) + snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR) /** event type check: reserved for kernel */ #define snd_seq_ev_is_reserved(ev) \ - (! snd_seq_event_types[(ev)->type]) + (! snd_seq_event_types[(ev)->type]) /** * macros to check event flags */ /** prior events */ -#define snd_seq_ev_is_prior(ev) \ - (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH) +#define snd_seq_ev_is_prior(ev) \ + (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH) /** get the data length type */ #define snd_seq_ev_length_type(ev) \ - ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK) + ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK) /** fixed length events */ -#define snd_seq_ev_is_fixed(ev) \ - (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED) +#define snd_seq_ev_is_fixed(ev) \ + (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED) /** variable length events */ #define snd_seq_ev_is_variable(ev) \ - (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE) + (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE) /** variable length on user-space */ #define snd_seq_ev_is_varusr(ev) \ - (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR) + (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR) /** time-stamp type */ #define snd_seq_ev_timestamp_type(ev) \ - ((ev)->flags & SND_SEQ_TIME_STAMP_MASK) + ((ev)->flags & SND_SEQ_TIME_STAMP_MASK) /** event is in tick time */ #define snd_seq_ev_is_tick(ev) \ - (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK) + (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK) /** event is in real-time */ #define snd_seq_ev_is_real(ev) \ - (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL) + (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL) /** time-mode type */ #define snd_seq_ev_timemode_type(ev) \ - ((ev)->flags & SND_SEQ_TIME_MODE_MASK) + ((ev)->flags & SND_SEQ_TIME_MODE_MASK) /** scheduled in absolute time */ #define snd_seq_ev_is_abstime(ev) \ - (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS) + (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS) /** scheduled in relative time */ #define snd_seq_ev_is_reltime(ev) \ - (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL) + (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL) /** direct dispatched events */ #define snd_seq_ev_is_direct(ev) \ - ((ev)->queue == SND_SEQ_QUEUE_DIRECT) + ((ev)->queue == SND_SEQ_QUEUE_DIRECT) /** \} */ diff -r deabf9fd3d28 -r a12fd0456f0c plugin/api/alsa/seq_event.h --- a/plugin/api/alsa/seq_event.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/api/alsa/seq_event.h Tue Apr 17 10:35:42 2018 +0100 @@ -48,213 +48,213 @@ /** Sequencer event type */ enum snd_seq_event_type { - /** system status; event data type = #snd_seq_result_t */ - SND_SEQ_EVENT_SYSTEM = 0, - /** returned result status; event data type = #snd_seq_result_t */ - SND_SEQ_EVENT_RESULT, + /** system status; event data type = #snd_seq_result_t */ + SND_SEQ_EVENT_SYSTEM = 0, + /** returned result status; event data type = #snd_seq_result_t */ + SND_SEQ_EVENT_RESULT, - /** note on and off with duration; event data type = #snd_seq_ev_note_t */ - SND_SEQ_EVENT_NOTE = 5, - /** note on; event data type = #snd_seq_ev_note_t */ - SND_SEQ_EVENT_NOTEON, - /** note off; event data type = #snd_seq_ev_note_t */ - SND_SEQ_EVENT_NOTEOFF, - /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */ - SND_SEQ_EVENT_KEYPRESS, - - /** controller; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_CONTROLLER = 10, - /** program change; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_PGMCHANGE, - /** channel pressure; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_CHANPRESS, - /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */ - SND_SEQ_EVENT_PITCHBEND, - /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_CONTROL14, - /** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_NONREGPARAM, - /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_REGPARAM, + /** note on and off with duration; event data type = #snd_seq_ev_note_t */ + SND_SEQ_EVENT_NOTE = 5, + /** note on; event data type = #snd_seq_ev_note_t */ + SND_SEQ_EVENT_NOTEON, + /** note off; event data type = #snd_seq_ev_note_t */ + SND_SEQ_EVENT_NOTEOFF, + /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */ + SND_SEQ_EVENT_KEYPRESS, + + /** controller; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_CONTROLLER = 10, + /** program change; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_PGMCHANGE, + /** channel pressure; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_CHANPRESS, + /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */ + SND_SEQ_EVENT_PITCHBEND, + /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_CONTROL14, + /** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_NONREGPARAM, + /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_REGPARAM, - /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_SONGPOS = 20, - /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_SONGSEL, - /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_QFRAME, - /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_TIMESIGN, - /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */ - SND_SEQ_EVENT_KEYSIGN, - - /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_START = 30, - /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_CONTINUE, - /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_STOP, - /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_SETPOS_TICK, - /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_SETPOS_TIME, - /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_TEMPO, - /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_CLOCK, - /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_TICK, - /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_QUEUE_SKEW, - /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */ - SND_SEQ_EVENT_SYNC_POS, + /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_SONGPOS = 20, + /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_SONGSEL, + /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_QFRAME, + /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_TIMESIGN, + /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */ + SND_SEQ_EVENT_KEYSIGN, + + /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_START = 30, + /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_CONTINUE, + /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_STOP, + /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_SETPOS_TICK, + /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_SETPOS_TIME, + /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_TEMPO, + /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_CLOCK, + /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_TICK, + /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_QUEUE_SKEW, + /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */ + SND_SEQ_EVENT_SYNC_POS, - /** Tune request; event data type = none */ - SND_SEQ_EVENT_TUNE_REQUEST = 40, - /** Reset to power-on state; event data type = none */ - SND_SEQ_EVENT_RESET, - /** Active sensing event; event data type = none */ - SND_SEQ_EVENT_SENSING, + /** Tune request; event data type = none */ + SND_SEQ_EVENT_TUNE_REQUEST = 40, + /** Reset to power-on state; event data type = none */ + SND_SEQ_EVENT_RESET, + /** Active sensing event; event data type = none */ + SND_SEQ_EVENT_SENSING, - /** Echo-back event; event data type = any type */ - SND_SEQ_EVENT_ECHO = 50, - /** OSS emulation raw event; event data type = any type */ - SND_SEQ_EVENT_OSS, + /** Echo-back event; event data type = any type */ + SND_SEQ_EVENT_ECHO = 50, + /** OSS emulation raw event; event data type = any type */ + SND_SEQ_EVENT_OSS, - /** New client has connected; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_CLIENT_START = 60, - /** Client has left the system; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_CLIENT_EXIT, - /** Client status/info has changed; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_CLIENT_CHANGE, - /** New port was created; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_PORT_START, - /** Port was deleted from system; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_PORT_EXIT, - /** Port status/info has changed; event data type = #snd_seq_addr_t */ - SND_SEQ_EVENT_PORT_CHANGE, + /** New client has connected; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_CLIENT_START = 60, + /** Client has left the system; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_CLIENT_EXIT, + /** Client status/info has changed; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_CLIENT_CHANGE, + /** New port was created; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_PORT_START, + /** Port was deleted from system; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_PORT_EXIT, + /** Port status/info has changed; event data type = #snd_seq_addr_t */ + SND_SEQ_EVENT_PORT_CHANGE, - /** Ports connected; event data type = #snd_seq_connect_t */ - SND_SEQ_EVENT_PORT_SUBSCRIBED, - /** Ports disconnected; event data type = #snd_seq_connect_t */ - SND_SEQ_EVENT_PORT_UNSUBSCRIBED, + /** Ports connected; event data type = #snd_seq_connect_t */ + SND_SEQ_EVENT_PORT_SUBSCRIBED, + /** Ports disconnected; event data type = #snd_seq_connect_t */ + SND_SEQ_EVENT_PORT_UNSUBSCRIBED, - /** Sample select; event data type = #snd_seq_ev_sample_control_t */ - SND_SEQ_EVENT_SAMPLE = 70, - /** Sample cluster select; event data type = #snd_seq_ev_sample_control_t */ - SND_SEQ_EVENT_SAMPLE_CLUSTER, - /** voice start */ - SND_SEQ_EVENT_SAMPLE_START, - /** voice stop */ - SND_SEQ_EVENT_SAMPLE_STOP, - /** playback frequency */ - SND_SEQ_EVENT_SAMPLE_FREQ, - /** volume and balance */ - SND_SEQ_EVENT_SAMPLE_VOLUME, - /** sample loop */ - SND_SEQ_EVENT_SAMPLE_LOOP, - /** sample position */ - SND_SEQ_EVENT_SAMPLE_POSITION, - /** private (hardware dependent) event */ - SND_SEQ_EVENT_SAMPLE_PRIVATE1, + /** Sample select; event data type = #snd_seq_ev_sample_control_t */ + SND_SEQ_EVENT_SAMPLE = 70, + /** Sample cluster select; event data type = #snd_seq_ev_sample_control_t */ + SND_SEQ_EVENT_SAMPLE_CLUSTER, + /** voice start */ + SND_SEQ_EVENT_SAMPLE_START, + /** voice stop */ + SND_SEQ_EVENT_SAMPLE_STOP, + /** playback frequency */ + SND_SEQ_EVENT_SAMPLE_FREQ, + /** volume and balance */ + SND_SEQ_EVENT_SAMPLE_VOLUME, + /** sample loop */ + SND_SEQ_EVENT_SAMPLE_LOOP, + /** sample position */ + SND_SEQ_EVENT_SAMPLE_POSITION, + /** private (hardware dependent) event */ + SND_SEQ_EVENT_SAMPLE_PRIVATE1, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR0 = 90, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR1, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR2, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR3, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR4, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR5, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR6, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR7, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR8, - /** user-defined event; event data type = any (fixed size) */ - SND_SEQ_EVENT_USR9, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR0 = 90, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR1, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR2, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR3, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR4, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR5, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR6, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR7, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR8, + /** user-defined event; event data type = any (fixed size) */ + SND_SEQ_EVENT_USR9, - /** begin of instrument management */ - SND_SEQ_EVENT_INSTR_BEGIN = 100, - /** end of instrument management */ - SND_SEQ_EVENT_INSTR_END, - /** query instrument interface info */ - SND_SEQ_EVENT_INSTR_INFO, - /** result of instrument interface info */ - SND_SEQ_EVENT_INSTR_INFO_RESULT, - /** query instrument format info */ - SND_SEQ_EVENT_INSTR_FINFO, - /** result of instrument format info */ - SND_SEQ_EVENT_INSTR_FINFO_RESULT, - /** reset instrument instrument memory */ - SND_SEQ_EVENT_INSTR_RESET, - /** get instrument interface status */ - SND_SEQ_EVENT_INSTR_STATUS, - /** result of instrument interface status */ - SND_SEQ_EVENT_INSTR_STATUS_RESULT, - /** put an instrument to port */ - SND_SEQ_EVENT_INSTR_PUT, - /** get an instrument from port */ - SND_SEQ_EVENT_INSTR_GET, - /** result of instrument query */ - SND_SEQ_EVENT_INSTR_GET_RESULT, - /** free instrument(s) */ - SND_SEQ_EVENT_INSTR_FREE, - /** get instrument list */ - SND_SEQ_EVENT_INSTR_LIST, - /** result of instrument list */ - SND_SEQ_EVENT_INSTR_LIST_RESULT, - /** set cluster parameters */ - SND_SEQ_EVENT_INSTR_CLUSTER, - /** get cluster parameters */ - SND_SEQ_EVENT_INSTR_CLUSTER_GET, - /** result of cluster parameters */ - SND_SEQ_EVENT_INSTR_CLUSTER_RESULT, - /** instrument change */ - SND_SEQ_EVENT_INSTR_CHANGE, + /** begin of instrument management */ + SND_SEQ_EVENT_INSTR_BEGIN = 100, + /** end of instrument management */ + SND_SEQ_EVENT_INSTR_END, + /** query instrument interface info */ + SND_SEQ_EVENT_INSTR_INFO, + /** result of instrument interface info */ + SND_SEQ_EVENT_INSTR_INFO_RESULT, + /** query instrument format info */ + SND_SEQ_EVENT_INSTR_FINFO, + /** result of instrument format info */ + SND_SEQ_EVENT_INSTR_FINFO_RESULT, + /** reset instrument instrument memory */ + SND_SEQ_EVENT_INSTR_RESET, + /** get instrument interface status */ + SND_SEQ_EVENT_INSTR_STATUS, + /** result of instrument interface status */ + SND_SEQ_EVENT_INSTR_STATUS_RESULT, + /** put an instrument to port */ + SND_SEQ_EVENT_INSTR_PUT, + /** get an instrument from port */ + SND_SEQ_EVENT_INSTR_GET, + /** result of instrument query */ + SND_SEQ_EVENT_INSTR_GET_RESULT, + /** free instrument(s) */ + SND_SEQ_EVENT_INSTR_FREE, + /** get instrument list */ + SND_SEQ_EVENT_INSTR_LIST, + /** result of instrument list */ + SND_SEQ_EVENT_INSTR_LIST_RESULT, + /** set cluster parameters */ + SND_SEQ_EVENT_INSTR_CLUSTER, + /** get cluster parameters */ + SND_SEQ_EVENT_INSTR_CLUSTER_GET, + /** result of cluster parameters */ + SND_SEQ_EVENT_INSTR_CLUSTER_RESULT, + /** instrument change */ + SND_SEQ_EVENT_INSTR_CHANGE, - /** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_SYSEX = 130, - /** error event; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_BOUNCE, - /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_USR_VAR0 = 135, - /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_USR_VAR1, - /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_USR_VAR2, - /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_USR_VAR3, - /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ - SND_SEQ_EVENT_USR_VAR4, + /** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_SYSEX = 130, + /** error event; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_BOUNCE, + /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_USR_VAR0 = 135, + /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_USR_VAR1, + /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_USR_VAR2, + /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_USR_VAR3, + /** reserved for user apps; event data type = #snd_seq_ev_ext_t */ + SND_SEQ_EVENT_USR_VAR4, - /** NOP; ignored in any case */ - SND_SEQ_EVENT_NONE = 255 + /** NOP; ignored in any case */ + SND_SEQ_EVENT_NONE = 255 }; /** Sequencer event address */ typedef struct snd_seq_addr { - unsigned char client; /**< Client id */ - unsigned char port; /**< Port id */ + unsigned char client; /**< Client id */ + unsigned char port; /**< Port id */ } snd_seq_addr_t; /** Connection (subscription) between ports */ typedef struct snd_seq_connect { - snd_seq_addr_t sender; /**< sender address */ - snd_seq_addr_t dest; /**< destination address */ + snd_seq_addr_t sender; /**< sender address */ + snd_seq_addr_t dest; /**< destination address */ } snd_seq_connect_t; /** Real-time data record */ typedef struct snd_seq_real_time { - unsigned int tv_sec; /**< seconds */ - unsigned int tv_nsec; /**< nanoseconds */ + unsigned int tv_sec; /**< seconds */ + unsigned int tv_nsec; /**< nanoseconds */ } snd_seq_real_time_t; /** (MIDI) Tick-time data record */ @@ -262,8 +262,8 @@ /** unioned time stamp */ typedef union snd_seq_timestamp { - snd_seq_tick_time_t tick; /**< tick-time */ - struct snd_seq_real_time time; /**< real-time */ + snd_seq_tick_time_t tick; /**< tick-time */ + struct snd_seq_real_time time; /**< real-time */ } snd_seq_timestamp_t; @@ -272,55 +272,55 @@ * * NOTE: only 8 bits available! */ -#define SND_SEQ_TIME_STAMP_TICK (0<<0) /**< timestamp in clock ticks */ -#define SND_SEQ_TIME_STAMP_REAL (1<<0) /**< timestamp in real time */ -#define SND_SEQ_TIME_STAMP_MASK (1<<0) /**< mask for timestamp bits */ +#define SND_SEQ_TIME_STAMP_TICK (0<<0) /**< timestamp in clock ticks */ +#define SND_SEQ_TIME_STAMP_REAL (1<<0) /**< timestamp in real time */ +#define SND_SEQ_TIME_STAMP_MASK (1<<0) /**< mask for timestamp bits */ -#define SND_SEQ_TIME_MODE_ABS (0<<1) /**< absolute timestamp */ -#define SND_SEQ_TIME_MODE_REL (1<<1) /**< relative to current time */ -#define SND_SEQ_TIME_MODE_MASK (1<<1) /**< mask for time mode bits */ +#define SND_SEQ_TIME_MODE_ABS (0<<1) /**< absolute timestamp */ +#define SND_SEQ_TIME_MODE_REL (1<<1) /**< relative to current time */ +#define SND_SEQ_TIME_MODE_MASK (1<<1) /**< mask for time mode bits */ -#define SND_SEQ_EVENT_LENGTH_FIXED (0<<2) /**< fixed event size */ -#define SND_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /**< variable event size */ -#define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2) /**< variable event size - user memory space */ -#define SND_SEQ_EVENT_LENGTH_MASK (3<<2) /**< mask for event length bits */ +#define SND_SEQ_EVENT_LENGTH_FIXED (0<<2) /**< fixed event size */ +#define SND_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /**< variable event size */ +#define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2) /**< variable event size - user memory space */ +#define SND_SEQ_EVENT_LENGTH_MASK (3<<2) /**< mask for event length bits */ -#define SND_SEQ_PRIORITY_NORMAL (0<<4) /**< normal priority */ -#define SND_SEQ_PRIORITY_HIGH (1<<4) /**< event should be processed before others */ -#define SND_SEQ_PRIORITY_MASK (1<<4) /**< mask for priority bits */ +#define SND_SEQ_PRIORITY_NORMAL (0<<4) /**< normal priority */ +#define SND_SEQ_PRIORITY_HIGH (1<<4) /**< event should be processed before others */ +#define SND_SEQ_PRIORITY_MASK (1<<4) /**< mask for priority bits */ /** Note event */ typedef struct snd_seq_ev_note { - unsigned char channel; /**< channel number */ - unsigned char note; /**< note */ - unsigned char velocity; /**< velocity */ - unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */ - unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */ + unsigned char channel; /**< channel number */ + unsigned char note; /**< note */ + unsigned char velocity; /**< velocity */ + unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */ + unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */ } snd_seq_ev_note_t; /** Controller event */ typedef struct snd_seq_ev_ctrl { - unsigned char channel; /**< channel number */ - unsigned char unused[3]; /**< reserved */ - unsigned int param; /**< control parameter */ - signed int value; /**< control value */ + unsigned char channel; /**< channel number */ + unsigned char unused[3]; /**< reserved */ + unsigned int param; /**< control parameter */ + signed int value; /**< control value */ } snd_seq_ev_ctrl_t; /** generic set of bytes (12x8 bit) */ typedef struct snd_seq_ev_raw8 { - unsigned char d[12]; /**< 8 bit value */ + unsigned char d[12]; /**< 8 bit value */ } snd_seq_ev_raw8_t; /** generic set of integers (3x32 bit) */ typedef struct snd_seq_ev_raw32 { - unsigned int d[3]; /**< 32 bit value */ + unsigned int d[3]; /**< 32 bit value */ } snd_seq_ev_raw32_t; /** external stored data */ typedef struct snd_seq_ev_ext { - unsigned int len; /**< length of data */ - void *ptr; /**< pointer to data (note: can be 64-bit) */ + unsigned int len; /**< length of data */ + void *ptr; /**< pointer to data (note: can be 64-bit) */ } #ifdef __GNUC__ __attribute__((packed)) @@ -332,22 +332,22 @@ /** Instrument type */ typedef struct snd_seq_instr { - snd_seq_instr_cluster_t cluster; /**< cluster id */ - unsigned int std; /**< instrument standard id; the upper byte means a private instrument (owner - client id) */ - unsigned short bank; /**< instrument bank id */ - unsigned short prg; /**< instrument program id */ + snd_seq_instr_cluster_t cluster; /**< cluster id */ + unsigned int std; /**< instrument standard id; the upper byte means a private instrument (owner - client id) */ + unsigned short bank; /**< instrument bank id */ + unsigned short prg; /**< instrument program id */ } snd_seq_instr_t; /** sample number */ typedef struct snd_seq_ev_sample { - unsigned int std; /**< sample standard id */ - unsigned short bank; /**< sample bank id */ - unsigned short prg; /**< sample program id */ + unsigned int std; /**< sample standard id */ + unsigned short bank; /**< sample bank id */ + unsigned short prg; /**< sample program id */ } snd_seq_ev_sample_t; /** sample cluster */ typedef struct snd_seq_ev_cluster { - snd_seq_instr_cluster_t cluster; /**< cluster id */ + snd_seq_instr_cluster_t cluster; /**< cluster id */ } snd_seq_ev_cluster_t; /** sample position */ @@ -355,9 +355,9 @@ /** sample stop mode */ typedef enum snd_seq_stop_mode { - SND_SEQ_SAMPLE_STOP_IMMEDIATELY = 0, /**< terminate playing immediately */ - SND_SEQ_SAMPLE_STOP_VENVELOPE = 1, /**< finish volume envelope */ - SND_SEQ_SAMPLE_STOP_LOOP = 2 /**< terminate loop and finish wave */ + SND_SEQ_SAMPLE_STOP_IMMEDIATELY = 0, /**< terminate playing immediately */ + SND_SEQ_SAMPLE_STOP_VENVELOPE = 1, /**< finish volume envelope */ + SND_SEQ_SAMPLE_STOP_LOOP = 2 /**< terminate loop and finish wave */ } snd_seq_stop_mode_t; /** sample frequency */ @@ -365,94 +365,94 @@ /** sample volume control; if any value is set to -1 == do not change */ typedef struct snd_seq_ev_volume { - signed short volume; /**< range: 0-16383 */ - signed short lr; /**< left-right balance; range: 0-16383 */ - signed short fr; /**< front-rear balance; range: 0-16383 */ - signed short du; /**< down-up balance; range: 0-16383 */ + signed short volume; /**< range: 0-16383 */ + signed short lr; /**< left-right balance; range: 0-16383 */ + signed short fr; /**< front-rear balance; range: 0-16383 */ + signed short du; /**< down-up balance; range: 0-16383 */ } snd_seq_ev_volume_t; /** simple loop redefinition */ typedef struct snd_seq_ev_loop { - unsigned int start; /**< loop start (in samples) * 16 */ - unsigned int end; /**< loop end (in samples) * 16 */ + unsigned int start; /**< loop start (in samples) * 16 */ + unsigned int end; /**< loop end (in samples) * 16 */ } snd_seq_ev_loop_t; /** Sample control events */ typedef struct snd_seq_ev_sample_control { - unsigned char channel; /**< channel */ - unsigned char unused[3]; /**< reserved */ - union { - snd_seq_ev_sample_t sample; /**< sample number */ - snd_seq_ev_cluster_t cluster; /**< cluster number */ - snd_seq_position_t position; /**< position */ - snd_seq_stop_mode_t stop_mode; /**< stop mode */ - snd_seq_frequency_t frequency; /**< frequency */ - snd_seq_ev_volume_t volume; /**< volume */ - snd_seq_ev_loop_t loop; /**< loop control */ - unsigned char raw8[8]; /**< raw 8-bit */ - } param; /**< control parameters */ + unsigned char channel; /**< channel */ + unsigned char unused[3]; /**< reserved */ + union { + snd_seq_ev_sample_t sample; /**< sample number */ + snd_seq_ev_cluster_t cluster; /**< cluster number */ + snd_seq_position_t position; /**< position */ + snd_seq_stop_mode_t stop_mode; /**< stop mode */ + snd_seq_frequency_t frequency; /**< frequency */ + snd_seq_ev_volume_t volume; /**< volume */ + snd_seq_ev_loop_t loop; /**< loop control */ + unsigned char raw8[8]; /**< raw 8-bit */ + } param; /**< control parameters */ } snd_seq_ev_sample_control_t; /** INSTR_BEGIN event */ typedef struct snd_seq_ev_instr_begin { - int timeout; /**< zero = forever, otherwise timeout in ms */ + int timeout; /**< zero = forever, otherwise timeout in ms */ } snd_seq_ev_instr_begin_t; /** Result events */ typedef struct snd_seq_result { - int event; /**< processed event type */ - int result; /**< status */ + int event; /**< processed event type */ + int result; /**< status */ } snd_seq_result_t; /** Queue skew values */ typedef struct snd_seq_queue_skew { - unsigned int value; /**< skew value */ - unsigned int base; /**< skew base */ + unsigned int value; /**< skew value */ + unsigned int base; /**< skew base */ } snd_seq_queue_skew_t; /** queue timer control */ typedef struct snd_seq_ev_queue_control { - unsigned char queue; /**< affected queue */ - unsigned char unused[3]; /**< reserved */ - union { - signed int value; /**< affected value (e.g. tempo) */ - snd_seq_timestamp_t time; /**< time */ - unsigned int position; /**< sync position */ - snd_seq_queue_skew_t skew; /**< queue skew */ - unsigned int d32[2]; /**< any data */ - unsigned char d8[8]; /**< any data */ - } param; /**< data value union */ + unsigned char queue; /**< affected queue */ + unsigned char unused[3]; /**< reserved */ + union { + signed int value; /**< affected value (e.g. tempo) */ + snd_seq_timestamp_t time; /**< time */ + unsigned int position; /**< sync position */ + snd_seq_queue_skew_t skew; /**< queue skew */ + unsigned int d32[2]; /**< any data */ + unsigned char d8[8]; /**< any data */ + } param; /**< data value union */ } snd_seq_ev_queue_control_t; /** Sequencer event */ typedef struct snd_seq_event { - snd_seq_event_type_t type; /**< event type */ - unsigned char flags; /**< event flags */ - unsigned char tag; /**< tag */ - - unsigned char queue; /**< schedule queue */ - snd_seq_timestamp_t time; /**< schedule time */ + snd_seq_event_type_t type; /**< event type */ + unsigned char flags; /**< event flags */ + unsigned char tag; /**< tag */ + + unsigned char queue; /**< schedule queue */ + snd_seq_timestamp_t time; /**< schedule time */ - snd_seq_addr_t source; /**< source address */ - snd_seq_addr_t dest; /**< destination address */ + snd_seq_addr_t source; /**< source address */ + snd_seq_addr_t dest; /**< destination address */ - union { - snd_seq_ev_note_t note; /**< note information */ - snd_seq_ev_ctrl_t control; /**< MIDI control information */ - snd_seq_ev_raw8_t raw8; /**< raw8 data */ - snd_seq_ev_raw32_t raw32; /**< raw32 data */ - snd_seq_ev_ext_t ext; /**< external data */ - snd_seq_ev_queue_control_t queue; /**< queue control */ - snd_seq_timestamp_t time; /**< timestamp */ - snd_seq_addr_t addr; /**< address */ - snd_seq_connect_t connect; /**< connect information */ - snd_seq_result_t result; /**< operation result code */ - snd_seq_ev_instr_begin_t instr_begin; /**< instrument */ - snd_seq_ev_sample_control_t sample; /**< sample control */ - } data; /**< event data... */ + union { + snd_seq_ev_note_t note; /**< note information */ + snd_seq_ev_ctrl_t control; /**< MIDI control information */ + snd_seq_ev_raw8_t raw8; /**< raw8 data */ + snd_seq_ev_raw32_t raw32; /**< raw32 data */ + snd_seq_ev_ext_t ext; /**< external data */ + snd_seq_ev_queue_control_t queue; /**< queue control */ + snd_seq_timestamp_t time; /**< timestamp */ + snd_seq_addr_t addr; /**< address */ + snd_seq_connect_t connect; /**< connect information */ + snd_seq_result_t result; /**< operation result code */ + snd_seq_ev_instr_begin_t instr_begin; /**< instrument */ + snd_seq_ev_sample_control_t sample; /**< sample control */ + } data; /**< event data... */ } snd_seq_event_t; diff -r deabf9fd3d28 -r a12fd0456f0c plugin/api/alsa/sound/asequencer.h --- a/plugin/api/alsa/sound/asequencer.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/api/alsa/sound/asequencer.h Tue Apr 17 10:35:42 2018 +0100 @@ -28,11 +28,11 @@ #ifndef __SOUND_ASEQUENCER_H #define __SOUND_ASEQUENCER_H -#define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */ +#define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */ -#define SNDRV_SEQ_EVENT_LENGTH_FIXED (0<<2) /* fixed event size */ -#define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /* variable event size */ +#define SNDRV_SEQ_EVENT_LENGTH_FIXED (0<<2) /* fixed event size */ +#define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /* variable event size */ -#define SNDRV_SEQ_EVENT_LENGTH_MASK (3<<2) +#define SNDRV_SEQ_EVENT_LENGTH_MASK (3<<2) #endif /* __SOUND_ASEQUENCER_H */ diff -r deabf9fd3d28 -r a12fd0456f0c plugin/api/dssi.h --- a/plugin/api/dssi.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/api/dssi.h Tue Apr 17 10:35:42 2018 +0100 @@ -71,9 +71,9 @@ unsigned long Bank; /** Program number (unique within its bank) for this program. - There is no restriction on the set of available programs: the - numbers do not need to be contiguous, there does not need to - be a program 0, etc. */ + There is no restriction on the set of available programs: the + numbers do not need to be contiguous, there does not need to + be a program 0, etc. */ unsigned long Program; /** Name of the program. */ @@ -248,13 +248,13 @@ * See also the configure OSC call documentation in RFC.txt. */ char *(*configure)(LADSPA_Handle Instance, - const char *Key, - const char *Value); + const char *Key, + const char *Value); #define DSSI_RESERVED_CONFIGURE_PREFIX "DSSI:" #define DSSI_GLOBAL_CONFIGURE_PREFIX "GLOBAL:" #define DSSI_PROJECT_DIRECTORY_KEY \ - DSSI_RESERVED_CONFIGURE_PREFIX "PROJECT_DIRECTORY" + DSSI_RESERVED_CONFIGURE_PREFIX "PROJECT_DIRECTORY" /** * get_program() @@ -278,7 +278,7 @@ * programs as well as their properties. */ const DSSI_Program_Descriptor *(*get_program)(LADSPA_Handle Instance, - unsigned long Index); + unsigned long Index); /** * select_program() @@ -308,8 +308,8 @@ * which a DSSI plugin is allowed to modify its own input ports.) */ void (*select_program)(LADSPA_Handle Instance, - unsigned long Bank, - unsigned long Program); + unsigned long Bank, + unsigned long Program); /** * get_midi_controller_for_port() @@ -338,7 +338,7 @@ * controllers 0 or 32 (MIDI Bank Select MSB and LSB). */ int (*get_midi_controller_for_port)(LADSPA_Handle Instance, - unsigned long Port); + unsigned long Port); /** * run_synth() @@ -388,9 +388,9 @@ * select controller to a plugin via run_synth. */ void (*run_synth)(LADSPA_Handle Instance, - unsigned long SampleCount, - snd_seq_event_t *Events, - unsigned long EventCount); + unsigned long SampleCount, + snd_seq_event_t *Events, + unsigned long EventCount); /** * run_synth_adding() @@ -402,9 +402,9 @@ * that does not provide it must set this member to NULL. */ void (*run_synth_adding)(LADSPA_Handle Instance, - unsigned long SampleCount, - snd_seq_event_t *Events, - unsigned long EventCount); + unsigned long SampleCount, + snd_seq_event_t *Events, + unsigned long EventCount); /** * run_multiple_synths() @@ -609,7 +609,7 @@ */ int (*request_non_rt_thread)(LADSPA_Handle Instance, - void (*RunFunction)(LADSPA_Handle Instance)); + void (*RunFunction)(LADSPA_Handle Instance)); }; /** @@ -641,19 +641,19 @@ * get_midi_controller_for_port() */ -#define DSSI_CC_BITS 0x20000000 -#define DSSI_NRPN_BITS 0x40000000 +#define DSSI_CC_BITS 0x20000000 +#define DSSI_NRPN_BITS 0x40000000 -#define DSSI_NONE -1 -#define DSSI_CONTROLLER_IS_SET(n) (DSSI_NONE != (n)) +#define DSSI_NONE -1 +#define DSSI_CONTROLLER_IS_SET(n) (DSSI_NONE != (n)) -#define DSSI_CC(n) (DSSI_CC_BITS | (n)) -#define DSSI_IS_CC(n) (DSSI_CC_BITS & (n)) -#define DSSI_CC_NUMBER(n) ((n) & 0x7f) +#define DSSI_CC(n) (DSSI_CC_BITS | (n)) +#define DSSI_IS_CC(n) (DSSI_CC_BITS & (n)) +#define DSSI_CC_NUMBER(n) ((n) & 0x7f) -#define DSSI_NRPN(n) (DSSI_NRPN_BITS | ((n) << 7)) -#define DSSI_IS_NRPN(n) (DSSI_NRPN_BITS & (n)) -#define DSSI_NRPN_NUMBER(n) (((n) >> 7) & 0x3fff) +#define DSSI_NRPN(n) (DSSI_NRPN_BITS | ((n) << 7)) +#define DSSI_IS_NRPN(n) (DSSI_NRPN_BITS & (n)) +#define DSSI_NRPN_NUMBER(n) (((n) >> 7) & 0x3fff) #ifdef __cplusplus } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/plugins/SamplePlayer.cpp --- a/plugin/plugins/SamplePlayer.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/plugins/SamplePlayer.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -157,17 +157,17 @@ SamplePlayer::instantiate(const LADSPA_Descriptor *, unsigned long rate) { if (!hostDescriptor || !hostDescriptor->request_non_rt_thread) { - SVDEBUG << "SamplePlayer::instantiate: Host does not provide request_non_rt_thread, not instantiating" << endl; - return 0; + SVDEBUG << "SamplePlayer::instantiate: Host does not provide request_non_rt_thread, not instantiating" << endl; + return 0; } SamplePlayer *player = new SamplePlayer(int(rate)); - // std::cerr << "Instantiated sample player " << std::endl; + // std::cerr << "Instantiated sample player " << std::endl; if (hostDescriptor->request_non_rt_thread(player, workThreadCallback)) { - SVDEBUG << "SamplePlayer::instantiate: Host rejected request_non_rt_thread call, not instantiating" << endl; - delete player; - return 0; + SVDEBUG << "SamplePlayer::instantiate: Host rejected request_non_rt_thread call, not instantiating" << endl; + delete player; + return 0; } return player; @@ -175,17 +175,17 @@ void SamplePlayer::connectPort(LADSPA_Handle handle, - unsigned long port, LADSPA_Data *location) + unsigned long port, LADSPA_Data *location) { SamplePlayer *player = (SamplePlayer *)handle; float **ports[PortCount] = { - &player->m_output, - &player->m_retune, - &player->m_basePitch, + &player->m_output, + &player->m_retune, + &player->m_basePitch, &player->m_concertA, - &player->m_sustain, - &player->m_release + &player->m_sustain, + &player->m_release }; *ports[port] = (float *)location; @@ -200,9 +200,9 @@ player->m_sampleNo = 0; for (size_t i = 0; i < Polyphony; ++i) { - player->m_ons[i] = -1; - player->m_offs[i] = -1; - player->m_velocities[i] = 0; + player->m_ons[i] = -1; + player->m_offs[i] = -1; + player->m_velocities[i] = 0; } } @@ -231,7 +231,7 @@ SamplePlayer *player = (SamplePlayer *)handle; - QMutexLocker locker(&player->m_mutex); + QMutexLocker locker(&player->m_mutex); if (QFileInfo(value).exists() && QFileInfo(value).isDir()) { @@ -261,10 +261,10 @@ SamplePlayer *player = (SamplePlayer *)handle; if (!player->m_sampleSearchComplete) { - QMutexLocker locker(&player->m_mutex); - if (!player->m_sampleSearchComplete) { - player->searchSamples(); - } + QMutexLocker locker(&player->m_mutex); + if (!player->m_sampleSearchComplete) { + player->searchSamples(); + } } if (program >= player->m_samples.size()) return 0; @@ -283,8 +283,8 @@ void SamplePlayer::selectProgram(LADSPA_Handle handle, - unsigned long, - unsigned long program) + unsigned long, + unsigned long program) { SamplePlayer *player = (SamplePlayer *)handle; player->m_pendingProgramChange = (int)program; @@ -294,11 +294,11 @@ SamplePlayer::getMidiController(LADSPA_Handle, unsigned long port) { int controllers[PortCount] = { - DSSI_NONE, - DSSI_CC(12), - DSSI_CC(13), - DSSI_CC(64), - DSSI_CC(72) + DSSI_NONE, + DSSI_CC(12), + DSSI_CC(13), + DSSI_CC(64), + DSSI_CC(72) }; return controllers[port]; @@ -306,7 +306,7 @@ void SamplePlayer::runSynth(LADSPA_Handle handle, unsigned long samples, - snd_seq_event_t *events, unsigned long eventCount) + snd_seq_event_t *events, unsigned long eventCount) { SamplePlayer *player = (SamplePlayer *)handle; @@ -327,38 +327,38 @@ if (player->m_pendingProgramChange >= 0) { #ifdef DEBUG_SAMPLE_PLAYER - SVDEBUG << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << endl; + SVDEBUG << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << endl; #endif - player->m_mutex.lock(); + player->m_mutex.lock(); - int program = player->m_pendingProgramChange; - player->m_pendingProgramChange = -1; + int program = player->m_pendingProgramChange; + player->m_pendingProgramChange = -1; - if (!player->m_sampleSearchComplete) { - player->searchSamples(); - } - - if (program < int(player->m_samples.size())) { - QString path = player->m_samples[program].second; - QString programName = player->m_samples[program].first; - if (programName != player->m_program) { - player->m_program = programName; - player->m_mutex.unlock(); - player->loadSampleData(path); - } else { - player->m_mutex.unlock(); - } - } + if (!player->m_sampleSearchComplete) { + player->searchSamples(); + } + + if (program < int(player->m_samples.size())) { + QString path = player->m_samples[program].second; + QString programName = player->m_samples[program].first; + if (programName != player->m_program) { + player->m_program = programName; + player->m_mutex.unlock(); + player->loadSampleData(path); + } else { + player->m_mutex.unlock(); + } + } } if (!player->m_sampleSearchComplete) { - QMutexLocker locker(&player->m_mutex); + QMutexLocker locker(&player->m_mutex); - if (!player->m_sampleSearchComplete) { - player->searchSamples(); - } + if (!player->m_sampleSearchComplete) { + player->searchSamples(); + } } } @@ -371,7 +371,7 @@ #ifdef DEBUG_SAMPLE_PLAYER SVDEBUG << "SamplePlayer::searchSamples: Directory is \"" - << m_sampleDir << "\"" << endl; + << m_sampleDir << "\"" << endl; #endif QDir dir(m_sampleDir, "*.wav"); @@ -406,10 +406,10 @@ file = sf_open(path.toLocal8Bit().data(), SFM_READ, &info); #endif if (!file) { - cerr << "SamplePlayer::loadSampleData: Failed to open file " - << path << ": " - << sf_strerror(file) << endl; - return; + cerr << "SamplePlayer::loadSampleData: Failed to open file " + << path << ": " + << sf_strerror(file) << endl; + return; } samples = info.frames; @@ -422,47 +422,47 @@ tmpResamples = 0; if (info.samplerate != m_sampleRate) { - - double ratio = (double)m_sampleRate / (double)info.samplerate; - size_t target = (size_t)(double(info.frames) * ratio); - SRC_DATA data; + + double ratio = (double)m_sampleRate / (double)info.samplerate; + size_t target = (size_t)(double(info.frames) * ratio); + SRC_DATA data; - tmpResamples = (float *)malloc(target * info.channels * sizeof(float)); - if (!tmpResamples) { - free(tmpFrames); - return; - } + tmpResamples = (float *)malloc(target * info.channels * sizeof(float)); + if (!tmpResamples) { + free(tmpFrames); + return; + } - memset(tmpResamples, 0, target * info.channels * sizeof(float)); + memset(tmpResamples, 0, target * info.channels * sizeof(float)); - data.data_in = tmpFrames; - data.data_out = tmpResamples; - data.input_frames = info.frames; - data.output_frames = target; - data.src_ratio = ratio; + data.data_in = tmpFrames; + data.data_out = tmpResamples; + data.input_frames = info.frames; + data.output_frames = target; + data.src_ratio = ratio; - if (!src_simple(&data, SRC_SINC_BEST_QUALITY, info.channels)) { - free(tmpFrames); - tmpFrames = tmpResamples; - samples = target; - } else { - free(tmpResamples); - } + if (!src_simple(&data, SRC_SINC_BEST_QUALITY, info.channels)) { + free(tmpFrames); + tmpFrames = tmpResamples; + samples = target; + } else { + free(tmpResamples); + } } /* add an extra sample for linear interpolation */ tmpSamples = (float *)malloc((samples + 1) * sizeof(float)); if (!tmpSamples) { - free(tmpFrames); - return; + free(tmpFrames); + return; } for (i = 0; i < samples; ++i) { - int j; - tmpSamples[i] = 0.0f; - for (j = 0; j < info.channels; ++j) { - tmpSamples[i] += tmpFrames[i * info.channels + j]; - } + int j; + tmpSamples[i] = 0.0f; + for (j = 0; j < info.channels; ++j) { + tmpSamples[i] += tmpFrames[i * info.channels + j]; + } } free(tmpFrames); @@ -477,9 +477,9 @@ m_sampleCount = samples; for (i = 0; i < Polyphony; ++i) { - m_ons[i] = -1; - m_offs[i] = -1; - m_velocities[i] = 0; + m_ons[i] = -1; + m_offs[i] = -1; + m_velocities[i] = 0; } if (tmpOld) free(tmpOld); @@ -489,8 +489,8 @@ void SamplePlayer::runImpl(unsigned long sampleCount, - snd_seq_event_t *events, - unsigned long eventCount) + snd_seq_event_t *events, + unsigned long eventCount) { unsigned long pos; unsigned long count; @@ -502,67 +502,67 @@ if (!m_mutex.tryLock()) return; if (!m_sampleData || !m_sampleCount) { - m_sampleNo += sampleCount; - m_mutex.unlock(); - return; + m_sampleNo += sampleCount; + m_mutex.unlock(); + return; } for (pos = 0, event_pos = 0; pos < sampleCount; ) { - while (event_pos < eventCount - && pos >= events[event_pos].time.tick) { + while (event_pos < eventCount + && pos >= events[event_pos].time.tick) { - if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) { + if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) { #ifdef DEBUG_SAMPLE_PLAYER cerr << "SamplePlayer: found NOTEON at time " << events[event_pos].time.tick << endl; #endif - snd_seq_ev_note_t n = events[event_pos].data.note; - if (n.velocity > 0) { - m_ons[n.note] = - m_sampleNo + events[event_pos].time.tick; - m_offs[n.note] = -1; - m_velocities[n.note] = n.velocity; - } else { - if (!m_sustain || (*m_sustain < 0.001)) { - m_offs[n.note] = - m_sampleNo + events[event_pos].time.tick; - } - } - } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF && - (!m_sustain || (*m_sustain < 0.001))) { + snd_seq_ev_note_t n = events[event_pos].data.note; + if (n.velocity > 0) { + m_ons[n.note] = + m_sampleNo + events[event_pos].time.tick; + m_offs[n.note] = -1; + m_velocities[n.note] = n.velocity; + } else { + if (!m_sustain || (*m_sustain < 0.001)) { + m_offs[n.note] = + m_sampleNo + events[event_pos].time.tick; + } + } + } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF && + (!m_sustain || (*m_sustain < 0.001))) { #ifdef DEBUG_SAMPLE_PLAYER cerr << "SamplePlayer: found NOTEOFF at time " << events[event_pos].time.tick << endl; #endif - snd_seq_ev_note_t n = events[event_pos].data.note; - m_offs[n.note] = - m_sampleNo + events[event_pos].time.tick; - } + snd_seq_ev_note_t n = events[event_pos].data.note; + m_offs[n.note] = + m_sampleNo + events[event_pos].time.tick; + } - ++event_pos; - } + ++event_pos; + } - count = sampleCount - pos; - if (event_pos < eventCount && - events[event_pos].time.tick < sampleCount) { - count = events[event_pos].time.tick - pos; - } + count = sampleCount - pos; + if (event_pos < eventCount && + events[event_pos].time.tick < sampleCount) { + count = events[event_pos].time.tick - pos; + } int notecount = 0; - for (i = 0; i < Polyphony; ++i) { - if (m_ons[i] >= 0) { + for (i = 0; i < Polyphony; ++i) { + if (m_ons[i] >= 0) { ++notecount; - addSample(i, pos, count); - } - } + addSample(i, pos, count); + } + } #ifdef DEBUG_SAMPLE_PLAYER cerr << "SamplePlayer: have " << notecount << " note(s) sounding currently" << endl; #endif - pos += count; + pos += count; } m_sampleNo += sampleCount; @@ -580,9 +580,9 @@ if (m_concertA) { ratio *= *m_concertA / 440.f; } - if (m_basePitch && float(n) != *m_basePitch) { - ratio *= powf(1.059463094f, float(n) - *m_basePitch); - } + if (m_basePitch && float(n) != *m_basePitch) { + ratio *= powf(1.059463094f, float(n) - *m_basePitch); + } } if (long(pos + m_sampleNo) < m_ons[n]) return; @@ -590,49 +590,49 @@ gain = (float)m_velocities[n] / 127.0f; for (i = 0, s = pos + m_sampleNo - m_ons[n]; - i < count; - ++i, ++s) { + i < count; + ++i, ++s) { - float lgain = gain; - float rs = float(s) * ratio; - unsigned long rsi = lrintf(floorf(rs)); + float lgain = gain; + float rs = float(s) * ratio; + unsigned long rsi = lrintf(floorf(rs)); - if (rsi >= m_sampleCount) { + if (rsi >= m_sampleCount) { #ifdef DEBUG_SAMPLE_PLAYER cerr << "Note " << n << " has run out of samples (were " << m_sampleCount << " available at ratio " << ratio << "), ending" << endl; #endif - m_ons[n] = -1; - break; - } + m_ons[n] = -1; + break; + } - if (m_offs[n] >= 0 && - long(pos + i + m_sampleNo) > m_offs[n]) { + if (m_offs[n] >= 0 && + long(pos + i + m_sampleNo) > m_offs[n]) { - unsigned long dist = - pos + i + m_sampleNo - m_offs[n]; + unsigned long dist = + pos + i + m_sampleNo - m_offs[n]; - unsigned long releaseFrames = 200; - if (m_release) { - releaseFrames = long(*m_release * float(m_sampleRate) + 0.0001f); - } + unsigned long releaseFrames = 200; + if (m_release) { + releaseFrames = long(*m_release * float(m_sampleRate) + 0.0001f); + } - if (dist > releaseFrames) { + if (dist > releaseFrames) { #ifdef DEBUG_SAMPLE_PLAYER cerr << "Note " << n << " has expired its release time (" << releaseFrames << " frames), ending" << endl; #endif - m_ons[n] = -1; - break; - } else { - lgain = lgain * (float)(releaseFrames - dist) / - (float)releaseFrames; - } - } - - float sample = m_sampleData[rsi] + - ((m_sampleData[rsi + 1] - - m_sampleData[rsi]) * - (rs - (float)rsi)); + m_ons[n] = -1; + break; + } else { + lgain = lgain * (float)(releaseFrames - dist) / + (float)releaseFrames; + } + } + + float sample = m_sampleData[rsi] + + ((m_sampleData[rsi + 1] - + m_sampleData[rsi]) * + (rs - (float)rsi)); - m_output[pos + i] += lgain * sample; + m_output[pos + i] += lgain * sample; } } diff -r deabf9fd3d28 -r a12fd0456f0c plugin/plugins/SamplePlayer.h --- a/plugin/plugins/SamplePlayer.h Tue Apr 17 10:03:51 2018 +0100 +++ b/plugin/plugins/SamplePlayer.h Tue Apr 17 10:35:42 2018 +0100 @@ -37,17 +37,17 @@ ~SamplePlayer(); enum { - OutputPort = 0, - RetunePort = 1, - BasePitchPort = 2, + OutputPort = 0, + RetunePort = 1, + BasePitchPort = 2, ConcertAPort = 3, - SustainPort = 4, - ReleasePort = 5, - PortCount = 6 + SustainPort = 4, + ReleasePort = 5, + PortCount = 6 }; enum { - Polyphony = 128 + Polyphony = 128 }; static const char *const portNames[PortCount]; @@ -69,7 +69,7 @@ static void selectProgram(LADSPA_Handle, unsigned long, unsigned long); static int getMidiController(LADSPA_Handle, unsigned long); static void runSynth(LADSPA_Handle, unsigned long, - snd_seq_event_t *, unsigned long); + snd_seq_event_t *, unsigned long); static void receiveHostDescriptor(const DSSI_Host_Descriptor *descriptor); static void workThreadCallback(LADSPA_Handle); diff -r deabf9fd3d28 -r a12fd0456f0c rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/rdf/RDFFeatureWriter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -146,14 +146,14 @@ m_rdfDescriptions[pluginId] = PluginRDFDescription(pluginId); if (m_rdfDescriptions[pluginId].haveDescription()) { - cerr << "NOTE: Have RDF description for plugin ID \"" + SVCERR << "NOTE: Have RDF description for plugin ID \"" << pluginId << "\"" << endl; } else { - cerr << "NOTE: No RDF description for plugin ID \"" + SVCERR << "NOTE: No RDF description for plugin ID \"" << pluginId << "\"" << endl; if (!m_network) { - cerr << " Consider using the --rdf-network option to retrieve plugin descriptions" << endl; - cerr << " from the network where possible." << endl; + SVCERR << " Consider using the --rdf-network option to retrieve plugin descriptions" << endl; + SVCERR << " from the network where possible." << endl; } } } @@ -194,7 +194,7 @@ QString timelineURI = m_trackTimelineURIs[trackId]; if (timelineURI == "") { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing features without having established a timeline URI!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing features without having established a timeline URI!" << endl; exit(1); } @@ -211,7 +211,7 @@ QString signalURI = m_trackSignalURIs[trackId]; if (signalURI == "") { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having established a signal URI!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having established a signal URI!" << endl; exit(1); } @@ -229,7 +229,7 @@ QString signalURI = m_trackSignalURIs[trackId]; if (signalURI == "") { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing track-level features without having established a signal URI!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing track-level features without having established a signal URI!" << endl; exit(1); } @@ -702,19 +702,19 @@ sampleRate = transform.getSampleRate(); if (sampleRate == 0.f) { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the sample rate properly!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the sample rate properly!" << endl; return; } stepSize = transform.getStepSize(); if (stepSize == 0) { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the step size properly!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the step size properly!" << endl; return; } blockSize = transform.getBlockSize(); if (blockSize == 0) { - cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the block size properly!" << endl; + SVCERR << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the block size properly!" << endl; return; } } diff -r deabf9fd3d28 -r a12fd0456f0c transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/CSVFeatureWriter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -117,8 +117,8 @@ } else if (i->first == "digits") { int digits = atoi(i->second.c_str()); if (digits <= 0 || digits > 100) { - cerr << "CSVFeatureWriter: ERROR: Invalid or out-of-range value for number of significant digits: " << i->second << endl; - cerr << "CSVFeatureWriter: NOTE: Continuing with default settings" << endl; + SVCERR << "CSVFeatureWriter: ERROR: Invalid or out-of-range value for number of significant digits: " << i->second << endl; + SVCERR << "CSVFeatureWriter: NOTE: Continuing with default settings" << endl; } else { m_digits = digits; } diff -r deabf9fd3d28 -r a12fd0456f0c transform/FeatureExtractionModelTransformer.cpp --- a/transform/FeatureExtractionModelTransformer.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -100,7 +100,7 @@ if (!factory) { m_message = tr("No factory available for feature extraction plugin id \"%1\" (unknown plugin type, or internal error?)").arg(pluginId); SVCERR << m_message << endl; - return false; + return false; } DenseTimeValueModel *input = getConformingInput(); @@ -117,7 +117,7 @@ if (!m_plugin) { m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId); SVCERR << m_message << endl; - return false; + return false; } TransformFactory::getInstance()->makeContextConsistentWithPlugin @@ -128,7 +128,7 @@ int channelCount = input->getChannelCount(); if ((int)m_plugin->getMaxChannelCount() < channelCount) { - channelCount = 1; + channelCount = 1; } if ((int)m_plugin->getMinChannelCount() > channelCount) { m_message = tr("Cannot provide enough channels to feature extraction plugin \"%1\" (plugin min is %2, max %3; input model has %4)") @@ -137,7 +137,7 @@ .arg(m_plugin->getMaxChannelCount()) .arg(input->getChannelCount()); SVCERR << m_message << endl; - return false; + return false; } int step = primaryTransform.getStepSize(); @@ -217,7 +217,7 @@ if (outputs.empty()) { m_message = tr("Plugin \"%1\" has no outputs").arg(pluginId); SVCERR << m_message << endl; - return false; + return false; } for (int j = 0; j < (int)m_transforms.size(); ++j) { @@ -290,17 +290,17 @@ bool haveBinCount = m_descriptors[n]->hasFixedBinCount; if (haveBinCount) { - binCount = (int)m_descriptors[n]->binCount; + binCount = (int)m_descriptors[n]->binCount; } m_needAdditionalModels[n] = false; // cerr << "FeatureExtractionModelTransformer: output bin count " -// << binCount << endl; +// << binCount << endl; if (binCount > 0 && m_descriptors[n]->hasKnownExtents) { - minValue = m_descriptors[n]->minValue; - maxValue = m_descriptors[n]->maxValue; + minValue = m_descriptors[n]->minValue; + maxValue = m_descriptors[n]->maxValue; haveExtents = true; } @@ -330,14 +330,14 @@ switch (m_descriptors[n]->sampleType) { case Vamp::Plugin::OutputDescriptor::VariableSampleRate: - if (outputRate != 0.0) { - modelResolution = int(round(modelRate / outputRate)); - } - break; + if (outputRate != 0.0) { + modelResolution = int(round(modelRate / outputRate)); + } + break; case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: - modelResolution = m_transforms[n].getStepSize(); - break; + modelResolution = m_transforms[n].getStepSize(); + break; case Vamp::Plugin::OutputDescriptor::FixedSampleRate: if (outputRate <= 0.0) { @@ -347,7 +347,7 @@ modelResolution = int(round(modelRate / outputRate)); // cerr << "modelRate = " << modelRate << ", descriptor rate = " << outputRate << ", modelResolution = " << modelResolution << endl; } - break; + break; } bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); @@ -516,13 +516,13 @@ EditableDenseThreeDimensionalModel::BasicMultirateCompression, false); - if (!m_descriptors[n]->binNames.empty()) { - std::vector names; - for (int i = 0; i < (int)m_descriptors[n]->binNames.size(); ++i) { - names.push_back(m_descriptors[n]->binNames[i].c_str()); - } - model->setBinNames(names); - } + if (!m_descriptors[n]->binNames.empty()) { + std::vector names; + for (int i = 0; i < (int)m_descriptors[n]->binNames.size(); ++i) { + names.push_back(m_descriptors[n]->binNames[i].c_str()); + } + model->setBinNames(names); + } out = model; @@ -621,9 +621,9 @@ // SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: input model is " << getInputModel() << endl; DenseTimeValueModel *dtvm = - dynamic_cast(getInputModel()); + dynamic_cast(getInputModel()); if (!dtvm) { - SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; + SVDEBUG << "FeatureExtractionModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; } return dtvm; } @@ -665,12 +665,12 @@ int channelCount = input->getChannelCount(); if ((int)m_plugin->getMaxChannelCount() < channelCount) { - channelCount = 1; + channelCount = 1; } float **buffers = new float*[channelCount]; for (int ch = 0; ch < channelCount; ++ch) { - buffers[ch] = new float[primaryTransform.getBlockSize() + 2]; + buffers[ch] = new float[primaryTransform.getBlockSize() + 2]; } int stepSize = primaryTransform.getStepSize(); @@ -754,8 +754,8 @@ contextStart + contextDuration) break; } -// SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame " -// << blockFrame << ", endFrame " << endFrame << ", blockSize " +// SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame " +// << blockFrame << ", endFrame " << endFrame << ", blockSize " // << blockSize << endl; int completion = int @@ -927,23 +927,23 @@ sv_frame_t frame = blockFrame; if (m_descriptors[n]->sampleType == - Vamp::Plugin::OutputDescriptor::VariableSampleRate) { + Vamp::Plugin::OutputDescriptor::VariableSampleRate) { - if (!feature.hasTimestamp) { - SVDEBUG - << "WARNING: FeatureExtractionModelTransformer::addFeature: " - << "Feature has variable sample rate but no timestamp!" - << endl; - return; - } else { - frame = RealTime::realTime2Frame(feature.timestamp, inputRate); - } + if (!feature.hasTimestamp) { + SVDEBUG + << "WARNING: FeatureExtractionModelTransformer::addFeature: " + << "Feature has variable sample rate but no timestamp!" + << endl; + return; + } else { + frame = RealTime::realTime2Frame(feature.timestamp, inputRate); + } // cerr << "variable sample rate: timestamp = " << feature.timestamp // << " at input rate " << inputRate << " -> " << frame << endl; } else if (m_descriptors[n]->sampleType == - Vamp::Plugin::OutputDescriptor::FixedSampleRate) { + Vamp::Plugin::OutputDescriptor::FixedSampleRate) { sv_samplerate_t rate = m_descriptors[n]->sampleRate; if (rate <= 0.0) { @@ -984,16 +984,16 @@ SparseOneDimensionalModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; model->addPoint(SparseOneDimensionalModel::Point (frame, feature.label.c_str())); - + } else if (isOutput(n)) { - SparseTimeValueModel *model = + SparseTimeValueModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; for (int i = 0; i < (int)feature.values.size(); ++i) { @@ -1051,7 +1051,7 @@ duration, velocity / 127.f, feature.label.c_str())); - // GF: end -- added for flexi note model + // GF: end -- added for flexi note model } else if (isOutput(n)) { float velocity = 100; @@ -1096,14 +1096,14 @@ feature.label.c_str())); } } - + } else if (isOutput(n)) { - - DenseThreeDimensionalModel::Column values = feature.values; - - EditableDenseThreeDimensionalModel *model = + + DenseThreeDimensionalModel::Column values = feature.values; + + EditableDenseThreeDimensionalModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; // cerr << "(note: model resolution = " << model->getResolution() << ")" // << endl; @@ -1127,48 +1127,48 @@ if (isOutput(n)) { - SparseOneDimensionalModel *model = + SparseOneDimensionalModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); + model->setCompletion(completion, true); } else if (isOutput(n)) { - SparseTimeValueModel *model = + SparseTimeValueModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); + model->setCompletion(completion, true); } else if (isOutput(n)) { - NoteModel *model = getConformingOutput(n); - if (!model) return; + NoteModel *model = getConformingOutput(n); + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); - + model->setCompletion(completion, true); + } else if (isOutput(n)) { - FlexiNoteModel *model = getConformingOutput(n); - if (!model) return; + FlexiNoteModel *model = getConformingOutput(n); + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); + model->setCompletion(completion, true); } else if (isOutput(n)) { - RegionModel *model = getConformingOutput(n); - if (!model) return; + RegionModel *model = getConformingOutput(n); + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); + model->setCompletion(completion, true); } else if (isOutput(n)) { - EditableDenseThreeDimensionalModel *model = + EditableDenseThreeDimensionalModel *model = getConformingOutput(n); - if (!model) return; + if (!model) return; if (model->isAbandoning()) abandon(); - model->setCompletion(completion, true); //!!!m_context.updates); + model->setCompletion(completion, true); //!!!m_context.updates); } } diff -r deabf9fd3d28 -r a12fd0456f0c transform/FeatureExtractionModelTransformer.h --- a/transform/FeatureExtractionModelTransformer.h Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/FeatureExtractionModelTransformer.h Tue Apr 17 10:35:42 2018 +0100 @@ -70,7 +70,7 @@ void addFeature(int n, sv_frame_t blockFrame, - const Vamp::Plugin::Feature &feature); + const Vamp::Plugin::Feature &feature); void setCompletion(int, int); diff -r deabf9fd3d28 -r a12fd0456f0c transform/FileFeatureWriter.cpp --- a/transform/FileFeatureWriter.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/FileFeatureWriter.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -46,7 +46,7 @@ } else if (m_support & SupportOneFileTotal) { m_singleFileName = QString("output.%1").arg(m_extension); } else { - cerr << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl; + SVCERR << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl; } } } @@ -130,7 +130,7 @@ if (m_support & SupportOneFilePerTrackTransform && m_support & SupportOneFilePerTrack) { if (m_singleFileName != "") { - cerr << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl; + SVCERR << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl; } else { m_manyFiles = true; } @@ -144,7 +144,7 @@ // OneFilePerTrack), so we need to be able to // override it // if (m_manyFiles) { -// cerr << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl; +// SVCERR << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl; // } else { m_singleFileName = i->second.c_str(); // } @@ -153,7 +153,7 @@ } else if (i->first == "stdout") { if (m_support & SupportStdOut) { if (m_singleFileName != "") { - cerr << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl; + SVCERR << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl; } else { m_stdout = true; } @@ -172,8 +172,8 @@ { if (m_singleFileName != "") { if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) { - cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl; - cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; + SVCERR << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl; + SVCERR << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; return ""; } return m_singleFileName; @@ -219,8 +219,8 @@ filename = QDir(dirname).filePath(filename); if (QFileInfo(filename).exists() && !(m_force || m_append)) { - cerr << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl; - cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; + SVCERR << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl; + SVCERR << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; return ""; } @@ -300,7 +300,7 @@ if (m_append) mode |= QIODevice::Append; if (!file->open(mode)) { - cerr << "FileFeatureWriter: ERROR: Failed to open output file \"" << filename + SVCERR << "FileFeatureWriter: ERROR: Failed to open output file \"" << filename << "\" for writing" << endl; delete file; m_files[key] = 0; diff -r deabf9fd3d28 -r a12fd0456f0c transform/ModelTransformerFactory.cpp --- a/transform/ModelTransformerFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/ModelTransformerFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -261,8 +261,8 @@ // SVDEBUG << "ModelTransformerFactory::transformerFinished(" << transformer << ")" << endl; if (!transformer) { - cerr << "WARNING: ModelTransformerFactory::transformerFinished: sender is not a transformer" << endl; - return; + cerr << "WARNING: ModelTransformerFactory::transformerFinished: sender is not a transformer" << endl; + return; } if (m_runningTransformers.find(transformer) == m_runningTransformers.end()) { diff -r deabf9fd3d28 -r a12fd0456f0c transform/RealTimeEffectModelTransformer.cpp --- a/transform/RealTimeEffectModelTransformer.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/RealTimeEffectModelTransformer.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -50,12 +50,12 @@ // SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl; RealTimePluginFactory *factory = - RealTimePluginFactory::instanceFor(pluginId); + RealTimePluginFactory::instanceFor(pluginId); if (!factory) { - cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" - << pluginId << "\"" << endl; - return; + cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" + << pluginId << "\"" << endl; + return; } DenseTimeValueModel *input = getConformingInput(); @@ -67,9 +67,9 @@ input->getChannelCount()); if (!m_plugin) { - cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" + cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" << pluginId << "\"" << endl; - return; + return; } TransformFactory::getInstance()->setPluginParameters(transform, m_plugin); @@ -93,7 +93,7 @@ m_outputs.push_back(model); } else { - + SparseTimeValueModel *model = new SparseTimeValueModel (input->getSampleRate(), transform.getBlockSize(), 0.0, 0.0, false); @@ -112,9 +112,9 @@ RealTimeEffectModelTransformer::getConformingInput() { DenseTimeValueModel *dtvm = - dynamic_cast(getInputModel()); + dynamic_cast(getInputModel()); if (!dtvm) { - SVDEBUG << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; + SVDEBUG << "RealTimeEffectModelTransformer::getConformingInput: WARNING: Input model is not conformable to DenseTimeValueModel" << endl; } return dtvm; } @@ -183,13 +183,13 @@ while (blockFrame < contextStart + contextDuration + latency && !m_abandoned) { - int completion = int - ((((blockFrame - contextStart) / blockSize) * 99) / + int completion = int + ((((blockFrame - contextStart) / blockSize) * 99) / (1 + ((contextDuration) / blockSize))); - sv_frame_t got = 0; + sv_frame_t got = 0; - if (channelCount == 1) { + if (channelCount == 1) { if (inbufs && inbufs[0]) { auto data = input->getData (m_input.getChannel(), blockFrame, blockSize); @@ -206,7 +206,7 @@ } } } - } else { + } else { if (inbufs && inbufs[0]) { auto data = input->getMultiChannelData (0, channelCount - 1, blockFrame, blockSize); @@ -228,7 +228,7 @@ } } } - } + } /* cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl; @@ -281,15 +281,15 @@ } } - if (blockFrame == contextStart || completion > prevCompletion) { + if (blockFrame == contextStart || completion > prevCompletion) { // This setCompletion is probably misusing the completion // terminology, just as it was for WritableWaveFileModel - if (stvm) stvm->setCompletion(completion); - if (wwfm) wwfm->setWriteProportion(completion); - prevCompletion = completion; - } + if (stvm) stvm->setCompletion(completion); + if (wwfm) wwfm->setWriteProportion(completion); + prevCompletion = completion; + } - blockFrame += blockSize; + blockFrame += blockSize; } if (m_abandoned) return; diff -r deabf9fd3d28 -r a12fd0456f0c transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Tue Apr 17 10:03:51 2018 +0100 +++ b/transform/TransformFactory.cpp Tue Apr 17 10:35:42 2018 +0100 @@ -112,20 +112,20 @@ std::set dset; for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); - i != m_transforms.end(); ++i) { + i != m_transforms.end(); ++i) { #ifdef DEBUG_TRANSFORM_FACTORY cerr << "inserting transform into set: id = " << i->second.identifier << endl; #endif - dset.insert(i->second); + dset.insert(i->second); } TransformList list; for (std::set::const_iterator i = dset.begin(); - i != dset.end(); ++i) { + i != dset.end(); ++i) { #ifdef DEBUG_TRANSFORM_FACTORY cerr << "inserting transform into list: id = " << i->identifier << endl; #endif - list.push_back(*i); + list.push_back(*i); } return list; @@ -158,20 +158,20 @@ std::set dset; for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin(); - i != m_uninstalledTransforms.end(); ++i) { + i != m_uninstalledTransforms.end(); ++i) { #ifdef DEBUG_TRANSFORM_FACTORY cerr << "inserting transform into set: id = " << i->second.identifier << endl; #endif - dset.insert(i->second); + dset.insert(i->second); } TransformList list; for (std::set::const_iterator i = dset.begin(); - i != dset.end(); ++i) { + i != dset.end(); ++i) { #ifdef DEBUG_TRANSFORM_FACTORY cerr << "inserting transform into uninstalled list: id = " << i->identifier << endl; #endif - list.push_back(*i); + list.push_back(*i); } return list; @@ -248,7 +248,7 @@ std::set types; for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); - i != m_transforms.end(); ++i) { + i != m_transforms.end(); ++i) { types.insert(i->second.type); } @@ -376,17 +376,17 @@ i != transforms.end(); ++i) { TransformDescription desc = i->second; - QString identifier = desc.identifier; + QString identifier = desc.identifier; QString maker = desc.maker; QString td = desc.name; QString tn = td.section(": ", 0, 0); QString to = td.section(": ", 1); - if (names[tn] > 1) { + if (names[tn] > 1) { maker.replace(QRegExp(tr(" [\\(<].*$")), ""); - tn = QString("%1 [%2]").arg(tn).arg(maker); - } + tn = QString("%1 [%2]").arg(tn).arg(maker); + } if (to != "") { desc.name = QString("%1: %2").arg(tn).arg(to); @@ -394,8 +394,8 @@ desc.name = tn; } - m_transforms[identifier] = desc; - } + m_transforms[identifier] = desc; + } m_transformsPopulated = true; } @@ -416,7 +416,7 @@ for (int i = 0; i < (int)plugs.size(); ++i) { - QString pluginId = plugs[i]; + QString pluginId = plugs[i]; piper_vamp::PluginStaticData psd = factory->getPluginStaticData(pluginId); @@ -434,10 +434,10 @@ QString outputName = QString::fromStdString(o.name); - QString transformId = QString("%1:%2") + QString transformId = QString("%1:%2") .arg(pluginId).arg(QString::fromStdString(o.identifier)); - QString userName; + QString userName; QString friendlyName; //!!! return to this QString units = outputs[j].unit.c_str(); QString description = QString::fromStdString(psd.basic.description); @@ -464,13 +464,13 @@ } } - if (basicOutputs.size() == 1) { - userName = pluginName; + if (basicOutputs.size() == 1) { + userName = pluginName; friendlyName = pluginName; - } else { - userName = QString("%1: %2").arg(pluginName).arg(outputName); + } else { + userName = QString("%1: %2").arg(pluginName).arg(outputName); friendlyName = outputName; - } + } bool configurable = (!psd.programs.empty() || !psd.parameters.empty()); @@ -479,7 +479,7 @@ cerr << "Feature extraction plugin transform: " << transformId << " friendly name: " << friendlyName << endl; #endif - transforms[transformId] = + transforms[transformId] = TransformDescription(TransformDescription::Analysis, category, transformId, @@ -491,7 +491,7 @@ //!!! units, "", configurable); - } + } } } @@ -499,37 +499,37 @@ TransformFactory::populateRealTimePlugins(TransformDescriptionMap &transforms) { std::vector plugs = - RealTimePluginFactory::getAllPluginIdentifiers(); + RealTimePluginFactory::getAllPluginIdentifiers(); if (m_exiting) return; static QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$"); for (int i = 0; i < (int)plugs.size(); ++i) { - QString pluginId = plugs[i]; + QString pluginId = plugs[i]; RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(pluginId); - if (!factory) { - cerr << "WARNING: TransformFactory::populateTransforms: No real time plugin factory for instance " << pluginId << endl; - continue; - } + if (!factory) { + cerr << "WARNING: TransformFactory::populateTransforms: No real time plugin factory for instance " << pluginId << endl; + continue; + } const RealTimePluginDescriptor *descriptor = factory->getPluginDescriptor(pluginId); if (!descriptor) { - cerr << "WARNING: TransformFactory::populateTransforms: Failed to query plugin " << pluginId << endl; - continue; - } - + cerr << "WARNING: TransformFactory::populateTransforms: Failed to query plugin " << pluginId << endl; + continue; + } + //!!! if (descriptor->controlOutputPortCount == 0 || // descriptor->audioInputPortCount == 0) continue; // cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId << " has " << descriptor->controlOutputPortCount << " control output ports, " << descriptor->audioOutputPortCount << " audio outputs, " << descriptor->audioInputPortCount << " audio inputs" << endl; - - QString pluginName = descriptor->name.c_str(); + + QString pluginName = descriptor->name.c_str(); QString category = factory->getPluginCategory(pluginId); bool configurable = (descriptor->parameterCount > 0); QString maker = descriptor->maker.c_str(); @@ -856,7 +856,7 @@ TransformFactory::getTransformName(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].name; + return m_transforms[identifier].name; } else return ""; } @@ -864,7 +864,7 @@ TransformFactory::getTransformFriendlyName(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].friendlyName; + return m_transforms[identifier].friendlyName; } else return ""; } @@ -872,7 +872,7 @@ TransformFactory::getTransformUnits(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].units; + return m_transforms[identifier].units; } else return ""; } @@ -880,7 +880,7 @@ TransformFactory::getTransformInfoUrl(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].infoUrl; + return m_transforms[identifier].infoUrl; } else return ""; } @@ -913,7 +913,7 @@ TransformFactory::isTransformConfigurable(TransformId identifier) { if (m_transforms.find(identifier) != m_transforms.end()) { - return m_transforms[identifier].configurable; + return m_transforms[identifier].configurable; } else return false; }