Gwion Samples

lorem ipsum

some code

<<< "Hello, World!" >>>;
built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground

Simple vibrato examples

the while true way

#import Modules

var SinOsc sin ~> dac;

var SinOsc lfo ~> blackhole;
4 => lfo.freq;
5 => lfo.amp;

var int base;

spork {
  while(true) {
    lfo.last() + base => sin.freq;
    samp => now;
  }
};

repeat(3) {
  foreach(note : [ `c3`, `d3`, `e3`, `g3` ]) {
    note :=> base;
    .25::second => now;
  }
}

the Sifting way

Alternatively you can use the Sift operator

#import Modules

var SinOsc sin ~> dac;

var SinOsc lfo ~> blackhole;
4 => lfo.freq;
10 => lfo.amp;

var int base;

lfo |> \a { a + base } |> sin.freq;

repeat(3) {
  foreach(note : [ `c3`, `d3`, `e3`, `g3` ]) {
    note :=> base;
    .25::second => now;
  }
}

built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground

Risset Beats

using beating frequencies to compose music.

#import STK

5.0 :=> var float songlength;

[880.0, 587.0, 440.0, 392.0, 370.0, 392.0] :=> var float[] freqs;
[0.5, 1.5, 2.5, 3.0, 3.5, 4.0] :=> var float[] soundtimes;
[0.5, 0.5, 1.0, 1.0, 1.0, 1.0] :=> var float[] amps;
[20, 20, 20, 20, 20, 20] :=> var int[] num;

var stk.SineWave s[freqs.size()][0];
var Gain g[freqs.size()][0];

repeat(i, freqs.size()) {
    new stk.SineWave[num[i]] :=> s[i];
    new Gain[num[i]] :=> g[i];
    0.5 / num[i] :=> const float scale;
    repeat(j, num[i]) {
        freqs[i] + j * 1.0 / songlength :=> const float freq;
        freq * soundtimes[i]  :=> const float phase;
        phase => s[i][j].addPhase;
        freq => s[i][j].setFrequency;
        s[i][j] ~> g[i][j] ~> dac;
        amps[i]*scale => g[i][j].gain;
    }
}

songlength::minute => now;

built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground

A sporth sample

Sporth (short for SoundPipe fORTH), is a small stack-based musical language, roughly inspired by stack languages like Forth and PostScript.

It is embedded in a plugin.

#import Sporth
#import Math

110 :=> const float bpm;
(60.0 / bpm) :: second :=> const dur t;
[0, 1, 5, 7, 8] :=> const int[] scale;

fun void loop_me(const int root) {
  var int stp;
  var int nbars;
  var int block;

  var Sporth s ~> dac;
  s.parse("0 p 0.01 port mtof 1 p 0.003 port 1 1 2 p 0.01 port fm 0.5 * dup dup 0.94 10000 revsc drop 0.1 * +");
  s.p(1, 0.2);

  root :=> var int base;
  while(true) {
    if(stp == 0) {
        s.p(1, 0.4);
        nbars++;
    } else
      s.p(1, 0.4);
    if(nbars > block) {
      if(base == root)
        53 :=> base;
      else
        60 :=> base;
      1 :=> nbars;
    }
    s.p(0, base + scale[stp] + 12 * Math.rand2(-1, 1));
    s.p(2, Math.rand2f(0.1, 3));
    0.25::t => now;
    (stp + 1) % scale.size() :=> stp;
  }
}

spork loop_me(60);
spork loop_me(36);
minute => now;

built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground

N-Oscillator Drone

An interesting soundscape created by layering harmonics on top of a base frequency and offsetting every oscillator's pitch by a tiny amount.

#import Modules

fun void osc(float osc_freq, float total, float amp: .75) {
	var SawOsc sin ~> dac;

	osc_freq => sin.freq;
	amp / total => sin.amp;

	while (true)
		minute => now;
}

300   :=> const int total;            #! total oscillators to distribute over the number of harmonics
5     :=> const int harmonics;        #! number of harmonics to create based on the multiplication of the base frequency
0.005 :=> const float freq_variance;  #! frequency offset between oscillators
40    :=> const float base_freq;      #! base frequency to use for the harmonics
.75   :=> const float amp;            #! 0-1 gain

for (0 :=> var int j; j < harmonics; j++) {
	for (1 :=> var int i; i < (total / harmonics) + 1; i++) {
		((i * freq_variance) + j) + (base_freq * j) :=> const auto freq;
		spork osc(freq, total, amp);

		<<< "harmonic ${j + 1}/${harmonics} => osc ${i}/${total / harmonics} @ ${freq}Hz" >>>;
	}
}

10::minute => now;

built with mdr and mdBook
You'll find the source here, Luke! note: privacy guards may interfere with the playground