Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
total-serialism
Advanced tools
A set of methods for the generation and transformation of number sequences useful in algorithmic composition
Visit the Total Serialism Documentation for interactive examples.
total-serialism
is a set of methods used for procedurally generating and transforming number sequences. This library is mainly designed with algorithmic composition of music in mind, but can surely be useful for other purposes that involve generation and manipulation of arrays and numbers. The library is a result of my research in algorithmic composition, livecoding and electronic music and was first prototyped with Max/MSP in the Mercury livecoding environment.
This library is a work in progress. I'm always interested in receiving inspiration, suggestions, enhancements, literature and more. Feel free to file an issue here or make a pull request and I will gladly look into it!
$ npm install total-serialism
// entire package
const Srl = require('total-serialism');
// subset of library
const Gen = require('total-serialism').Generative;
// entire package
const Srl = require('total-serialism/build/ts.es5.js');
// subset of library
const Algo = require('total-serialism/build/ts.es5.js').Algorithmic;
Include latest or specific version of bundled minified es5 through url in index.html
<script src="https://unpkg.com/total-serialism/build/ts.es5.min.js"></script>
<script src="https://unpkg.com/total-serialism@1.6.12/build/ts.es5.min.js"></script>
Use in a html <script>
like so:
// entire package
const Srl = TotalSerialism;
// subset of library
const Rand = TotalSerialism.Stochastic;
The library consists of a few subsets:
Generative
: Basic methods that generate arrays of number sequences, such as methods that generate an ascending array of numbers evenly spread between a low and high value.Algorithmic
: These are also generative methods, but are in general more complex algorithms, such as euclidean rhythm generation, lindenmayer string expansion, fibonacci sequence, pisano periods and more.Stochastic
: Methods for procedurally generating number sequences based on various types of randomness, such as white noise (evenly distributed), rolling dice, flipping a coin and more. Also includes Markov Chain.Transform
: Methods that transform the array in some fashion. Think of methods such as reversing, palindrome, duplicating, inversing, interleaving and more.Statistic
: A set of methods from Statistics and Probability Theory that allow for analysis of number sequences for statistical purposes. For example getting the average value or the most common value from an array.Translate
: Translate between different notation systems. For example convert midi values to frequency, or note names to midi integers. Or use a relative semitone notation system and convert to midi. Map values in an Array to a specified scale, and output the relative values in the specified scale, root and octave.Utility
: Basic arithmetic and methods necessary to run functions in the libraries above. But can also be of help in your own algorithmic processes.A libary of statistical methods is now included, featuring methods for returning the mean, median and mode from an array
// Get the average (artihmetic mean) value from an array
Stat.average([1, 2, 3, 4, 5, 6, 7, 8, 9]);
//=> 5
// Return the center value (median) from an array
Stat.center([1, 5, 6, 9, 13]);
//=> 6
// Returns the most common value (mode) from an array as an array
Stat.common([8, 4, 3, 11, 9, 0, 11, 2, 10, 5, 11, 0]);
//=> [ 11 ]
Set a global scale and map relative values to that scale to stay in tune
// Set the global scale used with toScale() and toMidi() methods
TL.setScale('minor_harmonic', 'c');
// Map relative numbers to a specified scale class (including root)
// output as midi value. Specify an octave (default = 'C3' = 4 => 48)
TL.toMidi([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 4);;
//=> [ 48, 48, 50, 51, 51, 53, 55, 55, 56, 56, 59, 59 ]
Generate Lindenmayer system sequences
// Cantor set as 0's and 1's in an array ruleset
Algo.linden(1, 3, {1: [1, 0, 1], 0: [0, 0, 0]});
//=> [ 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1 ]
Generate Pisano periods and Fibonacci sequences
Algo.pisano(7);
//=> [ 0, 1, 1, 2, 3, 5, 1, 6, 0, 6, 6, 5, 4, 2, 6, 1 ]
Algo.fibonacci(2, 100);
//=> [ '354224848179261915075', '573147844013817084101' ]
The entire library
const Serialism = require('total-serialism');
Or an individual section
const Gen = require('total-serialism').Generative;
const Algo = require('total-serialism').Algorithmic;
const Mod = require('total-serialism').Transform;
const Rand = require('total-serialism').Stochastic;
const Util = require('total-serialism').Utility;
The following links redirect to p5.js sketches coded in the p5 browser editor. These sketches demonstrate some of the methods from this library, used in both sound (for algorithmic composing) and visuals. The sketches use the ts.es5.min.js bundled minified version of this package. See install for instructions on how to include the minified version in the index.html and script.
A simple synth with a generative melody the notes are generated through chaining of a few methods. Using: Gen.spreadInclusive(), Mod.duplicate(), Util.add()
A simple arpeggiator with a melody generated from multiple periods of a scaled sine function. The period of the function changes over time. using: Gen.sine()
A simple bass synthesizer with a 4 note progression, using euclidean rhythm generators to make a rhythm by adding 2 arrays of euclidean rhythms together. Using: Algo.euclid(), Util.add()
A arpeggiator that uses a generated melody from multiple periods of a scaled cosine function and plays a rhythm generated by a hexadecimal value. Using: Algo.hexBeat(), Gen.cosine()
This library is inspired by the composition techniques named Serialism
and Total Serialism
. The technique approaches the parameters that make up a piece of music as individual series of values. These parameters are (but not limited to) pitch, duration/rhythm and velocity/dynamic.
Serialism originated from the twelve-tone
technique, described in 1919 by Josef Hauer in his published work "Law of the twelve tones". This technique starts out with a randomly ordered set of the twelve chromatic notes. From there on out you can apply transformations on this set, such as reverse/retrograde, inverse, transpose, and combinations between those.
For many of the functions programmed much inspiration was gained from Laurie Spiegels paper on "Manipulation of Musical Patterns" (1981) in which she suggests to "extract a basic "library" consisting of the most elemental transformations which have consistently been successfully used on musical patterns, a basic group of "tried-and-true" musical manipulations."
The euclidean rhythm generator was inspired by the famous paper by Godfried Toussaint and the hexadecimal rhythm generator was inspired by Steven Yi's implementation in the CSound livecoding environment and a workshop given by him during the ICLC 2020 in Limerick.
Inspiration for the sequencing also came from the Live Coding scene and current programming languages available such as Tidal, Extempore, SonicPi and more. In Live Coding the Serialism technique is very common when programming music. In many cases the rhythms, melodies, and other musical expressions are expressed in arrays that are iterated based on the timing of the system.
The inspiration for usage of Integer Sequences came from composers such as Iannis Xenakis, who used the fibonacci formula in his piece Nomos Alpha and referred to the technique as Fibonacci Motion. Also Xenakis referred to the usuage of set theory for composition as Symbolic Music.
The Hexadecimal rhythm generator was inspired by a workshop by Steven Yi at the International Conference on Live Coding 2020 at the University of Limerick, Ireland.
Some methods from the Transformational and Stochastic library are inspired by objects or functions in the Max/MSP programming environment. Such as the urn, spread and spreadInclusive methods.
Nick Collins - Algorithmic Composition Methods for Breakbeat Science
Alex McLean - Tidal Pattern Language for Live Coding of Music
Godfried Toussaint - The Euclidean Algorithm Generates Traditional Musical Rhythms
Iannis Xenakis - Formalized Music, Thought and Mathematics in Music
Thomas DeLio - Nomos Alpha: The Dialects of Structure and Materials
This library is a work in progress, and I'm always interested to receive inspiration, suggestions, enhancements, literature and more. Feel free to file an issue here and I will gladly look into it!
Total Serialism is a result of research in algorithmic composition with the Mercury livecoding environment.
The MIT License
Copyright (c) 2020 Timo Hoogland
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A set of methods for the generation and transformation of number sequences useful in algorithmic composition
The npm package total-serialism receives a total of 177 weekly downloads. As such, total-serialism popularity was classified as not popular.
We found that total-serialism demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.