Skip to content

Commit

Permalink
Merge branch 'master-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed Mar 6, 2018
2 parents 537e6b7 + c834792 commit 025bf01
Show file tree
Hide file tree
Showing 110 changed files with 2,726 additions and 1,949 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version := 2.5.21
version := 2.5.23

system ?= $(shell uname -s)

ifeq ($(system), Darwin)
LIB_EXT = dylib
else
ifneq ($(findstring MINGW32, $(system)),)
ifneq ($(findstring MINGW, $(system)),)
LIB_EXT = dll
EXE = .exe
else
Expand Down
103 changes: 51 additions & 52 deletions architecture/ca-qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,87 +125,86 @@ ztimedmap GUI::gTimedZoneMap;
//------------------------------------------------------------------------
class Sensor
{
private:
QSensor* fSensor;
int fType;
QSensorReading* fReader;
QSensor* create(int type) const;
public:
enum { kSensorStart = 1, kAccelerometer = 1, kGyroscope, kSensorMax };

Sensor(int type) : fSensor(0), fType(type), fReader(0)
{ fSensor = create (type); fSensor->connectToBackend(); }
virtual ~Sensor() { if (available()) activate (false); delete fSensor; }

int isAccel() const { return fType == kAccelerometer; }
int isGyro () const { return fType == kGyroscope; }
bool available() const { return fSensor->isConnectedToBackend(); }
bool active() const { return fSensor->isActive(); }
void activate(bool state){ fSensor->setActive(state); fReader = fSensor->reading(); }
int count() { return fReader ? fReader->valueCount() : 0; }
float value(int i) const { return fReader->value(i).value<float>(); }
private:

QSensor* fSensor;
int fType;
QSensorReading* fReader;
QSensor* create(int type) const;

public:
enum { kSensorStart = 1, kAccelerometer = 1, kGyroscope, kSensorMax };

Sensor(int type) : fSensor(0), fType(type), fReader(0)
{ fSensor = create (type); fSensor->connectToBackend(); }
virtual ~Sensor() { if (available()) activate (false); delete fSensor; }

int isAccel() const { return fType == kAccelerometer; }
int isGyro () const { return fType == kGyroscope; }
bool available() const { return fSensor->isConnectedToBackend(); }
bool active() const { return fSensor->isActive(); }
void activate(bool state){ fSensor->setActive(state); fReader = fSensor->reading(); }
int count() { return fReader ? fReader->valueCount() : 0; }
float value(int i) const { return fReader->value(i).value<float>(); }
};

//------------------------------------------------------------------------
QSensor* Sensor::create (int type) const
QSensor* Sensor::create(int type) const
{
switch (type) {
case kAccelerometer: return new QAccelerometer();
case kGyroscope: return new QGyroscope();
default:
cerr << "unknown sensor type " << type << endl;
}
return 0;
switch (type) {
case kAccelerometer: return new QAccelerometer();
case kGyroscope: return new QGyroscope();
default: cerr << "unknown sensor type " << type << endl;
}
return 0;
}

//------------------------------------------------------------------------
class Sensors : public QObject
{
private:

APIUI* fUI;
Sensor fAccel, fGyro;
int fTimerID;
public:
typedef std::map<int, Sensor*> TSensors;
Sensors(APIUI* ui)
: fUI(ui), fAccel(Sensor::kAccelerometer), fGyro(Sensor::kGyroscope), fTimerID(0) {}
virtual ~Sensors() { killTimer(fTimerID); }
void start();
protected:
void timerEvent(QTimerEvent*);

public:

typedef std::map<int, Sensor*> TSensors;
Sensors(APIUI* ui)
: fUI(ui), fAccel(Sensor::kAccelerometer), fGyro(Sensor::kGyroscope), fTimerID(0) {}
virtual ~Sensors() { killTimer(fTimerID); }
void start();

protected:

void timerEvent(QTimerEvent*);
};

//------------------------------------------------------------------------
void Sensors::timerEvent(QTimerEvent*)
{
if (fAccel.active()) {
if (fAccel.active()) {
int count = fAccel.count();
for (int i = 0; (i< count) && (i < 3); i++) {
fUI->propagateAcc(i, fAccel.value(i));
fUI->propagateAcc(i, fAccel.value(i));
}
}
if (fGyro.active()) {
}
if (fGyro.active()) {
int count = fGyro.count();
for (int i = 0; (i< count) && (i < 3); i++) {
fUI->propagateGyr(i, fGyro.value(i));
fUI->propagateGyr(i, fGyro.value(i));
}
}
}
}

//------------------------------------------------------------------------
void Sensors::start()
{
bool activate = false;
if (fAccel.available()) { fAccel.activate(true); activate = true; }
if (fGyro.available()) { fGyro.activate(true); activate = true; }
if (activate) fTimerID = startTimer(10);
bool activate = false;
if (fAccel.available()) { fAccel.activate(true); activate = true; }
if (fGyro.available()) { fGyro.activate(true); activate = true; }
if (activate) fTimerID = startTimer(10);
}
#endif

Expand Down
5 changes: 3 additions & 2 deletions architecture/faust/au/AUUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ struct auUIObject {
virtual ~auUIObject()
{}

virtual void GetName(char *text) {
virtual void GetName(char *text)
{
std::strcpy(text, fLabel.c_str());
}

Expand All @@ -82,7 +83,7 @@ struct auUIObject {
}

virtual long GetID()
{ /* returns the sum of all the ASCII characters contained in the parameter's label */
{ /* returns the sum of all the ASCII characters contained in the parameter's label */
int i;
long acc;
for (i = 0, acc = 0; i < fLabel.length(); i++)
Expand Down
2 changes: 2 additions & 0 deletions architecture/faust/dsp/dsp-checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class dsp_checker : public decorator_dsp
fFP_NAN = 0;
}

virtual ~dsp_checker() {}

void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs)
{
fDSP->compute(count, inputs, outputs);
Expand Down
138 changes: 69 additions & 69 deletions architecture/faust/dsp/dsp-tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,82 +143,82 @@ class Interleaver
class AudioChannels
{

protected:

const unsigned int fNumFrames;
const unsigned int fNumChannels;
FAUSTFLOAT** fChannels;

public:

AudioChannels(int nframes, int nchannels) : fNumFrames(nframes), fNumChannels(nchannels)
{
fChannels = new FAUSTFLOAT*[nchannels];

// allocate audio channels
for (unsigned int i = 0; i < fNumChannels; i++) {
fChannels[i] = new FAUSTFLOAT[fNumFrames];
for (unsigned int j = 0; j < fNumFrames; j++) {
fChannels[i][j] = 0;
protected:

const unsigned int fNumFrames;
const unsigned int fNumChannels;
FAUSTFLOAT** fChannels;

public:

AudioChannels(int nframes, int nchannels) : fNumFrames(nframes), fNumChannels(nchannels)
{
fChannels = new FAUSTFLOAT*[nchannels];

// allocate audio channels
for (unsigned int i = 0; i < fNumChannels; i++) {
fChannels[i] = new FAUSTFLOAT[fNumFrames];
for (unsigned int j = 0; j < fNumFrames; j++) {
fChannels[i][j] = 0;
}
}
}
}

virtual ~AudioChannels()
{
// free separate input channels
for (int i = 0; i < fNumChannels; i++) {
delete[] fChannels[i];
}
delete[] fChannels;
}

//---------------------------------------------------------------------------------------
// interleavedRead: read, from the interleaved buffer <inbuffer>, <length> frames on
// <inchannels> channels. The samples are written to the <fNumChannels> internal
// <fChannels>.
void interleavedRead(float* inbuffer, unsigned int length, unsigned int inchannels)
{
assert(length <= fNumFrames);
unsigned int C = std::min(inchannels, fNumChannels);
unsigned int L = std::min(length, fNumFrames);

for (unsigned int f = 0; f < L; f++) {
unsigned int p = f * inchannels;
for (unsigned int c = 0; c < C; c++) {
fChannels[c][f] = inbuffer[p++];
}
for (unsigned int c = C; c < fNumChannels; c++) {
fChannels[c][f] = 0;

virtual ~AudioChannels()
{
// free separate input channels
for (int i = 0; i < fNumChannels; i++) {
delete[] fChannels[i];
}
delete[] fChannels;
}
}

//----------------------------------------------------------------------------------------
// interleavedWrite: write to the interleaved buffer <inbuffer>, <length> frames on
// <outchannels> channels. The samples are read from <fNumChannels> internal
// <fChannels>.
void interleavedWrite(float* outbuffer, unsigned int length, unsigned int outchannels)
{
assert(length <= fNumFrames);
unsigned int C = std::min(outchannels, fNumChannels);
unsigned int F = std::min(length, fNumFrames);

for (unsigned int f = 0; f < F; f++) {
int p = f * outchannels;
for (unsigned int c = 0; c < C; c++) {
outbuffer[p++] = fChannels[c][f];

//---------------------------------------------------------------------------------------
// interleavedRead: read, from the interleaved buffer <inbuffer>, <length> frames on
// <inchannels> channels. The samples are written to the <fNumChannels> internal
// <fChannels>.
void interleavedRead(float* inbuffer, unsigned int length, unsigned int inchannels)
{
assert(length <= fNumFrames);
unsigned int C = std::min(inchannels, fNumChannels);
unsigned int L = std::min(length, fNumFrames);

for (unsigned int f = 0; f < L; f++) {
unsigned int p = f * inchannels;
for (unsigned int c = 0; c < C; c++) {
fChannels[c][f] = inbuffer[p++];
}
for (unsigned int c = C; c < fNumChannels; c++) {
fChannels[c][f] = 0;
}
}
for (unsigned int c = C; c < outchannels; c++) {
outbuffer[p++] = 0;
}

//----------------------------------------------------------------------------------------
// interleavedWrite: write to the interleaved buffer <inbuffer>, <length> frames on
// <outchannels> channels. The samples are read from <fNumChannels> internal
// <fChannels>.
void interleavedWrite(float* outbuffer, unsigned int length, unsigned int outchannels)
{
assert(length <= fNumFrames);
unsigned int C = std::min(outchannels, fNumChannels);
unsigned int F = std::min(length, fNumFrames);

for (unsigned int f = 0; f < F; f++) {
unsigned int p = f * outchannels;
for (unsigned int c = 0; c < C; c++) {
outbuffer[p++] = fChannels[c][f];
}
for (unsigned int c = C; c < outchannels; c++) {
outbuffer[p++] = 0;
}
}
}
}

//----------------------------------------------------------------------------------------
// buffers: the internal buffers ready to use in the compute() method of a faust dsp

FAUSTFLOAT** buffers() { return fChannels; }

//----------------------------------------------------------------------------------------
// buffers: the internal buffers ready to use in the compute() method of a Faust dsp

FAUSTFLOAT** buffers() { return fChannels; }
};

#endif
2 changes: 1 addition & 1 deletion architecture/faust/dsp/faust-dynamic-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ struct dsp_aux {
void createJSON(const string& name_app)
{
// JSON creation
JSONUI json(name_app, fDSP->getNumInputs(), fDSP->getNumOutputs());
JSONUI json(name_app, "", fDSP->getNumInputs(), fDSP->getNumOutputs());
fDSP->buildUserInterface(&json);
fDSP->metadata(&json);
fJSON = json.JSON();
Expand Down
12 changes: 6 additions & 6 deletions architecture/faust/dsp/faust-poly-engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class FaustPolyEngine {
*/
void setParamValue(const char* address, float value)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
if (id >= 0) {
fAPIUI.setParamValue(id, value);
// In POLY mode, update all voices
Expand All @@ -330,7 +330,7 @@ class FaustPolyEngine {
*/
float getParamValue(const char* address)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
return (id >= 0) ? fAPIUI.getParamValue(id) : 0.f;
}

Expand Down Expand Up @@ -424,7 +424,7 @@ class FaustPolyEngine {
*/
float getParamMin(const char* address)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
return (id >= 0) ? fAPIUI.getParamMin(id) : 0.f;
}

Expand All @@ -443,7 +443,7 @@ class FaustPolyEngine {
*/
float getParamMax(const char* address)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
return (id >= 0) ? fAPIUI.getParamMax(id) : 0.f;
}

Expand All @@ -462,7 +462,7 @@ class FaustPolyEngine {
*/
float getParamInit(const char* address)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
return (id >= 0) ? fAPIUI.getParamInit(id) : 0.f;
}

Expand All @@ -481,7 +481,7 @@ class FaustPolyEngine {
*/
const char* getMetadata(const char* address, const char* key)
{
int id = fAPIUI.getParamIndex(address);
int id = (address) ? fAPIUI.getParamIndex(address) : -1;
return (id >= 0) ? fAPIUI.getMetadata(id, key) : "";
}

Expand Down
Loading

0 comments on commit 025bf01

Please sign in to comment.