uint32 PMixDocument::addNode (const PluginDescription* desc, double x, double y) { AudioProcessorGraph::Node* node = nullptr; if (desc != nullptr) { String errorMessage; AudioPluginInstance* instance = audioEngine.createPluginInstance(*desc, errorMessage); jassert(instance != nullptr); node = audioEngine.getGraph().addNode (instance); FaustAudioPluginInstance* faustProc = dynamic_cast<FaustAudioPluginInstance*>(instance); if (faustProc) { faustProc->initialize(getLibraryPath(), drawPath); } if (node != nullptr) { node->properties.set ("x", x); node->properties.set ("y", y); node->properties.set ("uiLastX", Random::getSystemRandom().nextInt (500)); node->properties.set ("uiLastY", Random::getSystemRandom().nextInt (500)); node->properties.set ("uiStatus", kUIStatusEmbed); if (!InternalPluginFormat::isInternalFormat(desc->name)) { node->properties.set ("colour", defaultColours.getNextColour().toString()); node->properties.set ("iposx", x); node->properties.set ("iposy", y); node->properties.set ("update", false); Array<var> presets; node->properties.set("presets", presets); Array<var> params; node->properties.set("params", params); } changed(); } else { AlertWindow::showMessageBox (AlertWindow::WarningIcon, TRANS("Couldn't create node"), errorMessage); return 0xFFFFFFFF; } } return node->nodeID; }
libmaus::util::DynamicLibrary::DynamicLibrary(std::string const & rmodname) : modname(rmodname), lib(0) { // try without subdirectory (uninstalled module) lib = dlopen(modname.c_str(),RTLD_LAZY); // if not found then try with directory (installed module) if ( ! lib ) { std::string const instmodname = getLibraryPath() + std::string("/") + std::string(PACKAGE_NAME)+std::string("/")+std::string(PACKAGE_VERSION)+std::string("/")+modname; lib = dlopen(instmodname.c_str(),RTLD_LAZY); } if ( ! lib ) { ::libmaus::exception::LibMausException se; se.getStream() << "Failed to dlopen(\"" << modname << "\",RTLD_LAZY): " << dlerror() << std::endl; se.finish(); throw se; } }
void PMixDocument::createNodeFromXml (XmlElement& xml, const String& newSourceCode) { PluginDescription pd; forEachXmlChildElement (xml, e) { if (pd.loadFromXml (*e)) break; } String errorMessage; AudioPluginInstance* instance = audioEngine.createPluginInstance(pd, errorMessage); jassert(instance != nullptr); if (pd.pluginFormatName == "FAUST") { FaustAudioPluginInstance* faustProc = dynamic_cast<FaustAudioPluginInstance*>(instance); faustProc->initialize(getLibraryPath(), drawPath); if (newSourceCode.length()) faustProc->setSourceCode(newSourceCode, true); // TODO: this is a bit wrong! faustProc->prepareToPlay(44100., 8192); // xml.setAttribute("numInputs", faustProc->getNumInputChannels()); // xml.setAttribute("numOutputs", faustProc->getNumOutputChannels()); ??? } AudioProcessorGraph::Node::Ptr node (audioEngine.getGraph().addNode (instance, xml.getIntAttribute ("uid"))); if (!newSourceCode.length()) { if (const XmlElement* const state = xml.getChildByName ("STATE")) { MemoryBlock m; m.fromBase64Encoding (state->getAllSubText()); node->getProcessor()->setStateInformation (m.getData(), (int) m.getSize()); } } node->properties.set ("x", xml.getDoubleAttribute ("x")); node->properties.set ("y", xml.getDoubleAttribute ("y")); node->properties.set ("uiLastX", xml.getIntAttribute ("uiLastX")); node->properties.set ("uiLastY", xml.getIntAttribute ("uiLastY")); node->properties.set ("uiStatus", xml.getIntAttribute ("uiStatus")); // presets etc for faust & plugin nodes if(!InternalPluginFormat::isInternalFormat(pd.name)) { node->properties.set ("colour", xml.getStringAttribute ("colour")); node->properties.set ("iposx", xml.getDoubleAttribute ("iposx")); node->properties.set ("iposy", xml.getDoubleAttribute ("iposy")); if (const XmlElement* const params = xml.getChildByName ("PARAMS")) { var vparams = JSON::parse(params->getAllSubText()); node->properties.set ("params", vparams); } Array<var> presetsArr; forEachXmlChildElement (xml, e) { if (e->hasTagName ("PRESET")) { DynamicObject* obj = new DynamicObject(); obj->setProperty("name", e->getStringAttribute("name")); obj->setProperty("x", e->getDoubleAttribute("x")); obj->setProperty("y", e->getDoubleAttribute("y")); obj->setProperty("radius", e->getDoubleAttribute("radius")); obj->setProperty("hidden", e->getBoolAttribute("hidden")); // obj->setProperty("distance", e->getDoubleAttribute("distance")); obj->setProperty("coeff", e->getDoubleAttribute("coeff")); var vparams = JSON::parse(e->getAllSubText()); obj->setProperty("state", vparams); obj->setProperty("uid", e->getIntAttribute("uid")); var preset = var(obj); presetsArr.add(preset); } } node->properties.set("presets", presetsArr); }
w_instance NativeProperties_init(JNIEnv *env, w_instance classSystem) { w_thread thread = JNIEnv2w_thread(env); char *utf8; w_string s; w_fifo fifo; w_int i; prop_hashtable = ht_create("hashtable:native system properties", 17, ht_stringHash, ht_stringCompare, 0, 0); woempa(1, "Created prop_hashtable\n"); s = cstring2String(UNICODE_SUBSETS, strlen(UNICODE_SUBSETS)); ht_write(prop_hashtable, (w_word)cstring2String("mika.unicode.subsets", 20), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.unicode.subsets", s); utf8 = getInstallationDir(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("java.home", 9), (w_word)s); woempa(1, "Set %s -> %w\n", "java.home", s); utf8 = getExtensionDir(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("java.ext.dirs", 13), (w_word)s); woempa(1, "Set %s -> %w\n", "java.ext.dirs", s); utf8 = getLibraryPath(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("java.library.path", 17), (w_word)s); woempa(1, "Set %s -> %w\n", "java.library.path", s); s = utf2String(VERSION_STRING, strlen(VERSION_STRING)); ht_write(prop_hashtable, (w_word)utf2String("mika.version", 12), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.version", s); s = utf2String(WONKA_INFO, strlen(WONKA_INFO)); ht_write(prop_hashtable, (w_word)utf2String("mika.vm.options", 15), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.vm.options", s); s = utf2String(DEFAULT_HEAP_SIZE, strlen(DEFAULT_HEAP_SIZE)); ht_write(prop_hashtable, (w_word)utf2String("mika.default.heap.size", 22), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.default.heap.size", s); s = utf2String(AWT_INFO, strlen(AWT_INFO)); ht_write(prop_hashtable, (w_word)utf2String("mika.awt.options", 16), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.awt.options", s); #ifdef O4P s = utf2String(O4P_INFO, strlen(O4P_INFO)); ht_write(prop_hashtable, (w_word)utf2String("mika.o4p.options", 16), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.o4p.options", s); #endif #ifdef OSWALD s = utf2String(OSWALD_INFO, strlen(OSWALD_INFO)); ht_write(prop_hashtable, (w_word)utf2String("mika.oswald.options", 19), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.oswald.options", s); #endif s = utf2String(BUILD_HOST, strlen(BUILD_HOST)); ht_write(prop_hashtable, (w_word)utf2String("mika.build.host", 15), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.build.host", s); utf8 = __DATE__ " " __TIME__; s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("mika.build.time", 15), (w_word)s); woempa(1, "Set %s -> %w\n", "mika.build.time", s); utf8 = getOSName(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("os.name", 7), (w_word)s); woempa(1, "Set %s -> %w\n", "os.name", s); utf8 = getOSVersion(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("os.version", 10), (w_word)s); woempa(1, "Set %s -> %w\n", "os.version", s); utf8 = getOSArch(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("os.arch", 7), (w_word)s); woempa(1, "Set %s -> %w\n", "os.arch", s); utf8 = getUserName(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("user.name", 9), (w_word)s); woempa(1, "Set %s -> %w\n", "user.name", s); utf8 = getUserHome(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("user.home", 9), (w_word)s); woempa(1, "Set %s -> %w\n", "user.home", s); utf8 = getUserDir(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("user.dir", 8), (w_word)s); woempa(1, "Set %s -> %w\n", "user.dir", s); utf8 = getUserLanguage(); s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("user.language", 13), (w_word)s); woempa(1, "Set %s -> %w\n", "user.language", s); utf8 = "Mika " VERSION_STRING; s = utf2String(utf8, strlen(utf8)); ht_write(prop_hashtable, (w_word)utf2String("java.runtime.name", 17), (w_word)s); woempa(1, "Set %s -> %w\n", "java.runtime.name", s); enterUnsafeRegion(thread); keyArray = allocArrayInstance_1d(JNIEnv2w_thread(env), clazzArrayOf_String, prop_hashtable->occupancy); enterSafeRegion(thread); fifo = ht_list_keys_no_lock(prop_hashtable); i = 0; while ((s = (w_string)getFifo(fifo))) { woempa(7, "keyArray[%d] = %w\n", i, s); setArrayReferenceField(keyArray, getStringInstance(s), i); ++i; } return keyArray; }