Generative musical composition in Csound: a toolkit for building families of Markov transition matrices from a few base matrices (interpolation, entropy relaxation, rotation), plus a composition engine that plays Markov chains over musical material using them. Demonstrated on the microtonal Markov material from [ocultado].
MatrixGen/
├── orc/ UDOs (#include'd by every .csd)
│ ├── matrix_udos.orc MatInterp, MatEntropy, MatRotate, BuildBiasedMatrix
│ ├── composition_udos.orc NextMarkovState, PlayChain, PlayMetaChain
│ ├── export_udos.orc ExportMatrixCsound (dump a matrix as paste-ready Csound text)
│ └── utilFunctions.orc PrintMat, PrintMatHeat (print/debug helpers)
│
├── compositions/ the finished pieces (this is the result)
│ ├── pecaGestos.csd full reimplementation of the Gestos Markov material
│ ├── GestosModelMatrizA.csd reference transition matrix (BuildBiasedMatrix)
│ ├── GestosModelMatrizB.csd Matrix A rotated (MatRotate) to privilege a different state
│ ├── GestosModelInterpolation.csd morph A → B in 4 steps (MatInterp), one continuous chain
│ ├── GestosModelEntropy.csd Matrix A relaxing toward uniform in 4 steps (MatEntropy)
│ └── audio/ rendered .wav for each piece above (committed, ready to listen)
│
├── examples/ generic engine demos + dev/test scripts (not the main result)
│ ├── peca_exemplo.csd validated reference example (don't edit to experiment)
│ ├── experimentoComposicao.csd playground for composing/experimenting (plays live, -odac)
│ ├── test_matrix_udos.csd numeric tests for the matrix module
│ ├── test_biased_matrix.csd tests for BuildBiasedMatrix + ExportMatrixCsound (round-trip check)
│ ├── test_composition_udos.csd tests for PlayChain's 3 variant-selection modes
│ ├── testeManualMatrizes.csd manual tests for MatInterp/MatEntropy/MatRotate
│ └── brincarComMatrizes.csd playground for tuning BuildBiasedMatrix parameters
│
└── docs/
├── MANUAL.md how to use every UDO (signatures, examples, usage rules)
├── markov-csound-spec.md original Gestos Markov specification (source material)
└── referenciasDiversas.md assorted references
Requires Csound installed (csound --version to
check) and a General MIDI soundfont. Files expect FluidR3_GM.sf2 at the
repo root (not versioned here — freely redistributable, download it from
e.g. https://member.keymusician.com/Member/FluidR3_GM/index.html and place
it at ./FluidR3_GM.sf2).
cd MatrixGen/compositions
csound pecaGestos.csd
Always run csound from inside the folder that contains the .csd
(compositions/ or examples/), not from the repo root. Csound resolves
-o/output paths relative to the current working directory, not to the
.csd file's own location — running from the wrong directory won't error,
it'll just silently write the .wav somewhere unexpected.
The pieces in compositions/ render to audio/*.wav (already committed —
you can just listen to those directly without installing Csound).
peca_exemplo.csd and the test_*.csd files in examples/ also render to
a file; experimentoComposicao.csd plays live (-odac).
N×N transition matrices are linear f-tables (row-major), with N set via a
global variable (giN). Operations, all generalized for any N:
MatInterp— interpolates between two matrices (linear or exponential).MatEntropy— pushes a matrix toward the uniform distribution (by degree).MatRotate— cyclically permutes states (two modes: full relabeling, or column-only/privilege shift).BuildBiasedMatrix— generates a matrix from affinity scores (softmax) instead of hand-typed probabilities.ExportMatrixCsound(orc/export_udos.orc) — writes a generated matrix out as ready-to-paste Csound source text.
See docs/MANUAL.md for full signatures and examples.
Plays Markov chains over musical material (rhythm + pitch per state, with 3
variant-selection modes), with two modes: procedural (you write the
calls) and meta-chain (a higher-level matrix decides on its own between
different configurations). PlayChain calls can be chained with real
continuity — even across a mid-piece change of transition matrix — which is
what GestosModelInterpolation.csd/GestosModelEntropy.csd demonstrate.
See docs/MANUAL.md for details.