Giter Club home page Giter Club logo

rhythm's Introduction

Rhythm

Various python utilities for

  • generating
  • manipulating
  • converting

representations of rhythms.

Usage

The utilities are designed to be used in a shell. For detailed usage of each utility, use the --help flag.

Most of these utilities accept and produce rhythms in two formats: grids and lists of iois.

Grids encode rhythms as a sequence of zeros and ones. Each subsequent item in the sequence corresponds to a subsequent unit of time. The real duration of such a unit is mostly left unspecified, except when a rhythm needs to be converted to sound. A one indicates that an onset occurs during the unit in the rhythm encoded by the grid. A zero indicates that the unit is silent.

Sequences of inter-onset intervals (iois) encode rhythms as the intervals, expressed in units corresponding to some duration of real time, between the onsets occurring in the rhythm encoded by the sequence of iois. By convention, the first number in this sequence corresponds to the interval between the start of the rhythm and the first onset, the last unit in the sequence corresponds to the interval between the last onset of the rhythm and the end of the rhythm. Although the start and end of a rhythm are mostly virtual notions that may not correspond to physical phenomena, this ensures that ioi sequences have the same level of expressivity as grid sequences.

A general description of each utility and some examples of their use is given below.

generator.py

Can be used to generate combinatorically complete sets of rhythms.

python generator.py 12 --iois --repetitions 4 --phase 0

will generate all rhythms with a duration of exactly 12 units and a phase of zero (the rhythms do not begin with a silence). Each rhythm is repeated for times and written onto a separate line in the output.

metrical.py

Given a generative grammar describing a particular meter, generate all rhythms that contain syncopations (relative to the specified meter) with strengths no greater than a specified maximum. By the default, this maximum is zero---only regular passages (Longuet-Higgins and Lee, 1984) are generated in that case.

python metrical.py 2 3 2 --syncopation 1

Generates all rhythms that can be generated by the meter [232] (for example a duple compound meter with 16th notes as smallest units) with a maximum syncopation strength of 1.

convert.py

Relies on fluidsynth to be installed.

Converts a rhythm read from standard input into one out of a range of file formats.

echo 1 3 2 2 2 3 | python convert.py rhythm.ogg --format ogg --repetitions 4 --click-track --period 6 --pulse 3 --click-track-phase 1

will render the rhythm 32223 to ogg format. Furthermore, a click track with a low woodblock sound every 3 units and a high woodblock sound every 6 units is added. The click-track is phase-shifted by one unit.

lfind.py

Given standard input or a set of input files containing a list of line numbers, prints the content of those lines in a reference file. Useful when you have a dataset, generated for example with generator.py, and want to pull a specific (set of) rhythm(s) from this dataset. For example to listen to them.

python generator.py 12 --iois --repetitions 4 --phase 0 > rhythms.txt
echo 42 | python lfind.py rhythms.txt | convert.py 42.mid --format midi 

findl.py

This script prints the line numbers indicating the line-wise intersection between a set of input files or standard input and a reference file. The line numbers indicate lines in the reference file. Accepts flags to format the output as python or lisp lists.

In conjunction with the script for generating metrical rhythms, this can be useful for finding metrically ambiguous rhythms.

The commands below can be used to find the set of rhythms that can be interpreted both as a duple compound and a triple simple rhythm with a maximum syncopation of 1.

python metrical.py 2 3 2 --syncopation 1 > compound-rhythms.txt
python metrical.py 3 2 2 --syncopation 1 > simple-rhythms.txt
python findl.py compound-rhythms.txt simple-rhythms.txt

gridviz.py

Visualize a rhythm as a sequence of shaded (onsets) and unshaded (silences) dots. Optionally, a metrical grid can be drawn above the rhythm.

python gridviz.py --foreground-color 000000 0 2 1 1 2 4 2 2 --input-format ioi -o grid.svg -s 2 2

will draw a grid corresponding to the rhythm 0 2 1 1 2 4 2 2

rhythm's People

Contributors

bjvanderweij avatar

Watchers

Dicky Mirrors avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.