Skip to content

Commit

Permalink
added ShaperOS and OscOS3
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Pluta committed Apr 15, 2024
1 parent 7d34564 commit 4e253ee
Show file tree
Hide file tree
Showing 39 changed files with 2,230 additions and 616 deletions.
Binary file modified .DS_Store
Binary file not shown.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ add_library(FM7aOS MODULE OversamplingOscillators.cpp)
add_library(FM7bOS MODULE OversamplingOscillators.cpp)
add_library(PM7OS MODULE OversamplingOscillators.cpp)

add_library(BuchlaFoldOS MODULE OversamplingWavefolders.cpp)
add_library(SergeFoldOS MODULE OversamplingWavefolders.cpp)

add_library(SawBL MODULE OversamplingOscillators.cpp)
add_library(SquareBL MODULE OversamplingOscillators.cpp)
add_library(ImpulseBL MODULE OversamplingOscillators.cpp)
add_library(TriBL MODULE OversamplingOscillators.cpp)

#add_library(ShaperOS MODULE OversamplingWavetableOsc.cpp)
add_library(ShaperOS MODULE OversamplingWavefolders.cpp)
add_library(OscOS MODULE OversamplingWavefolders.cpp)
add_library(ShaperOS MODULE OversamplingWavetableOscillators.cpp)
add_library(ShaperOS2 MODULE OversamplingWavetableOscillators.cpp)
add_library(OscOS MODULE OversamplingWavetableOscillators.cpp)
add_library(OscOS2 MODULE OversamplingWavetableOscillators.cpp)
add_library(OscOS3 MODULE OversamplingWavetableOscillators.cpp)
add_library(BuchlaFoldOS MODULE OversamplingWavetableOscillators.cpp)
add_library(SergeFoldOS MODULE OversamplingWavetableOscillators.cpp)
13 changes: 4 additions & 9 deletions OversamplingOscillators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ namespace SawOS
const float *phase = in(Phase);
float *outbuf = out(Out1);

int over_sampling_ratio = oversample.getOversamplingRatio();

for (int i = 0; i < nSamples; ++i)
{
float out;
for (int k = 0; k < oversample.getOversamplingRatio(); k++)
osBuffer[k] = saw.next(freq[i], phase[i], m_freqMul / oversample.getOversamplingRatio());
for (int k = 0; k < over_sampling_ratio; k++)
osBuffer[k] = saw.next(freq[i], phase[i], m_freqMul / over_sampling_ratio);
if (m_oversamplingIndex != 0)
out = oversample.downsample();
else
Expand Down Expand Up @@ -103,11 +105,6 @@ namespace SinOscOS
float out = saw.next(freq, phase + m_phaseOffset, m_freqMul); // saw returns a value between -1 and 1
m_val = sin((out + 1) * pi);
return m_val;
// return sinTable.lookup((out+1.f)*2048.f);
// for(int k = 0; k<overSamplingRatio; k++)
// osBuffer[k] = saw.next(freq, phase, m_freqMul/overSamplingRatio);
// for (int i2 = 0; i2 < overSamplingRatio; i2++)
// osBuffer[i2] = sinTable.lookup((osBuffer[i2]+1.f)*2048.f);
}

SinOSNext::~SinOSNext() {}
Expand Down Expand Up @@ -332,8 +329,6 @@ namespace FM7bOS
mods[i][j] = in(4 + j + (i * 4));
}

//Print("%i \n", m_oversamplingIndex);

float freqs2[4];

int wavetypes[4];
Expand Down
Binary file added OversamplingOscillators.zip
Binary file not shown.
14 changes: 7 additions & 7 deletions OversamplingOscillators/HelpSource/BuchlaFoldOS.schelp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TITLE:: BuchlaFoldOS
summary:: Oversampled Buchla 259 shaped Wavefolder
categories:: UGens>Distortion
related:: SergeFoldOS, SinOscOS, TriOS, SawOS, SquareOS, VarSawOS, PMOscOS, PM7OS, FM7OS
related:: SergeFoldOS, ShaperOS, ShaperOS2

DESCRIPTION::
A wavefolder in the shape of the classic Buchla 259 wavefolder. Derived from LINK::http://https://www.researchgate.net/publication/337591033_Virtual_Analog_Buchla_259_Wavefolder?enrichId=rgreq-24e9bcbf39508bb5b2598f920279b17c-XXX&enrichSource=Y292ZXJQYWdlOzMzNzU5MTAzMztBUzo4MzAwODY2MjY0MzA5NzdAMTU3NDkxOTQ4MjI1OQ%3D%3D&el=1_x_2&_esc=publicationCoverPdf##Virual Analog Buchla 259e Wavefolder ::
Expand Down Expand Up @@ -34,9 +34,9 @@ code::
(
{
var sig = SinOsc.ar(40);
var amp = MouseX.kr(0,10).poll;
var amp = MouseX.kr(0,20).poll;
var out = BuchlaFoldOS.ar(sig, amp, 1);
out.dup
out.dup*0.2
}.scope
)

Expand All @@ -57,7 +57,7 @@ code::
var v5 = buchlaCell.(sig, sign, 4.08, 0.2673, 1.0907, 36.363);
var v6 = sig*5;
var out = ((v1+v2+v3*(-1)))+v4+v5+v6;
out/5
out/5*0.2
}.scope
)

Expand All @@ -67,7 +67,7 @@ code::
var sig = SinOsc.ar(40);
var amp = MouseX.kr(0,20).poll;
var out = BuchlaFoldOS.ar(sig, amp, 1);
out.tanh.dup
out.tanh.dup*0.2
}.scope
)

Expand All @@ -81,7 +81,7 @@ code::
var out = BuchlaFoldOS.ar(sig, amp, 4);
out = LPF.ar(out, 4000);

out.tanh.dup
out.tanh.dup*0.2
}.scope
)

Expand All @@ -96,7 +96,7 @@ code::

out = LPF.ar(out.tanh, 4000);

out.dup
out.dup*0.2
}.scope
)

Expand Down
130 changes: 130 additions & 0 deletions OversamplingOscillators/HelpSource/FM7aOS.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
TITLE:: FM7aOS
summary:: an oversampled 4 oscillator cluster
categories:: UGens>Oscillator
related:: FM7bOS, FM7OS

DESCRIPTION::
4 oscillators, each able to be any of the 4 basic waveforms, and each able to modulate one another with 0 or 1 sample delay at the oversampling frequency. in other words, at 96K, these could modulate each other 1.536 million times per second.

FM7aOS and FM7bOS are similar; FM7aOS uses Chowning style through-zero modulation. FM7bOS uses analog synth "1V/Oct" style modulation.

CLASSMETHODS::

METHOD:: ar


ARGUMENT:: ctlMatrix
a 4 value array, with each value being an audio-rate frequency value for the 4 oscillators

ARGUMENT:: modMatrix
a 4X4 matrix, with each 4 value sub-array being the amount the current oscillator is modulated by the other oscillators

ARGUMENT:: synthTypes
a 4 value array, with each value indicating the type of oscillator to use
0=Sine Wave, 1=Triangle, 2=Square, 3=Saw

ARGUMENT:: oversample
OverSampling Index

0 = none, 1 = 2x, 2 = 4x, 3 = 8x, 4 = 16x

ARGUMENT:: mul
mul

ARGUMENT:: add
add


EXAMPLES::

code::
(
{
var ctls, mods, chans, synth_type;
ctls = [
// freq
400, 300, 300*3/4, 0
];
//modulation amount from each oscillator
mods = [
[0, MouseX.kr(0,2000), 0, 0],
[MouseY.kr(0,2000),0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
chans = [0,0];
//0 = sine, 1 = tri, 2 = square, 3 = saw
synth_type = [3,2,0,0];
FM7aOS.ar(ctls, mods*2, synth_type).slice(chans) * 0.1;
}.scope;
)

//a gui controlling 3 synths feeding back on each other

(
var win, gui;
var synth = {
var ctls, mods, chans, sound;
ctls = [
// freq, phase, amp
\freq0.ar(200),
\freq1.ar(200),
\freq2.ar(200),
0
];
mods = [
[0, \mod0.ar(250), \mod1.ar(250), 0],
[\mod2.ar(250), 0, \mod3.ar(250), 0],
[\mod4.ar(250), \mod5.ar(250), 0, 0],
[0, 0, 0, 0]
];
chans = [0,0];
sound = FM7aOS.ar(ctls, mods, [\osc0.ar(2),\osc1.ar(3),\osc2.ar(3)], 4).softclip;

sound[0].dup*0.1;

}.play;

var labels = ["freq0", "freq1", "freq2", "mod0", "mod1", "mod2", "mod3", "mod4", "mod5", "osc0", "osc1", "osc2"];

var specs = [ControlSpec(0.01,4000, 'exp'), ControlSpec(0,3000), ControlSpec(0,3,'lin', 1)];

var label_boxes = labels.size.collect{|i| StaticText().string_(labels[i])};

var boxes = labels.size.collect{|i| NumberBox()};

var sliders = labels[0..2].collect{|item, i|
Slider().action_{|sl|
var num = specs[0].map(sl.value);
synth.set(labels[i].asSymbol, num);
boxes[i].value_(num)
}}
.addAll(labels[3..8].collect{|item, i|
Slider().action_{|sl|
var num = specs[1].map(sl.value);
synth.set(labels[i].asSymbol, num);
boxes[i+3].value_(num)
}})
.addAll(labels[9..11].collect{|item, i|
Slider().action_{|sl|
var num = specs[2].map(sl.value);
synth.set(labels[i].asSymbol, specs[2].map(sl.value));
boxes[i+9].value_(num)
}});

sliders.do{|slider| slider.valueAction_(1.0.rand)};


win = Window("");
win.layout =
VLayout(
HLayout(*label_boxes),
HLayout(*sliders),
HLayout(*boxes)
);
win.front;

win.onClose_({synth.free});
)

::
130 changes: 130 additions & 0 deletions OversamplingOscillators/HelpSource/FM7bOS.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
TITLE:: FM7bOS
summary:: an oversampled 4 oscillator cluster
categories:: UGens>Oscillator
related:: FM7aOS, FM7OS

DESCRIPTION::
4 oscillators, each able to be any of the 4 basic waveforms, and each able to modulate one another with 0 or 1 sample delay at the oversampling frequency. in other words, at 96K, these could modulate each other 1.536 million times per second.

FM7aOS and FM7bOS are similar; FM7aOS uses Chowning style through-zero modulation. FM7bOS uses analog synth "1V/Oct" style modulation.

CLASSMETHODS::

METHOD:: ar


ARGUMENT:: ctlMatrix
a 4 value array, with each value being an audio-rate frequency value for the 4 oscillators

ARGUMENT:: modMatrix
a 4X4 matrix, with each 4 value sub-array being the amount the current oscillator is modulated by the other oscillators

ARGUMENT:: synthTypes
a 4 value array, with each value indicating the type of oscillator to use
0=Sine Wave, 1=Triangle, 2=Square, 3=Saw

ARGUMENT:: oversample
OverSampling Index

0 = none, 1 = 2x, 2 = 4x, 3 = 8x, 4 = 16x

ARGUMENT:: mul
mul

ARGUMENT:: add
add


EXAMPLES::

code::
(
{
var ctls, mods, chans, synth_type;
ctls = [
// freq
400, 300, 300*3/4, 0
];
//modulation amount from each oscillator
mods = [
[0, MouseX.kr(0,2000), 0, 0],
[MouseY.kr(0,2000),0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
chans = [0,0];
//0 = sine, 1 = tri, 2 = square, 3 = saw
synth_type = [3,2,0,0];
FM7aOS.ar(ctls, mods*2, synth_type).slice(chans) * 0.1;
}.scope;
)

//a gui controlling 3 synths feeding back on each other

(
var win, gui;
var synth = {
var ctls, mods, chans, sound;
ctls = [
// freq, phase, amp
\freq0.ar(200),
\freq1.ar(200),
\freq2.ar(200),
0
];
mods = [
[0, \mod0.ar(250), \mod1.ar(250), 0],
[\mod2.ar(250), 0, \mod3.ar(250), 0],
[\mod4.ar(250), \mod5.ar(250), 0, 0],
[0, 0, 0, 0]
];
chans = [0,0];
sound = FM7aOS.ar(ctls, mods, [\osc0.ar(2),\osc1.ar(3),\osc2.ar(3)], 4).softclip;

sound[0].dup*0.1;

}.play;

var labels = ["freq0", "freq1", "freq2", "mod0", "mod1", "mod2", "mod3", "mod4", "mod5", "osc0", "osc1", "osc2"];

var specs = [ControlSpec(0.01,4000, 'exp'), ControlSpec(0,3000), ControlSpec(0,3,'lin', 1)];

var label_boxes = labels.size.collect{|i| StaticText().string_(labels[i])};

var boxes = labels.size.collect{|i| NumberBox()};

var sliders = labels[0..2].collect{|item, i|
Slider().action_{|sl|
var num = specs[0].map(sl.value);
synth.set(labels[i].asSymbol, num);
boxes[i].value_(num)
}}
.addAll(labels[3..8].collect{|item, i|
Slider().action_{|sl|
var num = specs[1].map(sl.value);
synth.set(labels[i].asSymbol, num);
boxes[i+3].value_(num)
}})
.addAll(labels[9..11].collect{|item, i|
Slider().action_{|sl|
var num = specs[2].map(sl.value);
synth.set(labels[i].asSymbol, specs[2].map(sl.value));
boxes[i+9].value_(num)
}});

sliders.do{|slider| slider.valueAction_(1.0.rand)};


win = Window("");
win.layout =
VLayout(
HLayout(*label_boxes),
HLayout(*sliders),
HLayout(*boxes)
);
win.front;

win.onClose_({synth.free});
)

::
4 changes: 2 additions & 2 deletions OversamplingOscillators/HelpSource/OscOS.schelp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TITLE:: OscOS
summary:: Oversampled Wavetable Oscillator
categories:: Undocumented classes, UGens>Undocumented
related:: BuchlaFoldOS, ShaperOS
categories:: UGens>Oscillator
related:: BuchlaFoldOS, ShaperOS, OscOS3

DESCRIPTION::
An oversampled wavetable oscillator that interpolates between adjacent tables.
Expand Down
Loading

0 comments on commit 4e253ee

Please sign in to comment.