Shlerb and ShlispTools

]

Tools for Shlisp/Shnth developers. If you don’t recognize both words starting with “Sh”, this is probably not for you.

Online documentation:

Executables:

Classes/Modules:

Shlerb code examples:

Shlisp & Shnth come from Sbobo - shbobo.net

Installation

Add this line to your application’s Gemfile:

gem 'shlisp_tools'

And then execute:

$ bundle

Or install it yourself as:

$ gem install shlisp_tools

Shlerb

Shlerb is a command-line program that generates Shlisp code from a template file and uploads it to a Shnth, assuming that you have one attached to your computer, and that you have the “shlisp” program (from shbobo.net) on your path. If there are errors translating the file, the error is displayed and nothing is uploaded.

Shlerb template files are just shlisp source files (“txts”) with optional sections of Ruby code that start with “<%” or “<%=” and end with “%>”. Sections that start with “<%” are simply evaluated as Ruby code and are used to set variables or constants or do some other processing. Section that begin with “<%=” are also evaulated as Ruby code, but the output is printed and is thus useful for generating shlisp code.

Usage

shlerb FILENAME

where FILENAME is something like cool_shnth_patches.txt.erb or cool_shnth_patches.shlerb. The contents of the file should be shlisp code with optional ERB sections containing Ruby code. (For more information on ERB, see en.wikipedia.org/wiki/ERuby). The Ruby code has access to the modules and classes mentioned above.

Examples

Here’s an example of a shlerb file with a single situation. It plays a six-note meta-slendro scale on the keys in the order majora, majorb, majorc, majord, minord, minorc. The tones fade in slowly and will tend to (intentionally) distort as they reach full amplitude. The scale used is part of the collection of pre-defined scales that come with ShlispTools.

<%
  Slew_mul = 5
  Slew_add = 5
  Modo_mul = 2
%>
<% s1 = Scales::MetaSlendro_1.mul(120) %> 
{
  <%= Shnth::Situation_1 %>

  ; 60Hz-ish
  (srate (short 72 79))

  (arab

    (pan
      (add
        (modo (horna <%= s1[Shnth::Bar_A].n %> <%= s1[Shnth::Bar_A].d %> (slewa (majora) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
        (modo (hornc <%= s1[Shnth::Bar_C].n %> <%= s1[Shnth::Bar_C].d %> (slewc (majorc) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
        (modo (horne <%= s1[Shnth::Bar_d].n %> <%= s1[Shnth::Bar_d].d %> (slewe (minord) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
      )
      144
    )

    (pan
      (add
        (modo (hornb <%= s1[Shnth::Bar_B].n %> <%= s1[Shnth::Bar_B].d %> (slewb (majorb) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
        (modo (hornd <%= s1[Shnth::Bar_D].n %> <%= s1[Shnth::Bar_D].d %> (slewd (majord) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
        (modo (hornf <%= s1[Shnth::Bar_c].n %> <%= s1[Shnth::Bar_c].d %> (slewf (minorc) <%= Slew_mul %> <%= Slew_add %>)) <%= Modo_mul %>)
      )
      80
    )

  )
}

You can also define your own scales and add a scaling factor to bring them into the right range for your srate.

<%

  # shortcuts for long names
  S = ShlispTools::Scale
  R = ShlispTools::Ratio

  # define scale with 1/1 = 100 100
  myMetaSlendro = S::Scale.new([
    R::Ratio.new( 1,  1),
    R::Ratio.new(37, 32),
    R::Ratio.new(21, 16),
    R::Ratio.new(49, 32),
    R::Ratio.new( 7,  4),
    R::Ratio.new( 2,  1)
  ]).mul(100)

  # get nume and deno for a given scale degree, using indexes 0 through 5 for a six-note scale
  #   1/1:
  #   myMetaSlendro[0].nume
  #   myMetaSlendro[0].deno
  #
  #   37/32
  #   myMetaSlendro[1].nume
  #   myMetaSlendro[1].deno
  #
  #   ... 

%>

Shtool

Shtool is a command-line program that collects together a few useful calculations.

Usage

shtool [[OPERATION] args ...]

Use shtool help for a list of the current set of operations and what they do. For help with any operation, use shtool OPERATION_NAME to see what arguments ar expected.

Caveats

TODO

Contributing

  1. Fork it

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Commit your changes (git commit -am 'Add some feature')

  4. Push to the branch (git push origin my-new-feature)

  5. Create new Pull Request