All Projects → defaultxr → cl-patterns

defaultxr / cl-patterns

Licence: MIT License
Library for writing patterns to generate or process (a)musical sequences of mathematically (un)related (non-)compound values in Lisp.

Programming Languages

common lisp
692 projects
emacs lisp
2029 projects

Projects that are alternatives of or similar to cl-patterns

recurse
re<urse is a declarative language for generating musical patterns
Stars: ✭ 32 (-48.39%)
Mutual labels:  sequencer, midi, live-coding, livecoding
melrose
interactive programming of melodies, producing MIDI
Stars: ✭ 130 (+109.68%)
Mutual labels:  midi, music-composition, livecoding
braid
Polyrhythms in Python: a sequencer and musical notation system for monophonic MIDI synths
Stars: ✭ 34 (-45.16%)
Mutual labels:  sequencer, midi, livecoding
Webaudiofont
Use full GM set of musical instruments to play MIDI and single sounds or effects. Support for reverberation and equaliser. No plugins, no Flash. Pure HTML5 implementation compatible with desktop and mobile browser. See live examples.
Stars: ✭ 600 (+867.74%)
Mutual labels:  midi, music-composition, synth
Fsynth
Web-based and pixels-based collaborative synthesizer
Stars: ✭ 146 (+135.48%)
Mutual labels:  midi, live-coding, supercollider
Helio Workstation
One music sequencer for all major platforms, desktop and mobile
Stars: ✭ 2,257 (+3540.32%)
Mutual labels:  sequencer, midi, music-composition
Flok
Web-based P2P collaborative editor for live coding sounds and images
Stars: ✭ 119 (+91.94%)
Mutual labels:  live-coding, supercollider, livecoding
Audiokitsynthone
AudioKit Synth One: Open-Source iOS Synthesizer App
Stars: ✭ 1,258 (+1929.03%)
Mutual labels:  sequencer, midi, synth
Textbeat
🎹 plaintext music sequencer and midi shell, with vim playback 🥁
Stars: ✭ 274 (+341.94%)
Mutual labels:  sequencer, midi, music-composition
Miti
miti is a musical instrument textual interface. Basically, its MIDI, but with human-readable text. 🎵
Stars: ✭ 103 (+66.13%)
Mutual labels:  sequencer, midi, music-composition
ws-ldn-12
ARM / STM32F7 DIY synth workshop
Stars: ✭ 62 (+0%)
Mutual labels:  sequencer, midi, synth
Main-Supercollider-Files
my supercollider codes, version history is at the branches
Stars: ✭ 21 (-66.13%)
Mutual labels:  supercollider, synth
monome-rack
VCV Rack plugin for monome Eurorack modules
Stars: ✭ 161 (+159.68%)
Mutual labels:  sequencer, music-composition
improviz
A live-coded visual performance tool
Stars: ✭ 85 (+37.1%)
Mutual labels:  live-coding, livecoding
flow-synth
*UNMAINTAINED* A modular digital audio workstation for synthesis, sequencing, live coding, visuals, etc
Stars: ✭ 36 (-41.94%)
Mutual labels:  live-coding, livecoding
tidal-looper
Different looper variants for SuperDirt to provide live sampling in TidalCycles.
Stars: ✭ 55 (-11.29%)
Mutual labels:  live-coding, supercollider
glicol
(Audio) graph-oriented live coding language and music DSP library written in Rust
Stars: ✭ 853 (+1275.81%)
Mutual labels:  live-coding, livecoding
kotoist
A VST plugin for live coding and algorithmic composition
Stars: ✭ 37 (-40.32%)
Mutual labels:  midi, live-coding
alda-clj
A Clojure library for live-coding music with Alda
Stars: ✭ 54 (-12.9%)
Mutual labels:  music-composition, live-coding
facet
Facet is a live coding system for algorithmic music
Stars: ✭ 72 (+16.13%)
Mutual labels:  midi, livecoding

cl-patterns

A library for writing patterns to generate or process (a)musical sequences of mathematically (un)related (non-)compound values in Lisp.

Put more simply, cl-patterns is a system for making music and noise via Lisp code.

It is heavily inspired by SuperCollider’s patterns system, with aims to implement much of it, but in a more robust, expressive, consistent, reflective, and lispy way:

  • robust: prefer coercing values into something “correct” rather than failing or giving an error. if you’re “in the zone” and writing music, you probably want your compositional tools to “do what you mean” and allow you to take as many sensible shortcuts as possible, rather than forcing you to waste time manually declaring and setting up everything.
  • expressive: make writing music as easy and “natural” as possible, so that patterns can be built in real-time, in performance settings, without having to think so hard about how to bend the library to your will. I feel this is a weakness of SuperCollider.
  • consistent: edge cases minimized, arguments for the various functions in an intuitive order, thus resulting in less cognitive load for the user.
  • reflective: store more data about the stream state and more metadata about the patterns. make it easier for a pattern to access the values of another pattern, for patterns to affect other patterns, etc.
  • lispy: prefer lisp idioms rather than direct translations of the SuperCollider way of doing things (while still keeping things relatively similar so it’s not a huge adjustment for SC users to make).

In addition to emulating most of SuperCollider’s patterns system, another goal is to further extend it with more tools and more ways to write patterns/sequences. The most obvious example being a “drum sequence” notation like k - - - k - - - k - - - k - - - for a four-to-the-floor beat. The idea is that Lisp’s macros should make it possible to more expressively write music with code.

Intro

Make sure you have Quicklisp installed and working with your Lisp implementation, then load cl-patterns:

(ql:quickload :cl-patterns)
(in-package #:cl-patterns)

Create a pattern like so:

(defparameter *pat* (pbind :foo (pseq '(1 2 3))
                           :bar (prand '(9 8 7) 5)))

Since patterns are basically “templates”, you need to turn them into pstream objects in order to actually get output from them:

(defparameter *pstream* (as-pstream *pat*))

Then, you can get results from the pstream one at a time with next, or many at a time with next-n or next-upto-n:

(next-n *pstream* 3)
;; => ((EVENT :FOO 1 :BAR 8) (EVENT :FOO 2 :BAR 9) (EVENT :FOO 3 :BAR 8))

To actually hear sound output, you’ll need to start an audio server. Right now, SuperCollider is the main audio server that cl-patterns is tested against, but there is also preliminary support for Incudine as well as MIDI output through ALSA.

To use the SuperCollider backend, simply load the cl-patterns/supercollider system with quicklisp. This will automatically take care of loading the required cl-collider library for you:

(ql:quickload :cl-patterns/supercollider)

From here, you can take a look at the code in the supercollider-example.lisp file for a short example of how to define your own synths and play them with patterns. You may also be interested in my cl-collider tutorial for a more in-depth introduction to cl-collider.

For more information on how to use cl-patterns, refer to tutorial.org for an introduction.

You can get a list of all defined patterns using (all-patterns). Every pattern should have usage information and examples in its docstring, which of course can be accessed using the standand describe or documentation functions.

Features

This library isn’t just a copy of SuperCollider’s patterns - I wanted to improve upon them as well. For a list of notable features in cl-patterns, see features.org.

If you’re familiar with SuperCollider, you may also want to look at sc-differences.org for a listing of differences between this library and SC’s patterns, or sc.org for a listing of patterns in SuperCollider and their equivalent (and implementation status) in cl-patterns.

Emacs “Helper Functions”

Included in res/emacs/ are a few small libraries that make it more convenient to work with cl-patterns and the synthesis engines it supports from inside Emacs. Their functionality includes:

  • commands for playing/stopping the pattern, buffer, proxy, or other object under point
  • command to stop all playing patterns, nodes, etc.
  • command to open the SuperCollider documentation for a specified class (with completion)
  • skeletons for commonly-used patterns/functions
  • and a few other utility functions.

Here’s the recommended setup to load these libraries automatically via your Emacs init file:

(defun cl-patterns-helpers-load ()
  (interactive)
  (sly-eval-async '(cl:namestring (asdf:system-source-directory (asdf:find-system 'cl-patterns)))
    (lambda (path)
      (load (concat path "res/emacs/cl-patterns-helpers") nil nil nil t)
      (load (concat path "res/emacs/cl-patterns-skeletons") nil nil nil t)))
  (define-key sly-mode-map (kbd "C-c p") 'cl-patterns-play-or-end-context-or-select-pdef)
  (define-key sly-mode-map (kbd "C-c P") 'cl-patterns-play-or-stop-context-or-select-pdef)
  (define-key sly-mode-map (kbd "C-c s") 'cl-patterns-stop-all)
  (define-key sly-doc-map (kbd "s") 'cl-patterns-supercollider-documentation))

(add-hook 'sly-connected-hook 'cl-patterns-helpers-load)

The above should also work with slime; just replace all instances of “sly” with “slime”.

Current Status

Right now, the library may be described as being in a “alpha” state, as major changes (which may break code you write) are still very likely to happen. However, these changes should be documented in commit messages, so check those if you have any issues after updating.

Despite that, lots of functionality is already written and the library should be stable enough for normal usage in most cases.

Many tests have already been written to help guard against regressions.

Much documentation is still being written, but there is already a good amount of information in the doc directory, and in the docstrings for the patterns, functions, etc.

See TODO.org and roadmap.org for a listing of tasks that need to be completed and ideas for future features. The code itself is also littered with comments marked “FIX” noting various known issues and possible changes and optimizations that could be made.

Backends

The SuperCollider backend is the primary backend that cl-patterns is tested against so it should generally work the best and should be usable for most purposes.

The Incudine backend should work for most purposes, though currently multichannel expansion does not work.

The ALSA MIDI backend has some functionality complete and should be usable for basic tasks, but is still very much a work in progress.

Rough Edges

Don’t cut yourself on these. These are the weaker parts of the library; they’re still very much WIPs and are even less likely to be correct :^)

  • scales/tunings - calculations may be wrong sometimes; sometimes throw errors
  • pcycles - still needs work, API may change
  • sc-compatibility patterns - hardly anything written for these!
  • multichannel expansion - still somewhat new, might not work with all backends

Tour

doc

  • backends.org - information about cl-patterns backends, including how to write your own.
  • cookbook.org - a cookbook of ideas and inspiration for your cl-patterns hacking.
  • features.org - listing of notable features of cl-patterns.
  • isobar.org - list of patterns in isobar and their equivalents in cl-patterns.
  • other-libraries.org - listing of other libraries that have similar goals or may be useful in conjunction with cl-patterns.
  • patterns.org - organized index of the pattern classes included in cl-patterns.
  • roadmap.org - general overview of major goals for the future development of cl-patterns.
  • sc.org - a list of pattern classes and special keys in SuperCollider and their cl-patterns implementation status.
  • sc-differences.org - listing of things that differ between cl-patterns and SuperCollider.
  • special-keys.org - description of keys that have special effects when used in an event or pbind.
  • supercollider-example.lisp - short example of how to use cl-patterns with cl-collider.
  • TODO.org - a list of things and ideas that have not yet been implemented into cl-patterns, but may be in the future.
  • tutorial.org - explanation of the basic concepts of cl-patterns, meant for people who have never used SuperCollider’s patterns.
  • writing-your-own.org - information about how to write your own pattern classes.

res

emacs

src

  • package.lisp - the package definition file.
  • utility.lisp - general utility functions and special variable definitions.
  • conversions.lisp - functions to convert between units (i.e. midinote to frequency, decibels to amplitude, etc.).
  • scales.lisp - musical pitch (scales/tuning) data and structs.
  • event.lisp - code to represent and deal with events. includes the event class, information about special keys (i.e. freq, amp…), etc.
  • eseq.lisp - event sequence class and functionality.
  • backend.lisp - code to handle “backends”; i.e. how cl-patterns will actually “play” events.
  • clock.lisp - the scheduling functionality to make sure that each event is played at the proper time.
  • sugar.lisp - deprecated syntax sugar functions.

patterns

  • patterns.lisp - general pattern macros and functionality + the standard set of patterns; includes the pattern superclass, pbind, pseq, pk, etc.
  • bjorklund.lisp - Euclidean pattern functionality such as pbjorklund, etc.
  • cycles.lisp - TidalCycles-inspired patterns and notation, i.e. pcycles, etc.
  • tracker.lisp - tracker-inspired patterns and notation, i.e. ptracker and associated functions, macros, reader macros, etc.
  • sc-compatibility.lisp - patterns intended to be fully compatible with SuperCollider’s patterns system.
  • export.lisp - export all defined patterns in the *patterns* list.

backends

formats

extensions

t

contains the files for the FiveAM-based test suite for the library.

Community

As far as I’m aware there isn’t a huge community of people using this library to make music yet. However, if you need support or just want to chat, the “official” room is on Matrix: #cl-patterns:struct.ws.

Any bugs, feature requests, suggestions, etc should be submitted to the GitHub issue tracker. Please feel free to submit issues even if they might already be known as it helps to figure out what parts of the library to prioritize development on. It’s also nice to hear that people are using the library. :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].