aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jsyn/unitgen/PhaseShifter.java
diff options
context:
space:
mode:
authorRubbaBoy <[email protected]>2020-07-06 02:33:28 -0400
committerPhil Burk <[email protected]>2020-10-30 11:19:34 -0700
commit46888fae6eb7b1dd386f7af7d101ead99ae61981 (patch)
tree8969bbfd68d2fb5c0d8b86da49ec2eca230a72ab /src/com/jsyn/unitgen/PhaseShifter.java
parentc51e92e813dd481603de078f0778e1f75db2ab05 (diff)
Restructured project, added gradle, JUnit, logger, and more
Added Gradle (and removed ant), modernized testing via the JUnit framework, moved standalone examples from the tests directory to a separate module, removed sparsely used Java logger and replaced it with SLF4J. More work could be done, however this is a great start to greatly improving the health of the codebase.
Diffstat (limited to 'src/com/jsyn/unitgen/PhaseShifter.java')
-rw-r--r--src/com/jsyn/unitgen/PhaseShifter.java90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/com/jsyn/unitgen/PhaseShifter.java b/src/com/jsyn/unitgen/PhaseShifter.java
deleted file mode 100644
index 4b17245..0000000
--- a/src/com/jsyn/unitgen/PhaseShifter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2014 Phil Burk, Mobileer Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.jsyn.unitgen;
-
-import com.jsyn.ports.UnitInputPort;
-
-/**
- * PhaseShifter effects processor. This unit emulates a common guitar pedal effect but without the
- * LFO modulation. You can use your own modulation source connected to the "offset" port. Different
- * frequencies are phase shifted varying amounts using a series of AllPass filters. By feeding the
- * output back to the input we can get varying phase cancellation. This implementation was based on
- * code posted to the music-dsp archive by Ross Bencina. http://www.musicdsp.org/files/phaser.cpp
- *
- * @author (C) 2014 Phil Burk, Mobileer Inc
- * @see FilterLowPass
- * @see FilterAllPass
- * @see RangeConverter
- */
-
-public class PhaseShifter extends UnitFilter {
- /**
- * Connect an oscillator to this port to sweep the phase. A range of 0.05 to 0.4 is a good
- * start.
- */
- public UnitInputPort offset;
- public UnitInputPort feedback;
- public UnitInputPort depth;
-
- private double zm1;
- private double[] xs;
- private double[] ys;
-
- public PhaseShifter() {
- this(6);
- }
-
- public PhaseShifter(int numStages) {
- addPort(offset = new UnitInputPort("Offset", 0.1));
- addPort(feedback = new UnitInputPort("Feedback", 0.7));
- addPort(depth = new UnitInputPort("Depth", 1.0));
-
- xs = new double[numStages];
- ys = new double[numStages];
- }
-
- @Override
- public void generate(int start, int limit) {
- double[] inputs = input.getValues();
- double[] outputs = output.getValues();
- double[] feedbacks = feedback.getValues();
- double[] depths = depth.getValues();
- double[] offsets = offset.getValues();
- double gain;
-
- for (int i = start; i < limit; i++) {
- // Support audio rate modulation.
- double currentOffset = offsets[i];
-
- // Prevent gain from exceeding 1.0.
- gain = 1.0 - (currentOffset * currentOffset);
- if (gain < -1.0) {
- gain = -1.0;
- }
-
- double x = inputs[i] + (zm1 * feedbacks[i]);
- // Cascaded all-pass filters.
- for (int stage = 0; stage < xs.length; stage++) {
- double temp = ys[stage] = (gain * (ys[stage] - x)) + xs[stage];
- xs[stage] = x;
- x = temp;
- }
- zm1 = x;
- outputs[i] = inputs[i] + (x * depths[i]);
- }
- }
-}