String LoadSave::getLicense(var state) { if (!state.isObject()) return ""; DynamicObject* object_state = state.getDynamicObject(); NamedValueSet properties = object_state->getProperties(); if (properties.contains("license")) return properties["license"]; return ""; }
NamedValueSet* ConsolidatedTests::add_instruction(ConsolidatedTests::Client *client, const Identifier &inst, const var ¶meter) { NamedValueSet* instruction = new NamedValueSet(); instruction->set(inst, parameter); client->instructions.add(instruction); return instruction; }
bool Updater::getLatestComponents() { URL url = URL(UPDATER_URL_PREFIX).getChildURL("latest.php") .withParameter("channel", launcherApplication::getConfig()->getString("updater", "channel")) .withParameter("platform", launcherApplication::getConfig()->getString("updater", "platform")) .withParameter("components", "launcher,tremulous"); ScopedPointer<InputStream> stream(url.createInputStream(false, nullptr, nullptr, String(), 5000)); if (stream == nullptr) { return false; } var versionsVar = JSON::parse(*stream); if (versionsVar == var::null || !versionsVar.isObject()) { return false; } DynamicObject *versionsObject = versionsVar.getDynamicObject(); NamedValueSet *versionsSet = &versionsObject->getProperties(); components.clear(); for (int i = 0; i < versionsSet->size(); i++) { String componentName(versionsSet->getName(i)); Launcher::Component component(componentName); component.setRemoteVersion(versionsSet->getValueAt(i).toString()); components.add(component); } return true; }
void LoadSave::loadSaveState(std::map<std::string, String>& state, const NamedValueSet& properties) { if (properties.contains("author")) state["author"] = properties["author"]; if (properties.contains("patch_name")) state["patch_name"] = properties["patch_name"]; if (properties.contains("folder_name")) state["folder_name"] = properties["folder_name"]; }
void pluginParametersSetIndexed(AudioPluginInstance *instance, const NamedValueSet &indexedParameters) { int numParams = instance->getNumParameters(); for (int j = 0, m = indexedParameters.size(); j < m; ++j) { Identifier name = indexedParameters.getName(j); int i = name.toString().getIntValue(); var val = indexedParameters.getValueAt(j); if (!val.isVoid() && i >= 0 && i < numParams) { DBG << "Setting indexed parameter " << i << " - " << name.toString() << " to " << (float)val; instance->setParameter(i, (float)val); DBG << "... reported as " << instance->getParameter(i) << endl; } } }
bool NamedValueSet::operator== (const NamedValueSet& other) const noexcept { auto num = values.size(); if (num != other.values.size()) return false; for (int i = 0; i < num; ++i) { // optimise for the case where the keys are in the same order if (values.getReference(i).name == other.values.getReference(i).name) { if (values.getReference(i).value != other.values.getReference(i).value) return false; } else { // if we encounter keys that are in a different order, search remaining items by brute force.. for (int j = i; j < num; ++j) { if (auto* otherVal = other.getVarPointer (values.getReference(j).name)) if (values.getReference(j).value == *otherVal) continue; return false; } return true; } } return true; }
void IniFile::save() { const GenericScopedLock<CriticalSection> scopedlock(lock); String config; for (int i = 0; i < data.size(); i++) { String section(data.getName(i).toString()); DynamicObject *sectionObject = data[section].getDynamicObject(); NamedValueSet *sectionSet = §ionObject->getProperties(); if (sectionSet->size() == 0) { continue; } if (section != "__empty") { config += '['; config += section; #ifdef JUCE_WINDOWS config += "]\r\n"; #else config += "]\n"; #endif } for (int j = 0; j < sectionSet->size(); j++) { config += sectionSet->getName(j).toString(); config += '='; config += sectionSet->getValueAt(j).toString(); #ifdef JUCE_WINDOWS config += "\r\n"; #else config += '\n'; #endif } #ifdef JUCE_WINDOWS config += "\r\n"; #else config += '\n'; #endif } file.replaceWithText(config); }
// // allocate page of size pageSize to virtual address va and add entry to VTP // page table // ali_errnum_e MPFVTP::_allocate(btVirtAddr va, size_t pageSize, uint32_t flags) { ali_errnum_e err; MPFVTP_PAGE_SIZE mapType; // FIXME: can we reuse this? expensive! static? NamedValueSet *bufAllocArgs = new NamedValueSet(); btVirtAddr alloc; AAL_DEBUG(LM_AFU, "_allocate(" << std::hex << std::setw(2) << std::setfill('0') << (void *)va << ", " << std::dec << (unsigned int)pageSize << ")" << std::endl); // determine mapping type for page table entry if (pageSize == LARGE_PAGE_SIZE) { mapType = MPFVTP_PAGE_2MB; } else if (pageSize == SMALL_PAGE_SIZE) { mapType = MPFVTP_PAGE_4KB; } else { AAL_ERR(LM_AFU, "Invalid page size." << std::endl); return ali_errnumBadParameter; } // allocate buffer at va bufAllocArgs->Add(ALI_MMAP_TARGET_VADDR_KEY, static_cast<ALI_MMAP_TARGET_VADDR_DATATYPE>(va)); err = m_pALIBuffer->bufferAllocate(pageSize, &alloc, *bufAllocArgs); // insert VTP page table entry if (err == ali_errnumOK) { MPF_ASSERT_RET(va == alloc, ali_errnumNoMem); if (! ptInsertPageMapping(btVirtAddr(va), m_pALIBuffer->bufferGetIOVA((unsigned char *)va), mapType, flags)) { AAL_ERR(LM_All, "Page table insertion error." << std::endl); err = ali_errnumBadMapping; } } delete bufAllocArgs; return err; }
void pluginParametersSet(AudioPluginInstance *instance, const NamedValueSet ¶meters) { int numParams = instance->getNumParameters(); for (int i = 0; i < numParams; ++i) { Identifier name = instance->getParameterName(i); var val = parameters.getWithDefault(name, var::null); if (!val.isVoid()) { DBG << "Setting named parameter " << i << " - " << name.toString() << " to " << (float)val; instance->setParameter(i, (float)val); DBG << "... reported as " << instance->getParameter(i) << endl; } } }
void LoadSave::loadControls(SynthBase* synth, const NamedValueSet& properties) { mopo::control_map controls = synth->getControls(); for (auto control : controls) { String name = control.first; if (properties.contains(name)) { mopo::mopo_float value = properties[name]; control.second->set(value); } else { mopo::ValueDetails details = mopo::Parameters::getDetails(name.toStdString()); control.second->set(details.default_value); } } }
void LoadSave::loadControls(mopo::HelmEngine* synth, const CriticalSection& critical_section, const NamedValueSet& properties) { ScopedLock lock(critical_section); mopo::control_map controls = synth->getControls(); for (auto control : controls) { String name = control.first; if (properties.contains(name)) { mopo::mopo_float value = properties[name]; control.second->set(value); } else { mopo::ValueDetails details = mopo::Parameters::getDetails(name.toStdString()); control.second->set(details.default_value); } } }
void LoadSave::varToState(SynthBase* synth, std::map<std::string, String>& save_info, var state) { if (!state.isObject()) return; DynamicObject* object_state = state.getDynamicObject(); NamedValueSet properties = object_state->getProperties(); // Version 0.4.1 was the last build before we saved the version number. String version = "0.4.1"; if (properties.contains("synth_version")) version = properties["synth_version"]; // After 0.4.1 there was a patch file restructure. if (compareVersionStrings(version, "0.4.1") <= 0) { NamedValueSet new_properties; new_properties.set("settings", object_state); properties = new_properties; } var settings = properties["settings"]; DynamicObject* settings_object = settings.getDynamicObject(); NamedValueSet settings_properties = settings_object->getProperties(); Array<var>* modulations = settings_properties["modulations"].getArray(); // After 0.5.0 mixer was added and osc_mix was removed. And scaling of oscillators was changed. if (compareVersionStrings(version, "0.5.0") <= 0) { // Fix control control values. if (settings_properties.contains("osc_mix")) { mopo::mopo_float osc_mix = settings_properties["osc_mix"]; settings_properties.set("osc_1_volume", sqrt(1.0f - osc_mix)); settings_properties.set("osc_2_volume", sqrt(osc_mix)); settings_properties.remove("osc_mix"); } // Fix modulation routing. var* modulation = modulations->begin(); Array<var> old_modulations; Array<DynamicObject*> new_modulations; for (; modulation != modulations->end(); ++modulation) { DynamicObject* mod = modulation->getDynamicObject(); String destination = mod->getProperty("destination").toString(); if (destination == "osc_mix") { String source = mod->getProperty("source").toString(); mopo::mopo_float amount = mod->getProperty("amount"); old_modulations.add(mod); DynamicObject* osc_1_mod = new DynamicObject(); osc_1_mod->setProperty("source", source); osc_1_mod->setProperty("destination", "osc_1_volume"); osc_1_mod->setProperty("amount", -amount); new_modulations.add(osc_1_mod); DynamicObject* osc_2_mod = new DynamicObject(); osc_2_mod->setProperty("source", source); osc_2_mod->setProperty("destination", "osc_2_volume"); osc_2_mod->setProperty("amount", amount); new_modulations.add(osc_2_mod); } } for (var old_modulation : old_modulations) modulations->removeFirstMatchingValue(old_modulation); for (DynamicObject* modulation : new_modulations) modulations->add(modulation); } if (compareVersionStrings(version, "0.7.2") <= 0) { bool stutter_on = settings_properties["stutter_on"]; if (stutter_on) { settings_properties.set("stutter_resample_sync", 0); settings_properties.set("stutter_sync", 0); } } loadControls(synth, settings_properties); loadModulations(synth, modulations); loadSaveState(save_info, properties); }
void ConsolidatedTests::TwoPlayersSimple() { beginTest("Two Players Simple"); initialize_field_manager(4); set_delay(0); startserver(65002); register_callbacks(join_game, leave_game, take_cell, get_size, get_cell_player, is_there_a_winner); ScopedPointer<Client> frank = new Client(); frank->setName("Frank"); add_instruction(frank, "sleep", 10); add_instruction(frank, "join", ""); NamedValueSet* instruction = add_instruction(frank, "take", ""); instruction->set("x", 0); instruction->set("y", 1); instruction->set("name", "Frank"); instruction = add_instruction(frank, "take", ""); instruction->set("x", 0); instruction->set("y", 0); instruction->set("name", "Frank"); instruction = add_instruction(frank, "take", ""); instruction->set("x", 1); instruction->set("y", 0); instruction->set("name", "Frank"); instruction = add_instruction(frank, "take", ""); instruction->set("x", 1); instruction->set("y", 1); instruction->set("name", "Frank"); instruction = add_instruction(frank, "status", ""); instruction->set("x", 0); instruction->set("y", 1); add_instruction(frank, "sleep", 2); ScopedPointer<Client> susy = new Client(); susy->setName("Susy"); add_instruction(susy, "sleep", 5); add_instruction(susy, "join", ""); instruction = add_instruction(susy, "take", ""); instruction->set("x", 0); instruction->set("y", 1); instruction->set("name", "Susy"); instruction = add_instruction(susy, "take", ""); instruction->set("x", 0); instruction->set("y", 0); instruction->set("name", "Susy"); instruction = add_instruction(susy, "take", ""); instruction->set("x", 1); instruction->set("y", 0); instruction->set("name", "Susy"); instruction = add_instruction(susy, "take", ""); instruction->set("x", 1); instruction->set("y", 1); instruction->set("name", "Susy"); add_instruction(susy, "sleep", 3); for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { instruction = add_instruction(susy, "take", ""); instruction->set("x", i); instruction->set("y", j); instruction->set("name", "Susy"); } } pool.addJob(frank, false); pool.addJob(susy, false); while(pool.getNumJobs() > 0 ) { Thread::sleep(100); } stopserver(); while( server_running() > 0) { Thread::sleep(100); } release_field_manager(); Thread::sleep(1000); }
void LoadSave::varToState(mopo::HelmEngine* synth, const CriticalSection& critical_section, var state) { if (!state.isObject()) return; mopo::control_map controls = synth->getControls(); DynamicObject* object_state = state.getDynamicObject(); ScopedLock lock(critical_section); NamedValueSet properties = object_state->getProperties(); int size = properties.size(); for (int i = 0; i < size; ++i) { Identifier id = properties.getName(i); if (id.isValid()) { std::string name = id.toString().toStdString(); if (controls.count(name)) { mopo::mopo_float value = properties.getValueAt(i); controls[name]->set(value); } } } synth->clearModulations(); Array<var>* modulations = object_state->getProperty("modulations").getArray(); var* modulation = modulations->begin(); for (; modulation != modulations->end(); ++modulation) { DynamicObject* mod = modulation->getDynamicObject(); std::string source = mod->getProperty("source").toString().toStdString(); std::string destination = mod->getProperty("destination").toString().toStdString(); mopo::ModulationConnection* connection = new mopo::ModulationConnection(source, destination); connection->amount.set(mod->getProperty("amount")); synth->connectModulation(connection); } }