FAUST integration with Teensy 4.0

Hi guys!

So I'm trying to emulate a tube amp using a Teensy 4.0. I'm looking into a WDF methodology to do so and I'm experimenting with FAUST in order to implement WDF with their built-in libraries.

I'm still testing Teensy to see how far can it go in terms of processing nonlinearities so I'm trying to run a TubeScreamer FAUST code I found online which is listed below.

import("stdfaust.lib");

stage_a(in1) = wd.buildtree(tree_a)
with{
//nodes
vinA(i) = wd.u_resVoltage(i,1,in1);
c2(i) = wd.capacitor(i, 1*10^-6);
vB(i) = wd.resVoltage_Vout(i, 10*10^3, 4.5);
rA(i) = wd.resistor(i,220);
//declare connection tree
tree_a = vinA : wd.series : (c2, (wd.series : (rA, vB)));
};

stage_b(in1) = wd.buildtree(tree_b)
with{
//nodes
vinB(i) = wd.u_voltage(i,in1);
c3(i) = wd.capacitor(i, 0.047*10^-6);
r4(i) = wd.resistor_Iout(i, 4.7*10^3);
//declare connection tree
tree_b = vinB : wd.series : (c3, r4);
};

stage_c(in1) = wd.buildtree(tree_c)
with{
//nodes
jinC(i) = wd.resCurrent(i, 51*10^3+pot1*10^3, in1);
d1(i) = wd.u_diodeAntiparallel(i, 2.52*10^-9, 25.85*10^-3, 1, 1);
c4(i) = wd.capacitor_Vout(i, 41*10^-12);
tree_c = d1 : wd.parallel : (c4, jinC);
//declare connection tree
//pot1 = hslider("distortion 0 - 500k", 250, 0, 500, 0.1);
pot1=500;
};

//ingain = hslider("input gain", 1, 0, 1, 0.01);
//ingain=1;
ingain = nentry("input gain", 1, 0, 1, 0.01) : si.smoo;

inputprotect(in) = in*((in < clip) & (in > -clip)) + clip*(in > clip) + -clip*(in < -clip)
with{
//clip=0.026;
clip=nentry("clip", 0.026, 0, 1, 0.001) : si.smoo;
};

//onState = checkbox("On");
onState=1;
//att=0.1;
att=1;

gaincorrect(in) = in*(onState*-1 + 1)*10 + in;

process = _*att*ingain : inputprotect : stage_a <: _, stage_b * onState : _, stage_c : _- _ -4.5 : gaincorrect <: _, _;







Now, I've used the Truck button on FAUST IDE to export the .cpp and the .h of this project into the folder which contains the Arduino code that is going to be uploaded into the Teensy. This code is listed below.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include "tubescreamer.h"

tubescreamer screamer;
AudioInputI2S in;
AudioOutputI2S out;
AudioControlSGTL5000 sgtl5000_1;
AudioConnection patchCord1(in, 1, screamer,1);
AudioConnection patchCord2(in, 0, screamer,0);
AudioConnection patchCord3(screamer,0,out,0);
AudioConnection patchCord4(screamer,1,out,1);
//AudioConnection patchCord3(in, 0, out,0);
//AudioConnection patchCord4(in, 1, out,1);

void setup() {
AudioMemory(24);

// Enable the audio shield
sgtl5000_1.enable();
sgtl5000_1.volume(0.7);


//screamer.setParamValue("onState", 1.0);
screamer.setParamValue("input gain", 1.0);
screamer.setParamValue("clip", 0.001);
//screamer.setParamValue("pot1", 300);
}

void loop() {

}






The problem is I can't hear anything coming out of the AudioShield when I upload it. The synthesis example provided by FAUST (Faust Sawtooth) works so I suspect the problem is the connections with the ADC and/or DAC.

I don't know what I'm doing wrong so I welcome all your insights, thank you! And I'm sorry if I'm doing something dumb but I'm new at this.
 
Last edited:
You've not selected the input on the SGTL5000 or set the output level - perhaps add these in case the defaults aren't what you expect.
Code:
  sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_1.lineOutLevel(15);
Then check loopback works without the screamer in the pipeline, so you can be sure that's where the issue is.

[ I am assuming you are using line in and line out on the audio adapter ]
 
You've not selected the input on the SGTL5000 or set the output level - perhaps add these in case the defaults aren't what you expect.
Code:
  sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_1.lineOutLevel(15);
Then check loopback works without the screamer in the pipeline, so you can be sure that's where the issue is.

[ I am assuming you are using line in and line out on the audio adapter ]

Yes the loopback works perfectly if I take the screamer out of the signal chain. I tried those audioShield commands together with lineIn levelling but it still doesn't work. The problem is not with the connections or the hardware.
 
Back
Top