Skip to content

Commit

Permalink
Cleanup, documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed May 23, 2021
1 parent df65456 commit 7adb063
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 37 deletions.
35 changes: 18 additions & 17 deletions architecture/faust/gui/ControlSequenceUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@
#include "faust/gui/MapUI.h"

struct TSMessage {
uint64_t fDateSample;
uint64_t fDateSample;
std::string fPath;
FAUSTFLOAT fValue;
FAUSTFLOAT fValue;

TSMessage(uint64_t ds, const std::string& path, FAUSTFLOAT value)
:fDateSample(ds), fPath(path), fValue(value)
{}
};

/*
Allows to process a sequence of time-stamped controller messages.
Allows to process a sequence of time-stamped messages.
*/
class ControlSequenceUI : public MapUI {

protected:

std::vector<TSMessage> fSequence;
uint64_t fDateSample;
int fEvent;
uint64_t fDateSample;
int fEvent;

void processMessage(const TSMessage& message)
{
Expand All @@ -67,14 +67,16 @@ class ControlSequenceUI : public MapUI {
{
if (fSequence.size() == 0) return;

// Init if needed
// Restart from begining if needed
if (begin < fDateSample) {
fDateSample = 0;
fEvent = 0;
}

// Move until start of range
while (fSequence[fEvent].fDateSample < begin && fEvent < fSequence.size()) fEvent++;
while (fEvent < fSequence.size() && fSequence[fEvent].fDateSample < begin) {
fEvent++;
}

// Process all messages in [begin, end] range
while (fEvent < fSequence.size() && fSequence[fEvent].fDateSample <= end) {
Expand Down Expand Up @@ -122,18 +124,17 @@ struct OSCSequenceReader {
{
std::stringstream tokenizer(date);

std::string date1, date2;
getline(tokenizer, date1, '.');
getline(tokenizer, date2, '.');
std::string sec, frac;
getline(tokenizer, sec, '.');
getline(tokenizer, frac, '.');

std::istringstream date1_reader("0x" + date1);
std::istringstream date2_reader("0x" + date2);
uint32_t sec, frac;
date1_reader >> std::hex >> sec;
date2_reader >> std::hex >> frac;
std::istringstream sec_reader("0x" + sec);
std::istringstream frac_reader("0x" + frac);
uint32_t sec_t, frac_t;
sec_reader >> std::hex >> sec_t;
frac_reader >> std::hex >> frac_t;

double res = double(sec) + (double(frac)/std::pow(2,32));
return uint64_t(res * sample_rate);
return uint64_t(sample_rate * (double(sec_t) + (double(frac_t)/std::pow(2,32))));
}

static std::vector<TSMessage> read(const std::string& pathname, int sample_rate)
Expand Down
20 changes: 11 additions & 9 deletions architecture/sndfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@
#include "faust/dsp/dsp-tools.h"
#include "faust/misc.h"

#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

typedef sf_count_t (* sample_read)(SNDFILE* sndfile, void* buffer, sf_count_t frames);
typedef sf_count_t (* sample_write)(SNDFILE* sndfile, void* buffer, sf_count_t frames);

using namespace std;

/******************************************************************************
*******************************************************************************
Expand All @@ -82,6 +73,15 @@ using namespace std;

/*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/

#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif

typedef sf_count_t (* sample_read)(SNDFILE* sndfile, void* buffer, sf_count_t frames);
typedef sf_count_t (* sample_write)(SNDFILE* sndfile, void* buffer, sf_count_t frames);

using namespace std;

// loptrm : scan command-line arguments and remove and return long int value when found
static long loptrm(int* argcP, char* argv[], const char* longname, const char* shortname, long def)
{
Expand Down Expand Up @@ -172,6 +172,7 @@ int main(int argc_aux, char* argv_aux[])
exit(1);
}

// Handling of the file containing sequence of time-stamped OSC messages
ControlSequenceUI sequenceUI(OSCSequenceReader::read(cfilename, in_info.samplerate));
DSP.buildUserInterface(&sequenceUI);

Expand Down Expand Up @@ -230,6 +231,7 @@ int main(int argc_aux, char* argv_aux[])

int sample_rate = loptrm(&argc, argv, "--sample-rate", "-sr", kSampleRate);

// Handling of the file containing sequence of time-stamped OSC messages
ControlSequenceUI sequenceUI(OSCSequenceReader::read(cfilename, sample_rate));
uint64_t begin, end;
sequenceUI.getRange(begin, end);
Expand Down
22 changes: 11 additions & 11 deletions embedded/faustremote/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

## The libfaustremote library

The `libfaustremote` library allows to compile and process a Faust DSP program on a remote machine.
The `libfaustremote` library allows to compile and process a Faust DSP program on a remote machine.

### Remote server

The server launches a compilation service, waiting for DSPs to compile. Dependencies are:
* `LLVM` using macport
* `faust` make + sudo make install at the root of faust project
* `HTTPDFaust` make httpd + sudo make install at the root of faust project
* `microhttpd` using macport
* `libjacknet` download JackOSX package at: https://jackaudio.org
* `LLVM` using macport
* `faust` make + sudo make install at the root of Faust project
* `HTTPDFaust` make httpd + sudo make install at the root of Faust project
* `libmicrohttpd` using macport
* `libjacknet` download JackOSX package at: https://jackaudio.org

Here is the API:

Expand Down Expand Up @@ -44,7 +44,7 @@ To easily include remote processing in your projects, this API has been created.
* `createRemoteDSPFactoryFromString(const string& name_app, const string& dsp_content, int argc, const char* argv[], const string& ipServer, int portServer, string& error, int opt_level)`
* `createRemoteDSPInstance(remote_dsp_factory* factory, int argc, const char* argv[], int samplingRate, int bufferSize, string& error)`

Use instance as any "static" DSP:
Use instance as any static DSP:

* `virtual int getNumInputs()`
* `virtual int getNumOutputs()`
Expand All @@ -57,9 +57,9 @@ Use instance as any "static" DSP:

This example shows how to use the API. In this example you can pass in command line:

* `the IP of remote Server you want to use`
* `NetJack parameters of slave to be open on remote machine (localIP/Port/Latency/Compression)`
* `the dsp files you want to run in JACK/QT environment and the number of instances for each`
* `syntax is given with ./RemoteClient --help`
* the IP of remote Server you want to use
* NetJack parameters of slave to be open on remote machine (localIP/Port/Latency/Compression)
* the dsp files you want to run in JACK/QT environment and the number of instances for each
* syntax is given with `./RemoteClient --help`

The following has to be added at link time: `-lfaustremote -lcurl -ljacknet`.

0 comments on commit 7adb063

Please sign in to comment.