static void dump_noteval(note_p note, voice_p voice) { /* Find out the pitch */ int val = note->value + clef_current->offset; int octave; int key; int accidental; if (val < 0) { octave = - ((- val + OCTAVE_DIATON - 1) / OCTAVE_DIATON); val = (val - octave * OCTAVE_DIATON) % OCTAVE_DIATON; } else { octave = val / OCTAVE_DIATON; val = val % OCTAVE_DIATON; } accidental = measure_accidental[note->value]; if (note->tie_end != NO_ID) { tie_p tie = &ties[note->tie_end]; accidental = tie->notes[0]->accidental; } key = defaultKey(val, voice); VPRINTF(" dump note, keyed value = %d, accidental %d, measure accidental %d, key ofdset %d\n", val, note->accidental, measure_accidental[note->value], defaultKey(val, voice)); fprintf(lily_out, " %s", keyName(val)); if (note->accidental != 0) { dumpAccidental(note->accidental); measure_accidental[note->value] = note->accidental; } else if (accidental != 0) { /* Require the actual accidental for cross-bar ties */ note->accidental = accidental; dumpAccidental(accidental); } else { switch (key) { case 0: break; case 1: fprintf(lily_out, "is"); break; case 2: fprintf(lily_out, "isis"); break; case -1: fprintf(lily_out, "es"); break; case -2: fprintf(lily_out, "eses"); break; } } while (octave > 0) { fprintf(lily_out, "'"); octave--; } while (octave < 0) { fprintf(lily_out, ","); octave++; } }
bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags) { Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0); Iterator entry = findEntry(group, key, flags); if (entry != end()) { //qDebug() << "reverting" << entry.key() << " = " << entry->mValue; if (entry->bReverted) { // already done before return false; } KEntryKey defaultKey(entry.key()); defaultKey.bDefault = true; //qDebug() << "looking up default entry with key=" << defaultKey; const ConstIterator defaultEntry = constFind(defaultKey); if (defaultEntry != constEnd()) { Q_ASSERT(defaultEntry.key().bDefault); //qDebug() << "found, update entry"; *entry = *defaultEntry; // copy default value, for subsequent lookups } else { entry->mValue = QByteArray(); } entry->bDirty = true; entry->bReverted = true; // skip it when writing out to disk //qDebug() << "Here's what we have now:" << *this; return true; } return false; }
void KKeyChooser::keyMode( int m ) { kbMode = m; switch( kbMode ) { case NoKey: noKey(); break; case DefaultKey: defaultKey(); break; case CustomKey: default: toChange( wList->currentItem() ); break; } }
QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(defaultKey())); if (plugin) { QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(defaultKey(), list.at(0), QAudio::AudioOutput); } // if no plugin is marked as default or if the default plugin doesn't have any output device, // return the first output available from other plugins. QList<QAudioDeviceInfo> outputDevices = availableDevices(QAudio::AudioOutput); if (!outputDevices.isEmpty()) return outputDevices.first(); #endif return QAudioDeviceInfo(); }
UtlBoolean SipUdpServer::sendTo(const SipMessage& message, const char* address, int port, const char* szLocalSipIp) { UtlBoolean sendOk; UtlVoidPtr* pServerContainer = NULL; SipClient* pServer = NULL; if (szLocalSipIp) { UtlString localKey(szLocalSipIp); pServerContainer = (UtlVoidPtr*)this->mServers.findValue(&localKey); if (pServerContainer) { pServer = (SipClient*) pServerContainer->getValue(); } } else { // no local sip IP specified, so, use the default one UtlString defaultKey(mDefaultIp); pServerContainer = (UtlVoidPtr*) mServers.findValue(&defaultKey); if (pServerContainer) { pServer = (SipClient*) pServerContainer->getValue(); } } if (pServer) { sendOk = pServer->sendTo(message, address, port); } else { sendOk = false; } return(sendOk); }
void KnobSerialization::encode(YAML::Emitter& em) const { if (!_mustSerialize || _values.empty()) { return; } em << YAML::BeginMap; em << YAML::Key << "Name" << YAML::Value << _scriptName; // Instead of inserting in the map each boolean // we serialize strings, meaning that // if they are here, their value is true otherwise it goes to default std::list<std::string> propNames; int nDimsToSerialize = 0; int nDimsWithValue = 0; int nDimsWithDefValue = 0; for (PerViewValueSerializationMap::const_iterator it = _values.begin(); it != _values.end(); ++it) { for (PerDimensionValueSerializationVec::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { if (it2->_mustSerialize && _isPersistent) { ++nDimsToSerialize; if (it2->_serializeValue || !it2->_animationCurve.keys.empty() || it2->_slaveMasterLink.hasLink || !it2->_expression.empty()) { ++nDimsWithValue; } } } } for (std::size_t i = 0; i < _defaultValues.size(); ++i) { if (_defaultValues[i].serializeDefaultValue) { ++nDimsWithDefValue; } } if (nDimsToSerialize > 0) { // We serialize a value, we need to know which type of knob this is because at the time of deserialization the // application may not have created the corresponding knob already and may not know to what type it corresponds if (nDimsWithValue > 0) { em << YAML::Key; em << dataTypeToString(_dataType); em << YAML::Value; if (_values.size() > 1) { // Map against views em << YAML::BeginMap; } for (PerViewValueSerializationMap::const_iterator it = _values.begin(); it != _values.end(); ++it) { if (_values.size() > 1) { em << YAML::Key << it->first << YAML::Value; } // Starting dimensions, make a sequence if multiple dimensions are serialized if (it->second.size() > 1) { em << YAML::Flow << YAML::BeginSeq; } for (PerDimensionValueSerializationVec::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { const ValueSerialization& val = *it2; if (val._slaveMasterLink.hasLink) { // Wrap the link in a sequence of 1 element to distinguish with regular string knobs values em << YAML::Flow << YAML::BeginMap; std::stringstream ss; // Encode the hard-link into a single string if (!val._slaveMasterLink.masterNodeName.empty()) { em << YAML::Key << "N"; em << YAML::Value << val._slaveMasterLink.masterNodeName; } if (!val._slaveMasterLink.masterTableItemName.empty()) { em << YAML::Key << "T"; em << YAML::Value << val._slaveMasterLink.masterTableItemName; } if (!val._slaveMasterLink.masterKnobName.empty()) { em << YAML::Key << "K"; em << YAML::Value << val._slaveMasterLink.masterKnobName; } if (!val._slaveMasterLink.masterDimensionName.empty()) { em << YAML::Key << "D"; em << YAML::Value << val._slaveMasterLink.masterDimensionName; } if (!val._slaveMasterLink.masterViewName.empty()) { em << YAML::Key << "V"; em << YAML::Value << val._slaveMasterLink.masterViewName; } // Also serialize the curve in case the expression fails to restore correctly if (!val._animationCurve.keys.empty()) { em << YAML::Key << "Curve" << YAML::Value; val._animationCurve.encode(em); } em << YAML::EndMap; } else if (!val._expression.empty()) { // Wrap the expression in a sequence of 1 element to distinguish with regular string knobs values em << YAML::Flow << YAML::BeginMap; if (val._expressionLanguage == kKnobSerializationExpressionLanguagePython) { if (val._expresionHasReturnVariable) { // Multi-line expr em << YAML::Key << "pyMultiExpr"; } else { // single line expr em << YAML::Key << "pyExpr"; } } else if (val._expressionLanguage == kKnobSerializationExpressionLanguageExprtk) { em << YAML::Key << "exprtk"; } else { // Unknown language assert(false); } em << YAML::Value << val._expression; // Also serialize the curve in case the expression fails to restore correctly if (!val._animationCurve.keys.empty()) { em << YAML::Key << "Curve" << YAML::Value; val._animationCurve.encode(em); } em << YAML::EndMap; } else if (!val._animationCurve.keys.empty()) { em << YAML::Flow << YAML::BeginMap; em << YAML::Key << "Curve" << YAML::Value; val._animationCurve.encode(em); em << YAML::EndMap; } else { // No animation or link, directly write the value without a map // This is the general case so we keep it tight assert(_dataType != eSerializationValueVariantTypeNone); switch (_dataType) { case eSerializationValueVariantTypeBoolean: em << val._value.isBool; break; case eSerializationValueVariantTypeInteger: em << val._value.isInt; break; case eSerializationValueVariantTypeDouble: em << val._value.isDouble; break; case eSerializationValueVariantTypeString: em << val._value.isString; break; case eSerializationValueVariantTypeTable: { em << YAML::BeginSeq; for (std::list<std::vector<std::string> >::const_iterator it3 = val._value.isTable.begin(); it3 != val._value.isTable.end(); ++it3) { if (it3->size() > 1) { em << YAML::Flow << YAML::BeginSeq; for (std::vector<std::string>::const_iterator it4 = it3->begin(); it4 != it3->end(); ++it4) { em << *it4; } em << YAML::EndSeq; } else if (it3->size() == 1) { em << it3->front(); } } em << YAML::EndSeq; } break; case eSerializationValueVariantTypeNone: break; } } } // for each dimension if (it->second.size() > 1) { em << YAML::EndSeq; } } // for each view if (_values.size() > 1) { em << YAML::EndMap; } } // nDimsWithValue > 0 if (nDimsWithDefValue > 0) { { em << YAML::Key; std::string defaultKey("Default"); defaultKey += dataTypeToString(_dataType); em << defaultKey; em << YAML::Value; } // Starting dimensions if (_defaultValues.size() > 1) { em << YAML::Flow << YAML::BeginSeq; } for (std::size_t i = 0; i < _defaultValues.size(); ++i) { switch (_dataType) { case eSerializationValueVariantTypeBoolean: em << _defaultValues[i].value.isBool; break; case eSerializationValueVariantTypeInteger: em << _defaultValues[i].value.isInt; break; case eSerializationValueVariantTypeDouble: em << _defaultValues[i].value.isDouble; break; case eSerializationValueVariantTypeString: em << _defaultValues[i].value.isString; break; case eSerializationValueVariantTypeTable: { em << YAML::Flow << YAML::BeginSeq; for (std::list<std::vector<std::string> >::const_iterator it3 = _defaultValues[i].value.isTable.begin(); it3 != _defaultValues[i].value.isTable.end(); ++it3) { if (it3->size() > 1) { em << YAML::Flow << YAML::BeginSeq; for (std::vector<std::string>::const_iterator it4 = it3->begin(); it4 != it3->end(); ++it4) { em << *it4; } em << YAML::EndSeq; } else if (it3->size() == 1) { em << it3->front(); } } em << YAML::EndSeq; } break; case eSerializationValueVariantTypeNone: break; } } // for all dimensions if (_defaultValues.size() > 1) { em << YAML::EndSeq; } } // nDimsWithDefValue > 0 } // nDimsToSerialize > 0 TextExtraData* textData = dynamic_cast<TextExtraData*>(_extraData.get()); if (_extraData && _isPersistent) { ParametricExtraData* parametricData = dynamic_cast<ParametricExtraData*>(_extraData.get()); if (parametricData) { if (!parametricData->parametricCurves.empty()) { em << YAML::Key << "ParametricCurves" << YAML::Value; if (parametricData->parametricCurves.size() > 1) { // Multi-view em << YAML::BeginMap; } for (std::map<std::string,std::list<CurveSerialization> >::const_iterator it = parametricData->parametricCurves.begin(); it!= parametricData->parametricCurves.end(); ++it) { if (parametricData->parametricCurves.size() > 1) { // Multi-view em << YAML::Key << it->first << YAML::Value; } em << YAML::BeginSeq; for (std::list<CurveSerialization>::const_iterator it2 = it->second.begin(); it2!=it->second.end(); ++it2) { it2->encode(em); } em << YAML::EndSeq; } if (parametricData->parametricCurves.size() > 1) { // Multi-view em << YAML::EndMap; } } } else if (textData) { if (!textData->keyframes.empty()) { bool hasDeclaredTextAnim = false; for (std::map<std::string,std::map<double, std::string> >::const_iterator it = textData->keyframes.begin(); it != textData->keyframes.end(); ++it) { if (it->second.empty()) { continue; } if (!hasDeclaredTextAnim) { hasDeclaredTextAnim = true; em << YAML::Key << "TextAnim" << YAML::Value; if (textData->keyframes.size() > 1) { // Multi-view: start a map em << YAML::BeginMap; } } if (textData->keyframes.size() > 1) { em << YAML::Key << it->first << YAML::Value; } em << YAML::Flow; em << YAML::BeginSeq; for (std::map<double, std::string>::const_iterator it2 = it->second.begin(); it2!=it->second.end(); ++it2) { em << it2->first << it2->second; } em << YAML::EndSeq; } if (hasDeclaredTextAnim && textData->keyframes.size() > 1) { em << YAML::EndMap; } } if (std::abs(textData->fontColor[0] - 0.) > 0.01 || std::abs(textData->fontColor[1] - 0.) > 0.01 || std::abs(textData->fontColor[2] - 0.) > 0.01) { em << YAML::Key << "FontColor" << YAML::Value << YAML::Flow << YAML::BeginSeq << textData->fontColor[0] << textData->fontColor[1] << textData->fontColor[2] << YAML::EndSeq; } if (textData->fontSize != kKnobStringDefaultFontSize) { em << YAML::Key << "FontSize" << YAML::Value << textData->fontSize; } if (textData->fontFamily != NATRON_FONT) { em << YAML::Key << "Font" << YAML::Value << textData->fontFamily; } if (textData->italicActivated) { propNames.push_back("Italic"); } if (textData->boldActivated) { propNames.push_back("Bold"); } } } if (_isUserKnob) { // Num of dimensions can be figured out for knobs created by plug-in // Knobs created by user need to know it em << YAML::Key << "NDims" << YAML::Value << _dimension; em << YAML::Key << "TypeName" << YAML::Value << _typeName; if (_label != _scriptName) { em << YAML::Key << "Label" << YAML::Value << _label; } if (!_tooltip.empty()) { em << YAML::Key << "Hint" << YAML::Value << _tooltip; } if (_isSecret) { propNames.push_back("Secret"); } if (_disabled) { propNames.push_back("Disabled"); } if (!_triggerNewLine) { propNames.push_back("NoNewLine"); } if (!_evaluatesOnChange) { propNames.push_back("NoEval"); } if (_animatesChanged) { propNames.push_back("AnimatesChanged"); } if (!_isPersistent) { propNames.push_back("Volatile"); } if (!_iconFilePath[0].empty()) { em << YAML::Key << "UncheckedIcon" << YAML::Value << _iconFilePath[0]; } if (!_iconFilePath[1].empty()) { em << YAML::Key << "CheckedIcon" << YAML::Value << _iconFilePath[1]; } ChoiceExtraData* cdata = dynamic_cast<ChoiceExtraData*>(_extraData.get()); ValueExtraData* vdata = dynamic_cast<ValueExtraData*>(_extraData.get()); TextExtraData* tdata = dynamic_cast<TextExtraData*>(_extraData.get()); FileExtraData* fdata = dynamic_cast<FileExtraData*>(_extraData.get()); PathExtraData* pdata = dynamic_cast<PathExtraData*>(_extraData.get()); if (cdata) { if (!cdata->_entries.empty()) { em << YAML::Key << "Entries" << YAML::Value; em << YAML::Flow << YAML::BeginSeq; for (std::size_t i = 0; i < cdata->_entries.size(); ++i) { em << cdata->_entries[i]; } em << YAML::EndSeq; } if (!cdata->_helpStrings.empty()) { bool hasHelp = false; for (std::size_t i = 0; i < cdata->_helpStrings.size(); ++i) { if (!cdata->_helpStrings[i].empty()) { hasHelp = true; break; } } if (hasHelp) { em << YAML::Key << "Hints" << YAML::Value; em << YAML::Flow << YAML::BeginSeq; for (std::size_t i = 0; i < cdata->_helpStrings.size(); ++i) { em << cdata->_helpStrings[i]; } em << YAML::EndSeq; } } } else if (vdata) { if (vdata->min != INT_MIN && vdata->min != -DBL_MAX) { em << YAML::Key << "Min" << YAML::Value << vdata->min; } if (vdata->min != INT_MAX && vdata->min != DBL_MAX) { em << YAML::Key << "Max" << YAML::Value << vdata->max; } if (vdata->min != INT_MIN && vdata->min != -DBL_MAX) { em << YAML::Key << "DisplayMin" << YAML::Value << vdata->dmin; } if (vdata->min != INT_MAX && vdata->min != DBL_MAX) { em << YAML::Key << "DisplayMax" << YAML::Value << vdata->dmax; } } else if (tdata) { if (tdata->label) { propNames.push_back("IsLabel"); } if (tdata->multiLine) { propNames.push_back("MultiLine"); } if (tdata->richText) { propNames.push_back("RichText"); } } else if (pdata) { if (pdata->multiPath) { propNames.push_back("MultiPath"); } } else if (fdata) { if (fdata->useSequences) { propNames.push_back("Sequences"); } if (fdata->useExistingFiles) { propNames.push_back("ExistingFiles"); } if (!fdata->filters.empty()) { em << YAML::Key << "FileTypes" << YAML::Value << YAML::Flow << YAML::BeginSeq; for (std::size_t i = 0; i < fdata->filters.size(); ++i) { em << fdata->filters[i]; } em << YAML::EndSeq; } } } // if (_isUserKnob) { if (_hasViewerInterface) { if (!_inViewerContextItemLayout.empty() && _inViewerContextItemLayout != kInViewerContextItemLayoutSpacing) { em << YAML::Key << "InViewerLayout" << YAML::Value << _inViewerContextItemLayout; } else { if (_inViewerContextItemSpacing != kKnobInViewerContextDefaultItemSpacing) { em << YAML::Key << "InViewerSpacing" << YAML::Value << _inViewerContextItemSpacing; } } if (_isUserKnob) { if (!_inViewerContextLabel.empty()) { em << YAML::Key << "InViewerLabel" << YAML::Value << _inViewerContextLabel; } if (!_inViewerContextIconFilePath[0].empty()) { em << YAML::Key << "InViewerIconUnchecked" << YAML::Value << _inViewerContextIconFilePath[0]; } if (!_inViewerContextIconFilePath[1].empty()) { em << YAML::Key << "InViewerIconChecked" << YAML::Value << _inViewerContextIconFilePath[1]; } } } if (!propNames.empty()) { em << YAML::Key << "Props" << YAML::Value << YAML::Flow << YAML::BeginSeq; for (std::list<std::string>::const_iterator it2 = propNames.begin(); it2 != propNames.end(); ++it2) { em << *it2; } em << YAML::EndSeq; } em << YAML::EndMap; } // KnobSerialization::encode