Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Latest commit

 

History

History
154 lines (115 loc) · 5.53 KB

README.org

File metadata and controls

154 lines (115 loc) · 5.53 KB

This repository has moved to https://gitlab.com/jgkamat/alda-mode

Alda Mode https://melpa.org/packages/alda-mode-badge.svg https://stable.melpa.org/packages/alda-mode-badge.svg https://circleci.com/gh/jgkamat/alda-mode.svg?style=shield

The best way to edit your alda files in Emacs!

Alda mode is a simple mode to provide syntax highlighting and other basic language features for Alda, the music programming language written in Clojure.

http://i.imgur.com/lRAA27L.png

Installation

The easiest way to install alda-mode is through melpa. Simply M-x package-install alda-mode.

Once installed, place (require 'alda-mode) in your init.el.

For evil integration, simply install evil before alda-mode.

Alda files (.alda extension) should now have syntax highlighting via font-lock-mode when opened.

If melpa won’t work for you, M-x package-install-file alda-mode.el from this repository instead.

Alda Playback

alda-mode can play segments of alda from within Emacs! Simply highlight a section of alda code and run:

M-x alda-play-region

This will take a while during the first call, which will start the alda server within Emacs (if not already on your system). alda will need to be on your path.

Many other commands are available too, to allow playing an entire buffer, a file, or more!

Please submit any bugs with this feature as issues to this repository.

Alda History

When playing a region, sometimes you need ‘context’ for the playback. In alda, this is provided as ‘history’ through the java client, through alda play --history.

midi-square-wave:
    o2 c8 d e f g a b > c
    c < b a g f e d c

If you select and play the notes, without the midi-square-wave: header, you will not hear any sound, as you have not selected an instrument. While you are composing, you probably don’t want to select the entire score every time, so what you can do is add parts of the score you depend on to history!

midi-square-wave: # Highlight, and run 'alda-history-append-region'
    o2 c8 d e f g a b > c
    # now you can debug the notes on this line, without waiting for the line above
    c < b a g f e d c

If you wish to clear your history and return to a blank slate, run alda-history-clear. This can be useful for debugging issues in alda-mode, and can speed up alda execution if you added a lot to the history.

In previous releases, when the history was included in alda by default, history was applied for every command. This is not supported in alda-mode yet, but if you are interested, let me know!

Custom Alda Binary

If you want to use a custom alda binary, set alda-binary-location to your alda binary. Ex: (setq alda-binary-location "/usr/local/bin/alda")

Keep in mind, the server will only see the selection you make, and this has consequences. For example, you must run a snippet of code defining an instrument before you hear anything (or defining a marker before using it). alda-play-region will use a running alda server if it finds one, but will start one within Emacs if not found. Support is currently only tested under Linux for this command. Mac will probably work depending on your emacs install.

Evil Integration

Evil integration is automatically applied if you install evil before alda-mode. If you are installing evil after alda-mode, please reinstall/recompile alda-mode.

(package-install 'evil)
(package-install 'alda-mode)
(require 'alda-mode)

This will make a evil operator called alda-evil-play-region, defined when you require evil. If evil was not installed, this is replaced with a warning message.

Keybindings

alda-mode adds a couple simple keybindings by default. These are documented below:

KeybindFunctionExplanation
C-c C-ralda-play-regionPlays selected text
C-c C-calda-play-blockPlays the paragraph on point
C-c C-nalda-play-linePlays a single line
C-c C-balda-play-bufferPlays the entire buffer, as text (not as a file)

Here are some simple example keybinds for evil integration (or if you want to add your own custom keybindings):

(global-set-key (kbd "C-c a") 'alda-play-region) ;; Global alda-play-map
;; Requires evil integration
(define-key evil-motion-state-map "gp" 'alda-evil-play-region)

This will map C-c a to play a selected region, and gp to be an evil operator to do the same thing! (gpp will play the current line, gp20j plays 20 lines, etc).

Contributing

If you find a bug or want to improve alda-mode, submit a PR or file an issue! =)

License

alda-mode is licensed under the GPLv3.