Skip to content

defaultxr/tracker-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tracker-mode

A tracker-inspired livecodable music sequencer for Emacs.

Inspired by Chun Lee’s ”etracker”, which unfortunately doesn’t seem to be available online.

Tracker-mode is a sequencer for Emacs loosely modelled after traditional trackers. At the moment, patterns can only have a single column, and each step in the sequence must be elisp code which is run on that step. Obviously since arbitrary code can be run on each step, the sky is theoretically the limit with what you can do, however writing raw elisp is perhaps not the fastest way to compose music. In the future I’d like to address both of these deficiencies to make tracker-mode faster and more fun to use.

Installation

To install and load tracker-mode, run the following Elisp code (optionally adding them to your init.el as well).

Ensure the directory containing tracker-mode.el is in your load-path:

(add-to-list 'load-path "/path/to/tracker-mode/") ; replace this with the location you downloaded tracker-mode to.

Load tracker-mode:

(require 'tracker-mode)

(Optional) Set the port that OSC messages should be sent to:

(setq tracker-osc-port 4444)

(Optional) Define some convenience aliases. See the *Suggested Aliases section below for a way to make this easier.

Usage

To start a new track, use M-x tracker, which will create a new buffer and activate the mode.

Alternatively, if tracker-mode is loaded and you’ve previously saved a tracker-mode project with a .trk or .track file extension, simply opening the file will automatically start tracker-mode for that buffer.

To use the tracker, place the point at the end of a line beginning with three digits (i.e. 000). The point should be two spaces after the last digit. An easy way to make sure you’re at the right position is to type C-a, which is redefined in tracker-mode to move to the start of the step. Type your elisp code, and then when you’re finished editing the step, press C-c C-c to confirm and apply your edits to the step.

To begin playing the sequence, press C-c C-s. Continue editing more steps, ensuring you press C-c C-c to confirm each edit. When you’re done, press C-c C-s again to stop.

You can use C-c C-i to insert a new pattern, and C-c C-d to delete the pattern under point. M-up and M-down will increase or decrease the number under the point. This is useful, for example, if you want to gradually increase the BPM without having to manually retype the number each time.

To actually generate sound, it’s suggested to use Open Sound Control (OSC) to send messages to another program (or hardware that supports it). Tracker-mode includes convenience functions to make this easier:

If you’re using SuperCollider, these functions might be even more convenient:

  • tracker-sc-synth

Emacs itself can play sound using the built-in play-sound-file function. However, this is not recommended for the following reasons:

  • Emacs will completely lock up until the sound finishes playing (not even C-g works).
  • Only certain formats of wav and au files are supported.
  • Not all platforms are supported by this function.

Note

I’ve tried to make tracker-mode as robust as possible, so errors that occur in a step won’t completely halt playback. However, it’s still very easy to accidentally “break” playback by removing part of the “interface” (i.e. parts of the buffer that tracker-mode expects to find, such as the step numbers, BPM field, etc).

I intend to fix this in the future and make tracker-mode even more robust and fail-safe, but for now it’s probably best to simply refrain from making those kinds of mistakes ;^]

Suggested Aliases

Tracker-mode includes various convenience functions that may be useful for writing music with code. The standard names of these functions can be quite long, so you may want to define aliases for them to make composing music faster. This is especially handy if you’re composing in real time as part of a performance (i.e. livecoding).

If you’re feeling lazy, tracker-mode includes convenience functionality to manage these aliases for you.

First, to see an alist of the suggested aliases that can be installed, run:

(tracker-suggested-aliases)

If you don’t know what a function does, you can of course use the standard C-h f binding to read its documentation.

tracker-install-suggested-aliases can be used to install or uninstall some or all of the suggested aliases. Note that this function will not overwrite existing functions or aliases.

To install all of the aliases (skipping any whose symbols are already defined):

(tracker-install-suggested-aliases t)

To install some of the aliases (in this case, just the aliases rand and retrig):

(tracker-install-suggested-aliases 'rand 'retrig)

To uninstall all defined aliases:

(tracker-install-suggested-aliases nil)

Of course, to make these aliases permanent, you can simply add one of the above lines to your init.el.

Keys

  • M-down - tracker-decrease-number - decreases the number under the point.
  • M-up - tracker-increase-number - increases the number under the point.
  • C-a - tracker-back-to-indent - moves your cursor back to the beginning of the line.
  • C-c C-n - tracker-next-pattern - moves the point to the next pattern in the song.
  • C-c C-p - tracker-previous-pattern - moves the point to the previous pattern in the song.
  • C-c C-s - tracker-play-or-stop - starts or stops playing the song.
  • C-c C-l - tracker-latch-toggle - toggles “latching” the current pattern. while latched, the current pattern will be looped instead of proceeding to the next.
  • C-c C-i - tracker-insert-pattern - inserts a new pattern in the song after the current.
  • C-c C-c - tracker-confirm-step - confirms and applies the changes you’ve made to the current step, the BPM, track title, etc.
  • C-c C-k - tracker-revert-step - reverts the current step, undoing any changes you’ve made.
  • M-g b - tracker-goto-bpm - moves the point to the BPM field.
  • M-g s - tracker-goto-step - moves the point to the specified step in the current pattern.
  • M-g t - tracker-goto-title - moves the point to the title field.
  • M-g p - tracker-goto-pattern - jumps the point to the specified pattern.

Future

  • Implement latency to improve timing
  • Run the loop in its own thread rather than using timers
  • Make scheduling/timing mathematically exact
  • Implement OSC time tags (does osc.el support this?)
  • Look into tabulated-list-mode to see if it would work for tracker-mode.
  • Prevent Emacs’ built-in comment functions from breaking the interface (i.e. how M-; will comment out the step number instead of just the code in that step).
  • Optionally hide the non-active patterns
  • “Scroll mode” function (shows up as “S” in the status field); automatically moves the point to the current row when the track is playing
  • “Follow mode” function (shows up as “F” in the status field); automatically switches currently viewed pattern when the track is playing
  • Pattern clone function
  • Pattern resize function
  • Keep the point on the same step (or the closest one to it) when switching patterns
  • User should not be able to delete interface elements
  • Implement “steps per beat”
  • Color each Nth line’s numbers (000, 004, 008, 012, 016, etc, based on the number of steps per beat)
  • “Init” code: elisp that is run whenever the tracker starts to initialize variables/”loads” a song (after header but before patterns)
  • Ensure it’s possible to run tracker-mode in multiple buffers simultaneously
  • Implement current step overlay (highlight the step number of the current step)
  • Add more convenience functions
    • SuperCollider convenience functions
    • Pure Data convenience functions
    • retrig - re-executes the code a certain number of times with a delay.
  • Add functions to make to modifying parts of the sequence (i.e. to allow for “self-modifying” patterns).
  • Preprocess steps when confirming them
    • Interpret vars prefixed with % (or another character maybe?) as pattern- and/or step-local.
  • Make a transient map (set-transient-map) for changing numbers more quickly, and then rebind tracker-{increase,decrease}-number to bindings less likely to clobber others.
  • Optional integration with cl-patterns/thundersnow (not completely sure what this would entail? maybe export as pattern/eseq/etc?).
  • MIDI support/convenience functions? I don’t think Emacs has support for MIDI, but perhaps it could work to use amidicat like midimacs does…
  • Fix all the bugs marked with FIX in the code.

Similar

Other projects that are related or similar.

  • piano-mode - My work-in-progress minor mode that turns your computer keyboard into a musical keyboard similar to what some DAWs do. Note that this is in major need of an update, as it doesn’t really work very well at the moment…
  • cl-patterns - My Common Lisp algorithmic pattern sequencing library. Much more advanced than tracker-mode and it includes a tracker-inspired pattern of its own called ptrack.
  • midimacs - A semi-algorithmic MIDI sequencer in Emacs Lisp.
  • etracker - Chun Lee’s Emacs tracker mode for sequencing OSC messages; a major inspiration for tracker-mode.
  • zmusic - A simple Emacs-based sequencer.
  • emaccordion - Control Emacs with MIDI.

Releases

No releases published

Packages

No packages published