Fix the upgrade routine that was introduced with pull request #6747 which added the BPM value to some file names.
This also simplifies the implementation by using a map.
Note: this also removes the code about the prefix `factorysample:`. If it is used in some files these entries will also have to be added to the map.
## Bump CMT to d8bf8084aa3
Bump the CMT submodule to commit d8bf8084aa3 which contains the underlying fixes for issue #5167.
The CMT delay uses `sprintf` calls to generate the technical names and display names of the delays. These calls are locale dependent. As a consequence for example the feedback delay might have been saved either as "fbdelay_0.1s" (point) or "fbdelay_0,1s" (comma) in a save file.
The CMT fix makes sure that all delays use points in their names and thus that they now always report the same name strings.
## Add upgrade routine for CMT delays
Add an upgrade routine for CMT delays which works in conjunction with the upgraded CMT submodule. Because the delays will now always report their name with points old save files which might contain versions with the comma must be upgraded to a name with a point.
* clang-tidy: Apply cppcoreguidelines-init-variables everywhere (treating NaNs as zeros)
* Initialize msec and tick outside switch
* Update plugins/Vestige/Vestige.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/Vestige/Vestige.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/Vestige/Vestige.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/VstEffect/VstEffectControls.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/VstEffect/VstEffectControls.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/VstEffect/VstEffectControls.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Use initialization with =
* Use tabs
* Use static_cast
* Update DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Do not use tabs for alignment in src/core/DrumSynth.cpp
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
* Move x variable inside loop
* Use ternary operator for b variable
* Revert "Use tabs"
This reverts commit 07afd8a83f58b539c3673310b2aad4b63c9198a0.
* Remove unnecessary variables in XpressiveView
* Simplify initialization in Plugin
* Combine declaration and initialization in EqCurve
* Combine declaration and initialization in Song
* Combine declaration and initialization in AudioAlsa
* Combine declaration and initialization in EqCurve (again)
* Missed some
* Undo changes made to non-LMMS files
* Undo indentation changes in SidInstrument.cpp
* Combine declaration with assignment in IoHelper
* Combine declaration with assignment using auto in Carla
* Combine declaration with assignment
* Combine declaration with assignment in BasicFilters
* Simplify assignments in AudioFileProcessorWaveView::zoom
* Simplify out sample variable in BitInvader
* Remove sampleLength variable in DelayEffect
* Move gain variable in DynamicsProcessor
* Combine peak variable declaration with assignment in EqSpectrumView
* Move left/right lfo variables in for loop in FlangerEffect
* Use ternary operator for group variable in LadspaControlDialog
* Combine declaration with assignment in Lb302
* Combine declaration with assignment in MidiExport
* Combine declaration with assignment in MidiFile
* Combine declaration with assignment in MidiImport
* Use ternary operator for vel_adjusted variable in OpulenZ
* Move tmpL and dcblkL variables in for loop in ReverbSC
* Combine declaration with initialization in SlicerT
* Combine declaration with assignment in SaSpectrumView
* Combine declaration with assignment in SaWaterfallView
* Combine declaration with assignment in StereoEnhancerEffect
* Combine declaration with assignment in VibratingString
* Combine declaration with assignment in VstEffectControls
* Combine declaration with assignment in Xpressive
* Combine declaration with assignment in AutomatableModel
* Combine declaration with assignment in AutomationClip
* Move sample variable in for loop in BandLimitedWave
* Combine declaration with assignment in DataFile
* Combine declaration with assignment in DrumSynth
* Combine declaration with assignment in Effect
* Remove redundant assignment to nphsLeft in InstrumentPlayHandle
* Combine declaration with assignment in LadspaManager
* Combine declaration with assignment in LinkedModelGroups
* Combine declaration with assignment in MemoryHelper
* Combine declaration with assignment in AudioAlsa
* Combine declaration with assignment in AudioFileOgg
* Combine declaration with assignment in AudioPortAudio
* Combine declaration with assignment in AudioSoundIo
* Combine declaration with assignment in Lv2Evbuf
* Combine declaration with assignment in Lv2Proc
* Combine declaration with assignment in main
* Combine declaration with assignment in MidiAlsaRaw
* Combine declaration with assignment in MidiAlsaSeq
* Combine declaration with assignment in MidiController
* Combine declaration with assignment in MidiJack
* Combine declaration with assignment in MidiSndio
* Combine declaration with assignment in ControlLayout
* Combine declaration with assignment in MainWindow
* Combine declaration with assignment in ProjectNotes
* Use ternary operator for nextValue variable in AutomationClipView
* Combine declaration with assignment in AutomationEditor
* Move length variable in for-loop in PianoRoll
* Combine declaration with assignment in ControllerConnectionDialog
* Combine declaration with assignment in Graph
* Combine declaration with assignment in LcdFloatSpinBox
* Combine declaration with assignment in TimeDisplayWidget
* Remove currentNote variable in InstrumentTrack
* Combine declaration with assignment in DrumSynth (again)
* Use ternary operator for factor variable in BitInvader
* Use ternary operator for highestBandwich variable in EqCurve
Bandwich?
* Move sum variable into for loop in Graph
* Fix format in MidiSndio
* Fixup a few more
* Cleanup error variables
* Use ternary operators and combine declaration with initialization
* Combine declaration with initialization
* Update plugins/LadspaEffect/LadspaControlDialog.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/OpulenZ/OpulenZ.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update plugins/SpectrumAnalyzer/SaProcessor.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/midi/MidiAlsaRaw.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/gui/MainWindow.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/gui/clips/AutomationClipView.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/gui/editors/AutomationEditor.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/gui/widgets/Fader.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Move static_cast conversion into separate variable
* Use real index when interpolating
* Remove empty line
* Make helpBtn a private member
* Move controller type into separate variable
* Fix format of DrumSynth::waveform function
* Use tabs and static_cast
* Remove redundant if branch
* Refactor using static_cast/reinterpret_cast
* Add std namespace prefix
* Store repeated conditional into boolean variable
* Cast to int before assigning to m_currentLength
* Rename note_frames to noteFrames
* Update src/core/Controller.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/core/DrumSynth.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Update src/gui/widgets/Graph.cpp
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Revert changes that initialized variables redudantly
For situations where the initialization is
more complex or passed into a function
by a pointer, we dont need to do
initialization ourselves since it is
already done for us, just in a different way.
* Remove redundant err variable
* Remove explicit check of err variable
* Clean up changes and address review
* Do not initialize to 0/nullptr when not needed
* Wrap condition in parentheses for readability
---------
Co-authored-by: Kevin Zander <veratil@gmail.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
* replace QRegExp with QRegularExpression (find n replace)
* follow up to fix errors
* removed rpmalloc
* Fix compilation for qt5, to be fixed when qt6 fully supported.
Co-authored-by: Kevin Zander <veratil@gmail.com>
* Added QtGlobal header for version finding fix
* Use the other syntax to try fix compilation.
* Check for 5.12 instead.
* Fix the header
* Attempt at fixing it further.
* Use version checks properly in header file
* Use QT_VERSION_CHECK macro in sources
* Apply suggestions from messmerd's review
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
---------
Co-authored-by: Kevin Zander <veratil@gmail.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
* Initial Commit
Starts implementing Note Types. The two available types are
RegularNote and StepNote. PianoRoll now paints the color with a
different color for StepNotes. Pattern::addStep now sets the type of the
note to StepNote.
Negative size is still used to signal a step note.
* Update Pattern.cpp to account for the Note::Type
Updates the methods noteAtStep(), addStepNote() and checkType()
from Pattern.cpp to account for the note type and not the note length.
* Update PatternView::paintEvent to draw step notes
PatternView::paintEvent now draws the pattern if the pattern
type is BeatPattern and TCOs aren't fixed (Song Editor). Color used is
still the BeatPattern color (grey) and the conditional doesn't look very
nice and can be improved.
Pattern::beatPatternLength was also updated so it accounts for
the note type not note length. Review this method, as it looks a bit
weird (particularly the second conditional).
* Implements StepNotes setting a NPH with 0 frames
Now, instead of TimePos returning 0 for negative lengths, we
create a NotePlayHandle with 0 frames when the note type is StepNote on
InstrumentTrack::play.
* Improves PatternView::paintEvent conditional
Improves a conditional inside PatternView::paintEvent by
reversing the order in which they are executed.
* Adds upgrade method for backwards compatibility
Adds an upgrade method that converts notes with negative length
to StepNotes, so old projects can be loaded properly.
Explicitly set the Note::RegularNote value as 0.
Make the default "type" value "0", so notes without a type are
loaded as RegularNotes.
* Addresses Veratil's review
- Changes "addStepNote" so "checkType" isn't called twice in a
row.
- Changes style on a one line conditional.
* Uses ternary expression on statement
Reduces number of lines by using ternary expression.
* Addresses PR review (sakertooth)
- Changes class setter to inline
- Uses enum class instead of enum
- Uses auto and const where appropriate
* Finished changes from review (sakertooth)
- Used std::max instead of qMax
- Fixed style on lines changed in the PR
* Uses std::find_if to save codelines
As suggested by sakertooth, by using std::find_if we are able to
simplify the checkType method to two lines.
* Addresses review from sakertooth
- Reverts m_detuning in-class initialization
- Removes testing warning
- Removes unnecessary comment
* Addresses DomClark's review
- Rename the Note Types enum to avoid redundancy
- Uses std::all_of instead of std::find_if on MidiClip checkType
- Rewrites addStepNote so it sets the note type before adding it
to the clip, avoiding having to manually change the type of the clip
after adding the note
* Updates MidiExport to use Note Types
- Now MidiExport is updated to use note types instead of relying
on negative length notes.
- For that change it was necessary to find a way of letting
MidiExport know how long step notes should be. The solution found was to
add an attribute to the Instrument XML called "beatlen", which would
hold the number of frames of the instrument's beat. That would be
converted to ticks, so we could calculate how long the MIDI notes would
have to be to play the whole step note. If the attribute was not found,
the default value of 16 ticks would be used as a length of step notes,
as a fallback.
* Fixes ambiguity on enum usage
Due to changes in the name of enum classes, there was an
ambiguity caused in NotePlayHandle.cpp. That was fixed.
* Addresses new code reviews
- Addresses code review from PhysSong and Messmerd
* Fixes note drawing on Song Editor
- Notes were not being draw on the song editor for BeatClips.
This commit fixes this.
* Adds cassert header to TimePos.cpp
- Adds header to use assert() on TimePos.cpp
* Apply suggestions from code review
Fixes style on some lines
Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
* Reverts some changes on MidiExport
- Some changes were reverted on MidiExport and InstrumentTrack.
We were storing the beat length on the XML of Instrument Tracks, but in
reality the beat length is a per note attribute, and some instruments
could run into a segmentation fault when calling beat length without a
NotePlayHandle (i.e.: AFP). Because of that I reverted this change, so
the beat length is not stored on the XML anymore, and instead we have a
magic number on the MidiExport class that holds a default beat length
which is actually an upper limit for the MIDI notes of step notes. In
the future we can improve this by finding a way to store the beat length
on the note class to use it instead. The MidiExport logic is not
worsened at all because previously the beat length wasn't even
considered during export (it was actually improved making the exported
notes extend until the next one instead of cutting shorter).
* Fix the order of included files
---------
Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
* Added floating-point vorbis BPM tags to files in lmms/data/samples/beats
* Added rounded BPM to filenames, surrounded by square brackets and separated from the rest of the filename by an underscore
Updating to use the recommended method QSaveFile instead of QFile.
Hopefully fix issue where LMMS in rare occasions would produce empty
files on save.
---------
Co-authored-by: Kevin Zander <veratil@gmail.com>
* fixes#6354: Sample and Hold for LFO Controller
LFO controller's "white noise" wave shape didn't respect the frequency knob at all, so
Sample-and-Hold was added to extend the functionality of the LFO Controller with this
random waveshape. The original functionallity can still be accessed by setting the
FREQ knob to minimum (0.01)
---------
Co-authored-by: Kevin Zander <veratil@gmail.com>
Co-authored-by: saker <sakertooth@gmail.com>
Towards the end of the development for the fix of #6548 (via #6725) the upgrade code was refactored into its own class. While doing so it was forgotten to actually call the `upgrade` method on the `UpgradeExtendedNoteRange` instance. As a result almost all files should currently open in a wrong state with many instruments transposed. This commit fixes this.
Also explicitly check the assertion that BB tracks do not contain other BB tracks.
Extract the code that upgrades the extended note range into its own
class. This hides the helper functions that are related to the upgrade
from the other upgrade methods in DataFile.cpp.
The header file is put into the src/core directory as it is not part of
the public interface and therefore should not be included in the
"global" include directory. The whole thing is just an implementation
detail of the upgrade in DataFile.cpp.
Fix the base notes and automations of B+B tracks.
This fixes for example the problem that when a TripleOscillator had been
put into a B+B track, e.g. with version 1.2 that it sounded too high
when being loaded with a current master version. The cause seems to be
that the notes of the instrument pattern are corrected/transposed too
often (likely due to the collection of all tracks starting from the
song/document root).
The multiple correction of notes is fixed by traversing the song
structure in a more consise way. First all track containers of the song
are collected and for each of them the tracks are collected. These
tracks are then fixed one by one. B+B tracks are getting a special
handling while doing so. It is assumed that a B+B track cannot have
other B+B tracks inside and therefore all sub tracks of the B+B track
are searched for so that they can be fixed recursively.
Refactor some more functionality into static helper methods:
* Everything beneath a track is now fixed by the helper method
`fixTrack`.
* The fix of the base notes of the instruments themselves and the
extraction of the ids of automated base notes has been moved into
`fixInstrumentBaseNoteAndCollectIds`.
* The lambda `affected` has been converted into a static method because
it is must be accessible by one of the static helper methods.
* The code for fixing the automation tracks of a song has been moved
into the helper function `fixAutomationTracks`.
Fix the problem with the nested for loops that all had variables called
"i" by extracting a helper method with a corrected nesting. Due the
extraction we do not have to care anymore if the correction is running
beneath another for loop with potentially the same variable names.
Move the fix for the automated base notes to the code that fixes the
non-automated base notes.
Improve the fix for automation tracks and patterns by potentially
splitting them into two tracks:
* The original track which is adjusted to only contain patterns with
targets that are not base notes.
* A cloned track that only contains patterns with base note targets.
This is done by iterating over all automation tracks and checking which
types of automations they contain:
* Base note automations
* Automations of other targets
The result for each automation track are then evaluated as follows.
* If an automation track does not contain any base note automations it
is kept as it is, i.e. nothing is done.
* If an automation track only contains patterns with base note
automations its patterns are corrected in place.
* If an automation track contains patterns with base note automations
and other targets then the track is duplicated so that we can split it
as described above. This split and correction is done on a per pattern
level. Patterns that would become empty are removed.
Cloned tracks will keep the same names and attributes as their original
tracks.
TODOs
------
* Base notes are read as integers, corrected by an integer value of 12
and then stored back as an integer. In some files base notes have float
values, i.e. if the file was stored after the base notes have been
automated linearly.
* B&B tracks are not corrected although they can contain instruments
with (automated) base notes!
* Nested for-loops with "i" as their running variables. (Fix in a
separate commit)
Fix all base notes that are used in automations and their corresponding
automation values. Base notes that are automated are stored as elements
in the save file whereas non-automated base notes are stored as
attributes. So far the method `upgrade_extendedNoteRange` only upgraded
the non-automated base notes that are stored in attributes. This commit
fixes the automated ones which are stored in elements.
The fix works as follows:
* Collect all base note elements.
* Store their ids in a set so that we can later identify automations
that reference them.
* Collect all automation pattern and check if they reference a base
note.
* Adjust the values and out values of all automations that reference
base notes.
Note: for many older files the out values will be introduced by the
upgrade `method upgrade_automationNodes` and do not appear in the files
themselves!
This PR places all LMMS symbols into namespaces to eliminate any potential future name collisions between LMMS and third-party modules.
Also, this PR changes back `LmmsCore` to `Engine`, reverting c519921306 .
Co-authored-by: allejok96 <allejok96@gmail.com>
* Update ringbuffer submodule to fix includes
* Remove cyclic includes
* Remove Qt include prefixes
* Include C++ versions of C headers
E.g.: assert.h -> cassert
* Move CLIP_BORDER_WIDTH into ClipView
This allows to remove includes to TrackView.h in ClipView cpp files.
* Elliminate useless includes
This improves the include structure by elliminating includes that are
not used. Most of this was done by using `include-what-you-use` with
`CMAKE_C_INCLUDE_WHAT_YOU_USE` and `CMAKE_CXX_INCLUDE_WHAT_YOU_USE`
set to (broken down here):
```
include-what-you-use;
-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp;
-Xiwyu;--keep=*/xmmintrin.h;
-Xiwyu;--keep=*/lmmsconfig.h;
-Xiwyu;--keep=*/weak_libjack.h;
-Xiwyu;--keep=*/sys/*;
-Xiwyu;--keep=*/debug.h;
-Xiwyu;--keep=*/SDL/*;
-Xiwyu;--keep=*/alsa/*;
-Xiwyu;--keep=*/FL/x.h;
-Xiwyu;--keep=*/MidiApple.h;
-Xiwyu;--keep=*/MidiWinMM.h;
-Xiwyu;--keep=*/AudioSoundIo.h
```
* Fixup: Remove empty #if-#ifdef pairs
* Remove LMMS_HAVE_STD(LIB|INT)_H
Summary:
* `NULL` -> `nullptr`
* `gui` -> Function `getGUI()`
* `pluginFactory` -> Function `getPluginFactory()`
* `assert` (redefinition) -> using `NDEBUG` instead, which standard `assert` respects.
* `powf` (C stdlib symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `exp10` (nonstandard function symbol clash) -> removed and all expansions replaced with calls to `std::pow`.
* `PATH_DEV_DSP` -> File-scope QString of identical name and value.
* `VST_SNC_SHM_KEY_FILE` -> constexpr char* with identical name and value.
* `MM_ALLOC` and `MM_FREE` -> Functions with identical name and implementation.
* `INVAL`, `OUTVAL`, etc. for automation nodes -> Functions with identical names and implementations.
* BandLimitedWave.h: All integer constant macros replaced with constexpr ints of same name and value.
* `FAST_RAND_MAX` -> constexpr int of same name and value.
* `QSTR_TO_STDSTR` -> Function with identical name and equivalent implementation.
* `CCONST` -> constexpr function template with identical name and implementation.
* `F_OPEN_UTF8` -> Function with identical name and equivalent implementation.
* `LADSPA_PATH_SEPARATOR` -> constexpr char with identical name and value.
* `UI_CTRL_KEY` -> constexpr char* with identical name and value.
* `ALIGN_SIZE` -> Renamed to `LMMS_ALIGN_SIZE` and converted from a macro to a constexpr size_t.
* `JACK_MIDI_BUFFER_MAX` -> constexpr size_t with identical name and value.
* versioninfo.h: `PLATFORM`, `MACHINE` and `COMPILER_VERSION` -> prefixed with `LMMS_BUILDCONF_` and converted from macros to constexpr char* literals.
* Header guard _OSCILLOSCOPE -> renamed to OSCILLOSCOPE_H
* Header guard _TIME_DISPLAY_WIDGET -> renamed to TIME_DISPLAY_WIDGET_H
* C-style typecasts in DrumSynth.cpp have been replaced with `static_cast`.
* constexpr numerical constants are initialized with assignment notation instead of curly brace intializers.
* In portsmf, `Alg_seq::operator[]` will throw an exception instead of returning null if the operator index is out of range.
Additionally, in many places, global constants that were declared as `const T foo = bar;` were changed from const to constexpr, leaving them const and making them potentially evaluable at compile time.
Some macros that only appeared in single source files and were unused in those files have been removed entirely.
Add a band-limited, alias-free wavetable oscillator option to the
`Oscillator` class. Use it by default for Triple Oscillator.
Savefiles which do not have this feature enabled (e.g. old
savefiles) will be loaded without this feature to keep the sound
consistent.
Original author: @curlymorphic.
Fixed: @he29-net.
* Adds a baseDir for the local path
Adds a new Base for paths called "local:", which will translate to the dir where the currently opened project file is at. In the future this will allow us to make project bundles and make it easier to export and transfer projects to other people without breaking the paths to samples, presets, plugins and others.
* Starts implementing the makeBundle functionality
For now, to make a bundle LMMS has to be run through CLI with the makeBundle/--makeBundle command, followed by an input file and an output file ('lmms --makeBundle input.mmp output.mmp'). DataFile::writeBundle() is then called. For now, it only saves the mmp/mmpz file normally and also creates a "resources" folder if it doesn't exists. Later it will also manipulate the DataFile so all paths are local and copy all files to the resources folder.
TODO:
-Remove warnings.
-Implement the logic to manipulate the DataFile and copy files.
* Starts implementing logic to go through resources
Starts implementing the logic that will go through all the resources of the project file and add them to the bundle. We use a std::map of QString to std::vector<QString>: The first string is the DOM element tagname that is going to be searched for. The vector of strings holds all attributes this element can have that accesses resources. For now we just print those to the screen.
* Adds logic to copy files and update the project
The raw logic for creating the bundle is finished. It now copies the resource files and update the project to use "local:" paths to the new file now.
Now it's a matter of organizing things and adding safety checks for file operation errors basically.
* Makes the writeBundle method more organized
Improves comments and debugging warnings to make the writeBundle a bit more organized for review.
* Adds a project bundle folder
Adds a project bundle folder, inside which the bundles will be created. Instead of receiving an output project file name, the makeBundle command now receives a bundle name that will be used as the name of the bundle's folder.
Uses a typedef for the std::map with the tags and attributes with resources.
TODO:
- Fix the local: prefix so it works when we don't have the project file open (for CLI usage, or find another way to deal with it).
- Sanitize the bundle name.
- Allow overwriting bundles?
* Handles local paths when a project isn't open
The PathUtil base prefix conversion for "local:" uses the loaded song file name. When we are running the makebundle command from the CLI there isn't a loaded project, so those prefixes aren't converted properly. Now, when there isn't a project open PathUtil will return "local:" again when it tries to convert this base prefix. DataFile can then check if the base prefix is still there, and if it is it knows the conversion wasn't possible, so it does the conversion itself. To do that, a member called m_fileName was added to DataFile, which will hold the file being manipulated if that's where the DataFile originated from, and the local path can be retrieved from it.
* Sanitizes the bundle name
The bundle name is now sanitized. Since it's going to be used as a folder name, we need to keep the user from giving invalid folder names as a bundle's name. The rules for the name are:
1) It must start with a word character (either a digit or letter)
2) It can be followed by any number of letters, digits, whitespaces or hyphens
3) It must end with a word character (either a digit or letter)
A Regexp is used to check for the name validity.
* Moves away from projectbundle folder concept
This commit regresses some functionality. Project bundles will be saved just as any other project, except they will also have the resources folder. It will be up to the user to organize the bundles on their own folders. It's currently not allowed to save a bundle on a folder where there's one already though (if there's a resources folder already). Later it might be allowed to overwrite bundles in that case.
The projectbundles folder was dropped. The user can save project bundles anywhere in the system.
The DataFile::writeBundle was removed. It's functionality was merged into the DataFile::writeFile method, by adding a boolean on the parameters defining whether it should be saved with resources. The logic of copying the resource files and changing the paths inside the project DataFile was moved to DataFile::copyResources, making the methods a little bit less dense.
* Adds an option to save project as bundle
The "Save As" dialog now has an option to save project as a project bundle (with resources), which will save the file as a bundle.
Known bug:
- Because the "local:" base prefix is translated to the filename from the Engine::getSong(), it breaks when Song::guiSaveProjectAs is called, because that method changes the project name before saving. Urgent fix!
* Fix local: prefix saving bug
There was a bug where "local:" prefixes weren't resolved properly during saving because Song::guiSaveProjectAs() changed the project name to the destiny file name before saving. This resulted in the local paths using the destination file as a reference. Both Song::guiSaveProject() and Song::guiSaveProjectAs() were rewritten, and now they only rename the project after it's saved.
* Adds a warning message box
When the user tries to save a project bundle on a folder that already has a project bundle (contains a resources folder) a message box pops up telling the user it's not permitted and that another path should be chosen.
* Removes unused header
Forgot to remove <QRegExp> header when I removed the code that used it.
* Removes Vestige plugins bundling
For safety reasons, remove the possibility to bundle VSTs loaded
through vestige. Also runs a safety check during the project being
loaded (Song::loadProject) to check if either Vestige plugins or effect
plugins are using local paths, and abort the project load if so. That is
to avoid malicious code being run because of bad DLLs being shipped with
a project file.
* Extracts code from loadProject to another method
Extracts code that checks if a DataFile contains local paths to
plugins to another method inside DataFile.
* Removes debug warnings
Removes warnings previously used for debugging. Improves a
warning message on PathUtil.
* Fixes small bug with error logging
Fixes small bug, where a QMessageBox was being used to prompt an
error without checking if the gui is loaded first. Now we check for the
GUI and if we are in CLI mode we use a QTextStream instead.
* Saves the bundle in a newly created folder
Now a folder with the project name is created inside which the
bundle will be saved. This makes the process more convenient.
Some save errors that previously only triggered qWarnings now
trigger message boxes to warn the user of what happened (using a lambda
function that either shows message boxes or trigger qWarnings depending
whether a gui is present).
Makes it so saving a bundle doesn't change the loaded project
path, that way the user won't be able to accidentally "Save" over a
bundle which should not be done for now.
* Enhances the name conflict workaround
Now, instead of replacing the resource names with meaningless
numbers, the bundle save will just append a counter to the end of
filenames that have been repeated.
* Starts addressing Johannes review
* Adds makebundle action to bash completion file
Adds the bash completion code for the made bundle action.
* Improves safety check on project files
Now, instead of checking certain XML tags for local paths,
DataFile::hasLocalPlugin() will return true if ANY tag that isn't on the
RESOURCE_ELEMENTS list contains an attribute that starts with "local:".
The method is now recursive so it can go through all XML tags
during this check.
* Addresses Spekular change request
Uses basePrefix(Base::LocalDir) instead of "local:" on the
return of unresolved local paths.
* Makes hasLocalPlugins method const
* Replaces literal uses of "local:"
Instead of using "local:" we are now retrieving the base prefix
from PathUtil, so if we change the prefix on the future we don't need to
replace every mention to it as well.
* Fix some comments on the header and cpp file
* Changes variable on PathUtil to const
Changes the retrieved pointer to the song object to a const
pointer.
* Leave doxygen comment on CPP file only
There was 2 doxygen comments for the same method, on the header
and CPP file. The latter was kept since it goes into more details about
the functionality of the method.
* Fix doxygen comment @param
Fixes the doxygen comment from hasLocalPlugin().
* Remove assert statements
Some assert statements were being done wrong and are probably
even unnecessary for that piece of code, so they were removed.
* Skips local paths when looking for shortest path
PathUtil::toShortestRelative() was including the local paths on
the candidate paths, which could lead to a unallowed resource (i.e.:
vst plugin) to be assigned a local path even on a regular save.
The local paths are now skipped when looking for the shortest
relative path, since they should only be used by the bundle save on the
allowed resources.
* Address Spekular's review
Changes some of the PathUtil methods to allow a boolean pointer
to be used to return the status of the method, setting it to false if it
failed somewhere.
Also adds a parameter to toShortestRelative to either allow or
forbid local paths in the search for the shortest relative path.
* Replaces "ok" with "error"
* Init
* Suggested changes by @IanCaio, thanks!
* Selecting one file to import is enough.
* Explicit use of TimePos in favour of int where expected, as suggested.
* Make pattern import/export future proof with using DataFile instead of custom code to read/write the pattern file.
* Remove unused/duplicate imports
* Make import/export dialogs file-ext filter consistent.
Co-authored-by: CYBERDEViL <cyberdevil@notabug.org>
* Automatic formatting changes
* Give clips an empty name by default, display all names
- Stop giving clips the same name as their parent track on creation
- Stop hiding clip names that match the parent track name
- Never rename clips on track rename
- Never clear clip name when a clip is copied to another track
- Create an upgrade routine to clear default names from old projects (< 1.3.0-alpha-1)
- Bump version to 1.3.0-alpha-1
* Revert now-unnecessary version bump
* Merge with master and fix conflicts
* Formatting changes from review
* Change weird for loop conditions
* Properly revert AutomationPatter.h changes
* Only clear names that match our parent track, be more generous with use of legacyFileVersion
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
* First commit
This commit starts the improvements on the upgrade methods. We are going to change both the DataFile and ConfigManager to use separate version values from LMMS release versions, so we can easily bump those versions for new upgrade routines. This first commit starts implementing a new version value for the ConfigManager.
* Change code as per requested on review
As requested, the "configVersion" method was replaced by "legacyConfigVersion" instead, which is only used to return a configuration version if none is present in the configuration file.
The configuration version of the current build is stored in a local variable called CONFIG_VERSION, making version bumping easier.
Uses a switch statement instead of if-else to be able to make use of case-cascading.
TODO:
- Change the CONFIG_VERSION variable to a unsigned int?
- Start working on the DataFile.cpp.
* Changes the upgrade logic on DataFile.cpp
Starts refactoring the upgrade logic on DataFile.cpp. Now the "version" attribute is used to indicate which fileVersion we are loading. If the value of version is "1.0", we have a legacy file and use the legacyFileVersion method to retrieve the integer version using the LMMS version. If the value of version is an integer, we just read it. The integer indicates the position in a list of upgrade methods where we should start from and run the upgrade methods. The file version of the build is held in the FILE_VERSION const on DataFile.h. It HAS TO match the number of upgrade methods that we have on our list.
One of the versions had 2 upgrade routines (upgrade_1_2_0_rc3 and upgrade_1_2_0_rc2_42). They were merged into a single one (upgrade_1_2_0_rc3) because they were both called from a single version check, meaning that they are both part of a single fileVersion.
Two fatal errors were added (which can later be improved to show an error messagebox): One if the version attribute doesn't exist, and another one if we are using a FILE_VERSION that doesn't match the number of upgrade methods (to avoid mistakes while coding new upgrades later).
The configVersion variables and methods were changed to use unsigned int instead of int.
TODO:
- Make the list of upgrade methods static.
- Add debug messages for each upgrade routine for testing purposes.
* Make method vector a static const variable
On DataFile.cpp, we now use the vector list of upgrade methods as a static const variable, so it only has to be constructed once.
* Reorganize vector lists
Reorganize vector lists so they are more easily readable.
Revert changes on upgrade method names from ConfigManager.cpp.
* Makes the file version bumping automatic
The file version bumping on DataFile.cpp is now automatic (using the size of the m_upgradeMethods vector as a reference). FILE_VERSION constant was removed, and with it the qFatal error when it doesn't match the size of the methods vector.
* Improve formatting of version and upgrades lists
Improves the formatting of the vector lists of upgrade routines and LMMS versions (2 upgrade routines per line and 3 LMMS versions per line).
Adds a qWarning for every upgrade routine for testing purposes, plus a qWarning that tells the current fileVersion/configVersion when upgrade is called.
Removes extra space characters after the opening bracket of ConfigManager::upgrade_1_1_91.
* Changes ConfigManager to use a vector of methods
Changes ConfigManager to use a vector of upgrade methods, just like DataFile. The new Config Version can be calculated automatically now, so the CONFIG_VERSION constant was removed.
Corrects a small comment on Datafile.h.
* Addresses Dom's review requests
- Changes legacyConfigVersion and legacyFileVersion from const unsigned int to just unsigned int, since the const is irrelevant in this context.
- Changes the type alias for upgrade methods to start with an uppercase as per the code style guidelines. Moves the aliasing of the type to the class declaration so it can be used on both the method and on the vector list declaration.
- Changes the vector list names from m_upgradeMethods to UPGRADE_METHODS, so it's more visible they are a static constant.
- Move the upgradeVersions list from the legacyFileVersion method to the DataFile class, as an static const called UPGRADE_VERSIONS.
- Uses std::upper_bound instead of std::find_if for the legacyFileVersion method.
* Uses type alias on vector assignment
Uses the UpgradeMethod type alias when defining the upgrade methods vector from both ConfigManager and DataFile.
* Removes debugging warnings
Removes the qWarning() calls that were placed for debugging purposes.
Implementation of the Lv2 core, except for CV ports. No features or
extensions are supported yet.
You can now generate sound using Lv2 instruments (restricted to non-piano)
or effects.
For an explenation about the new classes, see Lv2Manager.h