Skip to content

Commit

Permalink
remove self-fm, use exponential fm for vibrato, aliasing tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyvanoekel committed Oct 14, 2024
1 parent fd22b5b commit 05143c2
Show file tree
Hide file tree
Showing 14 changed files with 2,023 additions and 2,087 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ jobs:
oscilluna-clap/build/Release/Oscilluna.clap
oscilluna-web.zip
tag_name: ${{ github.ref_name }}
name: Oscilluna CLAP Plugin (Windows) - ${{ github.ref_name }}
name: Oscilluna (Windows) - ${{ github.ref_name }}
prerelease: false
2 changes: 1 addition & 1 deletion Oscilluna.cmajorpatch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"CmajorVersion": 1,
"ID": "com.lily.oscilluna",
"version": "0.0.4",
"version": "0.0.5",
"name": "Oscilluna",
"description": "Oscilluna is a creative synthesizer that lets you draw custom waveshapes.",
"category": "generator",
Expand Down
4,035 changes: 1,994 additions & 2,041 deletions docs/cmaj_Oscilluna.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>Oscilluna - Web Demo</h1>
</body>

<script type="module">
import * as patch from "./cmaj_Oscilluna.js";
import * as patch from "./cmaj_Oscilluna.js?v=0.0.5";
import { createPatchViewHolder } from "./cmaj_api/cmaj-patch-view.js";
import PianoKeyboard from "./cmaj_api/cmaj-piano-keyboard.js";

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/view/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Oscilluna</title>
<script type="module" crossorigin src="./assets/index-DcGYXFBQ.js"></script>
<script type="module" crossorigin src="./assets/index-QHDcpc7y.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-ClfZTLdt.css">
</head>
<body>
Expand Down
7 changes: 5 additions & 2 deletions dsp/Controllers/FilterController.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace Synth
int filterRouting = 0;
int modMode = 0;
float depth = 0.0f;
float previousModSample = 0.0f;

event cutoff1(float f) {
filter1lp1.cutoff <- f;
Expand Down Expand Up @@ -81,10 +82,12 @@ namespace Synth
adsr.advance();
} else if (modMode == 4) {
// @todo: look into
modSample = osc1 * 2.5f * depth;
modSample = (previousModSample + (osc1 * 2.5f * depth)) * 0.5f;
previousModSample = modSample;
} else if (modMode == 5) {
// @todo: look into
modSample = osc2 * 2.5f * depth;
modSample = (previousModSample + (osc2 * 2.5f * depth)) * 0.5f;
previousModSample = modSample;
} else if (modMode == 1) {
modSample = lfo.out * depth;
lfo.advance();
Expand Down
17 changes: 8 additions & 9 deletions dsp/Controllers/OscillatorsController.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ namespace Synth
event paramsIn(Params p) {
fm = p.fmDirection;
fmDepth = p.fmDepth;
oscillator1.feedbackFmDepthIn <- p.osc1FeedbackFm;
oscillator2.feedbackFmDepthIn <- p.osc2FeedbackFm;
}
event wavetableIn1(float[] w) { oscillator1.wavetableIn <- w; }
event wavetableIn2(float[] w) { oscillator2.wavetableIn <- w; }
Expand All @@ -46,30 +44,31 @@ namespace Synth

void main() {
float tableSizeFloat = float(TABLE_SIZE);
float vibratoDepthFactor = tableSizeFloat * 0.0002f;

loop {
if (fm == 0) {
oscillator1.gainIn <- osc1Gain;
oscillator2.gainIn <- osc2Gain;
oscillator1.fmIn <- vibrato1 * vibratoDepthFactor * vDepth1;
oscillator2.fmIn <- vibrato2 * vibratoDepthFactor * vDepth2;
oscillator1.fmExpIn <- vibrato1 * vDepth1;
oscillator2.fmExpIn <- vibrato2 * vDepth2;
out1 <- oscillator1.out;
out2 <- oscillator2.out;
} else if (fm == 1) {
oscillator1.gainIn <- osc1Gain;
float osc1Sample = oscillator1.out;
oscillator1.fmIn <- vibrato1 * vibratoDepthFactor * vDepth1;
oscillator1.fmExpIn <- vibrato1 * vDepth1;
oscillator2.gainIn <- osc2Gain;
oscillator2.fmIn <- osc1Sample * fmDepth + vibrato2 * vibratoDepthFactor * vDepth2;
oscillator2.fmExpIn <- vibrato2 * vDepth2;
oscillator2.fmIn <- osc1Sample * fmDepth;
out1 <- osc1Sample;
out2 <- oscillator2.out;
} else {
oscillator2.gainIn <- osc2Gain;
float osc2Sample = oscillator2.out;
oscillator1.gainIn <- osc1Gain;
oscillator1.fmIn <- osc2Sample * fmDepth + vibrato1 * vibratoDepthFactor * vDepth1;
oscillator2.fmIn <- vibrato2 * vibratoDepthFactor * vDepth2;
oscillator1.fmExpIn <- vibrato1 * vDepth1;
oscillator1.fmIn <- osc2Sample * fmDepth;
oscillator2.fmExpIn <- vibrato2 * vDepth2;
out1 <- oscillator1.out;
out2 <- osc2Sample;
}
Expand Down
11 changes: 0 additions & 11 deletions dsp/Params.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ namespace Synth
float osc1VibratoDepth;
float osc2VibratoDepth;

float osc1FeedbackFm;
float osc2FeedbackFm;

int filter1Mode;
float filter1Cutoff;
float filter1Resonance;
Expand Down Expand Up @@ -108,9 +105,6 @@ namespace Synth
p.osc1VibratoDepth = 0.0f;
p.osc2VibratoDepth = 0.0f;

p.osc1FeedbackFm = 0.0f;
p.osc2FeedbackFm = 0.0f;

p.filter1Mode = 0;
p.filter1Cutoff= 8000.0f;
p.filter1Resonance = 0.5f;
Expand Down Expand Up @@ -257,9 +251,6 @@ namespace Synth
input event float osc1_vibrato_depth [[ name: "osc1_vibrato_depth", min: 0.0, max: 1.0, init: 0.0 ]];
input event float osc2_vibrato_depth [[ name: "osc2_vibrato_depth", min: 0.0, max: 1.0, init: 0.0 ]];

input event float osc1_feedback_fm [[ name: "osc1_feedback_fm", min: 0.0, max: 1.0, init: 0.0 ]];
input event float osc2_feedback_fm [[ name: "osc2_feedback_fm", min: 0.0, max: 1.0, init: 0.0 ]];

input event int filter1_mode [[ name: "filter1_mode", min: 0, max: 2, init: 0, text: "Off|LP 1|LP 2" ]];
input event float filter1_cutoff [[ name: "filter1_cutoff", min: 440, max: 18000, init: 2000, step: 1 ]];
input event float filter1_resonance [[ name: "filter1_resonance", min: 0, max: 1, init: 0.5 ]];
Expand Down Expand Up @@ -334,8 +325,6 @@ namespace Synth
event osc2_vibrato_rate (float f) { params.osc2VibratoRate = f; update(); }
event osc1_vibrato_depth (float f) { params.osc1VibratoDepth = f; update(); }
event osc2_vibrato_depth (float f) { params.osc2VibratoDepth = f; update(); }
event osc1_feedback_fm (float f) { params.osc1FeedbackFm = f; update(); }
event osc2_feedback_fm (float f) { params.osc2FeedbackFm = f; update(); }
event filter1_mode (int m) { params.filter1Mode = m; update(); }
event filter1_cutoff (float f) { params.filter1Cutoff = f; update(); }
event filter1_resonance (float f) { params.filter1Resonance = f; update(); }
Expand Down
2 changes: 1 addition & 1 deletion dsp/WaveBuilder.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Synth
}
}

let nyquistFrequency = (processor.frequency / 2.0f) * 0.8f;
let nyquistFrequency = (processor.frequency / 2.0f) * 0.9f;
int halfTableSize = TABLE_SIZE / 2.0f;
for (wrap<WAVETABLE_NUM_BUCKETS> i)
{
Expand Down
14 changes: 6 additions & 8 deletions dsp/WavetableOscillator.cmajor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Synth
input event float[] wavetableIn;
input stream float gainIn;
input stream float fmIn;
input event float feedbackFmDepthIn;
input stream float fmExpIn;
output stream float out;

float64 phase = 0.0f;
Expand All @@ -18,35 +18,33 @@ namespace Synth
float prevSample = 0.0f;
float prevPrevSample = 0.0f;
float feedbackFmDepth = 0.0f;
float invSampleRate = 1.0f / float(processor.frequency);
int indexOffset;

event frequencyIn (float f)
{
freq = f;
wavetableIndex = Util::frequency_to_wavetable_index(freq, WAVETABLE_BUCKETS_MIN_FREQUENCY, WAVETABLE_BUCKETS_MAX_FREQUENCY, WAVETABLE_NUM_BUCKETS);
phaseIncrement = freq * (float(TABLE_SIZE) / float(processor.frequency));
indexOffset = wavetableIndex * TABLE_SIZE;
}

event wavetableIn (float[] newTable) { wavetable = newTable; }
event feedbackFmDepthIn (float f) { feedbackFmDepth = f; }

void main()
{
float tableSizeFloat = float(TABLE_SIZE);
float maxFmIndex = tableSizeFloat * 0.05f;
float maxFmFeedbackIndex = tableSizeFloat * 0.0005f;

float maxExpFmIndex = 0.01f;
let referenceSampleRate = 44100.0f;
let fmAdjust = (referenceSampleRate / float(processor.frequency));

loop
{
float64 localPhase = phase;

let freqMod = freq * fmExpIn * maxExpFmIndex;
phaseIncrement = (freq + freqMod) * (float(TABLE_SIZE) * invSampleRate);
phase += phaseIncrement;
phase += (fmIn + prevfmIn) * maxFmIndex * fmAdjust;
phase -= (prevSample + prevPrevSample) * maxFmFeedbackIndex * feedbackFmDepth * fmAdjust;
prevfmIn = fmIn;

phase -= floor(phase / tableSizeFloat) * tableSizeFloat;
Expand Down
Loading

0 comments on commit 05143c2

Please sign in to comment.