From 7adb063cab7f33814d48099659915376aa5e6e04 Mon Sep 17 00:00:00 2001 From: Stephane Letz Date: Sun, 23 May 2021 12:15:42 +0200 Subject: [PATCH] Cleanup, documentation. --- architecture/faust/gui/ControlSequenceUI.h | 35 +++++++++++----------- architecture/sndfile.cpp | 20 +++++++------ embedded/faustremote/README.md | 22 +++++++------- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/architecture/faust/gui/ControlSequenceUI.h b/architecture/faust/gui/ControlSequenceUI.h index 55467bd23c..48b59f904f 100644 --- a/architecture/faust/gui/ControlSequenceUI.h +++ b/architecture/faust/gui/ControlSequenceUI.h @@ -33,9 +33,9 @@ #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) @@ -43,15 +43,15 @@ struct TSMessage { }; /* - 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 fSequence; - uint64_t fDateSample; - int fEvent; + uint64_t fDateSample; + int fEvent; void processMessage(const TSMessage& message) { @@ -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) { @@ -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 read(const std::string& pathname, int sample_rate) diff --git a/architecture/sndfile.cpp b/architecture/sndfile.cpp index b914303fe2..0964d33b54 100644 --- a/architecture/sndfile.cpp +++ b/architecture/sndfile.cpp @@ -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; - /****************************************************************************** ******************************************************************************* @@ -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) { @@ -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); @@ -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); diff --git a/embedded/faustremote/README.md b/embedded/faustremote/README.md index 3dadca67f4..64e5e4bf3b 100644 --- a/embedded/faustremote/README.md +++ b/embedded/faustremote/README.md @@ -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: @@ -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()` @@ -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`.