Commit Graph

121 Commits

Author SHA1 Message Date
IanCaio
fbea78945b Fix bug introduced by #5657 (#5982)
* Fix bug introduced by #5657

	There was a bug introduced by #5657 where reloading a project
and playing it could cause a Segmentation Fault crash. After some
debugging, @DomClark tracked the issue to be likely a use-after-free
being caused by m_oldAutomatedValues not being cleared when the project
was loaded again.
	This commit adds a line to clear the m_oldAutomatedValues map on
Song::clearProject(), which is called from Song::loadProject().
	Now, instead of using a Signal/Slot connection to move the
control of the models back to the controllers, every time the song is
processing the automations, the control of the models that were
processed in the last cycle are moved back to the controller. The same
is done under Song::stop(), so the last cycle models control is moved
back to the controller.
	That removes the need to have a pointer to the controlled model
in the controller object.
	Adds mixer model change request to avoid race condition.

Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
2021-04-21 00:26:29 -05:00
IanCaio
e16dca389e Adds support for local paths and project bundles (#5735)
* 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"
2021-04-02 17:12:16 +02:00
Andrés
372fe3bdcf Play automation pattern when midi controller connected (#5657)
* Play automation pattern when midi controller connected

* empty line removed

* Improved for clarity

* removed midi specific controller logic

* formatting changes

* comments added

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>

Co-authored-by: IanCaio <iancaio_dev@hotmail.com>
2021-03-26 20:40:38 -03:00
Alexandre Almeida
b701e82e3b Split Track.cpp and Track.h (#5806) (Fixes #5592) 2020-12-04 02:47:16 +01:00
Dominic Clark
4f74151f00 Fix export when rendering looped section multiple times (#5814)
Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
2020-12-01 19:38:04 +09:00
Hyunjin Song
d73ede58a3 Remove instrument track window caching to fix related bugs (#5808) 2020-12-01 11:03:58 +09:00
Alexandre Almeida
6e081265ba Rename MidiTime to TimePos (#5684)
Fixes #4866
2020-11-29 19:46:13 +01:00
Dominic Clark
246b822a6f Rework Song::processNextBuffer (#5723) 2020-11-27 13:46:06 +00:00
Dat Ng
3d8b31039f Qt deprecation fix (#5619)
Qt6 TODO: Orientation check by comparing angleDelta().x() and y() won't make sense
because the direction is arbitrary in Qt 6.
2020-09-13 11:09:46 +09:00
Hyunjin Song
5a7ec92cf0 Fix crash on CLI rendering (#5579)
This is a temporary workaround. To make all export options available in CLI,
some properties of TimeLineWidget should be moved to a core class.
2020-07-20 11:38:46 +09:00
Raine M. Ekman
a05306131b Consolidate error messages while loading project (#5269) 2020-06-04 14:21:30 +09:00
Cyp
8a190e4e13 Fix wrong lengths of exported tracks, when tracks have different lengths. (#5348)
* Fix wrong lengths of exported tracks, when tracks have different lengths.

Song::updateLength() was called in ProjectRenderer::run() after Song::startExport(),
updating m_length too late, resulting in it being used as the length of the wrong track.

* Fix "Export as loop" resetting after rendering the first track

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
2020-05-19 12:28:03 +09:00
Muhammed Furkan USLU
4dc26d1aab Fix issue #5409. (#5413)
Fix multiple uninitialized reads.
2020-03-08 07:31:36 +01:00
Hye Sung Jung
8679f79e2b fix spelling errors (#5385) 2020-02-01 13:38:59 +01:00
Alexandre Almeida
53e6b645c8 Use "bar" instead of "tact"
Closes #4865
2019-10-31 15:13:25 +01:00
Shmuel H
723a451ebc Add a save option to discard MIDI connections (#5021)
* Song: add isSavingProject.
* VersionedSaveDialog: Add support for a custom option dialog.
* AutomatableModel: Support the discardMIDIConnections save option.
* InstrumentTrack: Support the discardMIDIConnections save option.
* SaveOptions: Show the save option dialog on "save as".
2019-06-09 15:44:32 +03:00
Hyunjin Song
6d7ce58dec Merge branch 'stable-1.2'
# Conflicts:
#	CMakeLists.txt
#	cmake/linux/package_linux.sh.in
#	src/3rdparty/CMakeLists.txt
#	src/core/Track.cpp
#	src/gui/editors/PianoRoll.cpp
#	src/tracks/SampleTrack.cpp
2019-05-06 15:46:17 +09:00
Dominic Clark
ca9a9564cd Make more connections direct for automation (#4942) 2019-04-26 12:59:53 +01:00
Hyunjin Song
231a8407e8 Merge branch 'stable-1.2'
# Conflicts:
#	.travis.yml
#	.travis/linux..script.sh
#	.travis/linux.win32.script.sh
#	.travis/linux.win64.script.sh
#	.travis/osx..install.sh
#	.travis/osx..script.sh
#	data/locale/en.ts
#	data/locale/id.ts
#	include/Graph.h
#	include/VstSyncController.h
#	include/lmms_math.h
#	plugins/vst_base/RemoteVstPlugin.cpp
#	src/core/RemotePlugin.cpp
#	src/core/Song.cpp
#	src/core/Track.cpp
#	src/gui/SubWindow.cpp
#	src/gui/widgets/Graph.cpp
2019-02-24 20:45:52 +09:00
Steven Christy
b68c5ee5b5 Rendering looped sections multiple times on export (#4624) (#4639) 2019-01-27 10:22:47 +01:00
Dominic Clark
614bca7f04 Make ppqPos in VST sync sample accurate 2018-12-08 00:30:45 +01:00
Hyunjin Song
4252f755c2 Merge branch 'stable-1.2'
# Conflicts:
#	cmake/nsis/CMakeLists.txt
#	src/core/ProjectRenderer.cpp
#	src/tracks/Pattern.cpp
2018-10-29 16:20:58 +09:00
Hyunjin Song
d8fb07ff52 Fix minor glitches with sample tracks (#4666)
Switches some signal-slot connections to Qt::DirectConnection.
Now LMMS can handle loop points correctly and export samples without glitches.
Also tweaks some Mixer-related code to avoid related deadlocks on export.
2018-10-29 16:17:41 +09:00
Hyunjin Song
4069aaada2 Merge branch 'stable-1.2'
# Conflicts:
#	.travis/osx..install.sh
#	CMakeLists.txt
#	cmake/apple/install_apple.sh.in
#	doc/lmms.1
#	include/VstSyncController.h
#	plugins/carlabase/carla.h
#	plugins/vestige/vestige.cpp
#	plugins/vst_base/CMakeLists.txt
#	plugins/vst_base/RemoteVstPlugin.cpp
#	plugins/vst_base/Win64/CMakeLists.txt
#	plugins/zynaddsubfx/zynaddsubfx
#	plugins/zynaddsubfx/zynaddsubfx/src/Misc/QtXmlWrapper.cpp
#	src/core/Song.cpp
#	src/core/main.cpp
2018-09-18 09:54:38 +09:00
Hyunjin Song
f37ca49e6d Fix decimal separator handling (#4547)
Makes LMMS can handle both periods and commas properly when loading real numbers.
2018-09-12 11:02:40 +09:00
DomClark
2c5cda563b Fix kVstTransportChanged flag usage in VST sync
Changed according to feedback from AudioBlast. The flag used to be set most of the time, now it is only set when playback starts/stops, looping is toggled, or playback jumps around.
2018-09-11 22:01:11 +09:00
Lukas W
a87aa7e356 Merge branch 'stable-1.2'
# Conflicts:
#	src/gui/widgets/EffectView.cpp
2018-06-17 11:51:50 +02:00
Hyunjin Song
407973ad6f Fix crash when loading project with missing peak controller effect (#4391)
* Fix crash when loading project with missing peak controller effect

* Don't load/save dummy controller connections
2018-06-13 14:50:27 +09:00
Lukas W
d3c90a81b9 Fix automation processing priority
Fixes regression from 75077f6200 that caused
global automation tracks to have priority in processing.

Adds a test checking for the desired behaviour.

Fixes #4268
2018-06-01 15:12:47 +02:00
Hyunin Song
4b36ba9f81 Fix a regression from #3711 2018-05-02 12:41:10 +09:00
Michael Gregorius
ab2cc42eea Make Song::setModified more compact
Implement a comment from a code review by pulling condition of the
second if clause into the first one.
2017-12-26 00:33:11 +01:00
Michael Gregorius
9acff89ad3 Remove Song's dependency to MainWindow
Finally remove Song's dependency to MainWindow by moving the window
title update which is triggered due to a changed project file name from
the class Song into MainWindow.

Implementation details:
Add a new signal projectFileNameChanged to Song and connect the new slot
method MainWindow::onProjectFileNameChanged to it. Update the window
title whenever the slot is triggered.

Add a new private method Song::setProjectFileName which sets the project
file name and emits the signal (only if the file name really changes).
Call setProjectFileName everywhere where m_fileName was manipulated
directly. This is done to ensure that the signal can be potentially
emitted in all relevant situations.

Remove the calls to gui->mainWindow from
Song::createNewProjectFromTemplate.

These changes finally remove the include to "MainWindow.h". The include
for "ConfigManager.h" was previously done implicitly through the include
of "MainWindow.h" and therefore had to be added explicitly after the
latter is removed.
2017-12-26 00:33:11 +01:00
Michael Gregorius
b79999a6bf Move some window title updates from Song into MainWindow
Move the window title updates which are triggered due to a changed
modify state from Song to MainWindow.

Implementation details:
Add a new signal modified to Song and connect the new slot method
MainWindow::onSongModified to it.

Currently only the window title is updated in the slot. It is only
updated if the code is executed from the GUI main thread. This
implementation was taken over from the original implementation of
Song::setModified. The assumption here seems to be that the Song might
also be set as modified from other threads (which is a bad design).

Add a new private method Song::setModified(bool) and replace all direct
manipulations of m_modified in Song by calls to this method. This is done
to ensure that the signal can be emitted in all these cases. Make
Song::setModified() delegates to Song::setModified(bool) for the same
reason.

Other changes:
Slightly refactor MainWindow::resetWindowTitle to get rid of an
unnecessary if statement.
2017-12-26 00:33:11 +01:00
Michael Gregorius
07caf85bf5 Remove GUI related code from Song::stop
Add the new signal Song::stopped which is emitted when the song is
stopped. Connect the new slot method MainWindow::onSongStopped to that
signal. Remove all GUI updates from Song::stop and handle them in
MainWindow::onSongStopped.
2017-12-26 00:33:11 +01:00
Michael Gregorius
7fa62266a9 Move showing of save result dialog out of Song
Move the showing of save result dialogs, e.g. "The project XYZ is now
saved.", from the class Song into the class MainWindow.

Implementation details:
Add three new methods guiSaveProject, guiSaveProjectAs and
handleSaveResult to MainWindow. The first two correspond to the methods
with the same name in Song which don't do anything GUI related anymore.
The GUI related actions are instead implemented in the two new methods
in MainWindow. The method handleSaveResult shows the dialogs for
successful and failed saves, updates the list of recent files and the
title bar of the main window.

This commit also fixes a problem in Song::guiSaveProject where a failed
saved without a GUI would still have returned true, i.e. success.
2017-12-26 00:33:11 +01:00
Michael Gregorius
6a716ef985 Move import functionality from Song to MainWindow
Move the functionality of the method Song::importProject into the
MainWindow as it mainly consists of GUI related actions.

Add a new method Song::setLoadOnLauch to ensure that the boolean
Song::m_loadOnLaunch is still set at the end of the import.
2017-12-26 00:33:11 +01:00
Michael Gregorius
78d65ccc3a Move song export and track export from Song into MainWindow
The code to export a song and the tracks of a song mainly consisted of
GUI code. Therefore it was moved completely into MainWindow.

Add two new slots and a method that does the actual work to MainWindow.
Make both slots delegate to the worker method.
2017-12-26 00:33:11 +01:00
Michael Gregorius
989db1dc9b Move GUI dependencies out of Song::exportProjectMidi
Move all GUI dependencies out of Song::exportProjectMidi and move them
into the MainWindow.

Show the GUI in the new slot method MainWindow::onExportProjectMidi and
delegate to Song::exportProjectMidi once the file name has been
determined. The file name is given as a parameter to
Song::exportProjectMidi which still contains the business logic of
exporting the data.
2017-12-26 00:33:11 +01:00
Hussam Eddin Alhomsi
2469851e6b Allow exporting empty projects. 2017-12-04 14:43:13 +03:00
Hyunin Song
90b1fb57f0 Merge brnach 'stable-1.2' 2017-11-24 09:56:08 +09:00
Oskar Wallgren
01265ace66 Default project when cancelling project loading (#3941)
Default project when cancelling project loading

If a user isn't aware that the loading of a project has been
cancelled, it may be in an incomplete state. Saving such a project
will overwrite the original file and result in data loss. This is
solved by loading the default project on cancelling project loading.

Add Mixer::clearNewPlayHandles() to prevent crash when cancelling
loading of a single streamed instrument.
2017-11-17 02:03:49 +01:00
Hyunjin Song
57de274fe8 Fix time display (#3711)
Make Bar:Beat:Tick / Min:Sec:Msec agree with playhead
2017-11-14 23:42:26 -05:00
Hyunin Song
e0bd797876 Merge branch 'stable-1.2' 2017-10-03 15:56:16 +09:00
Hyunjin Song
c0682c94a4 Fix MIDI export (#3733)
* Re-enable MIDI export

* Fix logic for processing BB tracks and BB notes

* Consider master pitch and base note in MIDI export.

* Cut BB notes at the end of BB pattern.
2017-09-14 08:09:54 +09:00
liushuyu
da7b61535b Merge stable-1.2 into master 2017-09-09 13:55:36 -06:00
Lukas W
24d320de34 Fix some memory leaks (#3779) 2017-08-28 11:21:10 +02:00
Michael Gregorius
1f257f8125 Fix another memory leak by returning the error messages on the stack
Change Song::errorSummary() to return the string with the error messages
on the stack to remove another memory leak.
2017-07-27 19:16:05 +02:00
Michael Gregorius
017fb4b089 Fix a memory leak in Song (dynamically allocated error list)
Make the member Song::m_errors a static member to prevent memory leaks.
The member was allocated dynamically when an instance of a Song was
created but was not deleted in the destructor.
2017-07-27 19:07:19 +02:00
irrenhaus3
b83c1bdebe Respect build options in export dialogs (#3714)
* Respect build options in ExportProjectDialog

* Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog

* For compatibility with QVariant, ExportFileFormats is now explicitly an int.

* Don't break out of format identifier loop prematurely in Song export.
2017-07-27 09:10:32 +09:00
irrenhaus3
c8af34af2f Respect build options in export dialogs (#3714)
* Respect build options in ExportProjectDialog

* Use QItem user data instead of hard ordering to identify export format in ExportProjectDialog

* For compatibility with QVariant, ExportFileFormats is now explicitly an int.

* Don't break out of format identifier loop prematurely in Song export.
2017-07-26 19:48:25 +09:00