AudioBlog Header

In most guitar amplifiers a negative feedback loop is incorporated to flatten the frequency response and reduce noise, often taken from one of the speaker taps on the output transformer back to the cathode of one of the preamp valves. As this is not possible with the current valve models I decided to wrap the loop around various combinations of valves to see the results.

It is important that the feedback signal is 180 degrees out of phase with the original signal to ensure that he feedback is negative otherwise we will end up with howling feedback.

The valve models already invert the signal so if feedback is implemented around an odd number of valves no extra processing is necessary, if an even number the signal must be inverted.

Generally the level of feedback in guitar amps results in an overall gain reduction of between 6-10dB.

/*
	Experiments with Guitarix Components

	Series of experiments with aim of using the "tube" components 
	to build amplifiers as close as possible in topology as real valve amplifiers

	Steve Poskitt 2013

	Blog 1 - single valve stage
	Blog 2 - cascade valves to see effects of overload
	Blog 3 - add some NEGATIVE FEEDBACK and look at effects of filtering feedback loop
*/
import("guitarix.lib");

// Input gain so can test overload
gain =  vslider("Gain[alias][style:knob]",0,-20,20,0.1):db2linear: smoothi(0.999);
// A valve is represented by the tubestage function
// By time gain is at +6dB there are numerous harmonics above 22k with 1kHz input sine
// so there is a need for a lowpass filter to calm this down.
// Similarly you can also see harmonics at the very low end which could also cause problems
// In a guitar amp this is no problem as likely to roll off above 6500Hz anyhow

stage2 =  tubestage(TB_12AX7_250k,10.0,1500.0,1.204285):highpass( 2,40):lowpass( 2, 18000 ) ; 
stage1 = tubestage(TB_12AX7_68k,10.0,1500.0,1.204541) ;

feedback =  vslider("Feedback[alias][style:knob]",-60,-60,0.0,0.1):db2linear: smoothi(0.999);
// cascade produces more harmonics and a thicker distortion
// Suing sub as need to make feedback negative
// Once we get to around -6dB feedback gain we get mental high frequencies
// try lowpass on feedback loop to stop this helps but needs to be quite low
// With -3dB of feedback ( giving around 4dB reduction in output signal )
// we need lowpass at around 13400
// In guitarix amp sims they use 6531 lowpass in between stages 

// Listening the feedback does have the effect of tightening the sound some and reducing harmonics
// so could be useful as feedback tone is definitely different   
// Interestingly can apply 0dB feedback as long as lowpass is as low as 6900Hz
// any frequencies above that and level of feedback severely restricted
// Maybe due to phase shift as on scope there is a fair amount ( filters??? )
freq =  vslider("Freq[alias][style:knob]",20000,5000,20000,100);
process =(sub:stage1:*(gain):stage2)~(lowpass( 1, freq):*(feedback));

Several Faust models later the results are pretty promising but do come with some problems. Seems that the feedback signal needs careful filtering as the mixing of the feedback and original signal produces aliasing artifacts and these can result in additive feedback at high frequencies. More tweaking need to get the best compromise here.

 

Next step is to cascade several valve stages together and see what happens.

Using same single valve stage as previously now was time to see what happens when multiple stages are cascaded together, each stage being capable of overloading the next as in a real amplifier. Several parts of an original circuit are fairly straightforward to simulate with simple lowpass filters, in particular CR ( Capacitor-Resistor ) filters are commonly used between stages to block DC and to tailor the low frequency response of the circuit. In a real amp too much low frequency content can cause muddying of the sound as the low frequencies are of a higher energy than the high frequencies and distort much sooner. Looking at any circuit diagram of a Marshall amplifier reveals that the low frequencies are heavily reduced in the early stages to enable more distortion in the later stages yet retain a reasonable sound at the output, this is achieved using a bypass capacitor on the cathode resistor.


/*
    Experiments with Guitarix Components

    Series of experiments with aim of using the "tube" components
    to build amplifiers as close as possible in topology as real valve amplifiers

    Steve Poskitt Copyright 2013

    Blog 2 - cascade valves to see effects of overload
*/
import("guitarix.lib");

// Input gain so can test overload
gain =  vslider("Gain[alias][style:knob]",0,-20,20,0.1):db2linear: smoothi(0.999);
// A valve is represented by the tubestage function
// By time gain is at +6dB there are numerous harmonics above 22k with 1kHz input sine
// so there is a need for a lowpass filter to calm this down.
// Similarly you can also see harmonics at the very low end which could also cause problems
// In a guitar amp this is no problem as likely to roll off above 6500Hz anyhow

stage2 =  tubestage(TB_12AX7_250k,10.0,1500.0,1.204285):highpass( 2,40):lowpass( 2, 18000 ) ;
stage1 = tubestage(TB_12AX7_68k,10.0,1500.0,1.204541) ;

// cascade produces more harmonics and a thicker distortion
process = stage1:*(gain):stage2;

Again results very promising as frequency plots show as gain is increased the number of harmonics and their levels increase accordingly. As in a real circuit the distortion was heard to gradually increase until a certain level and then become unlistenable. Listening tests again confirm that the sound was very similar to that of a real amplifier.

Next step NFB( Negative Feedback Loops ).

 

 

 

As my aim was both to learn the intricacies of audio DSP programming and to assess the quality of valve simulations using DSP code I decided that the first project should just be a very simply one stage valve preamplifier, a simple task as the valve models are already coded and provided in the Guitarix framework.

Real valve amplifiers are incredibly simple in construction as valves are already basic voltage amplifiers ( unlike transistors which are basically high speed switches ). A single stage amplifier consists of one half of a small triode valve, 3 resistors and 1 or 2 capacitors plus the power source. The operating point of the valve is controlled by the values of these components and can be tuned for the intended purpose ( highest gain, cleanest signal etc etc ). In guitar amps it is not always required to find the operating point with least distortion so chosen values are mostly different from those found in hi-fi amps as some form of harmonic distortion is a necessary part of the final sound.

The valve models in Guitarix are based on ........ and are implemented using a lookup table generated with various parts of the circuit predefined ( power supply voltage, anode resistor, input resistor ). The resulting model can be tweaked at run time as the cathode resistor and resulting bias value are variables. The following values were used for initial experiments as they are the most common in guitar preamplifiers :

Valve 12AX7

Power Supply voltage 250V

Anode resistor 100k

Input/grid resistor 68k

Cathode resistor 1k5

Bias voltage 1.2V

/*
	Experiments with Guitarix Components
 
	Series of experiments with aim of using the "tube" components 
	to build amplifiers as close as possible in topology as real valve amplifiers
 
	Steve Poskitt Copyright 2013
 
*/
import("guitarix.lib");
 
// Input gain so can test overload
gain =  vslider("Gain[alias][style:knob]",0,-20,20,0.1):db2linear: smoothi(0.999);
// A valve is represented by the tubestage function
// By time gain is at +6dB there are numerous harmonics above 22k with 1kHz input sine
// so there is a need for a lowpass filter to calm this down.
// Similarly you can also see harmonics at the very low end which could also cause problems
// In a guitar amp this is no problem as likely to roll off above 6500Hz anyhow
stage1 =  tubestage(TB_12AX7_250k,40.0,1500.0,1.204285):highpass( 2,40):lowpass( 2, 18000 ) ; 
process = *(gain):stage1;

Results were promising, frequency analysis shows production of various harmonics, predominately even order with lower odd order too, the level of harmonics increased with level of input signal until distortion became audible. Generally a good result as in listening tests the result compared favorably with a real circuit, not identical but then the valve model does not take in to consideration phase distortions and the difference in sound of different manufacturers valves.

Next Step is to experiment with different cathode resistor values and compare results.

Choosing the tools.

As my interest had been sparked by the open source project Guitarix I decided to use that as a framework for my experiments, this would save a lot of programming time, as the framework already existed, and ease the learning curve for DSP prigramming as it makes use of the excellent Faust DSP programming language and its FaustWorks user interface. This enables the user to very quickly develop DSP algorithms and test them as it autogenerates highly optimised DSP code and builds a variety of different plugin architectures on the fly. Check it out at http://faust.grame.fr/.

 After a very short time I was happily writing DSP code in Faust and so ready to start the experiment.