项目作者: lvm

项目描述 :
Embedded language for SuperCollider :kiss::kiss::kiss::kiss::kiss:
高级语言: SuperCollider
项目地址: git://github.com/lvm/xoxo.git
创建时间: 2018-06-29T02:45:44Z
项目社区:https://github.com/lvm/xoxo

开源协议:

下载


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:

  1. this.preProcessor = PreProcessor.new.startDelimiter_("*:").endDelimiter_(":*");
  2. x = (
  3. lang: \xoxo,
  4. languages: (
  5. xoxo: {
  6. |code, event|
  7. /*
  8. `code` is what we wrote inside `*: ... :*`, ie: "synthdef:xoxoxoxo"
  9. `event` is the current event
  10. */
  11. // So, it splits the string to obtain...
  12. var values = code.split($:);
  13. // which synthdef to play
  14. var instrument = values[0].asSymbol;
  15. // and when to play, translating 'xoxo' to '[1,0,1,0]' which is used by the `\amp` key.
  16. var pattern = values.at(1).asList.collect{ |xo| (xo.asString == "x").binaryValue };
  17. // then we put everything together in a Pbind
  18. var output = Pbind(
  19. \amp, Pseq(pattern, inf),
  20. \instrument, instrument,
  21. \dur, 1/4
  22. );
  23. // which is embedded inside the Event in the `\xo` key.
  24. event.put(\xo, output);
  25. }
  26. )
  27. );

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

OBLIGATORY 4/4 PATTERN:

  1. *:kick:xooo:*.value(x).xo.play;
  2. *:hat:ooxo:*.value(x).xo.play;
  3. // or even shorter version:
  4. *:kick:xooo:*.(x).xo.play;
  5. *: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

  1. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  2. Version 2, December 2004
  3. Copyright (C) 2018 Mauro L. <mauro@sdf.org>
  4. Everyone is permitted to copy and distribute verbatim or modified
  5. copies of this license document, and changing it is allowed as long
  6. as the name is changed.
  7. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  8. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  9. 0. You just DO WHAT THE FUCK YOU WANT TO.