Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed May 16, 2024
1 parent 8e882ae commit 57aa622
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 131 deletions.
164 changes: 57 additions & 107 deletions embedded/faustgen/src/faustgen_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ dsp_factory* faustgen_factory::create_factory_from_sourcecode()
delete fSoundUI;
fSoundUI = new SoundUI(factory->getIncludePathnames(), -1, nullptr, true);
/*
std::vector<std::string> sound_directories = factory->getIncludePathnames();
for (int i = 0; i < sound_directories.size(); i++) {
std::vector<std::string> sound_directories = factory->getIncludePathnames();
for (int i = 0; i < sound_directories.size(); i++) {
post("sound_directories %d %s", i, sound_directories[i].c_str());
}
}
*/
return factory;
} else {
Expand Down Expand Up @@ -715,27 +715,18 @@ void faustgen_factory::display_svg()
}
}

bool faustgen_factory::open_file(const char* file)
{
char command[512];
#ifdef WIN32
snprintf(command, 512, "start \"\" \"%s%s\"", (*fLibraryPath.begin()).c_str(), file);
#else
snprintf(command, 512, "open \"%s%s\"", (*fLibraryPath.begin()).c_str(), file);
#endif
post(command);
return (system(command) == 0);
}

bool faustgen_factory::open_file(const char* appl, const char* file)
{
char command[512];
#ifdef WIN32
snprintf(command, 512, "start \"\" %s \"%s%s\"", appl, (*fLibraryPath.begin()).c_str(), file);
#else
snprintf(command, 512, "open -a %s \"%s%s\"", appl, (*fLibraryPath.begin()).c_str(), file);
#endif
return (system(command) == 0);
for (const auto& it : fLibraryPath) {
#ifdef WIN32
snprintf(command, 512, "start \"\" %s \"%s%s\"", appl, it.c_str(), file);
#else
snprintf(command, 512, "open -a %s \"%s%s\"", appl, it.c_str(), file);
#endif
if (system(command) == 0) return true;
}
return false;
}

void faustgen_factory::display_documentation()
Expand All @@ -756,101 +747,60 @@ void faustgen_factory::display_libraries_aux(const char* lib)
int i = 0;

while ((appl = TEXT_APPL_LIST[i++]) && (strcmp(appl, "") != 0)) {
if (open_file(appl, lib)) {
break;
}
if (open_file(appl, lib)) break;
}
}

void faustgen_factory::display_libraries()
{
// Open the libraries
#ifdef WIN32
open_file(FAUST_PDF_LIBRARY);
open_file("all.lib");
open_file("aanl.lib");
open_file("analyzers.lib");
open_file("basics.lib");
open_file("compressors.lib");
open_file("delays.lib");
open_file("demos.lib");
open_file("double.lib");
open_file("dx7.lib");
open_file("envelopes.lib");
open_file("filters.lib");
open_file("fds.lib");
open_file("hoa.lib");
open_file("instruments.lib");
open_file("interpolators.lib");
open_file("maths.lib");
open_file("maxmsp.lib");
open_file("mi.lib");
open_file("misceffects.lib");
open_file("noises.lib");
open_file("oscillators.lib");
open_file("phaflangers.lib");
open_file("physmodels.lib");
open_file("platform.lib");
open_file("quantizers.lib");
open_file("reducemaps.lib");
open_file("reverbs.lib");
open_file("routes.lib");
open_file("runtime.lib");
open_file("sf.lib");
open_file("signals.lib");
open_file("soundfiles.lib");
open_file("spats.lib");
open_file("stdfaust.lib");
open_file("synths.lib");
open_file("tonestacks.lib");
open_file("tubes.lib");
open_file("vaeffects.lib");
open_file("version.lib");
open_file("wdmodels.lib");
open_file("webaudio.lib");
#define OPEN_FILE open_file
OPEN_FILE(FAUST_PDF_LIBRARY);
#else
display_libraries_aux("all.lib");
display_libraries_aux("aanl.lib");
display_libraries_aux("analyzers.lib");
display_libraries_aux("basics.lib");
display_libraries_aux("compressors.lib");
display_libraries_aux("delays.lib");
display_libraries_aux("demos.lib");
display_libraries_aux("double.lib");
display_libraries_aux("dx7.lib");
display_libraries_aux("envelopes.lib");
display_libraries_aux("filters.lib");
display_libraries_aux("fds.lib");
display_libraries_aux("hoa.lib");
display_libraries_aux("instruments.lib");
display_libraries_aux("interpolators.lib");
display_libraries_aux("maths.lib");
display_libraries_aux("maxmsp.lib");
display_libraries_aux("mi.lib");
display_libraries_aux("misceffects.lib");
display_libraries_aux("noises.lib");
display_libraries_aux("oscillators.lib");
display_libraries_aux("phaflangers.lib");
display_libraries_aux("physmodels.lib");
display_libraries_aux("platform.lib");
display_libraries_aux("quantizers.lib");
display_libraries_aux("reducemaps.lib");
display_libraries_aux("reverbs.lib");
display_libraries_aux("routes.lib");
display_libraries_aux("runtime.lib");
display_libraries_aux("sf.lib");
display_libraries_aux("signals.lib");
display_libraries_aux("soundfiles.lib");
display_libraries_aux("spats.lib");
display_libraries_aux("stdfaust.lib");
display_libraries_aux("synths.lib");
display_libraries_aux("tonestacks.lib");
display_libraries_aux("tubes.lib");
display_libraries_aux("vaeffects.lib");
display_libraries_aux("version.lib");
display_libraries_aux("wdmodels.lib");
display_libraries_aux("webaudio.lib");
#define OPEN_FILE display_libraries_aux
#endif
OPEN_FILE("all.lib");
OPEN_FILE("aanl.lib");
OPEN_FILE("analyzers.lib");
OPEN_FILE("basics.lib");
OPEN_FILE("compressors.lib");
OPEN_FILE("delays.lib");
OPEN_FILE("demos.lib");
OPEN_FILE("double.lib");
OPEN_FILE("dx7.lib");
OPEN_FILE("envelopes.lib");
OPEN_FILE("filters.lib");
OPEN_FILE("fds.lib");
OPEN_FILE("hoa.lib");
OPEN_FILE("instruments.lib");
OPEN_FILE("interpolators.lib");
OPEN_FILE("maths.lib");
OPEN_FILE("maxmsp.lib");
OPEN_FILE("mi.lib");
OPEN_FILE("misceffects.lib");
OPEN_FILE("noises.lib");
OPEN_FILE("oscillators.lib");
OPEN_FILE("phaflangers.lib");
OPEN_FILE("physmodels.lib");
OPEN_FILE("platform.lib");
OPEN_FILE("quantizers.lib");
OPEN_FILE("reducemaps.lib");
OPEN_FILE("reverbs.lib");
OPEN_FILE("routes.lib");
OPEN_FILE("runtime.lib");
OPEN_FILE("sf.lib");
OPEN_FILE("signals.lib");
OPEN_FILE("soundfiles.lib");
OPEN_FILE("spats.lib");
OPEN_FILE("stdfaust.lib");
OPEN_FILE("synths.lib");
OPEN_FILE("tonestacks.lib");
OPEN_FILE("tubes.lib");
OPEN_FILE("vaeffects.lib");
OPEN_FILE("version.lib");
OPEN_FILE("wdmodels.lib");
OPEN_FILE("webaudio.lib");
}

void faustgen_factory::update_sourcecode(int size, char* source_code)
Expand Down
1 change: 0 additions & 1 deletion embedded/faustgen/src/faustgen_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class faustgen_factory {
int m_siginlets;
int m_sigoutlets;

bool open_file(const char* file);
bool open_file(const char* appl, const char* file);

void add_library_path(const std::string& library_path);
Expand Down
48 changes: 30 additions & 18 deletions embedded/faustgen/src/faustgen~.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ faustgen::faustgen(t_symbol* sym, long ac, t_atom* argv)
// sym can be "faustgen~" or "mc.faustgen~"
m_is_mc = (string(sym->s_name) == "mc.faustgen~");

fMidiHandler.startMidi();

// Allocate factory with a given "name"
int i;
t_atom* ap;
bool res = false;

fMidiHandler.startMidi();

// Allocate factory with a given "name"
for (i = 0, ap = argv; i < ac; i++, ap++) {
if (atom_gettype(ap) == A_SYM) {
res = allocate_factory(atom_getsym(ap)->s_name);
Expand Down Expand Up @@ -519,7 +519,7 @@ void faustgen::dblclick(long inlet)
case 1:
// Open the text editor to allow the user to input Faust sourcecode
if (m_is_mc && sys_getdspobjdspstate((t_object*)&m_ob)) {
post("WARNING : in multichannels mode, the editor cannot be safely used with running !");
post("WARNING : in multichannels mode, the editor cannot be safely used while running !");
} else {
display_dsp_source();
}
Expand Down Expand Up @@ -612,7 +612,7 @@ inline void faustgen::perform(int vs, t_sample** inputs, long numins, t_sample**
}
}

inline void faustgen::init(double samplerate, long inputs, long maxvectorsize)
inline void faustgen::init(double samplerate)
{
std::cout << "faustgen::init\n";

Expand All @@ -624,15 +624,6 @@ inline void faustgen::init(double samplerate, long inputs, long maxvectorsize)

// Load internal state
fSavedUI->load();

/*
// We need to know the real number of inputs to adapt perform
if (m_is_mc) {
delete fMCDSP;
// fMCDSP will not delete the fDSP object
fMCDSP = new dsp_adapter(fDSP, inputs, fDSP->getNumOutputs(), maxvectorsize, false);
}
*/
}

// Display source code
Expand Down Expand Up @@ -773,6 +764,9 @@ void faustgen::set_dirty()
jpatcher_set_dirty(mypatcher, 1);
}

/**
* Search the adc/dac object in the patcher.
*/
t_pxobject* faustgen::check_dac()
{
t_object *patcher, *box, *obj;
Expand All @@ -784,7 +778,11 @@ t_pxobject* faustgen::check_dac()
if ((object_classname(obj) == gensym("dac~"))
|| (object_classname(obj) == gensym("ezdac~"))
|| (object_classname(obj) == gensym("ezadc~"))
|| (object_classname(obj) == gensym("adc~"))) {
|| (object_classname(obj) == gensym("adc~"))
|| (object_classname(obj) == gensym("mc.dac~"))
|| (object_classname(obj) == gensym("mc.ezdac~"))
|| (object_classname(obj) == gensym("mc.ezadc~"))
|| (object_classname(obj) == gensym("mc.adc~"))) {
return (t_pxobject*)box;
}
}
Expand All @@ -808,7 +806,11 @@ void faustgen::create_jsui()
}
}
}

/**
* Allows to start/stop the ADC/DAC in the patcher.
*
* mess : "start" or "stop" message
*/
void faustgen::dsp_status(const char* mess)
{
t_pxobject* dac = nullptr;
Expand All @@ -822,18 +824,28 @@ void faustgen::dsp_status(const char* mess)
}
}

/**
* Set the object mute state.
*
* mute : 0|1
*/
void faustgen::mute(long inlet, long mute)
{
fMute = mute;
}

/**
* Called to get the number of outputs.
*
* outletindex : the outlet index starting from 0
*/
long faustgen::multichanneloutputs(long outletindex)
{
if (m_is_mc) {
std::cout << "faustgen::multichanneloutputs MC" << outletindex << std::endl;
std::cout << "faustgen::multichanneloutputs MC " << outletindex << std::endl;
return (outletindex == 0) ? fDSP->getNumOutputs() : 0;
} else {
std::cout << "faustgen::multichanneloutputs DEFAULT" << outletindex << std::endl;
std::cout << "faustgen::multichanneloutputs DEFAULT " << outletindex << std::endl;
return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion embedded/faustgen/src/faustgen~.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class faustgen : public MspCpp5<faustgen> {
void perform(int vs, t_sample** inputs, long numins, t_sample** outputs, long numouts);

// Callback given to setupIO
void init(double samplerate, long inputs, long maxvectorsize);
void init(double samplerate);

};

Expand Down
6 changes: 2 additions & 4 deletions embedded/faustgen/src/maxcpp5.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class MspCpp5 : public MaxCppBase<T> {
public:

typedef void (T::*maxmethodperform)(int vs, t_sample** inputs, long numins, t_sample** outputs, long numouts);
typedef void (T::*maxmethodinit)(double samplerate, long inputs, long maxvectorsize);
typedef void (T::*maxmethodinit)(double samplerate);

t_pxobject m_ob;
unsigned int m_siginlets, m_sigoutlets;
Expand Down Expand Up @@ -493,10 +493,8 @@ template<typename T> void MspCpp5<T>::internal_dsp_64(MspCpp5<T>* x,
long maxvectorsize,
long flags) {
T* self = (T*)x;
//long inputs = (self->m_is_mc) ? (long)object_method(dsp64, gensym("getnuminputchannels"), x, 0) : -1;
self->m_samplerate = samplerate;
//((self)->*(self->m_init))(samplerate, inputs, maxvectorsize);
((self)->*(self->m_init))(samplerate, -1, maxvectorsize);
((self)->*(self->m_init))(samplerate);

object_method(dsp64, gensym("dsp_add64"), x, MspCpp5<T>::internal_perform_64, 0, NULL);
}
Expand Down

0 comments on commit 57aa622

Please sign in to comment.