Browse Source

Update examples, add vco.scd

tags/v1.3.0
Brian Heim 5 years ago
parent
commit
1c7f0c0e4a
3 changed files with 42 additions and 4 deletions
  1. +3
    -2
      examples/gain.scd
  2. +2
    -2
      examples/rainbow.scd
  3. +37
    -0
      examples/vco.scd

+ 3
- 2
examples/gain.scd View File

@@ -1,10 +1,11 @@
// Simplest possible script using all variables, demonstrating buffering
// by Brian Heim
// by Andrew Belt
// adapted for SC by Brian Heim

~vcv_frameDivider = 1;
~vcv_bufferSize = 32;

~vcv_process = {|block|
~vcv_process = { |block|
// Loop through each row
VcvPrototypeProcessBlock.numRows.do { |i|
// Get gain knob


+ 2
- 2
examples/rainbow.scd View File

@@ -1,6 +1,6 @@
// Rainbow RGB LED example
// by Brian Heim
// adapted from example by Andrew Belt
// by Andrew Belt
// adapted for SC by Brian Heim

// Call process() every 256 audio samples
~vcv_frameDivider = 256;


+ 37
- 0
examples/vco.scd View File

@@ -0,0 +1,37 @@
// Voltage-controlled oscillator example
// by Andrew Belt
// adapted for SC by Brian Heim

~vcv_frameDivider = 1;
~vcv_bufferSize = 32;

~phase = 0;
~vcv_process = { |block|

var pitch, freq, deltaPhase;

// Knob ranges from -5 to 5 octaves
pitch = block.knobs[0] * 10 - 5;
// Input follows 1V/oct standard
// Take the first input's first buffer value
pitch = pitch + block.inputs[0][0];

// The relationship between 1V/oct pitch and frequency is `freq = 2^pitch`.
// Default frequency is middle C (C4) in Hz.
// https://vcvrack.com/manual/VoltageStandards.html#pitch-and-frequencies
freq = 261.6256 * pow(2, pitch);
postf("Freq: % Hz", freq);

deltaPhase = ~vcv_frameDivider * block.sampleTime * freq;

// Set all samples in output buffer
block.bufferSize.do { |i|
// Accumulate phase & wrap around range [0, 1]
~phase = (~phase + deltaPhase) % 1.0;

// Convert phase to sine output
block.outputs[0][i] = sin(2pi * ~phase) * 5;
};

block
}

Loading…
Cancel
Save