lyqi -- LilyPond quick insert mode
overview
lyqi-mode (LilyPond quick insert mode) is an Emacs major mode,
derived from LilyPond-mode, and inspired by its
LilyPond-quick-note-insert functionality, which aims at
saving key strokes during note entry: a note is inserted with a single
key stroke, its length, octave, alteration, being deduced thanks to
previous notes; length, octave and alteration can be
modified wherever and whenever by single key strokes.
Example:
| key strokes | output |
|---|---|
| j | sol4 |
| 8 | sol8 |
| k | sol8 la8 |
| l | sol8 la8 si8 |
| e | sol8 la8 sib8 |
| . | sol8 la8 sib8. |
| d | sol8 la8 sib8. do'8. |
| 5 | sol8 la8 sib8. do'32 |
| l | sol8 la8 sib8. do'32 sib32 |
| 4 | sol8 la8 sib8. do'32 sib4 |
If you don't know GNU LilyPond, please visit its homepage. Many thanks to its authors, Han-Wen Nienhuys and Jan Nieuwenhuizen, and its contributors.
features
- note insertion / modification
- Use your computer keyboard as a piano keyboard to insert notes. Length, octave, alteration are automatically chosed thanks to previous notes. You can then modify these caracteristics with dedicated keys. You can also modify a previously inserted note: just move the cursor after the note, and press modification keys.
- tuplets, ornaments, marks
- In
lyqi-mode, the whole keyboard is redefined in order to ease note entry, ie you cannot type random text as in a regular emacs mode. However, ornaments, marks, etc, are taken into account and can be easily inserted. - midi playing
- Notes are played when inserted or modified. Play back on a whole region can also be performed. Requires ALSA and timidity.
- language
- Several note languages are supported: nederlands english deutsch norsk svenska italiano catalan espanol. The user can customize the default language to use, and eventually switch between languages, or change the language used in a region.
- output octave mode
- Both octave modes supported by LilyPond -- relative and absolute
-- are proposed in
lyqi-mode. The default is absolute, but the user customize that property. A change of octave mode (relative <--> absolute) can also be executed on a region. - transposition
- Note transpositions can be done on whole regions.
- MIDI keyboard
- Thanks to rumor, a "monophonic MIDI keyboard to Lilypond converter", the user can use its midi keyboard for note input, and see the notes automatically inserted in the buffer. Rumor is also convenient for bad keyboard players (like me), thanks to its flat option: one hand on the MIDI keyboard, to insert notes, and the other on the computer keyboard, to eventually adjust note durations.
news
- 2004-03-14
- Versio 0.2.5: various suggestions and patches by Reuben
Thomas, including an alternate transposition command
(
lyqi-transpose-interval-region). Rumor related custom variables are now namedlyqi-rumor-default-.... Now uses rumor 1.0.3. - 2004-01-04
- Version 0.2.4: lyqi can now use an already running timidity
demon (custom variables are
lyqi-midi-use-external-timidity-serverandlyqi-midi-external-timidity-port, which can be set with thelyqi-midi-set-timidity-alsa-portcommand). Compatibility with elder eieio versions, thanks to Ferenc Wagner. Bug fix: Lyqi remembers the previously chosen language when back to lyqi-mode. - 2003-09-27
- Version 0.2.3: supports rumor 1.0.2a. New commands to change
rumor parameters (the prefix key for rumor commands is
C-c r).C-c r sto start,SPCto stop, see reference for custom. - 2003-09-13
- Version 0.2.2: supports rumor (start: C-c r, stop: SPC). `n' sets the last note alteration to natural, `=' resets the note octave.
- 2003-08-01
- Version 0.2.1: now, works also in XEmacs.
- 2003-07-28
- Version 0.2 released.
install
requirements
lyqi-mode depends on eieio,
"an Emacs lisp program which implements a controlled
object-oriented programming methodology following the CLOS
standard", and which may be already part of your Emacs
distribution.
Midi playing, which is optionnal, requires ALSA >=0.9 and TiMidity++.
Rumor sessions depends on... rumor (>= 1.0.3).
download
The package homepage is http://nicolas.sceaux.free.fr/lilypond/lyqi.html.
lyqi-0.2.5.tar.gz (last updated 2003-08-01) contains emacs-lisp source files, this documentation, and the source file for the virtual midi keyboard used for play-back.
emacs mode
- Download and extract the archive in a temporary directory. Move
emacs lisp files (
.el) to a relevant directory, for instance~/.elisp/lyqi/.$ cd /tmp $ tar zxf lyqi.tar.gz $ cd lyqi $ mkdir -p ~/.elisp/lyqi $ mv *.el ~/.elisp/lyqi
- Then, edit your
.emacsfile:;;--------- .emacs ----------- ;; adds ~/.elisp/lyqi in the load path (setq load-path (cons (expand-file-name "~/.elisp/lyqi") load-path)) ;; when loading LilyPond-mode, lyqi-mode library will also be loaded. ;; type `C-c q' in LilyPond-mode to switch to lyqi-mode. (eval-after-load "lilypond-mode" '(progn (load-library "lyqi-mode") (define-key LilyPond-mode-map "\C-cq" 'lyqi-mode))) - Finally, byte-compile elisp files:
$ emacs -batch -u <username> -f batch-byte-compile ~/.elisp/lyqi/*.el
midi
Midi note playing, which is optional, requires ALSA >=0.9 and TiMidity++. If you use Debian GNU/Linux, you may wish to look at this article to install and configure ALSA.
Here is how midi notes are played with lyqi-mode (not
very beautyfull):
- timidity is started as a server, with ALSA interface enabled;
- a basic virtual midi keyboard,
mymidikbd, is started. It will read pitches and lengths from its standard input, and send the corresponding midi events to the ALSA sequencer; - when the user inserts a note in the LilyPond file, Emacs writes its pitch and length to the keyboard process' standard input. Then a note is (hopefully) heard.
In order to enable this feature, we will compile and install the little virtual midi keyboard:
$ cd /tmp/lyqi # or wherever the archive is extracted $ make gcc -Wall -O -c -o mymidikbd.o mymidikbd.c gcc -lasound mymidikbd.o -o mymidikbd $ mkdir -p ~/bin $ mv mymidikbd ~/bin
Then, you may test if it works:
- in a shell, start timidity as a demon with ALSA interface
enabled:
$ timidity -iA -B2,8 -Os -EFreverb=0 Requested buffer size 2048, fragment size 1024 ALSA pcm 'default' set buffer size 2048, period size 1024 bytes TiMidity starting in ALSA server mode can't set sched_setscheduler - using normal priority Opening sequencer port: 133:0 133:1
Here we see that it has been started using sequencer port 133; - in an other shell, run
mymidikbd, with the port number given as the first argument:$ ~/bin/mymidikbd 133
mymidikbdwaits for pitches and length (in seconds) written in standard input. So type two numbers and press RETURN :$ ~/bin/mymidikbd 133 50 0.25 RET 52 0.25 RET
If you can hear notes, then it works.^d(EOF) stops the program.
user doc
In order to start lyqi-mode, visit a .ly
file in Emacs. LilyPond-mode should be then started. Type
C-c q or M-x lyqi-mode to switch to
lyqi-mode. Note that C-c q let you switch
back to regular LilyPond-mode.
In the following, I use italiano as a language for
notes, (a) because la-si-do notes are my mother tongue in music, and
(b) in order to emphasize key stroke save, and (c) to avoid confusion
between keys and notes.
All key bindings described here are default bindings, but they can be redefined by the user (this is Emacs!).
note entry
Notes are inserted by specifying their pitch. Use your computer keyboard as a mini piano keyboard:
| | | | | | | | | | | | | | | | | | | | | | | | | | | |_| |_| | |_| |_| |_| | | | | | | | | | | d | f | g | h | j | k | l | |___|___|___|___|___|___|___|
The first inserted note is a quater note. You change the duration with the number keys, and add/remove dots with the dot key. When you change a note duration, the next inserted note will have the same duration.
| key | 1 | 2 | 4 | 8 | 7 | 5 | 0 | 9 |
| duration | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 |
When inserting notes, octave is chosed so that the inserted note is the closer in pitch from the preceding (up to a fourth). You change a note octave with comma and quote keys.
| , | octave down |
| ' | octave up |
| = | reset octave |
To alterate a note, type the e and i keys
to flatten or sharpen the note. ! and ?
force reminder and cautionary accidentals.
| e | flatten note |
| i | sharpen note |
| n | natural |
| ! | force/unforce reminder accidental |
| ? | force/unforce cautionary accidental |
Finally, rests are inserted with the r key, and skips
with the s key.
For instance, the following key sequence:
r8ji'l l4. r8g,.l'7 l4. k7jhi8.k7 j.h5g8rproduces the following output:
r8 sold'8 si'8 si'4. r8 mi'8. si'16 si'4. la'16 sold'16 fad'8. la'16 sold'16. fad'32 mi'8 r8
rumor session
A rumor session is started by typing C-c r s.
Press SPC to stop the recording session.
Rumor options can be set thanks to custom variables (which are only
read when loading the lyqi-mode), or interactively thanks
to commands:
| custom variable | key | description |
|---|---|---|
lyqi-rumor-default-grain |
C-c r g |
Set minimum time resolution to the NUMth note. Only powers of two are valid, from 1 up to 128. |
lyqi-rumor-default-tempo |
C-c r t |
Metronome speed in beats per minute. |
lyqi-rumor-default-legato |
C-c r l |
If true, ignore any rests between notes. |
lyqi-rumor-default-no-dots |
C-c r d |
If true, do not use dotted notes. |
lyqi-rumor-default-flat |
C-c r f |
If true, output only pitches as you play, no lengths. |
lyqi-rumor-default-meter |
C-c r m |
"P/Q". Set time signature. Bar will have P beats of duration of the Qth note. Q must be a power of two. |
lyqi-rumor-default-key |
C-c r k |
Set base note of current scale. Valid values for KEY are "ces", "c", "cis", "des", .... Double sharps/flats are not allowed. Note that KEY has to be given using note language `nederlands'. |
Note: When setting a rumor parameter with one of these commands, rumor's behaviour will be changed the next time you launch it, ie setting a rumor argument during a rumor session will have no effect on the running session.
ornaments, marks
Some keys are self inserting : ~ ( ) < > { } [ ] |
SPACE, ie when the user hits the tilde key, a ~
character is inserted. These characters are used for beams, slurs,
ties, chords, bars, ie are frequently used.
Some LilyPond commands, in particular articulations, are a
combinaison of two characters: a prefix - or
_ or ^, and the command itself, for instance
do^. for a staccato do. To achieve that in
lyqi-mode, press the prefix key - or
_ or ^, then the second (whetever)
character. The backslash has also this behaviour, in order to write
\\ or \p, for instance.
These prefix characters can also be followed by longer strings, for
example do^\trill. This is done, in
lyqi-mode, by typing the sequence
C-<prefix-key>, then the command string, then
RETURN. The sharp and double quote keys also have this behaviour.
Example:
d8-_[f^.] | do'8 -_[ re'8^. ] |
d1 C-c ^ \fermata RET | do'1^\fermata |
d \p | do'1 \p |
transformations
Transformations can be accomplished on a whole region: transposition, octave mode change, language change.To transpose a region of notes, select it and type C-c
C-t, or M-x lyqi-transpose-region. You will be
asked the destination note, do being the reference: enter the
note (in LilyPond language) and press RET. The notes contained in the
region are then replaced by the transposed notes, non-notes being
hopefully left untouched.
For instance, in order to have a do transposed to the
la below, the note to tell (with italiano
language) will be la,. Suppose your LilyPond source file
contains the following line:
do'8 mi'8 sol'8 sol8 do'2
Select the line, type C-c C-t and then la,
RET. This will produce the output:
la8 dod'8 mi'8 mi8 la2
The lyqi-transpose-interval-region command expects an
interval, for instance 2- in order to transpose a note 2
notes below.
The lyqi-change-language-region command aims at
changing the language used for notes in the selected region. The user
is asked the source (default: current language) and destination
languages.
Finally, the lyqi-relative-to-absolute-region and
lyqi-absolute-to-relative-region change octave mode used
in region and rewrite notes accordingly.
play back
Notes can be played when inserted. To enable this feature, type
C-c m or M-x lyqi-midi-start-stop.
A whole region of notes can also be played: select a region and
type C-c p or M-x
lyqi-play-back-region. Note that this feature is quite
rudimentary. Encoutered notes are played sequentially, even if they
are part of a chord. It is mostly provided for ear-checking of small
parts.
If your system already runs a timidity demon, you may turn the
custom variable lyqi-midi-use-external-timidity-server to
t. The default ALSA sequencer port used by such a server
should be 128. To change it, set the
lyqi-midi-external-timidity-port custom variable in your
.emacs file or use the M-x
lyqi-midi-set-timidity-alsa-port command.
custom
Some properties may be customized:- lyqi-self-inserting-keys
- Self inserting characters (a string). When the user hits one of these keys,
the corresponding character is inserted. Default:
"()<>~{}|[] " - lyqi-self-inserting-+-char-keys
- A string. When the user hits one of these keys, the
corresponding character is inserted, plus an extra character,
asked to the user. Default:
"-_^\\" - lyqi-self-inserting-+-string-keys
- A (character key &optional end) list. When the user
hits key, character is inserted, plus a string,
asked to the user. If end is provided, it is finally
inserted. Default:
'((?- "\C-c-") (?_ "\C-c_") (?^ "\C-c^") (?\\ "\C-c\\") (?# "#") (?\" "\"" "\"")) - lyqi-force-duration
- Force durations to be written when inserting a note, rest or
skip, even if previous word has the same duration. Default:
t - lyqi-relative-octave-default
- If non-nil, enables relative octave mode at startup. Default:
nil - lyqi-default-language
- Default language used to write note names. Default:
'nederlands - lyqi-midi-demon-command
- Command used to start the midi daemon. Default:
"timidity -iA -B2,8 -Os -EFreverb=0" - lyqi-midi-keyboard-command
- Command used to start the midi keyboard process. Default:
"mymidikbd" - lyqi-midi-enabled-default
- If non-nil, enables midi playing by default. Default:
nil. - lyqi-midi-use-external-timidity-server
- If true, don't start a timidity server, but use an already
running one. Default:
nil. - lyqi-midi-external-timidity-port
- The ALSA sequencer port used by the already running timidity
demon. Default:
128.
-------- .emacs --------- ;; ... (custom-set-variables ;; other custom variables... '(lyqi-default-language 'italiano) '(lyqi-midi-keyboard-command "~/bin/mymidikbd") '(lyqi-midi-use-external-timidity-server t) ; timidity demon always running '(lyqi-midi-enabled-default t)) -------------------------
reference
Rests, skips
| key | command | description |
|---|---|---|
| s | lyqi-insert-skip | Insert a skip at point. |
| r | lyqi-insert-rest | Insert a rest at point. |
Note pitches
| key | command | description |
|---|---|---|
| d | lyqi-insert-note-do | Insert a new do / c note at point. |
| f | lyqi-insert-note-re | Insert a new re / d note at point. |
| g | lyqi-insert-note-mi | Insert a new mi / e note at point. |
| h | lyqi-insert-note-fa | Insert a new fa / f note at point. |
| j | lyqi-insert-note-sol | Insert a new sol / g note at point. |
| k | lyqi-insert-note-la | Insert a new la / a note at point. |
| l | lyqi-insert-note-si | Insert a new si / b note at point. |
| i | lyqi-change-alteration-up | Increase, if possible, the last note alteration. |
| e | lyqi-change-alteration-down | Decrease, if possible, the last note alteration. |
| n | lyqi-change-alteration-natural | Set, if possible, the last note alteration to natural. |
| ' | lyqi-change-octave-up | Increase the last note octave. |
| , | lyqi-change-octave-down | Decrease the last note octave. |
| = | lyqi-change-octave-zero | Set the last note octave to zero. |
Lengths
| key | command | description |
|---|---|---|
| 1 | lyqi-change-duration-1 | Change the previous word duration to 1. |
| 2 | lyqi-change-duration-2 | Change the previous word duration to 2. |
| 4 | lyqi-change-duration-4 | Change the previous word duration to 4. |
| 8 | lyqi-change-duration-8 | Change the previous word duration to 8. |
| 7 | lyqi-change-duration-16 | Change the previous word duration to 16. |
| 5 | lyqi-change-duration-32 | Change the previous word duration to 32. |
| 0 | lyqi-change-duration-64 | Change the previous word duration to 64. |
| 9 | lyqi-change-duration-128 | Change the previous word duration to 128. |
| . | lyqi-change-dots | Increase modulo 5 the previous word dot number. |
Accidentals
| key | command | description |
|---|---|---|
| ! | lyqi-change-reminder-alt | Change the last note's reminder alteration state. |
| ? | lyqi-change-cautionary-alt | Change the last note's cautionary alteration state. |
Rumor recording session
| key | command | description |
|---|---|---|
| C-c r s | lyqi-rumor-session-start | Start a rumor session. Press SPC to stop the session |
| SPC | lyqi-rumor-session-stop | Stop a running rumor session. |
| C-c r g | lyqi-rumor-set-grain | Set rumor's grain. |
| C-c r t | lyqi-rumor-set-tempo | Set rumor's tempo. |
| C-c r l | lyqi-rumor-set-legato | Change rumor's legato parameter. |
| C-c r d | lyqi-rumor-set-no-dots | Change rumor's no-dots parameter. |
| C-c r f | lyqi-rumor-set-flat | Change rumor's flat parameter. |
| C-c r m | lyqi-rumor-set-meter | Set rumor's meter. |
| C-c r k | lyqi-rumor-set-key | Set rumor's key. |
| C-c r p | lyqi-rumor-set-alsa-port | Set rumor's alsa-port. |
Ornaments, marks, etc.
| key | command | description |
|---|---|---|
| ~ | self-insert-command | |
| { | self-insert-command | |
| } | self-insert-command | |
| | | self-insert-command | |
| [ | self-insert-command | |
| ] | self-insert-command | |
| < | self-insert-command | |
| > | self-insert-command | |
| ( | self-insert-command | |
| ) | self-insert-command | |
| SPC | self-insert-command | |
| _ | lyqi-_-self-insert-+-char | |
| - | lyqi---self-insert-+-char | |
| ^ | lyqi-^-self-insert-+-char | |
| \ | lyqi-\-self-insert-+-char | |
| C-c _ | lyqi-_-self-insert-+-string | |
| C-c - | lyqi---self-insert-+-string | |
| C-c ^ | lyqi-^-self-insert-+-string | |
| C-c \ | lyqi-\-self-insert-+-string | |
| # | lyqi-#-self-insert-+-string | |
| " | lyqi-"-self-insert-+-string |
Transformations
| key | command | description |
|---|---|---|
| C-c C-t | lyqi-transpose-region | Interactively transpose the current region. The user is asked the transposition interval, starting from c/do. |
| lyqi-transpose-interval-region | Interactively transpose the current region. The user is asked the transposition interval in tones. | |
| lyqi-change-language-region | Change note language in region. The user is asked for source and destination languages. | |
| lyqi-absolute-to-relative-region | Rewrite region with relative octave mode instead of absolute octave mode. | |
| lyqi-relative-to-absolute-region | Rewrite region with absolute octave mode instead of relative octave mode. An octave transposition may be required afterward. |
Play back
| key | command | description |
|---|---|---|
| C-c m | lyqi-midi-start-stop | Start or stop midi playing. |
| C-c p | lyqi-play-back-region | If midi is on, play back notes in region. |
| lyqi-midi-set-timidity-alsa-port | When using an external timidity demon, set its ALSA sequencer port. |
Editing properties
| key | command | description |
|---|---|---|
| C-c C-l | lyqi-switch-language | Select the next output language. |
| C-c o | lyqi-switch-octave-mode | Switch between relative and absolute octave modes. |
Misc
| key | command | description |
|---|---|---|
| C-c h | lyqi-help | Display a help message in a dedicated buffer. |
| C-c q | lyqi-quit | Quit lyqi-mode, back to LilyPond-mode |
| M-f | lyqi-word-forward | Move to the following note end, if any, otherwise to the end of the following text word. |
| M-b | lyqi-word-backward | Move to the previous note beginning, if any, otherwise to the beginning of the previous text word. |
Last modified: Sat May 22 10:47:58 CEST 2004