:Author: Laborejo Software Suite
:Version: 1.8.0
:iconfont-remote!:
:!webfonts:


////
This documentation is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a
letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
A copy of the license has been provided in the file documentation/LICENSE.
////

////
https://powerman.name/doc/asciidoc
https://asciidoctor.org/docs/user-manual/
////

:sectnums:

:toc: left
:toc-title: Table of Contents
:toclevels: 3

= Patroneo

// Don't write in the empty line above line. It will be interpreted as author html tag
For program version 1.8.0

== Introduction


Patroneo (which is Esperanto for "Pattern") is an easy to use, pattern based midi sequencer, a
program that sends digital "notes" to software instruments such as synthesizers and samplers.

Patroneo is primarily designed for educational purposes, where the main goal is to teach the
importance of patterns and repetitions in any kind of music. However, Patroneo is a full sequencer
you can use to create real music. The constraints it presents will more likely boost your
creativity than suppressing it.

You have tracks with one pattern each. Turn on steps in the pattern to play
musical notes. Switch the patterns on and off in a sequence to create a song structure.
Connect external synthesizers and samplers to create sounds.


=== Quick Start

To get to know the most important functions and workflows, this video has been created.

video::https://www.laborejo.org/documentation/patroneo/patroneo-quickstart-english.mp4[width=500]

Or as Youtube Mirror

video::ygpwn0gzO8g[youtube, width=500]

=== Basic Principles

Patroneo organizes its music in tracks that contain measures. All measures of a track play the same
"pattern" that creates music through a sequence of "steps".

The track is connected to an instrument through JACK, so Patroneo itself does not produce any
sounds.

If you press Play, the track plays back from left to right. Whenever a measure is highlighted in
the Form Editor, the pattern is played.

If you want to hear different patterns from the same instrument, you create several tracks for the
same JACK instrument.

The selection of the tones per pattern is freely selectable. You can use normal musical scales or
set any tones in any order. If you change the scale later, the pattern sounds different without
having to switch tones on and off again.

Saving and loading your project is done by the New Session Manager (Agordejo). There you will find
a "Save" button.


=== Keyboard Controls

In principle, Patroneo can be operated with the mouse. The keyboard is needed for only a few
functions, such as changing track names or setting half-tone transposition. However, the keyboard
makes some workflows faster and more convenient.

.Shortcuts
* Space: Start and pause playback
* L: Play the current measure as a loop
* Home: Set playback to the beginning of the track.

== Description of the graphical user interface and its functions

Use your browser's search function to locate the individual letters like [B] and their explanation.

image::overview-english.png[Screenshot with Captions, link="overview-english.png"]

Patroneo consists of three parts: The Toolbar, the Form Editor, and the Pattern Editor. Between
form- and pattern editor there is a *[L] Handle* which you can grab with the left mouse button and
move it up or down to give more space to one or the other area.

=== Toolbar

The *[A] Toolbar* combines various commands with properties of the entire piece.

*[D] Clone Selected Track* adds a new track based on the currently selected one. This is an
important and often used command that is mainly used to enable variants. The cloned track is empty,
but inherits the scale of the original, its average velocity or volume, color and name. If the name
ends in a single letter like "A", "g" or a number, it is automatically incremented, as you can see
in the screenshot. The new track automatically connects to the same JACK instrument.

*[E] Add Track* adds an empty track. It is given a random name and is not connected in JACK. Scale,
note-names etc. will be taken from the currently selected track.

*[F] BPM / Tempo*: The tempo can be completely deactivated by unchecking the box. In this case, the
"JACK Transport" system takes over, as indicated by the "JACK" logo in the deactivated input field.
This allows programs running in parallel to create complex tempo sequences, which is not possible
in Patroneo alone. If the checkbox is activated, the specified tempo is considered to be beats per
minute. A "beat" is the selected note value of the list [H]. More on that later.

*[G] Measures per Track* controls the total length of the piece, whereby the absolute number of
seconds can change depending on how the tempo is selected and how long a measure should be. If the
number of measures is reduced, no measures are actually deleted, but just ignored. If you later set
the number of measures higher again, you will get your old configuration back. Patroneo nevers
stops playback on its own. Especially in a JACK-transport environment it will continue playing even
after its own end.

*[H] Steps per Pattern, in groups of ... so that each group produces a ...* note. Here you can set
how long the patterns are and what grouping below the beat they have. This is the most complicated
part in Patroneo and will be discussed later in this manual. For now it is recommended to ignore
the "groups" field. Steps per Pattern is simply the number of tones that can be switched on and
off. The drop down list selects how long each of these steps is.

*[I] Playback Controls* are three buttons. From left to right:

* Play / Pause. Press to play or pause the music at the current location. You can also press the space bar.
* Loop on and off. The currently played measure (in all tracks) is continuously repeated. This function is suitable for working in a certain place by getting to hear your changes quickly. The loop is broken up by pressing the button again or jumping around in the timeline (see letter Z below).
* To the start: Jumps back to the beginning, whether the music is playing or not.


=== Form Editor

In the *[B] Form Editor* you create the structure of a piece. To do this, the measures in each
track can be switched on and off as desired. One can imagine, for example, a drum set that plays
three bars in a row and makes a "break" every fourth bar. For this common drum technique you need
two tracks. In the screenshot this "3+1" pattern can be seen in the third section (bars 17 to 24)
in the orange bass track.

Whole parts (e.g. verse and chorus) are implemented by using different
tracks. To make the creation of related tracks as comfortable as possible, the "clone" command
exists (see letter D).

It is possible to zoom in on the measures. To do this, hold down the *CTRL* key and turn the mouse
wheel up or down. Please make sure that the mouse cursor is actually over the measures and not over
the track names or on the timeline.

*[Z] Timeline*:  a click with the left mouse button sets the playback position, even during
playback. In addition, the measure groups (not to be confused with grouping in the pattern, see
letter H) can be seen and set here. If you hover over the timeline with the mouse cursor, you can
reduce or increase the size of the groups with the mouse wheel. The  groups not only have an
cosmetical function but are also used as units of measurement if you want to delete or add entire
ranges (see letter K).

*[J] Track Names*. Here you can move tracks, rename them, give them a different color and more:

* A single click with the left mouse button on a name selects a track without changing anything. This is the best way to just look at a track. (A click on the measure area changes a measure immediately!)
* The double arrow on the far left can be used to move tracks up and down to organize them. It has no effect on the sound or the JACK connections. To move, click on the arrow with the left mouse button, hold it down and move the mouse up and down.
* The colored square shows the current color. A left mouse click opens a dialog.
* Track names can be changed at any time by a double-clicking with the left mouse button. Press the Return key to finish renaming. The JACK connection is retained when renaming. It is a good habit to end tracks on a single letter or number. These are used in "cloning" to construct a variant of the name. See the screenshot above.
* A click with the right mouse button on a name opens the context menu of a track. Here you can
 ** Switch all measures on or off (only applies to the visible measures)
 ** Invert the activated measures: Off becomes On and vice versa.
 ** Clone this track (same function as in the toolbar)
 ** Delete the track permanently and irreversibly
 ** Copy the measure sequence of another track onto the selected one. Measures that have already been set are preserved. If you use this function from an empty track you will practically get "copy track".

Now finally the *[K] Track* itself. A left click on a measure switches it on or off again. You can
switch several measures in a row on and off by holding down the left mouse button after clicking
and moving the mouse left or right. A right click on a specific measure opens a context menu:
Insert new measures in all tracks(!) at this position or delete measures from all tracks. The
number of measures results from the current measure group setting from the time line (see letter
Z).

These functions are especially understandable if you apply them to the first measure of a
group (after the white line). This allows you to insert new "parts" or delete an entire part.

A good method is also to change the group size for these functions briefly and then reset them
immediately afterwards.

*[X] Half Tone Transposition* is adjusted by holding down the SHIFT key and then turning the mouse
wheel up or down over an activated measure. In the measure itself a small text appears, e.g. +5h.
Five semitones upwards; C becomes F, MIDI note 60 becomes 65; the transposition is only valid for
the respective measure and is not visible in the pattern itself (see below). If the measure is
switched off (and on again), the transposition is deleted.

*[Y] In-Scale Transposition*. It is recommended to familiarize yourself with the pattern and its
scale (see letters O to R) first. Are you back? All right, here we go: If you hold the mouse cursor
over an activated measure, you can adjust the transposition, based on the scale, with the mouse
wheel up or down. The label shows how many steps up or down (-6s to +6s) this measure is shifted.
If the measure is switched off, the transposition also disappears. In the pattern itself (see
below) you cannot see whether a measure is transposed or not.

One can imagine that the steps in the pattern are shifted up or down in the rows behind the scenes.
Whatever tone is set in this row gets played. With a normal scale, this is musically easy to
understand: The tones are moved up or down in the scale.

However, if the scale is chosen freely,
there are non-intuitive outcomes; "up and down" with respect to pitches may lose their meaning. It
is possible to use two interleaved scales in the pattern and to switch between them by scale
transposition +1. Or even uses completely different tones, so that only the rhythm remains the
same.

Scale and half-tone transposition can be combined. First the scale is changed, then the semitone.
These combinations open up many creative possibilities!

=== Pattern Editor

The *[C] Pattern Editor* is used for composing. The tones, also called "steps", are used to form a
measure. The pattern is exactly as long as a measure and is played from left to right. There are
several possibilities for tonal arrangement, which are now explained.

The pattern is always as long as set in the toolbar (see letter H). Steps that have been set are
never deleted by rezising! If you make the measures shorter, tones "too far to the right" are
simply ignored. You can see them again as soon as you make the measures longer again.

If the pattern is larger than the screen you can either use the scroll bars or zoom. To zoom hold
down the *CTRL* key and turn the mouse wheel up or down.

At the top you can see a label for the *[M] Active Track*.

The pattern itself is arranged in rows and columns. The rows symbolise the (adjustable) pitches,
the columns show their rhythmic sequence and position in time.


==== Pattern Context Menu

A right click on a step opens a context menu that provides the following exclusive functions. For
all functions that reverse or invert ("On" becomes "Off" and vice versa), please note that all
volume information (see below) is lost.

"Row" here refer to all steps of the same pitch. From left to right.

* Invert row (an empty row is completely filled)
* Clear row
* Repeat to here to fill row (see below)
* Invert Steps (the whole pattern)
* All Steps On
* All Steps Off

The function "Repeat to here to fill row" opens up many creative possibilities: All steps from the
beginning of the row to the selected one (incl.) are taken as a "sub-pattern" which is used to fill
the rest of the row.  All existing steps will be deleted with their volumes.

For example, if you want a note every fourth step, activate the first step of the row, leave three
empty and click on the fourth step as context menu and select the fill function. The whole row will
now be a recurring pattern of "X o o o X o o o...".

==== Duration and Volume

A *[S] Step* is a grey or coloured box. Grey means pause, coloured means *[T] Sounding Tone*. A
click with the left mouse button switches the steps on and off. A right click opens the context
menu. Here you can switch all (currently visible) steps on, off or invert all: Off On becomes Off
and vice versa. All volume information (see below) will be lost.

All steps are equal length. *[V] Other Durations* are also possible: If you hold down the left
mouse button after activating a step, you can shorten or lengthen the tone by moving it to the left
or right. It must be at least half the length. A tone is at most as long as the measure itself.

You can activate as many steps in a row or simultaneously as you like. Thus *[W] Chords* can be
built.

Steps can have different *[U] Volumes*. For this Patroneo uses so-called MIDI Velocity. If you hold
the mouse cursor over an activated step, you can make its sound softer or louder by turning the
mouse wheel. The volumes are displayed as numbers between 1 and 127. If you want to see all volumes
at once you can click with the mouse wheel (middle mouse button) into the free area left or right
of the pattern. In addition, a step looks more transparent the quieter it is. If the step is
switched on and off, the volume is set back to the normal value, derived from the average volume of
all tones of this pattern.

You can use the *[M] Velocity* buttons to make all tones of a pattern quieter or louder. If you
click on it, the volume changes by 1 each, but if you hold the mouse cursor over a button and
rotate your mouse wheel the velocity changes by 10 each. It doesn't matter which velocity button
(plus or minus) you hover over.

To make all tones of a row quieter or louder hold the Alt key (not AltGr) and use your mousewheel
on a step of that row.

==== Pitches and Scales

Click with the middle mouse button on a step to hear the sound it plays. This allows you to
"pre-listen" before you decide to set a note. Tip: Hold down the middle mouse button and move the
mouse up and down the steps.

Which actual pitch is played ("MIDI Key") is determined by the *[R] Scale*. Patroneo always works
with eight-note scales. Normally, this is a common musical scale: seven different notes and the
octave of the root note.

Such common *[Q] Scales* can be selected directly. For example, major, minor, various so-called
"church modes" but also the blues scale or chromatic  (e.g. to GM drum mapping).

If you select a scale from the list, it will be built upon the bottom row. As a rule of thumb  this
is also the lowest note. In the screenshot this is midi note 60 / C4, located bottom left. You must
first select the root directly and then select a *[Q] Scale*.

There are four buttons to change the pitch of both the root note and the entire scale:

* *[O] Half Tone* Plus or minus shifts the whole scale up or down by one semitone each. This should not be confused with the temporary transposition from the form editor (see letter X). This is called destructive change, since the values themselves are permanently changed.
* *[P] Octave* Plus or minus shifts directly by a whole octave. You could also press the half-tone button 12 times. Don't.

As already described in the scale transposition (see letter Y), it is also possible to directly
input any value between 0 and 127 in the *[R] Fields of the Scale*. The tones do not have to have
musically meaningful intervals, nor do they have to be sorted in ascending or descending order.

==== Shadows

Often you want to add more tones to an existing track in a different pattern. A second voice,
question/answer technique etc. To help you, it is possible to display other tracks as *[2]
Shadows*. Just click with the middle mouse button on the track you want to see. This is only
possible in the measure area, not on the track name or on the timeline.

You can display as many shadows as you want, until you lose track. All shadows disappear as soon as
the active track changes.

Shadows are just a guidance and not litereal pitches: If you choose a shadow-track with a different
scale than your current one the shadow-pitches will be technically wrong. Shadows are very simple
in principle. They just show which steps are marked, nothing more.

=== Grouping in the Pattern

Grouping is part of the time signature.

As mentioned above *steps per pattern*, sets the length of the pattern. Patroneo starts with 8
steps per measure for a new project (see screenshot). On the far right is a drop down list, which
is set to "Quarter" for a new project. You start with a traditional 8/4 time signature.

The field *in groups of*  allows you to group steps together, each group being as long as specified
in the drop down list. This allows you to further subdivide your time signature. The "beat", i.e.
the tempo, is based on the main beats, the first step of each group.

.Examples
* 4/4 time signature with eights notes as smallest rhythmical unit
 ** 8 steps per pattern / in groups of 2 / so that each group produces a quarter
* 4/4 time signature subdivided as triplet eights notes (swing)
 ** 9 steps per pattern / in groups of 3 / so that each group produces a quarter
* 12/8 time signature
 ** 12 steps per pattern / in groups of 1 / so that each group produces an eigth
* 8/4 time signature subdivided as sixteenth notes
 ** 32 steps per pattern / in groups of 4 / so that each group produces a quarter

Normally, the time signature is set relatively at the beginning of a new project. However, it
happens every now and then that you need smaller rhythm values than you thought at the beginning.
If you simply increase the value of the grouping, you get more subdivisions, but the number of
steps remains the same. Likewise, the notes remain exactly in the "column" in which they were
previously placed. In other words, the music will sound different. Overall, the measure is also
getting shorter, since the same number of steps is now used for shorter steps.

Patroneo therefore offers the function *Convert Grouping* (in the Edit menu) to change the existing
measure structure and to resize steps already set so that the music sounds the same.

If you click on the button in the toolbar, a small dialog box opens in which you can enter the
desired grouping. It is also possible to set what should happen if the conversion would not work
properly for musical reasons (see below).

Conversion is often possible without any problems:

* If the grouping of `1` is set to a higher value, it always works
* If the grouping is set from `2` to `4` it always works

For all other transformations it depends on whether the existing tones lie between the new grid
after the conversion or not. The former case is not possible and you have to decide:

.Error Handling
* Do nothing (default)
** The operation is aborted, everything remains as before.
* Delete wrong steps
** Anything that would appear between the grid will be deleted or discarded.
* Merge wrong steps
** Impossible positions are moved to the next possible position. In any case, this means that the music now sounds different. Usually several notes are pushed on top of each other and form chords.

With a little experience you will be able to estimate what error handling you need.


== Installation and Start

Patroneo is exclusive for Linux. The best way to install is to use your package manager. 
If it is not there, or only in an outdated version, please ask your Linux distribution to provide a recent version.

If available in the package repository, please continue reading directly at "Start patroneo from Agordejo / New Session Manager".
If not, you can build Patroneo yourself.

.Build and Install
* Please check the supplied README.md for dependencies.
* You can download a release or clone the git version
  ** Download the latest version from https://www.laborejo.org/downloads and extract it.  
  ** git clone https://git.laborejo.org/lss/patroneo.git
* Change into the new directory and use these commands:
* `./configure --prefix=/usr`
  ** The default prefix is /usr/local
* `make`
* `sudo make install`

.Start patroneo from Agordejo (New Session Manager, NSM)
* Run `agordejo`
* Press the `New` button, and enter a name for your piece of music.
* Use the launcher to add `patroneo` to the session.
* Add any compatible programs, e.g. synthesizers.

Please read README.md for other ways of starting patroneo, which are impractical for actual use but can
be helpful for testing and development.

== Help and Development
You can help Patroneo in several ways: Testing and reporting errors, translating, marketing, support, programming and more.

=== Testing and Reporting Errors
If you find a bug in the program (or it runs too slow) please contact us in a way that suits you best.
We are thankful for any help.

.How to contact us
* Report bugs and issues: https://www.laborejo.org/bugs
* Website: https://www.laborejo.org
* E-Mail: info@laborejo.org
* If you see the opportunity and know that a developer will read it also forums, social media etc..

=== Programming
If you want to do some programming and don't know where to start please get in contact with us directly.
The short version is: clone the git, change the code, create a git patch or point me to your public git.

=== Translations
Patroneo is very easy to translate with the help of the Qt-Toolchain, without any need for programming.
The easiest way is to contact the developers and they will setup the new language.

However, here are the complete instructions for doing a translation completely on your own and integrating it into the program.
The program is split in two parts. A shared "template" between the Laborejo Software Suite and the actual program.

The process is the same for both parts, but needs to be done in different directories:
`template/qtgui` and plain `/qtgui`, relative to the root directory, where the patroneo executable is.

Everytime you see "template/qtgui" below you can substitute that with just "qtgui" to translate the other part of Patroneo.

You can add a new language like this: 

* Open a terminal and navigate to template/qtgui/resources/translations
* Edit the file `config.pro` with a text editor
  ** Append the name of your language in the last line, in the form `XY.ts`, where XY is the language code.
  ** Make sure to leave a space between the individual languages entries.
* Run `sh update.sh` in the same directory
  ** The program has now generated a new `.ts` file in the same directory.
* Start Qt Linguist with `linguist-qt5` (may be named differently) and open your newly generated file
* Select your "Target Language" and use the program to create a translation
* Send us the `.ts` file, such as by e-mail to info@laborejo.org

You can also incorporate the translation into Patroneo for testing purposes. This requires rudimentary Python knowledge.

* Run the "Release" option in QtLinguists "File" menu. It creates a `.qm` file in the same directory as your `.ts` file.
* Edit `template/qtgui/resources/resources.qrc` and duplicate the line `<file>translations/de.qm</file>` but change it to your new .qm file.
* run `sh buildresources.sh`
* Edit `engine/config.py`: add your language to the line that begins with "supportedLanguages" like this: `{"German": "de.qm", "Esperanto: "eo.qm"}`
  ** To find out your language string (German, Esperanto etc.) open the `python3` interpreter in a terminal and run the following command:
  ** `from PyQt5 import QtCore;QtCore.QLocale().languageToString(QtCore.QLocale().language())`

To test the new translation you can either run the program normally, if your system is set to that language. Alternatively start patroneo via the terminal:

* `LANGUAGE=de_DE.UTF-8 ./patroneo -V --save /dev/null`
