Giter Site home page Giter Site logo

xoxo's Introduction

xoxo

This is a very short (embedded) language for SuperCollider that uses PreProcessor Quark.
My main (and only) goal was to make it as short as possible (both the rhythmic Patterns and the language itself).
The whole implementation fits in 259 characters (so it fits in a twit... of 280 chars).
Here's an expanded version:

this.preProcessor = PreProcessor.new.startDelimiter_("*:").endDelimiter_(":*");
x = (
  lang: \xoxo,
  languages: (
    xoxo: {
      |code, event|
      /*
      `code` is what we wrote inside `*: ... :*`, ie: "synthdef:xoxoxoxo"
      `event` is the current event
      */
      // So, it splits the string to obtain...
      var values = code.split($:);
      // which synthdef to play
      var instrument = values[0].asSymbol;
      // and when to play, translating 'xoxo' to '[1,0,1,0]' which is used by the `\amp` key.
      var pattern = values.at(1).asList.collect{ |xo| (xo.asString == "x").binaryValue }; 
      // then we put everything together in a Pbind
      var output = Pbind(
        \amp, Pseq(pattern, inf),
        \instrument, instrument,
        \dur, 1/4        
      );
      // which is embedded inside the Event in the `\xo` key.
      event.put(\xo, output);
    }
  )
);

SYNTAX

The syntax is really basic:

  • *: to open the pattern
  • synthdef:pattern (x plays, o stays silent)
  • :* to close the pattern

XOXO <-> SC

A *:synth:xoxoxo:* Pattern by itself won't play anything because basically it's just a Function (x.at(\languages).at(\xoxo)), so as we would do with any other Function, we need to call it passing the whole x Event, which will return the Event with a new .xo key (the Pbind).

            .-------------------------> 1. xoxo pattern
           /         .----------------> 2. call it passing `x` Event with this tiny lang implementation,
          /         /      .----------> 3. we get an Event with a `xo` key (which cointains the Pbind)
         /         /      /   .-------> 4. Pbind.play
        /         /      /   /
,------------,,--------,,-,,---,
*:synth:xoxo:*.value(x).xo.play;

OBLIGATORY 4/4 PATTERN:

*:kick:xooo:*.value(x).xo.play;
*:hat:ooxo:*.value(x).xo.play;

// or even shorter version:

*:kick:xooo:*.(x).xo.play;
*:hat:ooxo:*.(x).xo.play;

BRING YOUR OWN SYNTHS

This language doesn't provide SynthDefs because I assumed you already have some stored and loaded.
If by chance you don't have any, you can use these provided by @hordiales.

LICENSE

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

 Copyright (C) 2018 Mauro L. <[email protected]> 

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO.

xoxo's People

Contributors

lvm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xoxo's Issues

Doc is not self-contained

I think would be good add to the documentation that you have to define a synths named 'kick' and 'hihat' to test it.

Propose something like (or link to a similar reference):

SynthDef("kick", {arg out = 0, amp = 0.3, sinfreq = 60, glissf = 0.9, att = 0.01, rel = 0.45, pan = 0;
var env, snd, ramp;
env = Env.perc(att, rel, amp).kr(doneAction: 2);
ramp = XLine.kr(
start: sinfreq,
end: sinfreq * glissf,
dur: rel
);
snd = SinOsc.ar(freq: ramp, mul: env);
snd = Pan2.ar(snd, pan);
Out.ar(out, snd);
}).add;

SynthDef("hihat", {arg out = 0, amp = 0.5, att = 0.01, rel = 0.2, ffreq = 6000, pan = 0;
var env, snd;
env = Env.perc(att, rel, amp).kr(doneAction: 2);
snd = WhiteNoise.ar;
snd = HPF.ar(in: snd, freq: ffreq, mul: env);
Out.ar(out, Pan2.ar(snd, pan));
}).add;

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.