Commit fb2175f1 authored by wargreen's avatar wargreen
Browse files

Cleaning repo

parent 89264ce9
/* ------------------------------------------------------------
author: "Wargreen"
copyright: "(c)Wargreen 2019"
license: "GPL v3"
name: "Ambisonic Encoder"
version: "0.1"
Code generated with Faust 2.15.11 (https://faust.grame.fr)
Compilation options: -vec -lv 0 -vs 64 -ftz 0 -mcd 16
------------------------------------------------------------ */
#ifndef __mydsp_H__
#define __mydsp_H__
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
#include <algorithm>
#include <cmath>
#include <math.h>
#ifndef FAUSTCLASS
#define FAUSTCLASS mydsp
#endif
#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif
class mydsp : public dsp {
private:
int fSamplingFreq;
float fConst0;
float fConst1;
float fConst2;
FAUSTFLOAT fHslider0;
float fRec1_perm[4];
float fConst3;
float fYec0_perm[4];
float fRec0_perm[4];
float fYec1_perm[4];
float fRec2_perm[4];
public:
void metadata(Meta* m) {
m->declare("author", "Wargreen");
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.0");
m->declare("copyright", "(c)Wargreen 2019");
m->declare("filename", "AmbiEnc.0.tmp");
m->declare("filters.lib/name", "Faust Filters Library");
m->declare("filters.lib/version", "0.0");
m->declare("license", "GPL v3");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.1");
m->declare("name", "Ambisonic Encoder");
m->declare("signals.lib/name", "Faust Signal Routing Library");
m->declare("signals.lib/version", "0.0");
m->declare("version", "0.1");
}
virtual int getNumInputs() {
return 2;
}
virtual int getNumOutputs() {
return 2;
}
virtual int getInputRate(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 0;
break;
}
case 1: {
rate = 0;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 1;
break;
}
case 1: {
rate = 1;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
static void classInit(int samplingFreq) {
}
virtual void instanceConstants(int samplingFreq) {
fSamplingFreq = samplingFreq;
fConst0 = std::min<float>(192000.0f, std::max<float>(1.0f, float(fSamplingFreq)));
fConst1 = std::exp((0.0f - (50.0f / fConst0)));
fConst2 = (1.0f - fConst1);
fConst3 = (289026.531f / fConst0);
}
virtual void instanceResetUserInterface() {
fHslider0 = FAUSTFLOAT(1.0f);
}
virtual void instanceClear() {
for (int l0 = 0; (l0 < 4); l0 = (l0 + 1)) {
fRec1_perm[l0] = 0.0f;
}
for (int l1 = 0; (l1 < 4); l1 = (l1 + 1)) {
fYec0_perm[l1] = 0.0f;
}
for (int l2 = 0; (l2 < 4); l2 = (l2 + 1)) {
fRec0_perm[l2] = 0.0f;
}
for (int l3 = 0; (l3 < 4); l3 = (l3 + 1)) {
fYec1_perm[l3] = 0.0f;
}
for (int l4 = 0; (l4 < 4); l4 = (l4 + 1)) {
fRec2_perm[l4] = 0.0f;
}
}
virtual void init(int samplingFreq) {
classInit(samplingFreq);
instanceInit(samplingFreq);
}
virtual void instanceInit(int samplingFreq) {
instanceConstants(samplingFreq);
instanceResetUserInterface();
instanceClear();
}
virtual mydsp* clone() {
return new mydsp();
}
virtual int getSampleRate() {
return fSamplingFreq;
}
virtual void buildUserInterface(UI* ui_interface) {
ui_interface->openVerticalBox("Ambisonic Encoder");
ui_interface->addHorizontalSlider("Radius (m)", &fHslider0, 1.0f, 0.0f, 50.0f, 0.00999999978f);
ui_interface->closeBox();
}
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
FAUSTFLOAT* input0_ptr = inputs[0];
FAUSTFLOAT* input1_ptr = inputs[1];
FAUSTFLOAT* output0_ptr = outputs[0];
FAUSTFLOAT* output1_ptr = outputs[1];
float fSlow0 = (fConst2 * float(fHslider0));
float fRec1_tmp[68];
float* fRec1 = &fRec1_tmp[4];
float fZec0[64];
float fZec1[64];
float fYec0_tmp[68];
float* fYec0 = &fYec0_tmp[4];
float fZec2[64];
float fRec0_tmp[68];
float* fRec0 = &fRec0_tmp[4];
float fYec1_tmp[68];
float* fYec1 = &fYec1_tmp[4];
float fRec2_tmp[68];
float* fRec2 = &fRec2_tmp[4];
int vindex = 0;
/* Main loop */
for (vindex = 0; (vindex <= (count - 64)); vindex = (vindex + 64)) {
FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* input1 = &input1_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex];
FAUSTFLOAT* output1 = &output1_ptr[vindex];
int vsize = 64;
/* Recursive loop 0 */
/* Pre code */
for (int j0 = 0; (j0 < 4); j0 = (j0 + 1)) {
fRec1_tmp[j0] = fRec1_perm[j0];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec1[i] = (fSlow0 + (fConst1 * fRec1[(i - 1)]));
}
/* Post code */
for (int j1 = 0; (j1 < 4); j1 = (j1 + 1)) {
fRec1_perm[j1] = fRec1_tmp[(vsize + j1)];
}
/* Vectorizable loop 1 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec0[i] = (1.0f / std::tan((fConst3 / fRec1[i])));
}
/* Vectorizable loop 2 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec1[i] = (1.0f - fZec0[i]);
}
/* Vectorizable loop 3 */
/* Pre code */
for (int j2 = 0; (j2 < 4); j2 = (j2 + 1)) {
fYec0_tmp[j2] = fYec0_perm[j2];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec0[i] = float(input0[i]);
}
/* Post code */
for (int j3 = 0; (j3 < 4); j3 = (j3 + 1)) {
fYec0_perm[j3] = fYec0_tmp[(vsize + j3)];
}
/* Vectorizable loop 4 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec2[i] = (fZec0[i] + 1.0f);
}
/* Vectorizable loop 5 */
/* Pre code */
for (int j6 = 0; (j6 < 4); j6 = (j6 + 1)) {
fYec1_tmp[j6] = fYec1_perm[j6];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec1[i] = float(input1[i]);
}
/* Post code */
for (int j7 = 0; (j7 < 4); j7 = (j7 + 1)) {
fYec1_perm[j7] = fYec1_tmp[(vsize + j7)];
}
/* Recursive loop 6 */
/* Pre code */
for (int j4 = 0; (j4 < 4); j4 = (j4 + 1)) {
fRec0_tmp[j4] = fRec0_perm[j4];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec0[i] = (0.0f - (((fRec0[(i - 1)] * fZec1[i]) - (fYec0[(i - 1)] + float(input0[i]))) / fZec2[i]));
}
/* Post code */
for (int j5 = 0; (j5 < 4); j5 = (j5 + 1)) {
fRec0_perm[j5] = fRec0_tmp[(vsize + j5)];
}
/* Recursive loop 7 */
/* Pre code */
for (int j8 = 0; (j8 < 4); j8 = (j8 + 1)) {
fRec2_tmp[j8] = fRec2_perm[j8];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec2[i] = (0.0f - (((fZec1[i] * fRec2[(i - 1)]) - (fYec1[(i - 1)] + float(input1[i]))) / fZec2[i]));
}
/* Post code */
for (int j9 = 0; (j9 < 4); j9 = (j9 + 1)) {
fRec2_perm[j9] = fRec2_tmp[(vsize + j9)];
}
/* Vectorizable loop 8 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output0[i] = FAUSTFLOAT(fRec0[i]);
}
/* Vectorizable loop 9 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output1[i] = FAUSTFLOAT(fRec2[i]);
}
}
/* Remaining frames */
if (vindex < count) {
FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* input1 = &input1_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex];
FAUSTFLOAT* output1 = &output1_ptr[vindex];
int vsize = (count - vindex);
/* Recursive loop 0 */
/* Pre code */
for (int j0 = 0; (j0 < 4); j0 = (j0 + 1)) {
fRec1_tmp[j0] = fRec1_perm[j0];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec1[i] = (fSlow0 + (fConst1 * fRec1[(i - 1)]));
}
/* Post code */
for (int j1 = 0; (j1 < 4); j1 = (j1 + 1)) {
fRec1_perm[j1] = fRec1_tmp[(vsize + j1)];
}
/* Vectorizable loop 1 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec0[i] = (1.0f / std::tan((fConst3 / fRec1[i])));
}
/* Vectorizable loop 2 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec1[i] = (1.0f - fZec0[i]);
}
/* Vectorizable loop 3 */
/* Pre code */
for (int j2 = 0; (j2 < 4); j2 = (j2 + 1)) {
fYec0_tmp[j2] = fYec0_perm[j2];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec0[i] = float(input0[i]);
}
/* Post code */
for (int j3 = 0; (j3 < 4); j3 = (j3 + 1)) {
fYec0_perm[j3] = fYec0_tmp[(vsize + j3)];
}
/* Vectorizable loop 4 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec2[i] = (fZec0[i] + 1.0f);
}
/* Vectorizable loop 5 */
/* Pre code */
for (int j6 = 0; (j6 < 4); j6 = (j6 + 1)) {
fYec1_tmp[j6] = fYec1_perm[j6];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec1[i] = float(input1[i]);
}
/* Post code */
for (int j7 = 0; (j7 < 4); j7 = (j7 + 1)) {
fYec1_perm[j7] = fYec1_tmp[(vsize + j7)];
}
/* Recursive loop 6 */
/* Pre code */
for (int j4 = 0; (j4 < 4); j4 = (j4 + 1)) {
fRec0_tmp[j4] = fRec0_perm[j4];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec0[i] = (0.0f - (((fRec0[(i - 1)] * fZec1[i]) - (fYec0[(i - 1)] + float(input0[i]))) / fZec2[i]));
}
/* Post code */
for (int j5 = 0; (j5 < 4); j5 = (j5 + 1)) {
fRec0_perm[j5] = fRec0_tmp[(vsize + j5)];
}
/* Recursive loop 7 */
/* Pre code */
for (int j8 = 0; (j8 < 4); j8 = (j8 + 1)) {
fRec2_tmp[j8] = fRec2_perm[j8];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec2[i] = (0.0f - (((fZec1[i] * fRec2[(i - 1)]) - (fYec1[(i - 1)] + float(input1[i]))) / fZec2[i]));
}
/* Post code */
for (int j9 = 0; (j9 < 4); j9 = (j9 + 1)) {
fRec2_perm[j9] = fRec2_tmp[(vsize + j9)];
}
/* Vectorizable loop 8 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output0[i] = FAUSTFLOAT(fRec0[i]);
}
/* Vectorizable loop 9 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output1[i] = FAUSTFLOAT(fRec2[i]);
}
}
}
};
#endif
declare name "Ambisonic Encoder";
declare version "0.1";
declare author "Wargreen";
declare license "GPL v3";
declare copyright "(c)Wargreen 2019";
import("stdfaust.lib");
ORDER = 1;
radius = hslider("Radius (m)", 1.0, 0, 50, 0.01) : si.smooth(ba.tau2pole(0.02));
azimut = hslider("Azimut (deg)", 180, 0, 359.99, 0.01) : si.smooth(ba.tau2pole(0.02));
elevation = hslider("Radius (deg)", 180, 0, 359.99, 0.01) : si.smooth(ba.tau2pole(0.02));
stereo = checkbox("Stereo input");
width = hslider("Stereo Width", 90, 0, 180, 0.01) : si.smooth(ba.tau2pole(0.02));
process = _,_ : par(i, 2, fi.lowpass(1, 92000/radius));
\ No newline at end of file
This diff is collapsed.
declare name "Ambisonic Encoder";
declare version "1.0";
declare author "Wargreen";
declare license "GPL v3";
declare copyright "(c) Wargreen 2019";
import("stdfaust.lib");
ORD = 1;
radius = hslider("Radius (m)", 1.0, 0.1, 50, 0.01) : si.smooth(ba.tau2pole(0.02));
azimut = (hslider("Azimut (deg)", 0, -180, 180, 0.01)) * (ma.PI/180) : si.smooth(ba.tau2pole(0.02));
//elevation = hslider("Elevation", 180, 0, 359.99, 0.01) : si.smooth(ba.tau2pole(0.02));
stereo = checkbox("Stereo input");
width = hslider("Stereo Width (deg)", 90, -180, 180, 0.01) : si.smooth(ba.tau2pole(0.02)) * (ma.PI/180);
erLvl = hslider("Early Reflection Lvl", 0, -20, 0, 0.01) : si.smooth(ba.tau2pole(0.02));
//preprocess = _;
//preprocess = fi.lowpass(1, 91930/radius) ;
preprocess = fi.highshelf( 1, ma.neg(0.43*radius), 15000);
//delay = _;
delay = de.fdelayltv(1,ma.SR, ma.SR * 1/340*radius) ;
volume(r) = 1. / (r * r * (r > 0.1) + (r < 0.1));
stereAzim(ch) = ma.neg( ba.if(stereo, ba.if(ch < 1, azimut-width/2, azimut+width/2), azimut));
encodedry(ch) = _ * volume(radius)<: ho.encoder(ORD, _, stereAzim(ch) );
encoderev(ch) = _ * ba.db2linear(erLvl) <: ho.encoder(ORD, _, stereAzim(ch));
addout = _,_;
dryprocess = par(i, 2, delay : encodedry(i)) :> _, par(i, ORD, addout);
revlateprocess = _,_ :>_;
revearlyprocess = par(i, 2, delay : encoderev(i)) :> _, par(i, ORD, addout);
process =_, _: par(i, 2,preprocess) <: dryprocess, revlateprocess, revearlyprocess;
\ No newline at end of file
/* ------------------------------------------------------------
author: "Wargreen"
copyright: "(c) Wargreen 2019"
license: "GPL v3"
name: "Ambisonic Encoder"
version: "0.1"
Code generated with Faust 2.14.4 (https://faust.grame.fr)
Compilation options: -vec -lv 0 -vs 64 -ftz 0 -mcd 16
------------------------------------------------------------ */
#ifndef __mydsp_H__
#define __mydsp_H__
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
#include <algorithm>
#include <cmath>
#include <math.h>
static float mydsp_faustpower2_f(float value) {
return (value * value);
}
#ifndef FAUSTCLASS
#define FAUSTCLASS mydsp
#endif
#ifdef __APPLE__
#define exp10f __exp10f
#define exp10 __exp10
#endif
class mydsp : public dsp {
private:
int fSamplingFreq;
float fConst0;
float fConst1;
float fConst2;
FAUSTFLOAT fHslider0;
float fRec0_perm[4];
float fYec0[262144];
int fYec0_idx;
int fYec0_idx_save;
float fYec1[262144];
int fYec1_idx;
int fYec1_idx_save;
float fConst3;
FAUSTFLOAT fHslider1;
float fRec1_perm[4];
FAUSTFLOAT fHslider2;
float fRec2_perm[4];
FAUSTFLOAT fCheckbox0;
public:
void metadata(Meta* m) {
m->declare("author", "Wargreen");
m->declare("basics.lib/name", "Faust Basic Element Library");
m->declare("basics.lib/version", "0.0");
m->declare("copyright", "(c) Wargreen 2019");
m->declare("delays.lib/name", "Faust Delay Library");
m->declare("delays.lib/version", "0.0");
m->declare("filename", "AmbiEnc.3.tmp");
m->declare("hoa.lib/author", "Pierre Guillot");
m->declare("hoa.lib/copyright", "2012-2013 Guillot, Paris, Colafrancesco, CICM labex art H2H, U. Paris 8");
m->declare("hoa.lib/name", "High Order Ambisonics library");
m->declare("license", "GPL v3");
m->declare("maths.lib/author", "GRAME");
m->declare("maths.lib/copyright", "GRAME");
m->declare("maths.lib/license", "LGPL with exception");
m->declare("maths.lib/name", "Faust Math Library");
m->declare("maths.lib/version", "2.1");
m->declare("name", "Ambisonic Encoder");
m->declare("signals.lib/name", "Faust Signal Routing Library");
m->declare("signals.lib/version", "0.0");
m->declare("version", "0.1");
}
virtual int getNumInputs() {
return 2;
}
virtual int getNumOutputs() {
return 7;
}
virtual int getInputRate(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 0;
break;
}
case 1: {
rate = 0;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel) {