Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
55 changes: 0 additions & 55 deletions Active2ndOrderLPF.xml

This file was deleted.

118 changes: 118 additions & 0 deletions CircuitElement/Potentiometer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
classdef Potentiometer < handle
methods
function o = Potentiometer(maxValue,parameterNumber,direction,skew,node1,node2,node3,varargin)
% varargin - optional input variable for a text label (string)

o.maxValue = maxValue;
o.parameterNumber = parameterNumber;
o.value = maxValue;

assert(direction == VariableResistorDirection.PROPORTIONAL || ...
direction == VariableResistorDirection.INVPROPORTIONAL,...
'Invalid Direction, must be VariableResistorDirection.PROPORTIONAL or VariableResistorDirection.INVPROPORTIONAL');
o.direction = direction;

assert(skew == VariableResistorSkew.LINEAR || ...
skew == VariableResistorSkew.LOG,...
'Invalid Skew, must be VariableResistorSkew.LINEAR or VariableResistorSkew.LOG');
o.skew = skew;

o.node1 = node1;
o.node2 = node2;
o.node3 = node3;

if (direction == VariableResistorDirection.PROPORTIONAL)
o.Vr1 = VariableResistor(maxValue,parameterNumber,VariableResistorDirection.PROPORTIONAL,skew,node1,node2,varargin{:});
o.Vr2 = VariableResistor(maxValue,parameterNumber,VariableResistorDirection.INVPROPORTIONAL,skew,node2,node3,varargin{:});
else
o.Vr1 = VariableResistor(maxValue,parameterNumber,VariableResistorDirection.INVPROPORTIONAL,skew,node1,node2,varargin{:});
o.Vr2 = VariableResistor(maxValue,parameterNumber,VariableResistorDirection.PROPORTIONAL,skew,node2,node3,varargin{:});
end

if (~isempty(varargin))
if (isstring(varargin{1,1}) || ischar(varargin{1,1}))
o.label = varargin{1,1};
end

if (length(varargin) == 2)
if (isstring(varargin{1,2}) || ischar(varargin{1,2}))
o.label = varargin{1,2};
end
end
end
end

function [Vr1] = getVariableResistor1(o)
Vr1 = o.Vr1;
end
function [Vr2] = getVariableResistor2(o)
Vr2 = o.Vr2;
end
function [maxValue] = getMaxValue(o)
maxValue = o.maxValue;
end
function [parameterNumber] = getParameterNumber(o)
parameterNumber = o.parameterNumber;
end
function setParameterNumber(o,parameterNumber)
o.parameterNumber = parameterNumber;
o.Vr1.setParameterNumber(parameterNumber);
o.Vr2.setParameterNumber(parameterNumber);
end
function setValue(o,value)
o.value = value;
o.Vr1.setValue(value);
o.Vr2.setValue(value);
end
function [value] = getNormValue(o)
value = o.value;
end
function [node1] = getNode1(o)
node1 = o.node1;
end
function [node2] = getNode2(o)
node2 = o.node2;
end
function [node3] = getNode3(o)
node3 = o.node3;
end
function [direction] = getDirection(o)
direction = o.direction;
end
function [skew] = getSkew(o)
skew = o.skew;
end
function [label] = getLabel(o)
label = o.label;
end
end

properties (Access = private)
maxValue;
value;
parameterNumber;
direction;
skew;
node1;
node2;
node3;
label = '';

Vr1;
Vr2;
end

methods (Access = private)
function setNormValue(o,normValue)
if (normValue < 0)
o.normValue = 0;
elseif (normValue > 1)
o.normValue = 1;
else
o.normValue = normValue;
end
end
end

end

24 changes: 22 additions & 2 deletions CircuitElement/VariableResistor.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
classdef VariableResistor < handle
methods
function o = VariableResistor(maxValue,parameterNumber,direction,skew,node1,node2,varargin)
% varargin - optional input variable for a text label (string)
% varargin{1} - optional input variable for a text label (string)
% varargin{2} - optional input variable for starting value

o.maxValue = maxValue;
o.parameterNumber = parameterNumber;
Expand All @@ -22,7 +23,23 @@
o.node2 = node2;

if (~isempty(varargin))
o.label = varargin{1,1};
if (isstring(varargin{1,1}) || ischar(varargin{1,1}))
% This must be text for the label
o.label = varargin{1,1};
else
% If not text, then it could be the starting value
setValue(o,varargin{1,1});
end

if (length(varargin) == 2)
if (isstring(varargin{1,2}) || ischar(varargin{1,2}))
% This must be text for the label
o.label = varargin{1,2};
else
% If not text, then it could be the starting value
setValue(o,varargin{1,2});
end
end
end
end
function [maxValue] = getMaxValue(o)
Expand All @@ -41,6 +58,9 @@ function setValue(o,normValue)
calculateValue(o);
value = o.value;
end
function [normValue] = getNormValue(o)
normValue = o.normValue;
end
function [node1] = getNode1(o)
node1 = o.node1;
end
Expand Down
16 changes: 12 additions & 4 deletions CircuitModel/Circuit.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ function prepare(o,sampleRate,bufferSize)
o.circuit.prepare(sampleRate,bufferSize);
end

function setSamples4Smooth(o,samples4Smooth)
o.circuit.setSamples4Smooth(samples4Smooth);
function setParameterUpdateIntervalInSamples(o,samples4Smooth)
o.circuit.setParameterUpdateIntervalInSamples(samples4Smooth);
end

function [remainingParameters] = setParameters(o,parameters)
remainingParameters = o.circuit.setParameters(parameters);
function setSmoothResponseTimeMilliseconds(o,milliseconds)
o.circuit.setSmoothResponseTimeMilliseconds(milliseconds);
end

function [remainingParameters] = setParametersWithSmoothing(o,parameters)
remainingParameters = o.circuit.setParametersWithSmoothing(parameters);
end

function [remainingParameters] = setParametersNoSmoothing(o,parameters)
remainingParameters = o.circuit.setParametersNoSmoothing(parameters);
end
end
end
21 changes: 17 additions & 4 deletions CircuitModel/CircuitChain.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,29 @@ function prepare(o,sampleRate,bufferSize)
end
end

function setSamples4Smooth(o,samples4Smooth)
function setParameterUpdateIntervalInSamples(o,samples4Smooth)
for m = 1:length(o.circuitChain)
o.circuitChain{m,1}.setSamples4Smooth(samples4Smooth);
o.circuitChain{m,1}.setParameterUpdateIntervalInSamples(samples4Smooth);
end
end

function setSmoothResponseTimeMilliseconds(o,milliseconds)
for m = 1:length(o.circuitChain)
o.circuitChain{m,1}.setSmoothResponseTimeMilliseconds(milliseconds);
end
end

function [remainingParameters] = setParameters(o,parameters)
function [remainingParameters] = setParametersWithSmoothing(o,parameters)
remainingParameters = parameters;
for m = 1:length(o.circuitChain)
remainingParameters = o.circuitChain{m,1}.setParametersWithSmoothing(remainingParameters);
end
end

function [remainingParameters] = setParametersNoSmoothing(o,parameters)
remainingParameters = parameters;
for m = 1:length(o.circuitChain)
remainingParameters = o.circuitChain{m,1}.setParameters(remainingParameters);
remainingParameters = o.circuitChain{m,1}.setParametersNoSmoothing(remainingParameters);
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions CircuitModel/CircuitLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
Vs;
Rs;
VarRs;
Pots;
Cs;
OPAmps;
Ds;
BJTs;
Tube12AX7s;
Output;
hasDCBlocker = false;
end

Expand All @@ -21,11 +23,13 @@
o.Vs = [];
o.Rs = [];
o.VarRs = [];
o.Pots = [];
o.Cs = [];
o.OPAmps = [];
o.Ds = [];
o.BJTs = [];
o.Tube12AX7s = [];
o.Output = [];
end
end

Expand Down
Binary file modified CircuitModel/CircuitModel.p
Binary file not shown.
8 changes: 6 additions & 2 deletions CircuitModel/CircuitProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@

prepare(o,sampleRate,bufferSize)

setSamples4Smooth(o,samples4Smooth)
setParameterUpdateIntervalInSamples(o,samples4Smooth)

setSmoothResponseTimeMilliseconds(o,milliseconds)

setParameters(o,parameters)
setParametersWithSmoothing(o,parameters)

setParametersNoSmoothing(o,parameters)
end
end
25 changes: 25 additions & 0 deletions Circuits/AmpClippers/Am_B15_Stage_1_A.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
classdef Am_B15_Stage_1_A < Circuit

methods
function [o] = Am_B15_Stage_1_A

o.layout.numNodes = 5;
o.layout.Vin = VoltageInput (1, 0);
o.layout.Vout = VoltageOutput (4, 0);
o.layout.Vs = VoltageSource (500, 5);

R1 = Resistor (47e3, 1, 2);
R2 = Resistor (5.6e6, 2, 0);
R3 = Resistor (5.6e6, 3, 0);
R4 = Resistor (470e3, 4, 5);
o.layout.Rs = [R1; R2; R3; R4];

TUBE1 = Tube12AX7 (Model12AX7.EXH, 2, 4, 3);
o.layout.Tube12AX7s = TUBE1;

o.layout.hasDCBlocker = true;

o.circuit = CircuitModel (o.layout);
end
end
end
28 changes: 28 additions & 0 deletions Circuits/AmpClippers/Am_B15_Stage_1_B.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
classdef Am_B15_Stage_1_B < Circuit

methods
function [o] = Am_B15_Stage_1_B

o.layout.numNodes = 5;
o.layout.Vin = VoltageInput (1, 0);
o.layout.Vout = VoltageOutput (4, 0);
o.layout.Vs = VoltageSource (500, 5);

R1 = Resistor (100e3, 1, 2);
R2 = Resistor (5.6e6, 2, 0);
R3 = Resistor (5.6e6, 3, 0);
R4 = Resistor (470e3, 4, 5);
o.layout.Rs = [R1; R2; R3; R4];

C1 = Capacitor (0.005e-6, 1, 2);
o.layout.Cs = C1;

TUBE1 = Tube12AX7 (Model12AX7.EXH, 2, 4, 3);
o.layout.Tube12AX7s = TUBE1;

o.layout.hasDCBlocker = true;

o.circuit = CircuitModel (o.layout);
end
end
end
Loading