Git Product home page Git Product logo

rhythmcompiler's Introduction

d = Dictionary.with(*[
	\x -> (buf: "buffer x"),
	\s -> (buf: "buffer s")
	]);
// using a dictionary for lookups here but currentEnvironment is used by default

c = Compile("x--s--x-", repeats: inf, lookup: d);

Pbindf(c, \instrument, \sampleSynth).trace.play;

Compile's lookup arg is used to map the alphabetical tokens in the rhythm string you want to compile to events
for example you might want to use a sample player that has a 'buf' argument, so you can gather some different events with the buffers into a kind of 'drum machine' dictionary d, and look them up in it.
Compile returns a Routine that yields events so you can easily plug it into a pbind, or use it inside a Task or other Routine.

syntax guide:

"x---" this is a note that lasts 4 'ticks' (ticks are deliberately kept vague)
brackets: "[x--x--]" brackets group things together for binops / unops
spaces: "x--- x--- x--- x---" spaces are ignored so this is just a 4/4 beat
dashes: "-- -- -- x-" this is 3 rests then a beat

binary operators:

  • % : "[x--x--]%4" pads the lhs to next multiple of the rhs so this will be transformed to "x--x-- --" (8 ticks in total)

  • | : truncates the lhs so "[x--x--]|4" -> "x--x"

  • ! : duplicate lhs "x--x-!3" --> "x--x- x--x- x--x-"

  • * : multiply -- "x--- x--- * 1.5" --> "x----- x-----"

  • / : does what you might think

unary operators:

  • : scrambles the lhs and embeds it in the routine (it will scramble it again each time if repeated)

I recommend to use myLib for useful extensions to the Symbol class, and for using modules with Import

rhythmcompiler's People

Contributors

crawdaddie avatar

Watchers

 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.