== Preamble

Session Management leads to simplification of workflows, overview and control over
programs and data and a good portion of convenience :)

No program exists on its own, because no program can do everything that is necessary for today's
music production.

This is obvious in a JACK environment, which is fundamentally modular: Different
programs fulfill different functions and "talk" to each other by sending data to each other.
A sequencer sends MIDI to a sampler or synthesizer, which is connected to a plug-in host for effects etc.

Even the most monolithic all-in-one DAWs have to, or want to, eventually connect to the outside
world. For example, to connect to a screen recorder or streaming program, include a word processor
for recording order or lyrics, or to use a function that is simply not available in the DAW.

Much of the work is already done by the JACK subsystem. All programs can share their music in
real time, have synchronized timelines and play in the same tempo.

What remains is the tedious work of always starting all programs, loading project files, connecting
audio channels etc. Session management in general (e.g. specifically written starter script files)
and Agordejo in particular do this work for you, or at the very least, greatly simplify it.

In contrast to the self-written script mentioned above, you don't have to decide in advance on a
setup, but everything is saved automatically as long as you manage everything through Agordejo.

=== Example

* Start Agordejo (Start menu, terminal etc.)
* Press the button "Quick New" on the left
* Now you get a choice of programs:
  * A double single click with the mouse starts a program
  * The program appears as entry in the other column and indicates that it is running
  * To show it's GUI you probably need to double click on this new entry.
* The programs "jackpatch" and "nsm-data" were already added automatically.
* Audio and midi ports can now be connected together in a patchbay. The connections are stored in Agordejo.
* The name of the session so far is simply a date. Through the menu you can enter a real name. Like "My song"
* If you are finished you can return to the session selection by using the menus "Save and Close"
* Now Agordejo could be closed itself.
  * All stored data is in a single directory on the hard disk (`~/.local/share/nms/My Song`)
* The session can be resumed: After double clicking on the name, all programs start automatically and connect their JACK ports to among themselves.


== Full Explanation


=== Selecting a Session

Sessions are displayed as a table, which you sort by clicking on a column header. Here is shown how
the session is called and when it was saved the last time, probably the two most important pieces
of information. Also shown is how many programs/clients are in the session and whether it contains
symbolic links. The latter is probably set to "Yes" if use a sampler, or similar, that contains
large audio files. These are initially only linked into the session, and not copied, to save disk
space. The displayed disk space usage is not the actual one, but includes the sizes of
symlink-targets. Only when you archive the session or replace the links with real files the number
becomes correct.

Finally, the directory in which the files are actually stored is also given.

Sessions represent the directory tree. A session is always a "leaf" and cannot include subsessions.
When creating or renaming sessions, you can also arrange them in the tree by using the usual slash
notation: `song123` -> `New album/song 123` or `Test/asdf` -> `Romantic pop ballads/My heart will
keep beating`. How to organize your sessions and how many subdirectories you create is up to you.
It is, however, not allowed to start the name with `/` or use the special characters `..`. The
tree view can be deactivated by a checkbox on the left side, e.g. to be able to sort them. This is
just a view, your data remains untouched.

Each session has a context menu (e.g. right mouse button) with further options: You can choose to
rename a session, delete it (including all associated files on the hard disk!) and more. These
functions are equivalent to your file manager. If you like, you can also use your file manager to
rename, move, or delete the session directories themselves (unless they are is currently open). You
don't need to restart Agordejo to do this, it will respond to the changes while running.

Click on "New session" to create one. In contrast to the quick view, you must enter the name
directly . As mentioned above, you can use the directory tree. In addition, there are several
(almost obligatory) programs suggested to start with. Normally one should accept all suggestions.
There is always the option to remove them later.

A double click on an existing session (or the "Load Selected" button) does just that.

=== In a Session

The view is divided into three areas: Program starter, programs in the current session
and the session notes. There is also a dynamic menu.

On the left side you see the program starter. A double-click starts a program instance in this
session. You can also start a program more than once. For available programs please refer to the
chapter "Program Database".

==== Running Programs

Started programs are located on the right side. A double-click switches the visibility
to hide its window if the program supports it. If not, nothing happens.

The following information is available per program:

* The name (possibly with icon)
* A "label" that programs can use freely (e.g. Fluajho shows the loaded .sf2 here)
* The program status
  * Stopped , not running
  * Ready, running
  * Launch, If the status halts here but the programs works, it is one that does not specifically support session mode. Agordejo cannot know if it is already running or not. Everything is fine! :)
  * Other states are only transitions and usually only visible for a very short time, e.g. Open / Loading
* Visibility (A cross for visible, blank for invisible)
* Changes - Are there currently unsaved changes?
* ID - A unique identifier that can be used to distinguish between multiple instances of the same program

All other functions are accessible via the menu or context menu. One click on a program selects it,
and the client menu in the menu bar will now apply to the client. Alternatively, you can
right-click on an entry for a context menu, which is identical to the menu.

In addition to self-explanatory functions there are also:

* Rename gives the program a self-chosen name, mostly to make its purpose clear and to distinguish it better from others. This feature is only available when 'nsm-data' is running in the session.
* Save only tells this program to save
* Remove takes the program out of the session. However, no files are deleted in the process. At the moment you have to "clean up" in your file manager by hand.

If the client "nsm-data" is in the session (this is the default setting) the lower area provides a
large text field for notes. It is the same as in the quick view. Write what you want: TODO lists,
lyrics, credits and sources from external Samples etc.

==== The Session Menu

In contrast to the quick view, full mode offers menus, which can also be accessed via the usual keyboard shortcuts (Ctrl+S for saving etc.).

* Save instructs all programs to save, the session continues to run
* Save and Close ends the session, after all programs saved
* Abort ends the session without saving the programs
* Save As saves the session under a different name and closes the current session without saving. From now on you work under the new name.
* Add Client offers the option to add any program, whether it is in the program database or not.
  * Any installed programs are suggested. Agordejo doesn't check them for usefulness for a music session, or even for runnability. You will find `ls` here as well as `agordejo` itself.

== Program-Database

Agordejos launcher is based on a program database, which is partly self-generated, partly
maintained by hand. As in a start menu Agordejo will offer you only programs that are actually
installed on your system.

The database is created at the first start. Depending on your system, this can take some moments to
a few minutes.

If you are reinstalling or uninstalling audio programs, you will need to update the database via
the command in the control menu. Program installations and system changes are even possible while
Agordejo is running (even in a session). After a DB update you can immediately access all new
programs.

If you do not see an installed program in our launcher, but you are sure that it supports session
management please report it to info@laborejo.org or under https://laborejo.org/bugs .

In addition, you can add (in full view) programs that are not in the database.

=== For advanced users

The strict rule is that only programs in the $PATH are included in the database. Absolutel paths
are not allowed, even if you enter the program name yourself through the menu. However sometimes
you just want to try out software, or you are a developer yourself and want to test without
system-wide installation.

In the control menu / settings is a tab "Program-PATH", where you can define and add your own
search paths. One absolute directory path per line, no wildcards, trailing slash don't matter.

For example: `/home/myuser/sources/newsequencer/bin/`

These search paths are not stored in the session, but locally in your `~/.config` directory.

== Tray

Agordejo has a tray icon, if your window manager supports it. A click on the trayicon shows or
hides Agordejo.

If you close Agordejo using the normal window manager function, such as a click on the [X], the
program and the session is not terminated, but minimized to the tray.

A right click on the icon gives you access to common functions:

You can directly start the most recently used sessions.

If a session is already running you can save, cancel etc.

Agordejo can also be completely exited here.


== Program parameters

As an advanced user, you can start Agordejo in the terminal and add some parameters.. For a
complete list please use the --help parameter.

For example:

* `--session newAlbum/mySong` starts the given session.
* `--continue` starts the last active session.
* `--hide` starts Agordejo as TrayIcon.
* `--url osc.udp://myhost.localdomain:14294/` connects to this server, if available, or starts the internal session server at this address. This is a very technical option and probably not needed.
* `--session-root /home/user/production2030` sets the root directory. Only sessions in this directory are displayed, everything is stored here.

The combination of `--continue` and `--hide` is essentially what many people expect from Session
Management: Resuming at the previous state, without any extra windows in their way.
If your system uses a start menu you will find not only the normal Agordejo starter but also
"Agordejo Continue" to start this mode directly.


== Miscellaneous / Explanations / FAQ

*Session Save and Exit responds slowly*: Agordejo is not a standalone program like an word
processor. The participating programs in the session are not plugins either. When you end the
session a signal is sent to all participating client to save.  This may take a few moments where
you are able to see "live" how individual programs terminate and disappear from the session.
Everything is fine.


*I have added a program but it does not save with the session*: Does the program support session
management? If not, Agordejo cannot do much. But you can ask the program developers to contact us
(info@laborejo.org) and we can work together on support.


*The programs hang on exit*: Sorry about that. Actually, the programs themselves are to blame, but
we are also interested in improving the situation by offering at least an emergency solution in the
future.


*Agordejo won't start! I start the program but I can't see anything*: Most likely Agordejo is
running, but invisible, because you exited it  from the tray last time. Is it in the tray? A
message should have popped up, maybe you missed it. If there is no tray in your window manager, the
program should always be visible. With all these special window managers in Linux it may be that
the tray detection did not work properly. Contingency plan is to delete
`~/.config/LaborejoSoftwareSuite/agordejo`. This will NOT remove any sessions, but only local
settings such as the visibility of the program window. At next start Agordejo will behave like the
very first start.


*JACK crashed. A lot of programs hang. What can I do to prevent data loss?* Probably already many
programs in the session are not running properly and are not reacting anymore. The best thing to do
is to use the 'Abort Session' function and restart everything. If the data has actually been
unsaved for a long time, you can also dare to save/exit. It may be necessary to re-draw some jack,
or all, jack connections by hand at the next start. If you want to be on the safe side, you can
manually make a copy of the session directory in your file manager before ending the session (with
inevitable crashes).


*A program update broke my session because it can no longer load its files.* Unfortunately, this is
a problem that even Agordejo can't solve. It also happens with LV2 plugins and with all other
software, such as office programs. If you fear that a program becomes incompatible in the future,
write down its version number in the session notes, so that you can at least, in an emergency,
reinstall the old program version (even if this is very is cumbersome).


*What's better? Monolithic DAW or session management?* Why not both? There is no conflict. Session
management is worthwhile with two or more participating programs, which one needs almost always.

You should not feel compelled to suddenly make everything modular with individual programs, only
because you use a session manager. Agordejo is designed to make your music production easier. If it
is faster and more comfortable to manage all plugins and effects e.g. in a single "Carla" instance
then you should do exactly that. If you basically want to do everything in Ardour, do that, but
start Ardour anyway in session management, because no program can do everything alone and the time
will come where you add a second one.

Session management is another level of hierarchy. Sequencers or DAWs are not plug-ins themselves.
Patroneo does not belong "in" Ardour and Ardour does not belong "in" Laborejo. Already in this
example each of the programs fulfils a different role because the others follow a different design
philosophy and cannot ever offer the same workflow. And more:

Some programs can't host plugins, some can't export audio files. They are not bad programs, but
programs that concentrate on one task. Furthermore, there is a lot of software that does not
directly do music production, but still is connected in the grander scheme:  Open Broadcast Studio
(OBS), music player, word processors and graphic programs etc.


*Agordejo contains functionality which is not within its scope*: Music production is very complex
and complexity is inevitable. It's like a waterbed: if you press down on one side, something
bounces up in another place. When you create a "clean and lean" program, which therefore implements
only a part of the complete workflow, then the missing part pops up somewhere else. A minimalistic
session manager provokes plug-ins (not LV2), helper-scripts, workarounds and hacks.

E.g. not to include file management provokes user errors like deleting the wrong files. If the SM
knows what to do and it can do it, then let it do it. Or crashes: Technically, crashing programs
are not the "problem" of the session managers, but they are part of the software reality. Crashes
happen every day and need to be handled. Can Agordejo simplify the work and help to restore good
conditions again? Then that should be done. Session management is also an opportunity to simplify
even complex technical scenarios, e.g. distributing sessions over the network.
