Commit 89264ce9 authored by wargreen's avatar wargreen
Browse files

Add release

parent 7bdca4c0
File added
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) {
int rate;
switch (channel) {
case 0: {
rate = 1;
break;
}
case 1: {
rate = 1;
break;
}
case 2: {
rate = 1;
break;
}
case 3: {
rate = 1;
break;
}
case 4: {
rate = 1;
break;
}
case 5: {
rate = 1;
break;
}
case 6: {
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 = (0.0174532924f * fConst2);
}
virtual void instanceResetUserInterface() {
fHslider0 = FAUSTFLOAT(1.0f);
fHslider1 = FAUSTFLOAT(180.0f);
fHslider2 = FAUSTFLOAT(90.0f);
fCheckbox0 = FAUSTFLOAT(0.0f);
}
virtual void instanceClear() {
for (int l0 = 0; (l0 < 4); l0 = (l0 + 1)) {
fRec0_perm[l0] = 0.0f;
}
for (int l1 = 0; (l1 < 262144); l1 = (l1 + 1)) {
fYec0[l1] = 0.0f;
}
fYec0_idx = 0;
fYec0_idx_save = 0;
for (int l2 = 0; (l2 < 262144); l2 = (l2 + 1)) {
fYec1[l2] = 0.0f;
}
fYec1_idx = 0;
fYec1_idx_save = 0;
for (int l3 = 0; (l3 < 4); l3 = (l3 + 1)) {
fRec1_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("Azimut (deg)", &fHslider1, 180.0f, 0.0f, 359.98999f, 0.00999999978f);
ui_interface->addHorizontalSlider("Radius (m)", &fHslider0, 1.0f, 0.00999999978f, 50.0f, 0.00999999978f);
ui_interface->addHorizontalSlider("Stereo Width (deg)", &fHslider2, 90.0f, -180.0f, 180.0f, 0.00999999978f);
ui_interface->addCheckButton("Stereo input", &fCheckbox0);
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];
FAUSTFLOAT* output2_ptr = outputs[2];
FAUSTFLOAT* output3_ptr = outputs[3];
FAUSTFLOAT* output4_ptr = outputs[4];
FAUSTFLOAT* output5_ptr = outputs[5];
FAUSTFLOAT* output6_ptr = outputs[6];
float fSlow0 = (fConst2 * float(fHslider0));
float fRec0_tmp[68];
float* fRec0 = &fRec0_tmp[4];
float fZec0[64];
float fZec1[64];
int iZec2[64];
int iZec3[64];
float fZec4[64];
float fZec5[64];
float fZec6[64];
float fZec7[64];
int iZec8[64];
float fZec9[64];
float fZec10[64];
float fZec11[64];
float fZec12[64];
float fZec13[64];
float fZec14[64];
float fSlow1 = (fConst3 * (float(fHslider1) + -180.0f));
float fRec1_tmp[68];
float* fRec1 = &fRec1_tmp[4];
float fSlow2 = (fConst2 * float(fHslider2));
float fRec2_tmp[68];
float* fRec2 = &fRec2_tmp[4];
int iSlow3 = int(float(fCheckbox0));
float fZec15[64];
float fZec16[64];
float fZec17[64];
float fZec18[64];
float fZec19[64];
int fullcount = count;
int vindex = 0;
/* Main loop */
for (vindex = 0; (vindex <= (fullcount - 64)); vindex = (vindex + 64)) {
FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* input1 = &input1_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex];
FAUSTFLOAT* output1 = &output1_ptr[vindex];
FAUSTFLOAT* output2 = &output2_ptr[vindex];
FAUSTFLOAT* output3 = &output3_ptr[vindex];
FAUSTFLOAT* output4 = &output4_ptr[vindex];
FAUSTFLOAT* output5 = &output5_ptr[vindex];
FAUSTFLOAT* output6 = &output6_ptr[vindex];
int vsize = 64;
/* Recursive loop 0 */
/* Pre code */
for (int j0 = 0; (j0 < 4); j0 = (j0 + 1)) {
fRec0_tmp[j0] = fRec0_perm[j0];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec0[i] = (fSlow0 + (fConst1 * fRec0[(i - 1)]));
}
/* Post code */
for (int j1 = 0; (j1 < 4); j1 = (j1 + 1)) {
fRec0_perm[j1] = fRec0_tmp[(vsize + j1)];
}
/* Vectorizable loop 1 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec0[i] = (0.00294117653f * fRec0[i]);
}
/* Vectorizable loop 2 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec1[i] = (fZec0[i] + 4.99999987e-06f);
}
/* Vectorizable loop 3 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
iZec2[i] = int(fZec1[i]);
}
/* Vectorizable loop 4 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec5[i] = std::floor(fZec1[i]);
}
/* Recursive loop 5 */
/* Pre code */
for (int j4 = 0; (j4 < 4); j4 = (j4 + 1)) {
fRec2_tmp[j4] = fRec2_perm[j4];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec2[i] = (fSlow2 + (fConst1 * fRec2[(i - 1)]));
}
/* Post code */
for (int j5 = 0; (j5 < 4); j5 = (j5 + 1)) {
fRec2_perm[j5] = fRec2_tmp[(vsize + j5)];
}
/* Vectorizable loop 6 */
/* Pre code */
fYec0_idx = ((fYec0_idx + fYec0_idx_save) & 262143);
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec0[((i + fYec0_idx) & 262143)] = float(input0[i]);
}
/* Post code */
fYec0_idx_save = vsize;
/* Vectorizable loop 7 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
iZec3[i] = int(std::min<float>(fConst0, float(std::max<int>(0, iZec2[i]))));
}
/* Vectorizable loop 8 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec6[i] = (0.0f - (fZec0[i] + (-1.0f - fZec5[i])));
}
/* Vectorizable loop 9 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec7[i] = (fZec0[i] - fZec5[i]);
}
/* Vectorizable loop 10 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
iZec8[i] = int(std::min<float>(fConst0, float(std::max<int>(0, (iZec2[i] + 1)))));
}
/* Vectorizable loop 11 */
/* Pre code */
fYec1_idx = ((fYec1_idx + fYec1_idx_save) & 262143);
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec1[((i + fYec1_idx) & 262143)] = float(input1[i]);
}
/* Post code */
fYec1_idx_save = vsize;
/* Recursive loop 12 */
/* Pre code */
for (int j2 = 0; (j2 < 4); j2 = (j2 + 1)) {
fRec1_tmp[j2] = fRec1_perm[j2];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec1[i] = (fSlow1 + (fConst1 * fRec1[(i - 1)]));
}
/* Post code */
for (int j3 = 0; (j3 < 4); j3 = (j3 + 1)) {
fRec1_perm[j3] = fRec1_tmp[(vsize + j3)];
}
/* Vectorizable loop 13 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec15[i] = (0.5f * fRec2[i]);
}
/* Vectorizable loop 14 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec4[i] = fYec0[(((i + fYec0_idx) - iZec3[i]) & 262143)];
fZec9[i] = fYec0[(((i + fYec0_idx) - iZec8[i]) & 262143)];
fZec10[i] = ((fZec4[i] * fZec6[i]) + (fZec7[i] * fZec9[i]));
}
/* Vectorizable loop 15 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec11[i] = fYec1[(((i + fYec1_idx) - iZec3[i]) & 262143)];
fZec12[i] = fYec1[(((i + fYec1_idx) - iZec8[i]) & 262143)];
fZec13[i] = ((fZec6[i] * fZec11[i]) + (fZec7[i] * fZec12[i]));
}
/* Vectorizable loop 16 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec16[i] = (iSlow3?(fRec1[i] - fZec15[i]):fRec1[i]);
}
/* Vectorizable loop 17 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec17[i] = (iSlow3?(fRec1[i] + fZec15[i]):fRec1[i]);
}
/* Vectorizable loop 18 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec14[i] = mydsp_faustpower2_f(fRec0[i]);
}
/* Vectorizable loop 19 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec18[i] = ((fZec10[i] * std::sin(fZec16[i])) + (fZec13[i] * std::sin(fZec17[i])));
}
/* Vectorizable loop 20 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec19[i] = ((fZec10[i] * std::cos(fZec16[i])) + (fZec13[i] * std::cos(fZec17[i])));
}
/* Vectorizable loop 21 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output0[i] = FAUSTFLOAT(((fZec10[i] + fZec13[i]) / fZec14[i]));
}
/* Vectorizable loop 22 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output1[i] = FAUSTFLOAT((fZec18[i] / fZec14[i]));
}
/* Vectorizable loop 23 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output2[i] = FAUSTFLOAT((fZec19[i] / fZec14[i]));
}
/* Vectorizable loop 24 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output3[i] = FAUSTFLOAT((float(input0[i]) + float(input1[i])));
}
/* Vectorizable loop 25 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output4[i] = FAUSTFLOAT(((fZec6[i] * (fZec4[i] + fZec11[i])) + (fZec7[i] * (fZec9[i] + fZec12[i]))));
}
/* Vectorizable loop 26 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output5[i] = FAUSTFLOAT(fZec18[i]);
}
/* Vectorizable loop 27 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
output6[i] = FAUSTFLOAT(fZec19[i]);
}
}
/* Remaining frames */
if (vindex < fullcount) {
FAUSTFLOAT* input0 = &input0_ptr[vindex];
FAUSTFLOAT* input1 = &input1_ptr[vindex];
FAUSTFLOAT* output0 = &output0_ptr[vindex];
FAUSTFLOAT* output1 = &output1_ptr[vindex];
FAUSTFLOAT* output2 = &output2_ptr[vindex];
FAUSTFLOAT* output3 = &output3_ptr[vindex];
FAUSTFLOAT* output4 = &output4_ptr[vindex];
FAUSTFLOAT* output5 = &output5_ptr[vindex];
FAUSTFLOAT* output6 = &output6_ptr[vindex];
int vsize = (fullcount - vindex);
/* Recursive loop 0 */
/* Pre code */
for (int j0 = 0; (j0 < 4); j0 = (j0 + 1)) {
fRec0_tmp[j0] = fRec0_perm[j0];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec0[i] = (fSlow0 + (fConst1 * fRec0[(i - 1)]));
}
/* Post code */
for (int j1 = 0; (j1 < 4); j1 = (j1 + 1)) {
fRec0_perm[j1] = fRec0_tmp[(vsize + j1)];
}
/* Vectorizable loop 1 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec0[i] = (0.00294117653f * fRec0[i]);
}
/* Vectorizable loop 2 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec1[i] = (fZec0[i] + 4.99999987e-06f);
}
/* Vectorizable loop 3 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
iZec2[i] = int(fZec1[i]);
}
/* Vectorizable loop 4 */
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fZec5[i] = std::floor(fZec1[i]);
}
/* Recursive loop 5 */
/* Pre code */
for (int j4 = 0; (j4 < 4); j4 = (j4 + 1)) {
fRec2_tmp[j4] = fRec2_perm[j4];
}
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fRec2[i] = (fSlow2 + (fConst1 * fRec2[(i - 1)]));
}
/* Post code */
for (int j5 = 0; (j5 < 4); j5 = (j5 + 1)) {
fRec2_perm[j5] = fRec2_tmp[(vsize + j5)];
}
/* Vectorizable loop 6 */
/* Pre code */
fYec0_idx = ((fYec0_idx + fYec0_idx_save) & 262143);
/* Compute code */
for (int i = 0; (i < vsize); i = (i + 1)) {
fYec0[((i + fYec0_idx) & 262143)] = float(input0[i]);
}
/* Post code */
fYec0_idx_save = vsize;
/* Vectorizable loop 7 */