Betablocker example code


04 June 2012

Here I collected my attempts to produce a specific kind of waveform with the BetaBlocker engine.

Saw

a = BBlockerProgram([\ORG, \INC, \JMP, 1]);
x = a.play(19000);
x.free;
a.plot(duration: 0.15);

Impulse

a = BBlockerProgram([\ORG, \NOT, \JMP, 1]);
x = a.play;
a.plot(duration: 0.001)

pulse (202)

(
var pulsewidth = 202;
a = BBlockerProgram([\ORG] ++ (\NOP ! pulsewidth) ++ [\NOT, \JMP, 1]); x = a.play;
)
a.plot(duration: 0.05);
(
var pulsewidth = 22;
a = BBlockerProgram([\ORG] ++ (\NOP ! pulsewidth) ++ [\NOT, \JMP, 1]); x = a.play;
)
a.plot(duration: 0.05)

DUP + ADD

a = BBlockerProgram([\ORG, \INC, \INC, \INC, \INC, \INC] ++ ([\DUP, \ADD]) ++ [\JMP, 2]);
x = a.play;
a.plot(duration: 0.05);

saw + impulse

(
var slope = 4;
a = BBlockerProgram([slope, \ORG] ++ ([\PSHL, -1, \ADD]) ++ [\JMP, 1]);
x = a.play;
)

POP destroy ( leak = false / leak = true )

a = BBlockerProgram([6, 7, 6, 245, \ORG, \NOP, \NOP, \NOP, \NOP] /* some space*/ ++ ([\PSHL, -6, \PSHL, -2, \POP]) ++ [\JMP, 1]);
a.fillUpRandom_(false)
a.plot(leak: true, duration: 0.5)
a.plot(leak: false, duration: 0.5)
x = a.play(leak: true);
a.fillUpRandom_(true)
a.plot(leak: false, duration: 0.5)
x = a.play(300, leak: true, vol: 0.025);
x.free;

POP destroy ( fillUpRandom = true )