From c6a5d278d3bc5d5ef9d313f7801da2a2e486c20b Mon Sep 17 00:00:00 2001 From: DiyunZ Date: Mon, 31 Aug 2026 20:29:06 -0500 Subject: [PATCH 1/5] Fix source-build warnings --- .github/workflows/build.yml | 1 + CMOD/src/Bottom.cpp | 91 +++++++++---------- CMOD/src/Define.h | 4 +- CMOD/src/Event.cpp | 41 ++++----- CMOD/src/Event.h | 2 +- CMOD/src/Main.cpp | 2 +- CMOD/src/Matrix.cpp | 15 ++- CMOD/src/ModParser.cpp | 2 +- CMOD/src/Modifier.cpp | 6 +- CMOD/src/NotationScore.cpp | 1 - CMOD/src/Note.cpp | 8 +- CMOD/src/Patter.cpp | 7 +- CMOD/src/Piece-experimental.cpp | 71 +++++++-------- CMOD/src/Random.cpp | 6 +- CMOD/src/Rational.h | 2 +- CMOD/src/Section.cpp | 20 ++-- CMOD/src/Sieve.cpp | 18 ++-- CMOD/src/SignalHandlers.cpp | 8 +- CMOD/src/TimeSignature.h | 6 +- CMOD/src/Utilities.cpp | 34 +++---- CMakeLists.txt | 4 +- LASS/src/AllPassFilter.cpp | 2 +- LASS/src/AuWriter.cpp | 2 +- LASS/src/BiQuadFilter.cpp | 9 +- LASS/src/BiQuadFilter.h | 1 + LASS/src/Constant.cpp | 7 +- LASS/src/DynamicVariableSequence.cpp | 26 +++--- LASS/src/DynamicVariableSequenceIterator.cpp | 2 +- LASS/src/Envelope.cpp | 46 +++++----- LASS/src/EnvelopeIterator.cpp | 2 +- LASS/src/EnvelopeLibrary.cpp | 22 ++--- LASS/src/Interpolator.cpp | 10 +- LASS/src/InterpolatorIterator.cpp | 10 +- LASS/src/LPCombFilter.cpp | 4 +- LASS/src/Loudness.cpp | 22 ++--- LASS/src/MarkovModel.h | 14 +-- LASS/src/MultiPan.cpp | 10 +- LASS/src/Pan.cpp | 2 +- LASS/src/Partial.cpp | 30 +++--- LASS/src/Partial.h | 4 +- LASS/src/ProbabilityEnvelope.cpp | 6 +- LASS/src/Reverb.cpp | 68 +++++++------- LASS/src/Score.cpp | 8 +- LASS/src/Score.h | 4 +- LASS/src/Sound.cpp | 46 +++++----- LASS/src/Sound.h | 2 +- LASS/src/SoundSample.cpp | 4 +- LASS/src/Spatializer.cpp | 2 +- LASS/src/Types.h | 5 + LASS/src/XmlReader.cpp | 27 +++--- LASSIE/src/core/EnvelopeLibraryEntry.cpp | 4 +- LASSIE/src/core/project_struct.cpp | 3 + LASSIE/src/dialogs/FunctionGenerator.cpp | 6 +- LASSIE/src/widgets/EnvLibDrawingArea.cpp | 12 +-- .../widgets/EventAttributesViewController.cpp | 2 +- LASSIE/src/widgets/ProjectViewController.cpp | 11 ++- LASSIE/src/windows/EnvelopeLibraryWindow.cpp | 6 +- LASSIE/src/windows/MainWindow.cpp | 2 +- external-libs/muParser/CMakeLists.txt | 5 + .../muParser/muParserTokenReader.cpp | 2 +- 60 files changed, 404 insertions(+), 395 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f5ace30..87f43140 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,6 +107,7 @@ jobs: cmake -S . -B build -G Ninja ` -DCMAKE_BUILD_TYPE=Release ` + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON ` "-DCMAKE_PREFIX_PATH=$env:Qt6_DIR" ` "-DCMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" ` -DVCPKG_TARGET_TRIPLET=x64-windows ` diff --git a/CMOD/src/Bottom.cpp b/CMOD/src/Bottom.cpp index 2565785e..969fbed2 100644 --- a/CMOD/src/Bottom.cpp +++ b/CMOD/src/Bottom.cpp @@ -343,7 +343,7 @@ void Bottom::buildSound(SoundAndNoteWrapper* _soundNoteWrapper) { pugi::xml_node distanceElement = GNES(partialEnvElement); Envelope* waveShape = (Envelope*) utilities->evaluateObject(XMLTC(partialEnvElement),(void*)this, eventEnv ); - float distance = utilities->evaluate(XMLTC(distanceElement),(void*)this); + float distance = static_cast(utilities->evaluate(XMLTC(distanceElement),(void*)this)); //instead of reading partials, generate spectrum envelope and add to sound generatePartials(newSound, baseFrequency, loudSones, distance, waveShape); @@ -363,7 +363,7 @@ void Bottom::buildSound(SoundAndNoteWrapper* _soundNoteWrapper) { Partial partial; //Set the partial number of the partial based on the current index. - partial.setParam(PARTIAL_NUM, i); + partial.setParam(PARTIAL_NUM, static_cast(i)); //Compute the deviation for partials above the fundamental. double deviation = 0; @@ -373,7 +373,7 @@ void Bottom::buildSound(SoundAndNoteWrapper* _soundNoteWrapper) { //Set the frequencies for each partial. float actualFrequency = setPartialFreq( - partial, deviation, baseFrequency, i); + partial, static_cast(deviation), baseFrequency, i); //Report the actual frequency. stringstream ss; if(i != 0) ss << "Partial " << i; else ss << "Fundamental"; @@ -461,21 +461,21 @@ void Bottom::buildNote(SoundAndNoteWrapper* _soundNoteWrapper) { vector noteMods = applyNoteModifiers(modifiersInfo); newNote->setModifiers(noteMods); // set childStaff - int noteStaff = utilities->evaluate(XMLTC(staffsInfo),(void*)this); + int noteStaff = static_cast(utilities->evaluate(XMLTC(staffsInfo),(void*)this)); // int noteStaff = applyNoteStaffs(_soundNoteWrapper->element); newNote->setStaffNum(noteStaff); //Set the pitch. float baseFrequency = computeBaseFreq(); - int absPitchNum; + int notePitch; if(wellTempPitch <= 0) { //if frequency is in Hertz - absPitchNum = newNote->HertzToPitch(baseFrequency); + notePitch = newNote->HertzToPitch(baseFrequency); } else { - absPitchNum = wellTempPitch; + notePitch = wellTempPitch; } - newNote->setPitchWellTempered(absPitchNum); + newNote->setPitchWellTempered(notePitch); // Set notation start, start absolute, and end times in edus newNote->setStartTime(_soundNoteWrapper->ts.startEDU.To()); @@ -528,12 +528,12 @@ float Bottom::computeBaseFreq() { /* 2nd arg is a string (HERTZ or POW2) */ if (utilities->evaluate(XMLTC(continuumFlagElement), NULL)==0) { //Hertz - baseFreqResult = utilities->evaluate(XMLTC(valueElement), (void*)this); + baseFreqResult = static_cast(utilities->evaluate(XMLTC(valueElement), (void*)this)); /* 3rd arg is a float (baseFreq in Hz) */ } else {//power of 2 /* 3rd arg is a float (power of 2) */ - float step = utilities->evaluate(XMLTC(valueElement), (void*)this); + float step = static_cast(utilities->evaluate(XMLTC(valueElement), (void*)this)); if(step <= log2(MINFREQ/C0) || step >= log2(CEILING/C0)) { cerr << "CMOD warning: " << context << " / FrequencyEntry1: power-of-two step " << step << " is outside the audible range (" @@ -541,7 +541,7 @@ float Bottom::computeBaseFreq() { << "Check the power-of-two expression; partial frequencies outside " << MINFREQ << " to " << CEILING << " Hz are clamped." << endl; } - baseFreqResult = C0 * pow(2, step); + baseFreqResult = static_cast(C0 * pow(2, step)); } } else if (frequencyMode == 0) { //equal tempered /* 2nd arg is an int */ @@ -554,10 +554,10 @@ float Bottom::computeBaseFreq() { "Check the pitch expression and choose a pitch that produces a finite, positive frequency."); } wellTempPitch = static_cast(pitch); - baseFreqResult = C0 * pow(WELL_TEMP_INCR, wellTempPitch); + baseFreqResult = static_cast(C0 * pow(WELL_TEMP_INCR, wellTempPitch)); } else {// fundamental /* 2nd arg is (float)fundamental_freq, 3rd arg is (int)overtone_num */ - float fund_freq = utilities->evaluate(XMLTC(valueElement), (void*)this); + float fund_freq = static_cast(utilities->evaluate(XMLTC(valueElement), (void*)this)); const double overtone = utilities->evaluate(XMLTC(valueElement2), this); if (overtone < 1 || overtone > std::numeric_limits::max()) { throw CmodError(CmodError::Kind::Project, @@ -585,7 +585,7 @@ float Bottom::computeLoudness() { // expVal += utilities->evaluate(XMLTC(loudnessElement), (void*)this); // } // expVal /= 10; - float loudval = utilities->evaluate(XMLTC(loudnessElement), (void*)this); + float loudval = static_cast(utilities->evaluate(XMLTC(loudnessElement), (void*)this)); // float diff = loudval - expVal; // loudval -= 0.4 * diff; // cout << "bottom loudness: " << loudval << endl; @@ -607,7 +607,7 @@ float Bottom::computeCarrierPhase() { return 0.0f; } - float phase = utilities->evaluate(phaseExpression, (void*)this); + float phase = static_cast(utilities->evaluate(phaseExpression, (void*)this)); if (!std::isfinite(phase)) { cerr << "WARNING: Carrier Phase for Bottom " << name << " is not finite; using 0 cycle." << endl; @@ -668,7 +668,7 @@ int Bottom::computeNumPartials(float baseFreq, pugi::xml_node _spectrum) { float Bottom::computeDeviation( pugi::xml_node _spectrum) { pugi::xml_node devElement = GNES(GNES(GNES(GFEC(_spectrum)))); - return utilities->evaluate(XMLTC(devElement), (void*)this); + return static_cast(utilities->evaluate(XMLTC(devElement), (void*)this)); } //----------------------------------------------------------------------------// @@ -676,7 +676,7 @@ float Bottom::computeDeviation( pugi::xml_node _spectrum) { float Bottom::setPartialFreq(Partial& part, float deviation, float baseFreq, int partNum) { // assign frequency to each partial - float pDev = deviation * (Random::Rand() - 0.5) * 2; + float pDev = static_cast(deviation * (Random::Rand() - 0.5) * 2); float pFreq = baseFreq * ((partNum + 1) + pDev); // if pFreq is out of range then set it to the closer of the max or min value @@ -926,7 +926,7 @@ void Bottom::spatializationMultiPan(Sound *s, /* ZIYUAN CHEN, July 2023 */ MultiPan Bottom::computeSpatializationMultiPan(vector mult) { - MultiPan multipan(mult.size(), mult); + MultiPan multipan(static_cast(mult.size()), mult); for (unsigned i = 0; i < mult.size(); i++) { delete mult[i]; @@ -1007,7 +1007,7 @@ MultiPan Bottom::computeSpatializationPolar(string thetaEnvStr, string radiusEnv //cout << "TIME THETA RADIUS" << endl; for (int i = 0; i <= numPolarSamples; i++) { time = (float)i / numPolarSamples; - theta = PI * thetaEnv->getScaledValueNew(time, 1.0); + theta = static_cast(PI * thetaEnv->getScaledValueNew(time, 1.0)); radius = radiusEnv->getScaledValueNew(time, 1.0); multipan.addEntryLocation(time, theta, radius); @@ -1030,8 +1030,8 @@ MultiPan Bottom::computeSpatializationPolar(string thetaEnvStr, string radiusEnv //----------------------------------------------------------------------------// void Bottom::applyFilter(Sound* s){ - pugi::xml_node filterElement = utilities->evaluateFil((void*) this); - if (filterElement == NULL) return; //no filter + pugi::xml_node evaluatedFilter = utilities->evaluateFil((void*) this); + if (evaluatedFilter == NULL) return; //no filter // // MakeFilter @@ -1040,8 +1040,8 @@ void Bottom::applyFilter(Sound* s){ // 4.5 // // - pugi::xml_node it = GNES(GFEC(filterElement)); - string type = XMLTC(it); + pugi::xml_node it = GNES(GFEC(evaluatedFilter)); + string filterType = XMLTC(it); it = GNES(it); double frequency = utilities->evaluate(XMLTC(it), (void*)this); it = GNES(it); @@ -1050,16 +1050,16 @@ void Bottom::applyFilter(Sound* s){ double gain = utilities->evaluate(XMLTC(it), (void*)this); int typeInt; - if (type =="LPF") typeInt = 0; - else if (type == "HPF") typeInt =1; - else if (type == "BPF") typeInt =2; - else if (type == "NF") typeInt =3; - else if (type == "PBEQF") typeInt =4; - else if (type == "LSF") typeInt =5; - else if (type == "HSF") typeInt =6; + if (filterType =="LPF") typeInt = 0; + else if (filterType == "HPF") typeInt =1; + else if (filterType == "BPF") typeInt =2; + else if (filterType == "NF") typeInt =3; + else if (filterType == "PBEQF") typeInt =4; + else if (filterType == "LSF") typeInt =5; + else if (filterType == "HSF") typeInt =6; else { throw CmodError(CmodError::Kind::Project, - "Unknown filter Type '" + type + "'.", + "Unknown filter Type '" + filterType + "'.", "Bottom '" + name + "' / Filter / Type", "Choose LPF, HPF, BPF, NF, PBEQF, LSF, or HSF, or remove the filter if it is not needed."); } @@ -1087,10 +1087,10 @@ void Bottom::applyFilter(Sound* s){ BiQuadFilter *filterObj= new BiQuadFilter( typeInt, - gain, - frequency, - utilities->getSamplingRate(), - bandWidth); + static_cast(gain), + static_cast(frequency), + static_cast(utilities->getSamplingRate()), + static_cast(bandWidth)); s->use_filter(filterObj); } @@ -1215,7 +1215,7 @@ Reverb* Bottom::computeReverberationSimple(pugi::xml_node sizeElement, int iPart "Set Room Size in the reverb definition if a non-default room is intended."); roomSize = 0.0; } else { - roomSize = utilities->evaluate(envstr, (void*)this); + roomSize = static_cast(utilities->evaluate(envstr, (void*)this)); } Reverb* reverbObj = new Reverb(roomSize, SAMPLING_RATE); @@ -1301,9 +1301,9 @@ Reverb* Bottom::computeReverberationMedium(pugi::xml_node percentElement, (Envelope*) utilities->evaluateObject(envstr, this, eventEnv); //3 floats: hi/low spread, gain all pass, delay - float hi_low_spread = utilities->evaluate(XMLTC(spreadElement),this); - float gain_all_pass = utilities->evaluate(XMLTC(allPassElement),this); - float delay = utilities->evaluate(XMLTC(delayElement),this); + float hi_low_spread = static_cast(utilities->evaluate(XMLTC(spreadElement),this)); + float gain_all_pass = static_cast(utilities->evaluate(XMLTC(allPassElement),this)); + float delay = static_cast(utilities->evaluate(XMLTC(delayElement),this)); if (!std::isfinite(delay) || delay < 0) { delete percent_rev; @@ -1444,8 +1444,8 @@ Reverb* Bottom::computeReverberationAdvanced(pugi::xml_node percentElement, } //2 floats: gain all pass, delay - float gain_all_pass = utilities->evaluate(XMLTC(allPassElement),this); - float delay = utilities->evaluate(XMLTC(delayElement),this); + float gain_all_pass = static_cast(utilities->evaluate(XMLTC(allPassElement),this)); + float delay = static_cast(utilities->evaluate(XMLTC(delayElement),this)); if (!std::isfinite(delay) || delay < 0) { delete percent_rev; @@ -2017,8 +2017,8 @@ vector Bottom::applyNoteModifiers( pugi::xml_node _playingMethods) { // } while ( currentTechnique != NULL); while (currentTechnique != NULL) { - string name = XMLTC(currentTechnique); - modNames.push_back(name); + string techniqueName = XMLTC(currentTechnique); + modNames.push_back(techniqueName); currentTechnique = GNES(currentTechnique); } @@ -2027,8 +2027,7 @@ vector Bottom::applyNoteModifiers( pugi::xml_node _playingMethods) { //----------------------------------------------------------------------------// -void Bottom::generatePartials(Sound* newsound, float frequency, float loudness, float distance, Envelope* waveShape){ - float strength = loudness*distance/256*2; //strength is normalized between 0 and 2 +void Bottom::generatePartials(Sound* newsound, float frequency, float, float, Envelope* waveShape){ if ((frequency < 233) || frequency > 932){ warnBottom(name, "Generate Spectrum / Frequency", @@ -2072,7 +2071,7 @@ void Bottom::generatePartials(Sound* newsound, float frequency, float loudness, Partial partial; //Set the partial number of the partial based on the current index. - partial.setParam(PARTIAL_NUM, i); + partial.setParam(PARTIAL_NUM, static_cast(i)); //Set the frequencies for each partial. float actualFrequency = setPartialFreq( diff --git a/CMOD/src/Define.h b/CMOD/src/Define.h index 28ae67af..50b0b6b2 100644 --- a/CMOD/src/Define.h +++ b/CMOD/src/Define.h @@ -70,8 +70,8 @@ static const double WELL_TEMP_INCR = pow(2, 1./12.); //static const double WELL_TEMP_INCR = pow(2, 1./24.); //static const double WELL_TEMP_INCR = 1.0594631; // static const float MAX_SONES = 256.; -static const float FIRST_CONST = -5.54; -static const float SECOND_CONST = -1.84; +static const float FIRST_CONST = static_cast(-5.54); +static const float SECOND_CONST = static_cast(-1.84); static const int SAMPLING_RATE = 44100; // constants for the Event class diff --git a/CMOD/src/Event.cpp b/CMOD/src/Event.cpp index 0bb346d3..05a71a1f 100644 --- a/CMOD/src/Event.cpp +++ b/CMOD/src/Event.cpp @@ -346,7 +346,7 @@ string Event::getTempoStringFromDOMElement(pugi::xml_node _element){ double fractionEntry1 = utilities->evaluate(XMLTC(thisElement),(void*)this); thisElement = GNES(thisElement); - double fractionEntry2 = utilities->evaluate(XMLTC(thisElement),(void*)this); + utilities->evaluate(XMLTC(thisElement),(void*)this); thisElement = GNES(thisElement); double valueEntry = utilities->evaluate(XMLTC(thisElement),(void*)this); @@ -653,21 +653,20 @@ bool Event::buildContinuum() { // get the start time float rawChildStartTime = 0.0; float rawChildDuration = 0.0; - int endTime = 0; if (align) { if (matrix == NULL) buildMatrix(false); MatPoint childPt = matrix->chooseContinuum(); - rawChildStartTime = childPt.stime; + rawChildStartTime = static_cast(childPt.stime); tsChild.startEDU = childPt.stime; tsChild.start = childPt.stime * tempo.getEDUDurationInSeconds().To(); - rawChildDuration = childPt.dur; + rawChildDuration = static_cast(childPt.dur); tsChild.durationEDU = childPt.dur; tsChild.duration = childPt.dur * tempo.getEDUDurationInSeconds().To(); } else { - rawChildStartTime = utilities->evaluate(XMLTC(childStartTimeElement),(void*)this); + rawChildStartTime = static_cast(utilities->evaluate(XMLTC(childStartTimeElement),(void*)this)); // how to process start time: EDU, SECONDS or PERCENTAGE if (startType == "1" ) { //"EDU" tsChild.start = rawChildStartTime * @@ -691,7 +690,7 @@ bool Event::buildContinuum() { childName = XMLTC(GFEC(childTypeElements[childType])); // get the duration - rawChildDuration = utilities->evaluate(XMLTC(childDurationElement),(void*)this); + rawChildDuration = static_cast(utilities->evaluate(XMLTC(childDurationElement),(void*)this)); // assign previousChild Duration here so that the next child can use it // a MISNOMER, actually the ENDTIME of present child @@ -831,11 +830,11 @@ bool Event::buildSweep() { if (matrix == NULL) buildMatrix(false); MatPoint childPt = matrix->chooseSweep(numChildren - currChildNum - 1); - rawChildStartTime = childPt.stime; + rawChildStartTime = static_cast(childPt.stime); tsChild.startEDU = childPt.stime; tsChild.start = childPt.stime * tempo.getEDUDurationInSeconds().To(); - rawChildDuration = childPt.dur; + rawChildDuration = static_cast(childPt.dur); tsChild.durationEDU = childPt.dur; tsChild.duration = childPt.dur * tempo.getEDUDurationInSeconds().To(); } else { @@ -843,7 +842,7 @@ bool Event::buildSweep() { // rawChildStartTime = // utilities->evaluate(XMLTC(childStartTimeElement),(void*)this); - rawChildStartTime = previousChildEndTime; //actually endTime + rawChildStartTime = static_cast(previousChildEndTime); //actually endTime //cout << "Event::buildSweep - rawChildStartTime=" << rawChildStartTime << endl; if (startType == "1" ) { //EDU @@ -861,7 +860,7 @@ bool Event::buildSweep() { if (tsChild.start < tsPrevious.end) { // Prevent events from overlapping tsChild.start = tsPrevious.end; - tsChild.startEDU = tsPrevious.end; + tsChild.startEDU = static_cast(tsPrevious.end); } // get the type @@ -869,7 +868,7 @@ bool Event::buildSweep() { childName = XMLTC(GFEC(childTypeElements[childType])); // get the duration - rawChildDuration = utilities->evaluate(XMLTC(childDurationElement),(void*)this); + rawChildDuration = static_cast(utilities->evaluate(XMLTC(childDurationElement),(void*)this)); //assign previousChild Duration here so that the next child can use it // this is a MISNOMER actually the endTime of the present child @@ -903,7 +902,7 @@ bool Event::buildSweep() { } if(startType == "1" && durType == "1") { - endTime = Event::verify_valid(previousChildEndTime); //missnomer ! + endTime = Event::verify_valid(static_cast(previousChildEndTime)); //missnomer ! tsChild.start = rawChildStartTime * //SEVER 5/19 2022 tempo.getEDUDurationInSeconds().To(); @@ -1251,7 +1250,7 @@ list Event::getNotes() { int Event::getCurrentLayer() { int countInLayer = 0; for(unsigned i = 0; i < layerVect.size(); i++) { - countInLayer += layerVect[i].size(); + countInLayer = static_cast(countInLayer + layerVect[i].size()); if(childType >= 0 && childType < countInLayer) return i; } @@ -1327,12 +1326,12 @@ string Event::getEDUDurationExactness(void) { //----------------------------------------------------------------------------// //Checked -string Event::unitTypeToUnits(string type) { - if(type == "UNITS" || type == "EDU") +string Event::unitTypeToUnits(string unitType) { + if(unitType == "UNITS" || unitType == "EDU") return "EDU"; - else if(type == "SECONDS") + else if(unitType == "SECONDS") return "sec."; - else if(type == "PERCENTAGE") + else if(unitType == "PERCENTAGE") return "normalized"; else return ""; @@ -1366,7 +1365,7 @@ bool Event::buildDiscrete() { string childName = XMLTC(GFEC(childTypeElements[childType])); if(durEDU > (int)maxChildDur) - durEDU = maxChildDur; + durEDU = static_cast(maxChildDur); tsChild.startEDU = stimeEDU; tsChild.durationEDU = durEDU; @@ -1510,9 +1509,9 @@ void Event::buildMatrix(bool discrete) { numTypesInLayers.push_back (numOfDiscretePackages); } - int parentEDUs = Note::str_to_int(tempo.getEDUPerSecond().toPrettyString()) * ts.duration; + int parentEDUs = static_cast(Note::str_to_int(tempo.getEDUPerSecond().toPrettyString()) * ts.duration); - matrix = new Matrix(childTypeElements.size(), attackSiv->GetNumItems(), + matrix = new Matrix(static_cast(childTypeElements.size()), attackSiv->GetNumItems(), durSiv->GetNumItems(), numTypesInLayers, parentEDUs, tempo, sieveAligned); if (discrete) { @@ -1570,7 +1569,7 @@ int Event::verify_valid(int endTime){ //cout << " " << endl; } - int length = attackSweep.size(); + int length = static_cast(attackSweep.size()); if (length == 0) { return endTime; } diff --git a/CMOD/src/Event.h b/CMOD/src/Event.h index 1f8f0ede..cc1237f1 100644 --- a/CMOD/src/Event.h +++ b/CMOD/src/Event.h @@ -427,7 +427,7 @@ class Event { /** * Converts "SECONDS" to "sec.", "PERCENTAGE" to "%", etc. **/ - string unitTypeToUnits(string type); + string unitTypeToUnits(string unitType); /** * helper functions diff --git a/CMOD/src/Main.cpp b/CMOD/src/Main.cpp index ad1aa5f3..05fdf960 100644 --- a/CMOD/src/Main.cpp +++ b/CMOD/src/Main.cpp @@ -100,7 +100,7 @@ static int runCmod(int parameterCount, char **parameterList) { time_t endTime; time(&endTime); - int seconds = difftime(endTime, startTime); + int seconds = static_cast(difftime(endTime, startTime)); int hr = seconds / 3600; int min = (seconds % 3600) / 60; int sec = seconds % 60; diff --git a/CMOD/src/Matrix.cpp b/CMOD/src/Matrix.cpp index 94f7b8fd..0a9f696d 100644 --- a/CMOD/src/Matrix.cpp +++ b/CMOD/src/Matrix.cpp @@ -33,7 +33,7 @@ extern EnvelopeLibrary envlib; //----------------------------------------------------------------------------// Matrix::Matrix(int numTypes, int numAttacks, int numDurations, - vector numTypesInLayers, int maxVal, + vector numTypesInLayers, int, Tempo tempo, bool sieveAligned) : sieveAligned(sieveAligned) , tempo(tempo) { @@ -127,7 +127,8 @@ void Matrix::setAttacks(Sieve* attackSieve, vector attackEnvs) { for (unsigned durNum = 0; durNum < matr[type][attNum].size(); durNum++) { matr[type][attNum][durNum].attdurprob += attackSieveValue; if (hasEnv) { - double attackEnvValue = attackEnvs[type]->getValue(attNum, matr[type].size()); + double attackEnvValue = attackEnvs[type]->getValue( + static_cast(attNum), static_cast(matr[type].size())); matr[type][attNum][durNum].attdurprob *= attackEnvValue; } matr[type][attNum][durNum].stime = attackStime; @@ -155,12 +156,8 @@ void Matrix::setDurations(Sieve* durSieve, int maxVal, vector durEnvs vector durProbs; durSieve->FillInVectors(durTimes, durProbs); - int start; int durEnd; - // this marks the end-window of the parent event - int maxStartTime = matr[0][matr[0].size()-1][0].stime; - bool hasEnv = durEnvs.size() >= matr.size(); //int oldType = 0; @@ -212,7 +209,8 @@ void Matrix::setDurations(Sieve* durSieve, int maxVal, vector durEnvs } else { matr[type][attNum][durNum].attdurprob *= durSieveVal; if (hasEnv) { - double durEnvVal = durEnvs[type]->getValue(durNum, matr[type][attNum].size()); + double durEnvVal = durEnvs[type]->getValue( + static_cast(durNum), static_cast(matr[type][attNum].size())); // cout << "Matrix::setDurations - durEnvVal=" << durEnvVal << endl; // int sever; cin >> sever; @@ -411,7 +409,7 @@ int Matrix::verify_valid(int endTime){ // beat-local anchor, keep the already valid EDU endpoint unchanged. if (short_attime.empty()) return endTime; - int length = short_attime.size(); + int length = static_cast(short_attime.size()); int low = 0; int high = length - 1; @@ -499,7 +497,6 @@ void Matrix::removeSweepConflicts(MatPoint &chosenPt) { // do for each dur int currStart = matr[type][attNum][durNum].stime; - int currEnd = currStart + matr[type][attNum][durNum].dur; if (chosenEnd > currStart) { matr[type][attNum][durNum].attdurprob = 0; diff --git a/CMOD/src/ModParser.cpp b/CMOD/src/ModParser.cpp index 79316df0..afbb66f1 100644 --- a/CMOD/src/ModParser.cpp +++ b/CMOD/src/ModParser.cpp @@ -167,7 +167,7 @@ void ModParser::parseExpr(const std::string& exp, int minVal, int maxVal) { std::vector operands; std::stack operators; unsigned chNum = 0; - int modIndex = 0; + size_t modIndex = 0; bool needsOperand = true; while (chNum < exp.size()) { char ch = exp[chNum]; diff --git a/CMOD/src/Modifier.cpp b/CMOD/src/Modifier.cpp index b12740ac..2d1842df 100644 --- a/CMOD/src/Modifier.cpp +++ b/CMOD/src/Modifier.cpp @@ -158,7 +158,7 @@ float Modifier::getProbability(double checkPoint) { return 0; } checkPt = checkPoint; - return probEnv->getValue(checkPoint, 1); + return probEnv->getValue(static_cast(checkPoint), 1); } //----------------------------------------------------------------------------// @@ -240,7 +240,7 @@ void Modifier::applyModSound(Sound* snd) { snd->setPartialParam(FREQTRANS_RATE_ENV, *(env_values[1])); snd->setPartialParam(FREQTRANS_WIDTH, *(env_values[2])); } else if (type == "WAVE_TYPE") { - snd->setPartialParam(WAVE_TYPE, env_values[0]->getValue(checkPt, 1)); + snd->setPartialParam(WAVE_TYPE, env_values[0]->getValue(static_cast(checkPt), 1)); } else if (type == "DETUNE"){ snd->setDetune(direction, spread, velocity); }else { @@ -314,7 +314,7 @@ void Modifier::applyModPartial(Sound* snd) { delete env_values.front(); env_values.pop_front(); } else if (type == "WAVE_TYPE") { - snd->get(partialNum).setParam(WAVE_TYPE, env_values.front()->getValue(checkPt, 1)); + snd->get(partialNum).setParam(WAVE_TYPE, env_values.front()->getValue(static_cast(checkPt), 1)); delete env_values.front(); env_values.pop_front(); } else { diff --git a/CMOD/src/NotationScore.cpp b/CMOD/src/NotationScore.cpp index f5c8f74b..b1db44b9 100644 --- a/CMOD/src/NotationScore.cpp +++ b/CMOD/src/NotationScore.cpp @@ -144,7 +144,6 @@ void NotationScore::Build() { // in terms of the previous tempo's EDU's vector
::iterator iter = score_staff[i].begin(); vector
::iterator next = score_staff[i].begin() + 1; - int last_start_time_edu = 0; string previous_time_signature; bool first_section = true; diff --git a/CMOD/src/Note.cpp b/CMOD/src/Note.cpp index e704933c..142df3e5 100644 --- a/CMOD/src/Note.cpp +++ b/CMOD/src/Note.cpp @@ -133,18 +133,16 @@ void Note::setPitchWellTempered(int absPitchNum) { int Note::HertzToPitch(float freqHz) { - int pitchNum; - if ( freqHz >= CEILING || freqHz <= MINFREQ) { cerr << "Warning: Note Frequency is " << freqHz << " Hz, outside the nominal " << MINFREQ << " to " << CEILING << " Hz range; using the nearest tempered pitch. " << "Suggestion: Check the Bottom event's Frequency setting if this pitch is not intended." << endl; } - pitchNum = rint(12 * log2(freqHz / C0)); - setPitchNum(pitchNum); + const int nearestPitch = static_cast(rint(12 * log2(freqHz / C0))); + setPitchNum(nearestPitch); - return pitchNum; + return nearestPitch; } //----------------------------------------------------------------------------// diff --git a/CMOD/src/Patter.cpp b/CMOD/src/Patter.cpp index 3e2bfa67..7df97445 100644 --- a/CMOD/src/Patter.cpp +++ b/CMOD/src/Patter.cpp @@ -106,7 +106,6 @@ void Patter::SimplePat() { for(unsigned i = 0; i < intervals.size(); i++) { int lastNum = patty.back(); - int thisNum = lastNum + intervals[i]; patty.push_back( lastNum + intervals[i] ); } @@ -142,7 +141,7 @@ void Patter::Adjust() { //---------------------------------------------------------------------------// void Patter::Equivalence(int modulo, int low, int high) { - int newElement, numTerms, pointNum; + int newElement, numTerms; int sign = -1; //cout << "\t PATTER Equivalence origin:"<< this->origin << endl; @@ -229,7 +228,7 @@ void Patter::Equivalence(int modulo, int low, int high) { //---------------------------------------------------------------------------// -void Patter::Symmetries(int modulo, int low, int high) { +void Patter::Symmetries(int, int, int) { cerr << "Patter::Symmetries - this method is not available at the present time" << endl; exit(1); @@ -237,7 +236,7 @@ void Patter::Symmetries(int modulo, int low, int high) { //---------------------------------------------------------------------------// -void Patter::Distort(int modulo, int low, int high) { +void Patter::Distort(int, int, int) { cerr << "Patter::Distort - this method is not available at the present time" << endl; exit(1); diff --git a/CMOD/src/Piece-experimental.cpp b/CMOD/src/Piece-experimental.cpp index 5a256312..b583f10d 100644 --- a/CMOD/src/Piece-experimental.cpp +++ b/CMOD/src/Piece-experimental.cpp @@ -386,8 +386,8 @@ Piece::Piece(string _workingPath, string _projectTitle){ throw; } }; - pieceSpan.start = evaluateSetting(pieceStartTime, "PieceStartTime"); - pieceSpan.duration = evaluateSetting(pieceDuration, "Duration"); + pieceSpan.start = static_cast(evaluateSetting(pieceStartTime, "PieceStartTime")); + pieceSpan.duration = static_cast(evaluateSetting(pieceDuration, "Duration")); if (!std::isfinite(pieceSpan.duration) || pieceSpan.duration <= 0) { throw CmodError(CmodError::Kind::Project, "The piece duration must be finite and greater than zero.", @@ -550,10 +550,10 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ if(type <= 4){ //Top, High, Medium, Low, Bottom thisEventElement = GNES(thisEventElement); //maxChildDur - float maxChildDur = (float)utilities->evaluate(XMLTC(thisEventElement), (void*)this); + utilities->evaluate(XMLTC(thisEventElement), (void*)this); thisEventElement = GNES(thisEventElement); //newEDUPerBeat - int newEDUPerBeat = (int) utilities->evaluate(XMLTC(thisEventElement),(void*)this); + utilities->evaluate(XMLTC(thisEventElement),(void*)this); thisEventElement = GNES(thisEventElement); //Time Signature element @@ -571,7 +571,6 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ pugi::xml_node DurationSieveElement = GNES(AttackSieveElement); pugi::xml_node methodFlagElement = GNES(DurationSieveElement); pugi::xml_node childStartTypeFlag = GNES(methodFlagElement); - pugi::xml_node childDurationTypeFlag = GNES(childStartTypeFlag); //Read Flag values (Needed for modification) string defFlag = XMLTC(methodFlagElement); @@ -581,7 +580,7 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ //Calculating start time orignality string startFlag = XMLTC(childStartTypeFlag); - int startFlagVal = atoi(startFlag.c_str()); + atoi(startFlag.c_str()); //layers, initialize child names thisEventElement = GNES(childEventDefElement); @@ -606,7 +605,7 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ if (XMLTC(flagElement) =="0"){ // Continuum pugi::xml_node entry1Element = GNES(flagElement); if (XMLTC(entry1Element)==""){ - numChildren = childTypeElements.size(); + numChildren = static_cast(childTypeElements.size()); } else { numChildren =(int) utilities->evaluate(XMLTC(entry1Element), (void*)this); @@ -627,7 +626,7 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ else {// by layer numChildren = 0; for (unsigned i = 0; i < layerElements.size(); i ++){ - numChildren +=utilities->evaluate(XMLTC(GFEC(layerElements[i])),(void*)this); + numChildren = static_cast(numChildren + utilities->evaluate(XMLTC(GFEC(layerElements[i])),(void*)this)); } } @@ -642,13 +641,10 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ if(flagVal == 0){ //Equal Temperament mVal += EQUAL_TEMP * (log(1 / EQUAL_TEMP)/log(2)); - pugi::xml_node freqEntry1 = GNES(GNES(frequencyFlagElement)); } else if(flagVal == 1){//Fundamental mVal += FUNDAMENTAL * (log(1 / FUNDAMENTAL)/log(2)); - pugi::xml_node freqEntry1 = GNES(GNES(frequencyFlagElement)); - pugi::xml_node freqEntry2 = GNES(freqEntry1); } else if(flagVal == 2){//Continuum @@ -664,9 +660,9 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ else { mVal += POW2 * (log(1 / POW2)/log(2)); /* 3rd arg is a float (power of 2) */ - float step = utilities->evaluate(XMLTC(freqEntry1), (void*)this); - double range = log10(CEILING / MINFREQ) / log10(2.); // change log base - double baseFreqResult = pow(2, step * range) * MINFREQ; // equal chance for all 8vs + float step = static_cast(utilities->evaluate(XMLTC(freqEntry1), (void*)this)); + double range = static_cast(log10(CEILING / MINFREQ) / log10(2.)); // change log base + static_cast(static_cast(pow(2, step * range) * MINFREQ)); // equal chance for all 8vs } } @@ -682,8 +678,9 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ for(int i = 0; i < numChildren; i++){ double childType = utilities->evaluate(XMLTC(childTypeElement),(void*)this); - string childName = XMLTC(GFEC(childTypeElements[childType])); - EventType childEventType = (EventType) utilities->evaluate(XMLTC(GNES(GFEC(childTypeElements[childType]))),(void*)this); + const size_t childTypeIndex = static_cast(childType); + string childName = XMLTC(GFEC(childTypeElements[childTypeIndex])); + EventType childEventType = (EventType) utilities->evaluate(XMLTC(GNES(GFEC(childTypeElements[childTypeIndex]))),(void*)this); pugi::xml_node childElement = utilities->getEventElement(childEventType, childName); childElements.push_back(childElement); @@ -697,7 +694,7 @@ return childElements; } //Experimental - For now only bottom events -void Piece::geneticOptimization(string fitnessFunction, double optimum){ +void Piece::geneticOptimization(string, double optimum){ // Step 1: Calculating current Aesthetic of the piece - User decides function string evName = utilities->topEventnames.at(0); @@ -958,7 +955,6 @@ vector Piece::modifyPiece(pugi::xml_node eventElement){ pugi::xml_node freqEntry1 = GNES(GNES(frequencyFlagElement)); if(GFEC(freqEntry1) != NULL){ - pugi::xml_node funcElement = GFEC(freqEntry1); //functionModifier(funcElement, 100); } @@ -1021,8 +1017,8 @@ vector Piece::modifyPiece(pugi::xml_node eventElement){ //char *loudnessvalue = XMLString::transcode(loudnessElement->getFirstChild()->getNodeValue()); //cout<<"hey:"<(childTypeElements.size()); } else { numChildren =(int) utilities->evaluate(XMLTC(entry1Element), (void*)this); @@ -1399,7 +1394,7 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne else {// by layer numChildren = 0; for (unsigned i = 0; i < layerElements.size(); i ++){ - numChildren +=utilities->evaluate(XMLTC(GFEC(layerElements[i])),(void*)this); + numChildren = static_cast(numChildren + utilities->evaluate(XMLTC(GFEC(layerElements[i])),(void*)this)); } } @@ -1428,8 +1423,8 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne pugi::xml_node freqEntry2 = GNES(freqEntry1); for(int i = 0; i < NUM_SAMPLES; i++){ - float fund_freq = utilities->evaluate(XMLTC(freqEntry1), (void*)this); - int overtone_step = utilities->evaluate(XMLTC(freqEntry2), (void*)this); + float fund_freq = static_cast(utilities->evaluate(XMLTC(freqEntry1), (void*)this)); + int overtone_step = static_cast(utilities->evaluate(XMLTC(freqEntry2), (void*)this)); double baseFreqResult = fund_freq * overtone_step; samples.push_back(baseFreqResult); } @@ -1446,9 +1441,9 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne } else { /* 3rd arg is a float (power of 2) */ - float step = utilities->evaluate(XMLTC(freqEntry1), (void*)this); - double range = log10(CEILING / MINFREQ) / log10(2.); // change log base - double baseFreqResult = pow(2, step * range) * MINFREQ; // equal chance for all 8vs + float step = static_cast(utilities->evaluate(XMLTC(freqEntry1), (void*)this)); + double range = static_cast(log10(CEILING / MINFREQ) / log10(2.)); // change log base + double baseFreqResult = static_cast(pow(2, step * range) * MINFREQ); // equal chance for all 8vs samples.push_back(baseFreqResult); } } @@ -1485,8 +1480,9 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne for(int i = 0; i < numChildren; i++){ double childType = utilities->evaluate(XMLTC(childTypeElement),(void*)this); - string childName = XMLTC(GFEC(childTypeElements[childType])); - EventType childEventType = (EventType) utilities->evaluate(XMLTC(GNES(GFEC(childTypeElements[childType]))),(void*)this); + const size_t childTypeIndex = static_cast(childType); + string childName = XMLTC(GFEC(childTypeElements[childTypeIndex])); + EventType childEventType = (EventType) utilities->evaluate(XMLTC(GNES(GFEC(childTypeElements[childTypeIndex]))),(void*)this); pugi::xml_node childElement = utilities->getEventElement(childEventType, childName); childElements.push_back(childElement); @@ -1510,7 +1506,6 @@ return childElements; std::sort(sampleData.begin(), sampleData.end()); - double sampleRange = sampleData[sampleData.size() - 1] - sampleData[0]; for(unsigned i = 0; i < sampleData.size(); i++){ if(partitionMethod.compare("Pow2") == 0){ @@ -1535,19 +1530,17 @@ return childElements; if(partitionMethod.compare("Pow2") == 0){ - numPartitions = ceil(log(max)/log(2)) - floor(log(min)/log(2)); + numPartitions = static_cast(ceil(log(max)/log(2)) - floor(log(min)/log(2))); } else if(partitionMethod.compare("Unit") == 0){ - numPartitions = max - min; + numPartitions = static_cast(max - min); } maxEntropy = log(numPartitions)/log(2); //redundancy = 1 - (shannonEntropy/maxEntropy); redundancy = maxEntropy - shannonEntropy; - double relativeShannonEntropy = shannonEntropy/maxEntropy; - double benseOriginality = relativeShannonEntropy/redundancy; cout<(time(NULL))); } } @@ -131,7 +131,7 @@ int Random::RandOrderInt(int low, int high, int id) { vector& choices = choicesMap[id]; // Choose a random element from available choices - int randIndex = RandInt(0, choices.size() - 1); + int randIndex = RandInt(0, static_cast(choices.size() - 1)); int result = choices[randIndex]; // Remove chosen element from choices @@ -182,7 +182,7 @@ int Random::ChooseFromProb(vector probs) { //----------------------------------------------------------------------------// void Random::AssignProb(list &myProbList) { - double len = myProbList.size(); + double len = static_cast(myProbList.size()); double prob = 0.0; list::iterator iter = myProbList.begin(); diff --git a/CMOD/src/Rational.h b/CMOD/src/Rational.h index 417476ba..a4bb9949 100644 --- a/CMOD/src/Rational.h +++ b/CMOD/src/Rational.h @@ -572,7 +572,7 @@ class Rational static Rational fromString(const std::string& str) { - T len = str.length(); + T len = static_cast(str.length()); T numerator = 0; T denominator = 0; bool isPastSlash = false; diff --git a/CMOD/src/Section.cpp b/CMOD/src/Section.cpp index ad0dec1a..dfbebba7 100644 --- a/CMOD/src/Section.cpp +++ b/CMOD/src/Section.cpp @@ -327,7 +327,6 @@ bool Section::operator!=(const TimeSignature& time_signature) const { void Section::EnsureNoteExpressible(Note* n) { int dur = n->end_t % time_signature_.beat_edus_; - int before = n->end_t; int min_diff = time_signature_.beat_edus_; bool note_needs_chop = true; @@ -348,7 +347,7 @@ void Section::EnsureNoteExpressible(Note* n) { } void Section::ResizeSection(int new_size) { - for(int bar_idx = section_.size(); bar_idx <= new_size; ++bar_idx) { + for(int bar_idx = static_cast(section_.size()); bar_idx <= new_size; ++bar_idx) { vector bar = vector(0); Note* n = new Note(); n->start_t = time_signature_.bar_edus_ * bar_idx; @@ -497,11 +496,19 @@ void Section::CapEnding() { } else if (remaining_edus_ == 0 && cur_bar_edus == 0) { return; // Sections align perfectly! } else { - int pow_2 = 0; + // The unsplit beat is always the first candidate. Establish its signature + // before searching smaller dyadic beats for a closer fit. + int pow_2 = 1; int best_pow_2 = 0; - int min_err = INT_MAX; - int ts_num, ts_den; - while (time_signature_.beat_edus_ % TimeSignature::Power(2, pow_2) == 0) { + int ts_num = total_edus_to_use / time_signature_.beat_edus_; + int ts_den = time_signature_.unit_note_; + const int remainder = total_edus_to_use % time_signature_.beat_edus_; + int min_err = 0; + if (remainder != 0) { + ++ts_num; + min_err = time_signature_.beat_edus_ - remainder; + } + while (min_err != 0 && time_signature_.beat_edus_ % TimeSignature::Power(2, pow_2) == 0) { int tmp_beat_edus = time_signature_.beat_edus_ / TimeSignature::Power(2, pow_2); if (total_edus_to_use % tmp_beat_edus == 0) { ts_num = total_edus_to_use / tmp_beat_edus; @@ -740,7 +747,6 @@ void Section::NoteInTuplet(Note* current_note, int tuplet_type, int duration) { int beat = duration / (time_signature_.beat_edus_ / tuplet_type); // working in tuplet beats int unit_in_tuplet = time_signature_.unit_note_ * TimeSignature::CalculateNearestPow2(tuplet_type); - int power_of_2 = TimeSignature::DiscreteLog2(unit_in_tuplet); while (beat > 0){ int power_of_2 = TimeSignature::DiscreteLog2(unit_in_tuplet); diff --git a/CMOD/src/Sieve.cpp b/CMOD/src/Sieve.cpp index 9f6f7e9c..16dc937f 100644 --- a/CMOD/src/Sieve.cpp +++ b/CMOD/src/Sieve.cpp @@ -57,7 +57,7 @@ string Sieve::getFileName() { //---------------------------------------------------------------------------// void Sieve::BuildFromExpr(int minVal, int maxVal, - const char *eMethod, const char *wMethod, + const char *, const char *wMethod, std::string expr, vector wArgVect, vector offsetVect) { ModParser mp(offsetVect); mp.parseExpr(expr, minVal, maxVal); @@ -132,9 +132,9 @@ int Sieve::GetNumItems() { int result = 0; if (eList.size() >= wList.size()) { - result = eList.size(); + result = static_cast(eList.size()); } else { - result = wList.size(); + result = static_cast(wList.size()); } return result; } @@ -261,8 +261,6 @@ void Sieve::Meaningful(int minVal, int maxVal, vector eArgVect, std::vector //---------------------------------------------------------------------------// void Sieve::Multiples(int minVal, int maxVal, vector numMods, std::vector offsetVect) { - int element, modulo; - eList.clear(); skip = 0; @@ -404,6 +402,12 @@ void Sieve::IncludeWeights(const vector& wArgVect) { //---------------------------------------------------------------------------// void Sieve::AddEnvelope(Envelope *env, string method) { + if (method != "CONSTANT" && method != "VARIABLE") { + throw CmodError(CmodError::Kind::Project, + "Sieve envelope method '" + method + "' is not supported.", + "Sieve -> Envelope Method", + "Choose CONSTANT or VARIABLE for the sieve's envelope method."); + } float value; double checkPoint; double probability; @@ -423,10 +427,10 @@ void Sieve::AddEnvelope(Envelope *env, string method) { } else { checkPoint = 0; } - value = env->getValue(checkPoint, 1.); + value = env->getValue(static_cast(checkPoint), 1.); if (method == "VARIABLE") { probability = Random::PreferedValueDistribution(value, checkPoint); - } else if (method == "CONSTANT") { + } else { probability = value; } diff --git a/CMOD/src/SignalHandlers.cpp b/CMOD/src/SignalHandlers.cpp index 49a676cc..e0289f88 100644 --- a/CMOD/src/SignalHandlers.cpp +++ b/CMOD/src/SignalHandlers.cpp @@ -1,6 +1,6 @@ #include "SignalHandlers.h" -void segfaultHandler(int signal) { +void segfaultHandler(int) { static const char diagnostic[] = "CMOD internal error: Unexpected invalid memory access (segmentation fault).\n" "Context: CMOD runtime\n" @@ -10,11 +10,11 @@ void segfaultHandler(int signal) { #ifdef _WIN32 _write(STDERR_FILENO, diagnostic, sizeof(diagnostic) - 1); #else - write(STDERR_FILENO, diagnostic, sizeof(diagnostic) - 1); + [[maybe_unused]] const auto written = write(STDERR_FILENO, diagnostic, sizeof(diagnostic) - 1); #endif void *buf[BACKTRACE_NUM + 2]; size_t size = backtrace(buf, BACKTRACE_NUM + 2); // Do a backtrace of the stack - char **messages = backtrace_symbols(buf, size); + char **messages = backtrace_symbols(buf, static_cast(size)); std::cerr << "--------------------------------------------------------------------------------\n"; if (size > 2 && messages != nullptr) { @@ -67,7 +67,7 @@ void segfaultHandler(int signal) { } // Unimplemented -void interruptHandler(int signal) { +void interruptHandler(int) { exit(1); } diff --git a/CMOD/src/TimeSignature.h b/CMOD/src/TimeSignature.h index 498c809e..0a91278f 100644 --- a/CMOD/src/TimeSignature.h +++ b/CMOD/src/TimeSignature.h @@ -39,7 +39,7 @@ struct TimeSignature { bar_edus_ = Note::str_to_int(tempo_.getEDUPerBar().toPrettyString()); unit_note_ = tempo_.getTimeSignatureBeat().Den(); // the note that represents one beat - tuplet_limit_ = CalculateTupletLimit(); + tuplet_limit_ = static_cast(CalculateTupletLimit()); ConstructTupletNames(); } @@ -54,7 +54,7 @@ struct TimeSignature { bar_edus_ = Note::str_to_int(tempo.getEDUPerBar().toPrettyString()); unit_note_ = tempo.getTimeSignatureBeat().Den(); // the note that represents one beat - tuplet_limit_ = CalculateTupletLimit(); + tuplet_limit_ = static_cast(CalculateTupletLimit()); ConstructTupletNames(); } @@ -70,7 +70,7 @@ struct TimeSignature { size_t tuplet_num = 1; while (beat_edus_ % tuplet_num == 0) { - valid_dividers_.push_back(beat_edus_ / tuplet_num); + valid_dividers_.push_back(static_cast(beat_edus_ / tuplet_num)); tuplet_num++; } diff --git a/CMOD/src/Utilities.cpp b/CMOD/src/Utilities.cpp index f99fd3b1..ce29448a 100644 --- a/CMOD/src/Utilities.cpp +++ b/CMOD/src/Utilities.cpp @@ -106,7 +106,7 @@ static int checkedIntegerArgument(double value, const string& function, } Utilities::Utilities(pugi::xml_node root, - string _workingPath, + string, bool _soundSynthesis, bool _outputParticel, int _numThreads, @@ -1122,16 +1122,16 @@ string Utilities::function_Stochos(pugi::xml_node _functionElement, void* _objec float returnVal = 0.0; if(method == "FUNCTIONS") { - float randomNumber; + float randomNumber = 0.0f; // stacked up envelopes: their values at the same moment add up to 1 for (int i = 0; i < (int)envVect.size(); i++) { - returnVal = envVect[i]->getValue(checkpoint, 1.); + returnVal = envVect[i]->getValue(static_cast(checkpoint), 1.); if(envVect.size() > 1) { // probability areas - if(i == 0) randomNumber = Random::Rand(); + if(i == 0) randomNumber = static_cast(Random::Rand()); if (returnVal >= randomNumber) { - returnVal = i; - i = envVect.size(); // done: break out of the for loop + returnVal = static_cast(i); + break; } } } @@ -1149,10 +1149,10 @@ string Utilities::function_Stochos(pugi::xml_node _functionElement, void* _objec } const size_t offset = static_cast(offsetValue); for(int i = 0; i < 2; i++) { - limit[i] = envVect[3 * offset + i]->getValue(checkpoint, 1); + limit[i] = envVect[3 * offset + i]->getValue(static_cast(checkpoint), 1); } - returnVal = envVect[3 * offset + 2]->getValue(Random::Rand(), 1); + returnVal = envVect[3 * offset + 2]->getValue(static_cast(Random::Rand()), 1); returnVal *= (limit[1] - limit[0]); returnVal += limit[0]; @@ -1722,13 +1722,13 @@ cout << "intList size: " << stringList.size() << " " << endl; // Find Expand parameters elementIter = GNES(elementIter); - int mod = evaluate ( XMLTranscode( elementIter), _object); + int mod = static_cast(evaluate(XMLTranscode(elementIter), _object)); elementIter = GNES(elementIter); - int low = evaluate ( XMLTranscode( elementIter), _object); + int low = static_cast(evaluate(XMLTranscode(elementIter), _object)); elementIter = GNES(elementIter); - int high = evaluate ( XMLTranscode( elementIter), _object); + int high = static_cast(evaluate(XMLTranscode(elementIter), _object)); // Recurse on the pattern to expand elementIter = GNES(elementIter); @@ -2075,7 +2075,7 @@ Envelope* Utilities::envLib(pugi::xml_node _functionElement, void* _object){ Envelope* env = envelopeLibrary->getEnvelope(envelopeNumber); //cout <<"EnvLib: #"<scale(scale); + env->scale(static_cast(scale)); return env; } @@ -2170,11 +2170,11 @@ Envelope* Utilities::makeEnvelope(pugi::xml_node _functionElement, void* _object float prevXVal = 0; while (x!=NULL && y!=NULL) { xy_point xy; - xy.x = evaluate(XMLTranscode(x), _object); - xy.y = evaluate(XMLTranscode(y), _object); + xy.x = static_cast(evaluate(XMLTranscode(x), _object)); + xy.y = static_cast(evaluate(XMLTranscode(y), _object)); if (xy.x - prevXVal < 0) { // flag to keep previous xval - xy.x = prevXVal * 1.01; + xy.x = static_cast(prevXVal * 1.01); } if (xy.y < 0) { // flag to keep previous yval xy.y = prevYVal; @@ -2230,7 +2230,7 @@ Envelope* Utilities::makeEnvelope(pugi::xml_node _functionElement, void* _object // Create a new envelope given the points and segments defined Envelope* madeEnv = new Envelope(points, segments); - madeEnv->scale(scale); + madeEnv->scale(static_cast(scale)); // Clean up the temporary point and segment collections points.clear(); @@ -2247,6 +2247,6 @@ Envelope* Utilities::getEnvelopeshape(int env_num, double scale){ cout << "Error in getEnvelopeShape: env_num exceeds size of EnvLibrary" << endl; return NULL; } - env->scale(scale); + env->scale(static_cast(scale)); return env; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 4653148d..b61d717b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,9 @@ option(BUILD_LASS_EXAMPLES "Build LASS examples" OFF) # see Cross Compiling with CMake -- Mastering CMake for more on the eponymous subject if(WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") + # /Wall includes default-off optimization chatter from the compiler and STL. + # Keep normal strict diagnostics and decode UTF-8 sources consistently. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /utf-8") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/toolchains/windows.cmake") elseif(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-deprecated") diff --git a/LASS/src/AllPassFilter.cpp b/LASS/src/AllPassFilter.cpp index 28501b34..636de049 100644 --- a/LASS/src/AllPassFilter.cpp +++ b/LASS/src/AllPassFilter.cpp @@ -194,7 +194,7 @@ void AllPassFilter::xml_read(XmlReader::xmltag *apftag) { char *value; if((value = apftag->findChildParamValue("g","value")) != 0) - set_g(atof(value)); + set_g(static_cast(atof(value))); if((value = apftag->findChildParamValue("D","value")) != 0) set_D(atoi(value)); diff --git a/LASS/src/AuWriter.cpp b/LASS/src/AuWriter.cpp index 085052c8..55fd4dba 100644 --- a/LASS/src/AuWriter.cpp +++ b/LASS/src/AuWriter.cpp @@ -109,7 +109,7 @@ bool AuWriter::write(vector& channels, string filename, } //Set the info parameters. - s_info.channels = channels.size(); + s_info.channels = static_cast(channels.size()); s_info.samplerate = channels[0]->getSamplingRate(); s_info.format = SF_FORMAT_PCM_24; bits = 0; //Do not use the incoming format, 24-bit is all-purpose. diff --git a/LASS/src/BiQuadFilter.cpp b/LASS/src/BiQuadFilter.cpp index 0fb0c3cc..3396b8ad 100755 --- a/LASS/src/BiQuadFilter.cpp +++ b/LASS/src/BiQuadFilter.cpp @@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include #include "SoundSample.h" #include "Track.h" #include "MultiTrack.h" @@ -58,11 +59,11 @@ BiQuadFilter::BiQuadFilter(int type, m_sample_type dbGain, m_sample_type freq,m_ /* setup variables */ - A = pow(10, dbGain /40); - omega = 2 * M_PI * freq /srate; + A = static_cast(pow(10, dbGain /40)); + omega = static_cast(2 * M_PI * freq /srate); sn = sin(omega); cs = cos(omega); - alpha = sn * sinh(M_LN2 /2 * bandwidth * omega /sn); + alpha = static_cast(sn * sinh(M_LN2 /2 * bandwidth * omega /sn)); beta = sqrt(A + A); @@ -124,7 +125,7 @@ BiQuadFilter::BiQuadFilter(int type, m_sample_type dbGain, m_sample_type freq,m_ a2 = (A + 1) - (A - 1) * cs - beta * sn; break; default: - cout << "Wrong Filter type selection. Please choose between 0-6" << endl; + throw std::invalid_argument("BiQuadFilter type must be between 0 and 6."); } cout << "The Filter type is " << type << ", the coefficients are:\na0: " << a0 << "\na1: " << a1 << "\nb0: " << b0 << "\nb1: " << b1 << "\nb2: " << b2 << endl; diff --git a/LASS/src/BiQuadFilter.h b/LASS/src/BiQuadFilter.h index 3d3e7fb6..595142fb 100755 --- a/LASS/src/BiQuadFilter.h +++ b/LASS/src/BiQuadFilter.h @@ -65,6 +65,7 @@ class BiQuadFilter : public Filter * \param freq The center or cutoff frequency in Hz * \param srate The sampling rate in samples per second * \param bandwidth The bandwidth in octaves + * \throws std::invalid_argument if type is outside the supported range 0-6 **/ BiQuadFilter(int type, m_sample_type dbGain, /* gain of filter */ m_sample_type freq, /* center frequency */ diff --git a/LASS/src/Constant.cpp b/LASS/src/Constant.cpp index cbd8a9f6..7919486f 100644 --- a/LASS/src/Constant.cpp +++ b/LASS/src/Constant.cpp @@ -135,20 +135,19 @@ void Constant::xml_read(XmlReader::xmltag *constanttag) char *value; if((value = constanttag->findChildParamValue("duration","value")) != 0) - setDuration(atof(value)); + setDuration(static_cast(atof(value))); if((value = constanttag->findChildParamValue("rate","value")) != 0) setSamplingRate(atoi(value)); if((value = constanttag->findChildParamValue("value","value")) != 0) - setValue(atof(value)); + setValue(static_cast(atof(value))); } //----------------------------------------------------------------------------// void Constant::xml_print( ofstream& xmlOutput, list& dynObjs ) { - int a = dynObjs.size(); //remove warning about unused parameter... - (void) a; + (void) dynObjs; xml_print(xmlOutput); } diff --git a/LASS/src/DynamicVariableSequence.cpp b/LASS/src/DynamicVariableSequence.cpp index bc92ce3e..2fbebd72 100644 --- a/LASS/src/DynamicVariableSequence.cpp +++ b/LASS/src/DynamicVariableSequence.cpp @@ -117,7 +117,7 @@ void DynamicVariableSequence::Print() return; } - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); int iLoop = 0; cout << endl; @@ -375,7 +375,7 @@ void DynamicVariableSequence::AddToShape return; } - int iNumSegments = segments.size(); + int iNumSegments = static_cast(segments.size()); m_time_type timeOffset = xyPoints_->at(xyPoints_->size() - 1).x; xy_point pointTemp; @@ -542,7 +542,7 @@ void DynamicVariableSequence::setSegmentInterpolationType inline bool DynamicVariableSequence::checkValidSegmentIndex (int index) { // check if index is valid - return ((index >= 0) && (segments_->size() > index)); + return ((index >= 0) && (segments_->size() > static_cast(index))); } @@ -550,7 +550,7 @@ inline bool DynamicVariableSequence::checkValidSegmentIndex (int index) inline bool DynamicVariableSequence::checkValidPointIndex (int index) { // check if index is valid - return ((index >= 0) && (xyPoints_->size() > index)); + return ((index >= 0) && (xyPoints_->size() > static_cast(index))); } @@ -586,7 +586,7 @@ void DynamicVariableSequence::generateTimes (m_time_type totalTime) #ifdef DEBUG_MODE cout << "DVS::generateTimes" << endl; #endif - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); double dTotalFixedTime = 0; double dTotalFlexPercent = 0; double dScaleRatio = 1; @@ -643,7 +643,7 @@ void DynamicVariableSequence::generateTimes (m_time_type totalTime) if (this->getSegmentTimeType(iIndex) == FIXED) { generatedSegmentTimes_->at(iIndex) = - this->getSegmentTime(iIndex) * dScaleRatio; + static_cast(this->getSegmentTime(iIndex) * dScaleRatio); } else { @@ -668,7 +668,7 @@ void DynamicVariableSequence::generateTimes (m_time_type totalTime) if (this->getSegmentTimeType(iIndex) == FLEXIBLE) { generatedSegmentTimes_->at(iIndex) = - this->getSegmentTime(iIndex) * dScaleRatio; + static_cast(this->getSegmentTime(iIndex) * dScaleRatio); } } } @@ -691,7 +691,7 @@ void DynamicVariableSequence::generateTimes (m_time_type totalTime) if (this->getSegmentTimeType(iIndex) == FLEXIBLE) { generatedSegmentTimes_->at(iIndex) = - generatedSegmentTimes_->at(iIndex) * flexTimeAvailable; + static_cast(generatedSegmentTimes_->at(iIndex) * flexTimeAvailable); } } } @@ -716,7 +716,7 @@ void DynamicVariableSequence::addInterpolators (m_rate_type rate) cout << "num points: " << xyPoints_->size() << endl; #endif - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); // clear out interpolators that are stored, if there are any stored if (interpolators_ != NULL) @@ -773,7 +773,7 @@ void DynamicVariableSequence::addInterpolators (m_rate_type rate) //----------------------------------------------------------------------------// void DynamicVariableSequence::scale(m_value_type factor) { - int iNumPoints = xyPoints_->size(); + int iNumPoints = static_cast(xyPoints_->size()); xy_point pointTemp; // for every point that we've got stored @@ -790,7 +790,7 @@ void DynamicVariableSequence::scale(m_value_type factor) //----------------------------------------------------------------------------// m_value_type DynamicVariableSequence::getMaxValue() { - int iNumPoints = xyPoints_->size(); + int iNumPoints = static_cast(xyPoints_->size()); m_value_type maxVal = 0.0; // for every point that we've got stored @@ -811,7 +811,7 @@ void DynamicVariableSequence::xml_print( ofstream& xmlOutput ) { DynamicVariable* pnt2dyn = this; - xmlOutput << "" << endl; + xmlOutput << "(pnt2dyn) << "\">" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; @@ -844,7 +844,7 @@ void DynamicVariableSequence::xml_print( ofstream& xmlOutput, list" << endl; - xmlOutput << "\t\t\t\t" << endl; + xmlOutput << "\t\t\t\t(pnt2dyn) << "\" />" << endl; // Update dynamic variable list if necessary list::const_iterator dynit; diff --git a/LASS/src/DynamicVariableSequenceIterator.cpp b/LASS/src/DynamicVariableSequenceIterator.cpp index c21669bf..00ca0935 100644 --- a/LASS/src/DynamicVariableSequenceIterator.cpp +++ b/LASS/src/DynamicVariableSequenceIterator.cpp @@ -115,7 +115,7 @@ bool DynamicVariableSequenceIterator::hasNext() m_value_type& DynamicVariableSequenceIterator::next() { bool gotNewValue = false; - int iNumInterpolators = interpolators_->size(); + int iNumInterpolators = static_cast(interpolators_->size()); // if we haven't started iterating yet, start with the first iterator if ((currentIterator_ == NULL) && (iNumInterpolators > 0)) diff --git a/LASS/src/Envelope.cpp b/LASS/src/Envelope.cpp index 24c452ea..6ee0a2fc 100644 --- a/LASS/src/Envelope.cpp +++ b/LASS/src/Envelope.cpp @@ -78,7 +78,7 @@ Envelope::Envelope(vector xy_points, vector segs) seg.x = tpt.x; seg.y = tpt.y; segments_->push_back(seg); - for (int i = 1; i < xy_points.size(); i++) + for (std::size_t i = 1; i < xy_points.size(); i++) { seg = segs.at(i - 1); seg.x = xy_points.at(i).x; @@ -112,7 +112,7 @@ Envelope::~Envelope() delete(segments_); if (interpolators_) { - for (int i = 0; i < interpolators_->size(); i++) { + for (std::size_t i = 0; i < interpolators_->size(); i++) { delete(interpolators_->at(i)); } delete(interpolators_); @@ -130,7 +130,7 @@ void Envelope::print() return; } - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); int iLoop = 0; cout << endl; @@ -349,7 +349,7 @@ void Envelope::defineShape() //=== envelope_segment temp_seg; m_value_type temp = 0; - for (int i = 0; i < segments_->size(); i++) { + for (std::size_t i = 0; i < segments_->size(); i++) { temp_seg = segments_->at(i); temp_seg.length = temp_seg.x - temp; segments_->at(i) = temp_seg; @@ -384,7 +384,7 @@ void Envelope::addToShape(vector segs) // for every element in the new collections - for (int i = startIndex; i < segs.size(); i++) + for (std::size_t i = static_cast(startIndex); i < segs.size(); i++) { // add the current segment and point + 1 to our existing vectors segTemp = segs.at(i); @@ -421,12 +421,12 @@ Envelope* Envelope::multiply(Envelope & env1, Envelope & env2) envelope_segment seg1, seg2, newseg; m_value_type length=0, max1=0, max2=0; // find the biggest x values - for (int i = 0; i < env1Segs->size(); i++) { + for (std::size_t i = 0; i < env1Segs->size(); i++) { if (env1Segs->at(i).x > max1) { max1 = env1Segs->at(i).x; } } - for (int i = 0; i < env2Segs->size(); i++) { + for (std::size_t i = 0; i < env2Segs->size(); i++) { if (env2Segs->at(i).x > max2) { max2 = env2Segs->at(i).x; } @@ -521,7 +521,7 @@ vector* Envelope::getPoints() vector< xy_point > *points = new vector(); xy_point xy; - for (int i = 0; i < segments_->size(); i++) { + for (std::size_t i = 0; i < segments_->size(); i++) { xy.x = segments_->at(i).x; xy.y = segments_->at(i).y; points->push_back(xy); @@ -665,7 +665,7 @@ void Envelope::setSegmentInterpolationType(int index, interpolation_type interTy inline bool Envelope::checkValidSegmentIndex(int index) { // check if index is valid - return ((index >= 0) && (segments_->size() > index)); + return ((index >= 0) && (segments_->size() > static_cast(index))); } //----------------------------------------------------------------------------// @@ -693,7 +693,7 @@ Iterator Envelope::valueIterator() //----------------------------------------------------------------------------// void Envelope::generateLengths(m_time_type totalLength) { - int iNumSegments = segments_->size() - 1; + int iNumSegments = static_cast(segments_->size() - 1); double dTotalFixedLength = 0; double dTotalFlexPercent = 0; double dScaleRatio = 1; @@ -741,8 +741,8 @@ void Envelope::generateLengths(m_time_type totalLength) for (int iIndex = 0; iIndex < iNumSegments; iIndex++) { // scale every FIXED length value if (this->getSegmentLengthType(iIndex) == FIXED) { - generatedSegmentLengths_->at(iIndex) = getSegmentLength(iIndex) * dScaleRatio; - setSegmentLength(iIndex, getSegmentLength(iIndex) * dScaleRatio); + generatedSegmentLengths_->at(iIndex) = static_cast(getSegmentLength(iIndex) * dScaleRatio); + setSegmentLength(iIndex, static_cast(getSegmentLength(iIndex) * dScaleRatio)); } else { // all flex length entries are set to 0 generatedSegmentLengths_->at(iIndex) = 0; @@ -757,7 +757,7 @@ void Envelope::generateLengths(m_time_type totalLength) // scale percentages for (int iIndex = 0; iIndex < iNumSegments; iIndex++) { if (getSegmentLengthType(iIndex) == FLEXIBLE) { - generatedSegmentLengths_->at(iIndex) = getSegmentLength(iIndex) * dScaleRatio; + generatedSegmentLengths_->at(iIndex) = static_cast(getSegmentLength(iIndex) * dScaleRatio); } } } @@ -772,7 +772,7 @@ void Envelope::generateLengths(m_time_type totalLength) for (int iIndex = 0; iIndex < iNumSegments; iIndex++) { // if this is a flex-length entry, set length accordingly if (getSegmentLengthType(iIndex) == FLEXIBLE) { - generatedSegmentLengths_->at(iIndex) = generatedSegmentLengths_->at(iIndex) * flexLengthAvailable; + generatedSegmentLengths_->at(iIndex) = static_cast(generatedSegmentLengths_->at(iIndex) * flexLengthAvailable); } } } @@ -781,9 +781,9 @@ void Envelope::generateLengths(m_time_type totalLength) //----------------------------------------------------------------------------// void Envelope::addInterpolators(m_rate_type rate) { - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); // clear out interpolators that are stored, if there are any stored - for (int i = 0; i < interpolators_->size(); i++) { + for (std::size_t i = 0; i < interpolators_->size(); i++) { delete(interpolators_->at(i)); } interpolators_->clear(); @@ -826,7 +826,7 @@ void Envelope::addInterpolators(m_rate_type rate) //----------------------------------------------------------------------------// void Envelope::scale(m_value_type factor) { - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); envelope_segment segTemp; // for every point that we've got stored @@ -842,7 +842,7 @@ void Envelope::scale(m_value_type factor) //----------------------------------------------------------------------------// m_value_type Envelope::getMaxValue() { - int iNumSegments = segments_->size(); + int iNumSegments = static_cast(segments_->size()); m_value_type maxVal = 0.0; // for every point that we've got stored @@ -895,7 +895,7 @@ void Envelope::xml_print(ofstream & xmlOutput) { DynamicVariable *pnt2dyn = this; - xmlOutput << "" << endl; + xmlOutput << "(pnt2dyn) << "\">" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; @@ -949,7 +949,7 @@ void Envelope::xml_print(ofstream & xmlOutput, list < DynamicVariable * >&dynObj //Print the pointer value as an ID, then the "meat" gets printed later xmlOutput << "\t\t\t\t" << endl; - xmlOutput << "\t\t\t\t" << endl; + xmlOutput << "\t\t\t\t(pnt2dyn) << "\" />" << endl; // Update dynamic variable list if necessary list < DynamicVariable * >::const_iterator dynit; @@ -970,7 +970,7 @@ void Envelope::xml_read(XmlReader::xmltag * envtag) envelope_segment seg; if((value = envtag->findChildParamValue("duration", "value")) != 0) - setDuration(atof(value)); + setDuration(static_cast(atof(value))); if((value = envtag->findChildParamValue("rate", "value")) != 0) { setSamplingRate(atoi(value)); @@ -979,10 +979,10 @@ void Envelope::xml_read(XmlReader::xmltag * envtag) while ((segtag = envtag->children->find("segment")) != 0) { XmlReader::xmltag * xy = segtag->children->find("xyPoint"); if ((value = xy->getParamValue("x")) != 0) { - seg.x = atof(value); + seg.x = static_cast(atof(value)); } if ((value = xy->getParamValue("y")) != 0) { - seg.y = atof(value); + seg.y = static_cast(atof(value)); } if ((value = segtag->findChildParamValue("type", "value")) != 0) { if (strcmp(value, "LINEAR") == 0) diff --git a/LASS/src/EnvelopeIterator.cpp b/LASS/src/EnvelopeIterator.cpp index e46ff47f..e5bb56ee 100644 --- a/LASS/src/EnvelopeIterator.cpp +++ b/LASS/src/EnvelopeIterator.cpp @@ -115,7 +115,7 @@ bool EnvelopeIterator::hasNext() m_value_type& EnvelopeIterator::next() { bool gotNewValue = false; - int iNumInterpolators = interpolators_->size(); + int iNumInterpolators = static_cast(interpolators_->size()); // if we haven't started iterating yet, start with the first iterator if ((currentIterator_ == NULL) && (iNumInterpolators > 0)) diff --git a/LASS/src/EnvelopeLibrary.cpp b/LASS/src/EnvelopeLibrary.cpp index 86fba10a..8e8d5876 100644 --- a/LASS/src/EnvelopeLibrary.cpp +++ b/LASS/src/EnvelopeLibrary.cpp @@ -51,7 +51,7 @@ EnvelopeLibrary::~EnvelopeLibrary () //----------------------------------------------------------------------------// EnvelopeLibrary::EnvelopeLibrary (EnvelopeLibrary & lib) { - for (int envs = 0; envs < lib.library.size (); envs++) + for (std::size_t envs = 0; envs < lib.library.size (); envs++) library.push_back(lib.library.at(envs)->clone() ); } @@ -67,7 +67,7 @@ EnvelopeLibrary & EnvelopeLibrary::operator= (EnvelopeLibrary & lib) library.clear (); // reassign new data - for (int envs = 0; envs < lib.library.size (); envs++) + for (std::size_t envs = 0; envs < lib.library.size (); envs++) library.push_back(lib.library.at(envs) ); } @@ -99,7 +99,7 @@ bool EnvelopeLibrary::saveLibrary (char * filename) outData << library.size () << "\n\n"; // write number of envelopes - for (int envs = 0; envs < library.size (); envs++) + for (std::size_t envs = 0; envs < library.size (); envs++) { temp_env = library.at(envs); temp_coll = temp_env -> getPoints (); @@ -108,7 +108,7 @@ bool EnvelopeLibrary::saveLibrary (char * filename) outData << (temp_coll -> size () ) << "\n"; // number of points - for (int pts = 0; pts < ( (temp_coll -> size () ) - 1); pts++) + for (int pts = 0; static_cast(pts) < ( (temp_coll -> size () ) - 1); pts++) { // write point data for this envelope // format: point nx, point ny @@ -241,7 +241,7 @@ int EnvelopeLibrary::loadLibrary (char * filename) inData.close (); } - return (library.size () ); + return static_cast(library.size () ); } //----------------------------------------------------------------------------// @@ -319,14 +319,14 @@ int EnvelopeLibrary::loadLibraryNewFormat (char * filename) inData.close (); } - return (library.size () ); + return static_cast(library.size () ); } //----------------------------------------------------------------------------// Envelope * EnvelopeLibrary::getEnvelope (int index) { - if (index > library.size () ) + if (static_cast(index) > library.size () ) return NULL; else return (library.at(index - 1) ) -> clone (); @@ -343,7 +343,7 @@ const Envelope& EnvelopeLibrary::getEnvelopeRef (int index) int EnvelopeLibrary::addEnvelope (Envelope * env) { library.push_back(env); - return (library.size () ); + return static_cast(library.size () ); } @@ -360,7 +360,7 @@ int EnvelopeLibrary::addEnvelope (vector points, //----------------------------------------------------------------------------// bool EnvelopeLibrary::updateEnvelope (int index, Envelope * env) { - if (index > library.size () ) + if (static_cast(index) > library.size () ) return false; else { @@ -375,7 +375,7 @@ void EnvelopeLibrary::showEnvelope (int index) { Envelope * temp_env; - if (index > library.size () ) + if (static_cast(index) > library.size () ) return; else { @@ -388,7 +388,7 @@ void EnvelopeLibrary::showEnvelope (int index) //----------------------------------------------------------------------------// int EnvelopeLibrary::size () { - return (library.size () ); + return static_cast(library.size () ); } diff --git a/LASS/src/Interpolator.cpp b/LASS/src/Interpolator.cpp index 6317a028..1b67cdac 100644 --- a/LASS/src/Interpolator.cpp +++ b/LASS/src/Interpolator.cpp @@ -85,7 +85,7 @@ void Interpolator::xml_print( ofstream& xmlOutput ) { DynamicVariable* pnt2dyn = this; - xmlOutput << "" << endl; + xmlOutput << "(pnt2dyn) << "\">" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; @@ -110,7 +110,7 @@ void Interpolator::xml_print( ofstream& xmlOutput, list& dynOb //Print the pointer value as an ID, then the "meat" gets printed later xmlOutput << "\t\t\t\t" << endl; - xmlOutput << "\t\t\t\t" << endl; + xmlOutput << "\t\t\t\t(pnt2dyn) << "\" />" << endl; // Update dynamic variable list if necessary list::const_iterator dynit; @@ -132,7 +132,7 @@ void Interpolator::xml_read(XmlReader::xmltag* envtag) if((value = envtag->findChildParamValue("duration","value")) != 0) { - setDuration(atof(value)); + setDuration(static_cast(atof(value))); } if((value = envtag->findChildParamValue("rate","value")) != 0) @@ -145,9 +145,9 @@ void Interpolator::xml_read(XmlReader::xmltag* envtag) float time = 0.0f; float val = 0.0f; if((value=entrytag->getParamValue("time")) != 0) - time = atof(value); + time = static_cast(atof(value)); if((value=entrytag->getParamValue("value")) != 0) - val = atof(value); + val = static_cast(atof(value)); //Add the entry to the collection. entries_.push_back(InterpolatorEntry(time,val)); } diff --git a/LASS/src/InterpolatorIterator.cpp b/LASS/src/InterpolatorIterator.cpp index 2bbc97c9..d0d1d719 100644 --- a/LASS/src/InterpolatorIterator.cpp +++ b/LASS/src/InterpolatorIterator.cpp @@ -168,9 +168,9 @@ m_value_type& ExponentialInterpolatorIterator::next() // m_value_type dy; if( y1 == 0 ) - y1 = .0001; + y1 = .0001f; if( y2 == 0 ) - y2 = .0001; + y2 = .0001f; m_value_type alpha = 3; if (y1 > y2) @@ -184,7 +184,7 @@ m_value_type& ExponentialInterpolatorIterator::next() m_time_type t2 = e.t_to_; m_time_type t = (((t2 - t1) / e.steps_) * (e.steps_ - stepsLeft_)) + t1; m_value_type I = (t - t1) / (t2 - t1); - m_value_type base = 2.718282; + m_value_type base = 2.718282f; value_ = y1 + (y2 - y1) * ((1 - pow (base, (I * alpha))) / (1 - pow (base, alpha))); } @@ -286,12 +286,12 @@ m_value_type& CubicSplineInterpolatorIterator::next() m_value_type a = y1; m_value_type b = m1; m_value_type c = ((3*l_slp)-(2*m1)-m2)/(x2-x1); - m_value_type d = (m1+m2-(2*l_slp))/(pow((x2-x1),2)); + m_value_type d = static_cast((m1+m2-(2*l_slp))/(pow((x2-x1),2))); m_value_type x_dif = x - x1; // the polynomial - m_value_type ux = a + (b*x_dif) + (c*(pow(x_dif,2))) + (d*(pow(x_dif,3))); + m_value_type ux = static_cast(a + (b*x_dif) + (c*(pow(x_dif,2))) + (d*(pow(x_dif,3)))); value_ = ux; } diff --git a/LASS/src/LPCombFilter.cpp b/LASS/src/LPCombFilter.cpp index 8862ea57..81d78c0e 100644 --- a/LASS/src/LPCombFilter.cpp +++ b/LASS/src/LPCombFilter.cpp @@ -163,11 +163,11 @@ void LPCombFilter::xml_read(XmlReader::xmltag *lptag) { char *value; if((value = lptag->findChildParamValue("g", "value")) != 0) - set_g(atof(value)); + set_g(static_cast(atof(value))); if((value = lptag->findChildParamValue("D", "value")) != 0) set_D(atoi(value)); if((value = lptag->findChildParamValue("lpf_g","value")) != 0) - set_lpf_g(atof(value)); + set_lpf_g(static_cast(atof(value))); } diff --git a/LASS/src/Loudness.cpp b/LASS/src/Loudness.cpp index 4b0e42f9..a068f2a3 100644 --- a/LASS/src/Loudness.cpp +++ b/LASS/src/Loudness.cpp @@ -116,13 +116,13 @@ void Loudness::calculate(Sound& snd, m_rate_type rate) // calculate the numerator: m_value_type gammaTotal = 0.0; for (int i=0; i(gammaTotal + bandGamma[i] * BANDS[i][F_FACTOR]); m_value_type numerator = snd.getParam(LOUDNESS) / (bandGamma[(int)maxGamma] + gammaTotal); // for each band: for (int b=0; b(CBands[b].partials_.size()); // for each partial for (int p=0; p BANDS[NUM_BANDS-1][UPPER_BOUND]) { return NUM_BANDS-1; - cout << "WARNING: Frequency (" << freq - << ") outside of any critical bands." << endl; } // common case: @@ -200,14 +196,14 @@ m_value_type Loudness::CriticalBand::getBandGamma(m_value_type maxAmp) for(int p = 0; p < (int)partials_.size(); p++) { - bandGamma += pow( + bandGamma = static_cast(bandGamma + pow( (double)(partials_[p].amp_ / maxAmp), - (double)(1.0 / log10(2.0) / BANDS[ID_][SLOPE]) ); + (double)(1.0 / log10(2.0) / BANDS[ID_][SLOPE]) )); } - bandGamma = pow( + bandGamma = static_cast(pow( (double)bandGamma, - (double)(log10(2.0) / BANDS[ID_][SLOPE]) ); + (double)(log10(2.0) / BANDS[ID_][SLOPE]) )); return bandGamma; } @@ -229,13 +225,13 @@ m_value_type Loudness::PartialSnapshot::getScalingFactor( m_value_type Ls = (amp_ / maxAmp) * numerator; // [eq 2.4] - m_value_type Lp = log(Ls) / log(2.0) * 10.0 + 40.0; + m_value_type Lp = static_cast(log(Ls) / log(2.0) * 10.0 + 40.0); // [eq 2.13] - m_value_type L = BANDS[bandID][OFFSET] + ( BANDS[bandID][SLOPE] * Lp ); + m_value_type L = static_cast(BANDS[bandID][OFFSET] + ( BANDS[bandID][SLOPE] * Lp )); // [eq 2.5] - m_value_type A = pow(10.0, (-1.0 * ( (120.0 - L) / 20.0 ) ) ); + m_value_type A = static_cast(pow(10.0, (-1.0 * ( (120.0 - L) / 20.0 ) ) )); return (A / amp_); diff --git a/LASS/src/MarkovModel.h b/LASS/src/MarkovModel.h index 9f949b2e..9bb92cd6 100644 --- a/LASS/src/MarkovModel.h +++ b/LASS/src/MarkovModel.h @@ -128,7 +128,7 @@ MarkovModel::MarkovModel(int size) { template int MarkovModel::getStateSize() const { - return transitionMatrix.size(); + return static_cast(transitionMatrix.size()); } @@ -141,8 +141,8 @@ const vector& MarkovModel::getTransitionProbabilities(int state) cons template void MarkovModel::makeConsistent() { - for (unsigned i = 0; i < transitionMatrix.size(); i++) { - vector& row = transitionMatrix[i]; + for (unsigned rowIndex = 0; rowIndex < transitionMatrix.size(); rowIndex++) { + vector& row = transitionMatrix[rowIndex]; // find row sum double sum = 0.0; for (unsigned i = 0; i < row.size(); i++) { @@ -180,16 +180,16 @@ template std::string MarkovModel::to_str() { std::stringstream ss; ss << getStateSize() << std::endl; - for (int i = 0; i < stateValues.size(); i++) { + for (std::size_t i = 0; i < stateValues.size(); i++) { ss << stateValues[i] << " "; } ss << std::endl; - for (int i = 0; i < initialDistribution.size(); i++) { + for (std::size_t i = 0; i < initialDistribution.size(); i++) { ss << initialDistribution[i] << " "; } ss << std::endl; - for (int i = 0; i < transitionMatrix.size(); i++) { - for (int j = 0; j < transitionMatrix[i].size(); j++) { + for (std::size_t i = 0; i < transitionMatrix.size(); i++) { + for (std::size_t j = 0; j < transitionMatrix[i].size(); j++) { ss << transitionMatrix[i][j] << " "; } } diff --git a/LASS/src/MultiPan.cpp b/LASS/src/MultiPan.cpp index 584f92ac..2754622b 100644 --- a/LASS/src/MultiPan.cpp +++ b/LASS/src/MultiPan.cpp @@ -222,8 +222,8 @@ void MultiPan::addEntry(double t, ...) va_start(marker, t); for(i=0;i(va_arg(marker, double)); + addEntryHelperFn(i, static_cast(t), y_i); } va_end(marker); } @@ -275,7 +275,7 @@ void MultiPan::addEntryLocation(float t, float theta, float radius) { curSpeaker = new Speaker(); - curTheta = 2.0 * M_PI * (double)i / (double)n_channels; + curTheta = static_cast(2.0 * M_PI * (double)i / (double)n_channels); curSpeaker->x = cos(curTheta); curSpeaker->y = sin(curTheta); //cout << "\tx = " << curSpeaker->x; @@ -295,14 +295,14 @@ void MultiPan::addEntryLocation(float t, float theta, float radius) for(i=0;idist = - 1.0 / ( + static_cast(1.0 / ( 1.0 * ( JBL_SQRD(curX - SpeakerList[i]->x) + JBL_SQRD(curY - SpeakerList[i]->y) ) + 0.5 - ); + )); total_dist += SpeakerList[i]->dist; } diff --git a/LASS/src/Pan.cpp b/LASS/src/Pan.cpp index f75be267..51e7b74d 100644 --- a/LASS/src/Pan.cpp +++ b/LASS/src/Pan.cpp @@ -87,7 +87,7 @@ MultiTrack* Pan::spatialize_Track(Track& t, int numTracks) for (m_sample_count_type i=0; i(1.0 - fabs(pos - panIter.next())); if (scale > 1.0) scale = 1.0; if (scale < 0.0) scale = 0.0; diff --git a/LASS/src/Partial.cpp b/LASS/src/Partial.cpp index 4eea375c..b3bdf55c 100644 --- a/LASS/src/Partial.cpp +++ b/LASS/src/Partial.cpp @@ -209,7 +209,7 @@ MultiTrack* Partial::render(int numChannels, m_time_type amptransprob; m_time_type freqtransprob; - srand(time(0)); + srand(static_cast(time(0))); //flags to tell if we are in a transient int amptransflag = 0; @@ -239,7 +239,7 @@ MultiTrack* Partial::render(int numChannels, amptransprob = amptrans_rate_it.next(); // grab the tremolo value - tremolo = tremolo_amp_it.next() * sin(2.0 * M_PI * tremolo_phase); + tremolo = static_cast(tremolo_amp_it.next() * sin(2.0 * M_PI * tremolo_phase)); // increment the tremolo phase tremolo_phase = pmod( tremolo_phase + (tremolo_rate_it.next() / samplingRate) ); @@ -280,7 +280,7 @@ MultiTrack* Partial::render(int numChannels, //decrease the check counter amptranscheck--; - amplitude = loudnes_scalar_it.next() * wave_shape_it.next() * (1.0 + tremolo); + amplitude = static_cast(loudnes_scalar_it.next() * wave_shape_it.next() * (1.0 + tremolo)); //apply transient modifier to amplitude amplitude = amplitude + amptransient*amplitude; @@ -327,7 +327,7 @@ MultiTrack* Partial::render(int numChannels, // perhaps the vibrato should be keyed to PartialNumber. // grab the vibrato value - vibrato = vibrato_amp_it.next() * sin(2.0 * M_PI * vibrato_phase); + vibrato = static_cast(vibrato_amp_it.next() * sin(2.0 * M_PI * vibrato_phase)); // increment the vibrato phase vibrato_phase = pmod( vibrato_phase + (vibrato_rate_it.next() / samplingRate) ); @@ -335,7 +335,7 @@ MultiTrack* Partial::render(int numChannels, frequency = frequency_it.next() * freq_it.next() * detuning_it.next(); // frequency = frequency_it.next() * freq_it.next(); // * detuning_it.next() //frequency += freq_deviation_it.next(); - frequency *= 1.0 + vibrato; + frequency = static_cast(frequency * (1.0 + vibrato)); //apply frequency transient adjustments @@ -355,7 +355,7 @@ MultiTrack* Partial::render(int numChannels, // expression exactly whenever the modulation depth is zero. m_value_type phase_mod_depth = phase_amp_it.next(); if (phase_mod_depth != 0.0) - phase += phase_mod_depth * sin(2.0 * M_PI * phase_mod_phase); + phase = static_cast(phase + phase_mod_depth * sin(2.0 * M_PI * phase_mod_phase)); // Advance the PM oscillator even while its depth is zero so that a // time-varying depth envelope can enter with continuous LFO phase. @@ -369,12 +369,12 @@ MultiTrack* Partial::render(int numChannels, { case 1: // random - sample = amplitude * 2 * ((((double) std::rand()) / ((double) RAND_MAX)) - 0.5); + sample = static_cast(amplitude * 2 * ((((double) std::rand()) / ((double) RAND_MAX)) - 0.5)); break; default: // calculate the sample - sample = amplitude * ( sin(2.0 * M_PI * phase)); + sample = static_cast(amplitude * ( sin(2.0 * M_PI * phase))); break; } @@ -459,7 +459,7 @@ void Partial::xml_print( ofstream& xmlOutput, list& revObjs, list" << endl; // Output reverb ID and update reverb collection if necessary - xmlOutput << "\t\t\t" << endl; + xmlOutput << "\t\t\t(reverbObj) << "\" />" << endl; list::const_iterator revit; for( revit=revObjs.begin(); revit != revObjs.end(); revit++ ) { @@ -540,7 +540,7 @@ void Partial::xml_print( ofstream& xmlOutput, list& revObjs, list" << endl; } -void Partial::xml_read(XmlReader::xmltag* partialtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP *dvHash) +void Partial::xml_read(XmlReader::xmltag* partialtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP *dvHash) { if(strcmp("partial",partialtag->name)) { @@ -552,7 +552,7 @@ void Partial::xml_read(XmlReader::xmltag* partialtag, DISSCO_HASHMAPfindChildParamValue("reverb_ptr", "id")) != 0) { - long id=atoi(value); + m_xml_id_type id=static_cast(std::strtoll(value, nullptr, 10)); Reverb * temp; temp = (*reverbHash)[id]; @@ -564,10 +564,10 @@ void Partial::xml_read(XmlReader::xmltag* partialtag, DISSCO_HASHMAPfindChildParamValue( "relative_amplitude", "value")) != 0) - setParam(RELATIVE_AMPLITUDE, atof(value)); + setParam(RELATIVE_AMPLITUDE, static_cast(atof(value))); if((value = partialtag->findChildParamValue("partial_num","value")) != 0) - setParam(PARTIAL_NUM, atoi(value)); + setParam(PARTIAL_NUM, static_cast(atoi(value))); // For sake of ease, I am going to forego searching for each item and instead // iterate thru the list of child tags. @@ -611,14 +611,14 @@ void Partial::xml_read(XmlReader::xmltag* partialtag, DISSCO_HASHMAP *dvHash) +void Partial::auxLoadParam(enum PartialDynamicParam param,XmlReader::xmltag *tag, DISSCO_HASHMAP *dvHash) { char *value; // Try and do a lookup if((value = tag->findChildParamValue("dv_ptr", "id")) != 0) { - long id=atol(value); + m_xml_id_type id=static_cast(std::strtoll(value, nullptr, 10)); DynamicVariable *dv=(*dvHash)[id]; if(dv) diff --git a/LASS/src/Partial.h b/LASS/src/Partial.h index 2c6cf3a6..d8dac579 100644 --- a/LASS/src/Partial.h +++ b/LASS/src/Partial.h @@ -227,7 +227,7 @@ class Partial : public ParameterLib /** * \deprecated **/ - void xml_read( XmlReader::xmltag* partialtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP *dvHash); + void xml_read( XmlReader::xmltag* partialtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP *dvHash); /** * This returns the total length (in seconds) of the partial. @@ -244,7 +244,7 @@ class Partial : public ParameterLib * \deprecated * Auxillary function to assist in loading dv's from XML **/ - void auxLoadParam(enum PartialDynamicParam param,XmlReader::xmltag *tag, DISSCO_HASHMAP *dvHash); + void auxLoadParam(enum PartialDynamicParam param,XmlReader::xmltag *tag, DISSCO_HASHMAP *dvHash); /** * This is phase-modulation. It basically does an inline diff --git a/LASS/src/ProbabilityEnvelope.cpp b/LASS/src/ProbabilityEnvelope.cpp index b9081d08..c45cddfd 100644 --- a/LASS/src/ProbabilityEnvelope.cpp +++ b/LASS/src/ProbabilityEnvelope.cpp @@ -2,7 +2,7 @@ #include m_value_type lerp(m_value_type a, m_value_type b, double c) { - return (1-c) * a + c * b; + return static_cast((1-c) * a + c * b); } ProbabilityEnvelope::ProbabilityEnvelope() { @@ -30,7 +30,7 @@ void ProbabilityEnvelope::generateCountTable(int num_steps) { stepTimes.resize(0); setSamplingRate(num_steps); - m_value_type x_step_size = 1.0 / num_steps; + m_value_type x_step_size = static_cast(1.0 / num_steps); Iterator it = valueIterator(); totalCounts = 0; @@ -45,7 +45,7 @@ void ProbabilityEnvelope::generateCountTable(int num_steps) { // TODO: throw uninitialized error m_value_type ProbabilityEnvelope::sample(double x) { - m_value_type target = totalCounts * x; + m_value_type target = static_cast(totalCounts * x); // now search for target in cumulativeStepCounts to find the time index size_t upper_idx = std::upper_bound(cumulativeStepCounts.begin(), cumulativeStepCounts.end(), target) - cumulativeStepCounts.begin(); diff --git a/LASS/src/Reverb.cpp b/LASS/src/Reverb.cpp index 8202b352..feb8f761 100644 --- a/LASS/src/Reverb.cpp +++ b/LASS/src/Reverb.cpp @@ -44,30 +44,30 @@ Reverb::Reverb(m_rate_type samplingRate) float lp_gain_list[REVERB_NUM_COMB_FILTERS]; int i; - comb_gain_list[0] = 0.46; - comb_gain_list[1] = 0.48; + comb_gain_list[0] = 0.46f; + comb_gain_list[1] = 0.48f; comb_gain_list[2] = 0.50; - comb_gain_list[3] = 0.52; - comb_gain_list[4] = 0.53; - comb_gain_list[5] = 0.55; + comb_gain_list[3] = 0.52f; + comb_gain_list[4] = 0.53f; + comb_gain_list[5] = 0.55f; vector segmentCollection; envelope_segment seg; - seg.x = 0.0; seg.y = 0.83; + seg.x = 0.0; seg.y = 0.83f; seg.interType = LINEAR; seg.lengthType = FLEXIBLE; segmentCollection.push_back(seg); - seg.x = 1.0; seg.y = 0.83; + seg.x = 1.0; seg.y = 0.83f; segmentCollection.push_back(seg); percentReverb = new Envelope(segmentCollection); - float hi_low_spread = 0.05; + float hi_low_spread = 0.05f; for(i=0;i(0.05 + (hi_low_spread * (0.95 - comb_gain_list[i]))); ConstructorCommon(percentReverb, &comb_gain_list[0], &lp_gain_list[0], - 0.7, 0.6, samplingRate); + 0.7f, 0.6f, samplingRate); } @@ -80,27 +80,27 @@ Reverb::Reverb(float room_size, m_rate_type samplingRate) vector segmentCollection; envelope_segment seg; - float flatReverb = 0.345 + (0.625 * room_size); + float flatReverb = static_cast(0.345 + (0.625 * room_size)); seg.x = 0.0; seg.y = flatReverb; seg.interType = LINEAR; seg.lengthType = FLEXIBLE; segmentCollection.push_back(seg); seg.x = 1.0; seg.y = flatReverb; segmentCollection.push_back(seg); percentReverb = new Envelope(segmentCollection); - float hilow_spread = 0.056 + (0.430 * room_size); - float gainAllPass = 0.7; - float delay = 0.176 + (0.233 * room_size); + float hilow_spread = static_cast(0.056 + (0.430 * room_size)); + float gainAllPass = 0.7f; + float delay = static_cast(0.176 + (0.233 * room_size)); // percentReverb->Print(); - comb_gain_list[0] = 0.46; - comb_gain_list[1] = 0.48; + comb_gain_list[0] = 0.46f; + comb_gain_list[1] = 0.48f; comb_gain_list[2] = 0.50; - comb_gain_list[3] = 0.52; - comb_gain_list[4] = 0.53; - comb_gain_list[5] = 0.55; + comb_gain_list[3] = 0.52f; + comb_gain_list[4] = 0.53f; + comb_gain_list[5] = 0.55f; for(i=0;i(0.05 + (hilow_spread * (0.95 - comb_gain_list[i]))); ConstructorCommon(percentReverb, &comb_gain_list[0], &lp_gain_list[0], gainAllPass, delay, samplingRate); @@ -116,17 +116,17 @@ Reverb::Reverb(Envelope *percentReverb, float hilow_spread, float gainAllPass, Envelope* temp = new Envelope(*percentReverb); percentReverb = new Envelope(*temp); - comb_gain_list[0] = 0.46; - comb_gain_list[1] = 0.48; + comb_gain_list[0] = 0.46f; + comb_gain_list[1] = 0.48f; comb_gain_list[2] = 0.50; - comb_gain_list[3] = 0.52; - comb_gain_list[4] = 0.53; - comb_gain_list[5] = 0.55; + comb_gain_list[3] = 0.52f; + comb_gain_list[4] = 0.53f; + comb_gain_list[5] = 0.55f; for(i=0;i(0.05 + (hilow_spread * (0.95 - comb_gain_list[i]))); } ConstructorCommon(percentReverb, &comb_gain_list[0], &lp_gain_list[0], gainAllPass, delay, samplingRate); @@ -238,9 +238,9 @@ void Reverb::ConstructorCommon(Envelope *percentReverbInput, float *combGainList float alpha = 0.0; // alpha is the steady state gain (which is also the max of the gain fn #define max(x,y) ((x) > (y) ? (x) : (y)) for(i=0;i<6;i++) - alpha = max(alpha, combGainList[i]/(1.0 - lpGainList[i])); - float T_r = -3.0 * delay / log(alpha); - decay_duration = T_r*1.0; + alpha = static_cast(max(alpha, combGainList[i]/(1.0 - lpGainList[i]))); + float T_r = static_cast(-3.0 * delay / log(alpha)); + decay_duration = static_cast(T_r*1.0); } /** @@ -556,7 +556,7 @@ void Reverb::xml_print( ofstream& xmlOutput ) { int i; Reverb* pnt2rev = this; - xmlOutput << "" << endl; + xmlOutput << "(pnt2rev) << "\">" << endl; // I don't know if this next line will work -AL xmlOutput << "\t" << endl; xmlOutput << "\t" << endl; @@ -584,16 +584,16 @@ void Reverb::xml_read(XmlReader::xmltag *reverbtag) char *value; if((value = reverbtag->findChildParamValue("gainDirect","value")) != 0) - set_gainDirect(atof(value)); + set_gainDirect(static_cast(atof(value))); if((value = reverbtag->findChildParamValue("gainReverb","value")) != 0) - set_gainReverb(atof(value)); + set_gainReverb(static_cast(atof(value))); if((value = reverbtag->findChildParamValue("allPassDelay","value")) != 0) - set_allPassDelay(atof(value)); + set_allPassDelay(static_cast(atof(value))); if((value = reverbtag->findChildParamValue("decay_duration","value")) != 0) - set_decay_duration(atof(value)); + set_decay_duration(static_cast(atof(value))); XmlReader::xmltag *childtag; int lpIndex = 0; diff --git a/LASS/src/Score.cpp b/LASS/src/Score.cpp index 39fce7dc..d734045e 100644 --- a/LASS/src/Score.cpp +++ b/LASS/src/Score.cpp @@ -408,7 +408,7 @@ void Score::scale(MultiTrack* mt) // ----- // create a scaling factor: - m_sample_type scalingFactor = 1.0 / maxAmp; + m_sample_type scalingFactor = static_cast(1.0 / maxAmp); // ----- // scale every value by this factor @@ -456,7 +456,7 @@ void Score::channelScale(MultiTrack* mt) // ----- // create a scaling factor: - m_sample_type scalingFactor = 1.0 / maxAmp; + m_sample_type scalingFactor = static_cast(1.0 / maxAmp); // ----- // scale every value by this factor @@ -501,7 +501,7 @@ void Score::anticlip(MultiTrack* mt) // scale if necessary if (totalAmp > 1.0) { - m_sample_type scalingFactor = 1.0 / totalAmp; + m_sample_type scalingFactor = static_cast(1.0 / totalAmp); for (int t=0; tget(0)->getWave().getSamplingRate()) << " seconds. Compressing [-6, " << todB(maxAmplitude) << ") to [-6, 0) dB" << endl; - maxAmplitude /= 0.99; //Never actually allow it to hit 0dB. + maxAmplitude = static_cast(maxAmplitude / 0.99); //Never actually allow it to hit 0dB. //m_sample_type normalizeValue = maxAmplitude; for (int t=0; tsize(); t++) diff --git a/LASS/src/Score.h b/LASS/src/Score.h index 70d3aff2..3e22b47e 100644 --- a/LASS/src/Score.h +++ b/LASS/src/Score.h @@ -212,8 +212,8 @@ class Score{ // **/ // void xml_read( XmlReader::xmltag *scoretag); - DISSCO_HASHMAP* reverbHash; - DISSCO_HASHMAP* dvHash; + DISSCO_HASHMAP* reverbHash; + DISSCO_HASHMAP* dvHash; private: ClippingManagementMode cmm_; diff --git a/LASS/src/Sound.cpp b/LASS/src/Sound.cpp index 756fdacd..b7ab270c 100644 --- a/LASS/src/Sound.cpp +++ b/LASS/src/Sound.cpp @@ -66,11 +66,11 @@ Sound::Sound(int numPartials, m_value_type baseFreq) for (int i=0; i(1/pow(2.71828,i))); // INCREMENT FREQUENCY MULTIPLIER FOR GLISSANDO p.setParam(FREQUENCY, baseFreq * (i+1)); - p.setParam(PARTIAL_NUM, i); + p.setParam(PARTIAL_NUM, static_cast(i)); partials_.push_back(p); } @@ -168,9 +168,9 @@ void Sound::setDetune(double direction, double spread, double velocity){ // Direction is a sign, not a magnitude. Canonicalizing here keeps the // renderer's two envelope branches compatible with legacy positive and // negative values such as 0.5 and -0.5. - setParam(DETUNE_DIRECTION, direction < 0.0 ? -1.0 : 1.0); - setParam(DETUNE_SPREAD,spread); - setParam(DETUNE_VELOCITY, velocity); + setParam(DETUNE_DIRECTION, direction < 0.0 ? -1.0f : 1.0f); + setParam(DETUNE_SPREAD, static_cast(spread)); + setParam(DETUNE_VELOCITY, static_cast(velocity)); // setParam(DETUNE_FUNDAMENTAL, 1); } @@ -430,9 +430,9 @@ cout << "Final spread= " << spread << endl; if(getParam(DETUNE_DIRECTION) < 0.0) // divergence (detuning) { //cout << " diverging (detuning)" << endl; - detuning_env->addEntry(x[0], y[2]); - detuning_env->addEntry(x[1], y[1]); - detuning_env->addEntry(x[2], y[0]); + detuning_env->addEntry(static_cast(x[0]), static_cast(y[2])); + detuning_env->addEntry(static_cast(x[1]), static_cast(y[1])); + detuning_env->addEntry(static_cast(x[2]), static_cast(y[0])); /* cout << " x0=" << x[0] << " y2=" << y[2] << endl; cout << " x1=" << x[1] << " y1=" << y[1] << endl; @@ -441,9 +441,9 @@ cout << " x2=" << x[2] << " y0=" << y[0] << endl; */ } else if(getParam(DETUNE_DIRECTION) > 0.0) { // convergence (tuning) //cout << " converging (tuning)" << endl; - detuning_env->addEntry(x[0], y[0]); - detuning_env->addEntry(x[1], y[1]); - detuning_env->addEntry(x[2], y[2]); + detuning_env->addEntry(static_cast(x[0]), static_cast(y[0])); + detuning_env->addEntry(static_cast(x[1]), static_cast(y[1])); + detuning_env->addEntry(static_cast(x[2]), static_cast(y[2])); /* cout << " x0=" << x[0] << " y0=" << y[0] << endl; cout << " x1=" << x[1] << " y1=" << y[1] << endl; @@ -474,20 +474,20 @@ void Sound::setup_detuning_env(LinearInterpolator *detuning_env){ x[0] = 0.0; y[0] = 1.0; - x[1] = (((vel*0.95)+1.0)/2.0); + x[1] = static_cast(((vel*0.95)+1.0)/2.0); y[1] = x[1]; x[2] = 1.0; y[2] = 0.0; // scale by the height spread of the envelope spread0 = getParam(DETUNE_SPREAD); - spread = spread0 * randy * 2.0 - spread0; + spread = static_cast(spread0 * randy * 2.0 - spread0); /* cout << " randy=" << randy << endl; cout << "Final spread= " << spread << endl; */ y[0] *= spread; - y[1] *= spread * (randy * 0.5); + y[1] = static_cast(y[1] * (spread * (randy * 0.5))); // then offset to normalize the whole thing at 1.0 y[0] += 1.0; @@ -531,7 +531,7 @@ m_time_type Sound::getTotalDuration(void) maxDuration = curDuration; } - maxDuration += ( (reverbObj != NULL) ? reverbObj->getDecay() : 0.0); + maxDuration = static_cast(maxDuration + ( (reverbObj != NULL) ? reverbObj->getDecay() : 0.0)); return maxDuration; } @@ -542,7 +542,7 @@ void Sound::xml_print( ofstream& xmlOutput, list& revObjs, list" << endl; // Output reverb ID and update reverb collection if necessary - xmlOutput << "\t\t" << endl; + xmlOutput << "\t\t(reverbObj) << "\" />" << endl; list::const_iterator revit; for( revit=revObjs.begin(); revit != revObjs.end(); revit++ ) @@ -577,7 +577,7 @@ void Sound::xml_print( ofstream& xmlOutput, list& revObjs, list* reverbHash, DISSCO_HASHMAP* dvHash) +void Sound::xml_read(XmlReader::xmltag* soundtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP* dvHash) { if(strcmp("sound",soundtag->name)) { @@ -588,16 +588,16 @@ void Sound::xml_read(XmlReader::xmltag* soundtag, DISSCO_HASHMAP char *value; if((value=soundtag->findChildParamValue("reverb_ptr","id")) != 0) - if(Reverb* temp = (*reverbHash)[atoi(value)]) + if(Reverb* temp = (*reverbHash)[static_cast(std::strtoll(value, nullptr, 10))]) use_reverb(temp); if((value = soundtag->findChildParamValue("duration","value")) != 0) - setParam(DURATION, atof(value)); + setParam(DURATION, static_cast(atof(value))); if((value = soundtag->findChildParamValue("start_time","value")) != 0) - setParam(START_TIME, atof(value)); + setParam(START_TIME, static_cast(atof(value))); if((value = soundtag->findChildParamValue("loudness","value")) != 0) - setParam(LOUDNESS, atof(value)); + setParam(LOUDNESS, static_cast(atof(value))); if((value = soundtag->findChildParamValue("loudness_rate","value")) != 0) - setParam(LOUDNESS_RATE, atof(value)); + setParam(LOUDNESS_RATE, static_cast(atof(value))); double detuneSpread = getParam(DETUNE_SPREAD); double detuneDirection = getParam(DETUNE_DIRECTION); double detuneVelocity = getParam(DETUNE_VELOCITY); @@ -617,7 +617,7 @@ void Sound::xml_read(XmlReader::xmltag* soundtag, DISSCO_HASHMAP if(hasDetuneParameters) setDetune(detuneDirection, detuneSpread, detuneVelocity); if((value = soundtag->findChildParamValue("detune_fundamental","value")) != 0) - setParam(DETUNE_FUNDAMENTAL, atof(value)); + setParam(DETUNE_FUNDAMENTAL, static_cast(atof(value))); XmlReader::xmltag *partialtag; diff --git a/LASS/src/Sound.h b/LASS/src/Sound.h index d766ffce..bb009e7a 100644 --- a/LASS/src/Sound.h +++ b/LASS/src/Sound.h @@ -251,7 +251,7 @@ class Sound /** * \deprecated **/ - void xml_read(XmlReader::xmltag* soundtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP* dvHash); + void xml_read(XmlReader::xmltag* soundtag, DISSCO_HASHMAP* reverbHash, DISSCO_HASHMAP* dvHash); /** * This returns the total duration of the sound. If there is no reverb diff --git a/LASS/src/SoundSample.cpp b/LASS/src/SoundSample.cpp index dc2b53b8..381fec49 100644 --- a/LASS/src/SoundSample.cpp +++ b/LASS/src/SoundSample.cpp @@ -99,7 +99,7 @@ m_rate_type SoundSample::getSamplingRate() //----------------------------------------------------------------------------// m_sample_count_type SoundSample::getSampleCount() { - return data_.size(); + return static_cast(data_.size()); } //----------------------------------------------------------------------------// @@ -120,7 +120,7 @@ void SoundSample::composite(SoundSample& ss, m_time_type startTime) } // find the number of samples to composite - m_sample_count_type samplesToCopy = ss.data_.size(); + m_sample_count_type samplesToCopy = ss.getSampleCount(); m_sample_count_type samplesToSkip = m_sample_count_type(startTime * float(samplingRate_)); m_sample_count_type lengthNeeded = samplesToCopy + samplesToSkip; diff --git a/LASS/src/Spatializer.cpp b/LASS/src/Spatializer.cpp index d33aba59..4e142e5f 100644 --- a/LASS/src/Spatializer.cpp +++ b/LASS/src/Spatializer.cpp @@ -43,7 +43,7 @@ MultiTrack* Spatializer::spatialize_Track(Track& t, int numTracks) Track* scaledTrack = new Track(t); - scaledTrack->scale( 1.0/float(numTracks) ); + scaledTrack->scale( static_cast(1.0/float(numTracks)) ); // create a new multitrack: MultiTrack* mt = new MultiTrack; diff --git a/LASS/src/Types.h b/LASS/src/Types.h index f1e510f0..c1fd43cd 100644 --- a/LASS/src/Types.h +++ b/LASS/src/Types.h @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __TYPES_H #define __TYPES_H +#include + //----------------------------------------------------------------------------// /** @@ -52,6 +54,9 @@ typedef float m_value_type; /// Specifies a rate for playback. typedef unsigned int m_rate_type; +/// Signed, pointer-width identifier used by the legacy LASS XML format. +typedef std::intptr_t m_xml_id_type; + /** * This is used in EnvelopeEntry to specify whether the entry * should be played for a fixed amount of time or a percentage of total time. diff --git a/LASS/src/XmlReader.cpp b/LASS/src/XmlReader.cpp index e42f6926..91373597 100644 --- a/LASS/src/XmlReader.cpp +++ b/LASS/src/XmlReader.cpp @@ -124,6 +124,7 @@ void XmlReader::xmltag::destroyTag() while(tp) { tagparam *next=tp->next; + tp->next=NULL; delete tp; tp=next; } @@ -188,31 +189,31 @@ void XmlReader::xmltagset::add(xmltag *itag) //----------------------------------------------------------------------------// XmlReader::xmltag* XmlReader::xmltagset::find(const char *name) { - xmltag *tag; + xmltag *foundTag; if(searchName) { if(!strcmp(searchName,name)) { - tag=auxfind(curSearch,name); - if(!tag) + foundTag=auxfind(curSearch,name); + if(!foundTag) { curSearch=NULL; searchName=NULL; return NULL; } - return tag; + return foundTag; } } searchName=name; - tag=auxfind(this,name); - if(!tag) + foundTag=auxfind(this,name); + if(!foundTag) { searchName=NULL; curSearch=NULL; return NULL; } - return tag; + return foundTag; } //----------------------------------------------------------------------------// @@ -281,11 +282,11 @@ bool XmlReader::closeFile() //----------------------------------------------------------------------------// void XmlReader::dewhitespace(char *c) { - int l=strlen(c); + std::size_t l=strlen(c); bool wsok=false; - int nl=0; + std::size_t nl=0; - for(int i=0;i(strlen(inputbuffer)); end=index(inputbuffer,'>'); } @@ -346,7 +347,7 @@ bool XmlReader::fillTagBuffer() if(!fgets(inputbuffer+nibuf,XML_BUFFER_SIZE-nibuf,fp)) return false; - nibuf=strlen(inputbuffer); + nibuf=static_cast(strlen(inputbuffer)); end=index(inputbuffer,'>'); } @@ -371,7 +372,7 @@ bool XmlReader::fillTagBuffer() memcpy(tagbuffer,start,end-start+1); memmove(inputbuffer,end+1,nibuf-(end-inputbuffer)+1); - nibuf-=end-inputbuffer+1; + nibuf=static_cast(nibuf-(end-inputbuffer+1)); tagbuffer[end-start+1]=0; dewhitespace(tagbuffer); diff --git a/LASSIE/src/core/EnvelopeLibraryEntry.cpp b/LASSIE/src/core/EnvelopeLibraryEntry.cpp index 9de6fd90..37bac799 100644 --- a/LASSIE/src/core/EnvelopeLibraryEntry.cpp +++ b/LASSIE/src/core/EnvelopeLibraryEntry.cpp @@ -101,7 +101,7 @@ EnvelopeLibraryEntry::EnvelopeLibraryEntry(Envelope* _envelope, int _number) EnvLibEntrySeg* prevSeg = nullptr; // build all but last segment - int lastIndex = segments->size() - 1; + int lastIndex = static_cast(segments->size() - 1); for (int i = 0; i < lastIndex; ++i) { // create node EnvLibEntryNode* node = new EnvLibEntryNode(segments->at(i).x, segments->at(i).y); @@ -189,4 +189,4 @@ EnvelopeLibraryEntry* EnvelopeLibraryEntry::duplicateEnvelope(EnvelopeLibraryEnt */ QString EnvelopeLibraryEntry::getNumberString() const { return QString::number(number); -} \ No newline at end of file +} diff --git a/LASSIE/src/core/project_struct.cpp b/LASSIE/src/core/project_struct.cpp index 712cd05d..752d7529 100644 --- a/LASSIE/src/core/project_struct.cpp +++ b/LASSIE/src/core/project_struct.cpp @@ -976,6 +976,9 @@ bool ProjectManager::parse(Project* p, const QString& filepath, #include Project::Project(const QString& _title, const QByteArray& _id){ +#ifndef TABEDITOR + Q_UNUSED(_id); +#endif if(_title.isEmpty()){ title = tr("Untitled"); }else{ diff --git a/LASSIE/src/dialogs/FunctionGenerator.cpp b/LASSIE/src/dialogs/FunctionGenerator.cpp index 916fc906..bc886905 100644 --- a/LASSIE/src/dialogs/FunctionGenerator.cpp +++ b/LASSIE/src/dialogs/FunctionGenerator.cpp @@ -130,9 +130,9 @@ FunctionWidget* FunctionGenerator::ensureRegisteredWidget(CMODFunction id) void FunctionGenerator::handleFunctionChanged(int index) { - QVariant data = ui->functionOptions->itemData(index); - if (!data.isValid()) return; - const CMODFunction id = static_cast(data.toInt()); + QVariant functionData = ui->functionOptions->itemData(index); + if (!functionData.isValid()) return; + const CMODFunction id = static_cast(functionData.toInt()); if (id == NOT_A_FUNCTION) { ui->resultTextEdit->clear(); diff --git a/LASSIE/src/widgets/EnvLibDrawingArea.cpp b/LASSIE/src/widgets/EnvLibDrawingArea.cpp index 229ea094..bf053b77 100644 --- a/LASSIE/src/widgets/EnvLibDrawingArea.cpp +++ b/LASSIE/src/widgets/EnvLibDrawingArea.cpp @@ -314,8 +314,8 @@ void EnvLibDrawingArea::paintEvent(QPaintEvent* event) void EnvLibDrawingArea::mouseMoveEvent(QMouseEvent* event) { int w = width(), h = height(); - double x = event->x()*(w+1)/double(w*w); - double y = 1.0 - event->y()*(h+1)/double(h*h); + double x = qRound(event->position().x())*(w+1)/double(w*w); + double y = 1.0 - qRound(event->position().y())*(h+1)/double(h*h); y = mouseAdjustY(y); // round to 3 decimals @@ -343,8 +343,8 @@ void EnvLibDrawingArea::mousePressEvent(QMouseEvent* event) if (!env) { QWidget::mousePressEvent(event); return; } activeSegment = nullptr; - mouseX = event->x(); - mouseY = height() - event->y(); + mouseX = qRound(event->position().x()); + mouseY = height() - qRound(event->position().y()); // pick a node within ±5px EnvLibEntryNode* cand = env->head; @@ -376,7 +376,7 @@ void EnvLibDrawingArea::mousePressEvent(QMouseEvent* event) // right-click → context menu if (event->button() == Qt::RightButton) { actionRemove->setEnabled(activeNode && activeNode->leftSeg && activeNode->rightSeg); - m_pMenuPopup->exec(event->globalPos()); + m_pMenuPopup->exec(event->globalPosition().toPoint()); } // left-click → start drag else if (event->button() == Qt::LeftButton) { @@ -612,4 +612,4 @@ double EnvLibDrawingArea::getAdjustedY(double y) const double EnvLibDrawingArea::mouseAdjustY(double y) const { return y*(upperY-lowerY) + lowerY; -} \ No newline at end of file +} diff --git a/LASSIE/src/widgets/EventAttributesViewController.cpp b/LASSIE/src/widgets/EventAttributesViewController.cpp index a86377bc..3a455432 100644 --- a/LASSIE/src/widgets/EventAttributesViewController.cpp +++ b/LASSIE/src/widgets/EventAttributesViewController.cpp @@ -674,8 +674,8 @@ void EventAttributesViewController::showCurrentEventData() { // populate fields ProjectManager *pm = Inst::get_project_manager(); // ui->nameEntry->setText(QString::fromStdString(m_currentlyShownEvent->getEventName())); - HEvent event; if(type <= bottom){ + HEvent event; if(type == bottom){ const BottomEvent& bottom_event = pm->bottomevents()[m_curreventindex]; ExtraInfo extra_info = bottom_event.extra_info; diff --git a/LASSIE/src/widgets/ProjectViewController.cpp b/LASSIE/src/widgets/ProjectViewController.cpp index 8c2807d9..7bbf7053 100644 --- a/LASSIE/src/widgets/ProjectViewController.cpp +++ b/LASSIE/src/widgets/ProjectViewController.cpp @@ -122,7 +122,7 @@ namespace PVCHelper { } } /* ProjectView constructor initializing values for XML file*/ -ProjectView::ProjectView(MainWindow* _mainWindow, QString _pathAndName) { +ProjectView::ProjectView(MainWindow* _mainWindow, QString /*_pathAndName*/) { ProjectManager *pm = Inst::get_project_manager(); qDebug() << "In PV Constructor p:" << pm->get_curr_project(); @@ -366,7 +366,8 @@ bool ProjectView::save(){ EnvLibEntryNode* currentNode; EnvLibEntrySeg* libSeg = envLib->head->rightSeg; - while (libSeg != NULL){ + // Every envelope has at least two nodes, hence at least one segment. + do { currentNode = libSeg->leftNode; stringBuffer = stringBuffer + QString::number(currentNode->x, 'f', 3); stringBuffer = stringBuffer + " "; @@ -389,7 +390,7 @@ bool ProjectView::save(){ stringBuffer = stringBuffer + QString::number((libSeg->rightNode->x) - (currentNode->x), 'f', 3) + "\n"; libSeg = libSeg->rightNode->rightSeg; - } + } while (libSeg != NULL); currentNode = currentNode->rightSeg->rightNode; stringBuffer = stringBuffer + QString::number(currentNode->x, 'f', 3) + " "; @@ -1312,8 +1313,8 @@ void ProjectView::insertEventCopy(const PaletteEventCopy& snapshot) const QList* layers = nullptr; if (const auto* event = std::get_if(&snapshot.value)) layers = &event->event_layers; - else if (const auto* event = std::get_if(&snapshot.value)) - layers = &event->event.event_layers; + else if (const auto* bottomEvent = std::get_if(&snapshot.value)) + layers = &bottomEvent->event.event_layers; if (layers) { for (const Layer& layer : *layers) { for (const Package& package : layer.discrete_packages) { diff --git a/LASSIE/src/windows/EnvelopeLibraryWindow.cpp b/LASSIE/src/windows/EnvelopeLibraryWindow.cpp index 9f7b6474..a716185d 100644 --- a/LASSIE/src/windows/EnvelopeLibraryWindow.cpp +++ b/LASSIE/src/windows/EnvelopeLibraryWindow.cpp @@ -115,7 +115,7 @@ EnvelopeLibraryWindow::EnvelopeLibraryWindow(QWidget* parent) this, &EnvelopeLibraryWindow::duplicateEnvelope); actionSave = new QAction("Save", this); - actionSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); + actionSave->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S)); connect(actionSave, &QAction::triggered, this, &EnvelopeLibraryWindow::fileSave); addAction(actionSave); @@ -431,8 +431,8 @@ void EnvelopeLibraryWindow::valueEntriesChanged() // Only update if we have valid numeric input bool xOk, yOk; - double xVal = xEntry->text().toDouble(&xOk); - double yVal = yEntry->text().toDouble(&yOk); + xEntry->text().toDouble(&xOk); + yEntry->text().toDouble(&yOk); if (xOk && yOk) { drawingArea->setActiveNodeCoordinate( diff --git a/LASSIE/src/windows/MainWindow.cpp b/LASSIE/src/windows/MainWindow.cpp index e141fa1b..12c43263 100644 --- a/LASSIE/src/windows/MainWindow.cpp +++ b/LASSIE/src/windows/MainWindow.cpp @@ -419,7 +419,7 @@ void MainWindow::runProject() const auto cmod = new QProcess(this); connect(cmod, QOverload::of(&QProcess::finished), - [=](const int exit_code) + [this](const int exit_code) { statusBar()->showMessage(tr("CMOD exited with code %1").arg(exit_code)); } diff --git a/external-libs/muParser/CMakeLists.txt b/external-libs/muParser/CMakeLists.txt index 1e31abc5..463bf32d 100644 --- a/external-libs/muParser/CMakeLists.txt +++ b/external-libs/muParser/CMakeLists.txt @@ -8,6 +8,11 @@ file(GLOB_RECURSE MUPARSER_SRC "${PROJECT_SOURCE_DIR}/*.h" ) +list(REMOVE_ITEM MUPARSER_SRC + "${PROJECT_SOURCE_DIR}/muParserTest.cpp" + "${PROJECT_SOURCE_DIR}/muParserTest.h" +) + ### in the future, we'll let this be shared if there's a viable muparser lib install add_library(MUPARSER STATIC ${MUPARSER_SRC}) target_compile_definitions(MUPARSER PUBLIC MUPARSER_STATIC) diff --git a/external-libs/muParser/muParserTokenReader.cpp b/external-libs/muParser/muParserTokenReader.cpp index 34c8800a..1957292d 100644 --- a/external-libs/muParser/muParserTokenReader.cpp +++ b/external-libs/muParser/muParserTokenReader.cpp @@ -270,7 +270,7 @@ namespace mu // Ignore all non printable characters when reading the expression while (szExpr[m_iPos] > 0 && szExpr[m_iPos] <= 0x20) { - // 14-31 are control characters. I donÄt want to have to deal with such strings at all! + // 14-31 are control characters. I don't want to have to deal with such strings at all! // (see https://en.cppreference.com/w/cpp/string/byte/isprint) if (szExpr[m_iPos] >= 14 && szExpr[m_iPos] <= 31) Error(ecINVALID_CHARACTERS_FOUND, m_iPos); From 2bfbf99900ee7827aa01ed362e7ea2ec2ad11cdf Mon Sep 17 00:00:00 2001 From: Maxwell Zheng Date: Mon, 31 Aug 2026 20:48:47 -0500 Subject: [PATCH 2/5] fix: clear remaining macOS compiler warnings Remove two write-only values that trigger Apple Clang diagnostics and make the macOS CI build reject future warning regressions. --- .github/workflows/build.yml | 1 + CMOD/src/Utilities.h | 3 --- LASS/src/AuWriter.cpp | 6 ++---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87f43140..bcddf27e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -147,6 +147,7 @@ jobs: run: | cmake -S . -B build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DCMAKE_PREFIX_PATH="${Qt6_DIR}" - name: Build diff --git a/CMOD/src/Utilities.h b/CMOD/src/Utilities.h index edca39dc..31fbd2cf 100644 --- a/CMOD/src/Utilities.h +++ b/CMOD/src/Utilities.h @@ -464,9 +464,6 @@ std::map notesEventnames; Piece* piece; Score* score; - // A flag to indicate that the CMOD computation is done. - bool doneCreatingSoundObjects = false; - }; #endif diff --git a/LASS/src/AuWriter.cpp b/LASS/src/AuWriter.cpp index 55fd4dba..3e119acb 100644 --- a/LASS/src/AuWriter.cpp +++ b/LASS/src/AuWriter.cpp @@ -171,8 +171,6 @@ bool AuWriter::write(vector& channels, string filename, float* chunk = new float[chunkFrames * channels.size()]; - int outOfBounds = 0; - for(m_sample_count_type currentIn = 0; currentIn < minSamples; currentIn += chunkFrames){ m_sample_count_type framesToWrite = chunkFrames; if(framesToWrite > minSamples - currentIn) @@ -182,8 +180,8 @@ bool AuWriter::write(vector& channels, string filename, m_sample_type sample = (*channels[c])[i]; //Check bounds. - if (sample > 1.0) {sample = 1.0; outOfBounds++;} - if (sample < -1.0) {sample = -1.0; outOfBounds++;} + if (sample > 1.0) {sample = 1.0;} + if (sample < -1.0) {sample = -1.0;} chunk[(i - currentIn) * channels.size() + c] = sample; } From 135b4fa3712be5489c21a8c227cd9bd394e43d29 Mon Sep 17 00:00:00 2001 From: DiyunZ Date: Mon, 31 Aug 2026 21:21:55 -0500 Subject: [PATCH 3/5] ci: fail Linux builds on compiler warnings --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcddf27e..8825d451 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,10 +55,11 @@ jobs: run: | cmake -S . -B build -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=ON \ -DCMAKE_PREFIX_PATH="${Qt6_DIR}" - name: Build - run: cmake --build build --parallel + run: cmake --build build --parallel --verbose windows: name: Windows build From 94e1b1289eeb3ecd98129fe7ba2debabd8c45081 Mon Sep 17 00:00:00 2001 From: DiyunZ Date: Mon, 31 Aug 2026 21:47:22 -0500 Subject: [PATCH 4/5] fix: remove dead start flag conversions The unused conversions discarded atoi results, triggering Linux -Wunused-result. --- CMOD/src/Piece-experimental.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CMOD/src/Piece-experimental.cpp b/CMOD/src/Piece-experimental.cpp index b583f10d..1b2ce7dd 100644 --- a/CMOD/src/Piece-experimental.cpp +++ b/CMOD/src/Piece-experimental.cpp @@ -570,7 +570,6 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ pugi::xml_node AttackSieveElement = GNES(childDurationElement); pugi::xml_node DurationSieveElement = GNES(AttackSieveElement); pugi::xml_node methodFlagElement = GNES(DurationSieveElement); - pugi::xml_node childStartTypeFlag = GNES(methodFlagElement); //Read Flag values (Needed for modification) string defFlag = XMLTC(methodFlagElement); @@ -578,10 +577,6 @@ vector Piece::calcEventM(pugi::xml_node eventElement){ if(definitionVal == 0){ //Only Continuum - //Calculating start time orignality - string startFlag = XMLTC(childStartTypeFlag); - atoi(startFlag.c_str()); - //layers, initialize child names thisEventElement = GNES(childEventDefElement); pugi::xml_node layerElement = GFEC(thisEventElement); @@ -1301,7 +1296,6 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne pugi::xml_node AttackSieveElement = GNES(childDurationElement); pugi::xml_node DurationSieveElement = GNES(AttackSieveElement); pugi::xml_node methodFlagElement = GNES(DurationSieveElement); - pugi::xml_node childStartTypeFlag = GNES(methodFlagElement); //Read Flag values (Needed for modification) string defFlag = XMLTC(methodFlagElement); @@ -1309,11 +1303,6 @@ void Piece::functionModifier(pugi::xml_node functionElement, int maxValue){ //Ne if(definitionVal == 0){ //Only Continuum - //Calculating start time orignality - string startFlag = XMLTC(childStartTypeFlag); - atoi(startFlag.c_str()); - - /*//Calculating Duration entropy samples.clear(); From 400e8568ef761684d5d8f956b8f0c5b44ca33f47 Mon Sep 17 00:00:00 2001 From: DiyunZ Date: Mon, 31 Aug 2026 22:10:07 -0500 Subject: [PATCH 5/5] ci: remove cross-platform warning noise Keep warning-as-error logs actionable by avoiding runner and dependency setup warnings. --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8825d451..d00f0f79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,9 @@ jobs: name: Linux build runs-on: ubuntu-22.04 steps: + - name: Configure Git defaults + run: git config --global init.defaultBranch main + - uses: actions/checkout@v5 - name: Install system dependencies @@ -70,14 +73,12 @@ jobs: shell: pwsh steps: + - name: Configure Git defaults + run: git config --global init.defaultBranch main + - name: Checkout repository uses: actions/checkout@v5 - - name: Configure MSVC environment - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: x64 - - name: Install Qt 6.8.1 uses: jurplel/install-qt-action@v4 with: @@ -89,7 +90,13 @@ jobs: - name: Install vcpkg dependencies run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $vsRoot = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if (-not $vsRoot) { throw "Visual Studio with the x64 C++ toolchain was not found." } + & "$vsRoot\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation + $vcpkgRoot = "$env:RUNNER_TEMP\vcpkg" + $env:VCPKG_ROOT = $vcpkgRoot git clone --depth 1 https://github.com/microsoft/vcpkg.git $vcpkgRoot & "$vcpkgRoot\bootstrap-vcpkg.bat" -disableMetrics @@ -102,7 +109,13 @@ jobs: env: CL: /EHsc /DNOMINMAX /DNOGDI /DMUPARSER_STATIC /D_CRT_SECURE_NO_WARNINGS run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $vsRoot = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if (-not $vsRoot) { throw "Visual Studio with the x64 C++ toolchain was not found." } + & "$vsRoot\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation + $vcpkgRoot = "$env:RUNNER_TEMP\vcpkg" + $env:VCPKG_ROOT = $vcpkgRoot Write-Host "MSVC flags: $env:CL" @@ -120,6 +133,14 @@ jobs: env: CL: /EHsc /DNOMINMAX /DNOGDI /DMUPARSER_STATIC /D_CRT_SECURE_NO_WARNINGS run: | + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + $vsRoot = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath + if (-not $vsRoot) { throw "Visual Studio with the x64 C++ toolchain was not found." } + & "$vsRoot\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation + + $vcpkgRoot = "$env:RUNNER_TEMP\vcpkg" + $env:VCPKG_ROOT = $vcpkgRoot + Write-Host "MSVC flags: $env:CL" cmake --build build --parallel --verbose @@ -127,12 +148,27 @@ jobs: name: macOS build runs-on: macos-14 steps: + - name: Configure Git defaults + run: git config --global init.defaultBranch main + - uses: actions/checkout@v5 - name: Install dependencies run: | brew update - brew install cmake ninja libsndfile + + if brew tap | grep -qx 'aws/tap'; then + brew untap aws/tap + fi + + dependencies=() + command -v cmake >/dev/null 2>&1 || dependencies+=(cmake) + command -v ninja >/dev/null 2>&1 || dependencies+=(ninja) + brew list --versions libsndfile >/dev/null 2>&1 || dependencies+=(libsndfile) + + if (( ${#dependencies[@]} )); then + brew install "${dependencies[@]}" + fi - name: Install Qt 6.8 uses: jurplel/install-qt-action@v4 @@ -152,4 +188,4 @@ jobs: -DCMAKE_PREFIX_PATH="${Qt6_DIR}" - name: Build - run: cmake --build build --parallel + run: cmake --build build --parallel --verbose