Exemplo n.º 1
0
StringPairArray mergePreprocessorDefs (StringPairArray inheritedDefs, const StringPairArray& overridingDefs)
{
    for (int i = 0; i < overridingDefs.size(); ++i)
        inheritedDefs.set (overridingDefs.getAllKeys()[i], overridingDefs.getAllValues()[i]);

    return inheritedDefs;
}
Exemplo n.º 2
0
bool metaDataContainsZeroIdentifiers (const StringPairArray& values)
{
    // (zero cue identifiers are valid for WAV but not for AIFF)
    const String cueString ("Cue");
    const String noteString ("CueNote");
    const String identifierString ("Identifier");

    const StringArray& keys = values.getAllKeys();

    for (int i = 0; i < keys.size(); ++i)
    {
        const String key (keys[i]);

        if (key.startsWith (noteString))
            continue; // zero identifier IS valid in a COMT chunk

        if (key.startsWith (cueString) && key.contains (identifierString))
        {
            const int value = values.getValue (key, "-1").getIntValue();

            if (value == 0)
                return true;
        }
    }

    return false;
}
Exemplo n.º 3
0
String replacePreprocessorDefs (const StringPairArray& definitions, String sourceString)
{
    for (int i = 0; i < definitions.size(); ++i)
    {
        const String key (definitions.getAllKeys()[i]);
        const String value (definitions.getAllValues()[i]);

        sourceString = sourceString.replace ("${" + key + "}", value);
    }

    return sourceString;
}
Exemplo n.º 4
0
StringPairArray ProjectExporter::BuildConfiguration::getUniquePreprocessorDefs() const
{
    StringPairArray perConfigurationDefs (parsePreprocessorDefs (getBuildConfigPreprocessorDefsString()));
    const StringPairArray globalDefs (project.getPreprocessorDefs());

    for (int i = 0; i < globalDefs.size(); ++i)
    {
        String globalKey   = globalDefs.getAllKeys()[i];

        int idx = perConfigurationDefs.getAllKeys().indexOf (globalKey);
        if (idx >= 0)
        {
            String globalValue = globalDefs.getAllValues()[i];

            if (globalValue == perConfigurationDefs.getAllValues()[idx])
                perConfigurationDefs.remove (idx);
        }
    }

    return perConfigurationDefs;
}
Exemplo n.º 5
0
const var EnviJSONRPC::toArray (const StringPairArray &stringPairArray)
{
	var ret = empty(false);
	DynamicObject *dso = ret.getDynamicObject();

	for (int i=0; i<stringPairArray.size(); i++)
	{
		dso->setProperty (stringPairArray.getAllKeys() [i], stringPairArray.getAllValues() [i]);
	}

	return (ret);
}
Exemplo n.º 6
0
String createGCCPreprocessorFlags (const StringPairArray& defs)
{
    String s;

    for (int i = 0; i < defs.size(); ++i)
    {
        String def (defs.getAllKeys()[i]);
        const String value (defs.getAllValues()[i]);
        if (value.isNotEmpty())
            def << "=" << value;

        s += " -D" + def;
    }

    return s;
}
Exemplo n.º 7
0
void SAMApplication:: MainMenuModel::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/)
{
    if (menuItemID >= recentProjectsBaseID && menuItemID < recentProjectsBaseID + 100)
    {
        // open a file from the "recent files" menu
        const File file(StoredSettings::getInstance()->recentFiles
                        .getFile(menuItemID - recentProjectsBaseID));

        getApp()->openFile(file);
        StoredSettings::getInstance()->recentFiles.addFile(file);
    }
    if(menuItemID >= exportersBaseID && menuItemID < exportersBaseID + 100)
    {
        StringPairArray spa = StoredSettings::getInstance()
            ->getExporters().getAllProperties();

        StoredSettings::getInstance()
            ->setCurrentExporter(spa.getAllKeys()[menuItemID - exportersBaseID]);
#ifdef JUCE_MAC
        menuItemsChanged();
#endif
    }
    else if (menuItemID >= snappingSizesBaseID && menuItemID < snappingSizesBaseID + 100)
    {
        if (getApp()->getActiveHolderComponent() != 0)
        {
            getApp()->getActiveHolderComponent()
                ->setSnappingGrid(snapSizes [menuItemID - snappingSizesBaseID],
                                  getApp()->getActiveHolderComponent()->isSnapActive(false),
                                  getApp()->getActiveHolderComponent()->isSnapShown());
        }
    }
    else if(menuItemID >= activeMDLsBaseID && menuItemID < activeMDLsBaseID + 100)
    {
        int mawId = menuItemID - activeMDLsBaseID;
        if(mawId < SAMApplication::getApp()->mainWindows.size())
            if(MainAppWindow* maw = SAMApplication::getApp()->mainWindows[mawId])
                maw->toFront(true);
    }
}
Exemplo n.º 8
0
    static void create (MemoryBlock& block, const StringPairArray& values)
    {
        if (values.getAllKeys().contains ("MidiUnityNote", true))
        {
            block.setSize ((sizeof (InstChunk) + 3) & ~3, true);
            InstChunk* const inst = static_cast <InstChunk*> (block.getData());

            inst->baseNote      = (int8) values.getValue ("MidiUnityNote", "60").getIntValue();
            inst->detune        = (int8) values.getValue ("Detune", "0").getIntValue();
            inst->lowNote       = (int8) values.getValue ("LowNote", "0").getIntValue();
            inst->highNote      = (int8) values.getValue ("HighNote", "127").getIntValue();
            inst->lowVelocity   = (int8) values.getValue ("LowVelocity", "1").getIntValue();
            inst->highVelocity  = (int8) values.getValue ("HighVelocity", "127").getIntValue();
            inst->gain          = (int16) ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Gain", "0").getIntValue());

            inst->sustainLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0Type", "0").getIntValue());
            inst->sustainLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0StartIdentifier", "0").getIntValue());
            inst->sustainLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0EndIdentifier", "0").getIntValue());
            inst->releaseLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1Type", "0").getIntValue());
            inst->releaseLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1StartIdentifier", "0").getIntValue());
            inst->releaseLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1EndIdentifier", "0").getIntValue());
        }
    }
Exemplo n.º 9
0
//==============================================================================
void ProjectSaver::writePluginCharacteristicsFile()
{
    StringPairArray flags;
    flags.set ("JucePlugin_Build_VST",                   boolToString (project.shouldBuildVST()));
    flags.set ("JucePlugin_Build_VST3",                  boolToString (project.shouldBuildVST3()));
    flags.set ("JucePlugin_Build_AU",                    boolToString (project.shouldBuildAU()));
    flags.set ("JucePlugin_Build_AUv3",                  boolToString (project.shouldBuildAUv3()));
    flags.set ("JucePlugin_Build_RTAS",                  boolToString (project.shouldBuildRTAS()));
    flags.set ("JucePlugin_Build_AAX",                   boolToString (project.shouldBuildAAX()));
    flags.set ("JucePlugin_Build_Standalone",            boolToString (project.shouldBuildStandalonePlugin()));
    flags.set ("JucePlugin_Build_Unity",                 boolToString (project.shouldBuildUnityPlugin()));
    flags.set ("JucePlugin_Enable_IAA",                  boolToString (project.shouldEnableIAA()));
    flags.set ("JucePlugin_Name",                        toStringLiteral (project.getPluginNameString()));
    flags.set ("JucePlugin_Desc",                        toStringLiteral (project.getPluginDescriptionString()));
    flags.set ("JucePlugin_Manufacturer",                toStringLiteral (project.getPluginManufacturerString()));
    flags.set ("JucePlugin_ManufacturerWebsite",         toStringLiteral (project.getCompanyWebsiteString()));
    flags.set ("JucePlugin_ManufacturerEmail",           toStringLiteral (project.getCompanyEmailString()));
    flags.set ("JucePlugin_ManufacturerCode",            toCharLiteral (project.getPluginManufacturerCodeString()));
    flags.set ("JucePlugin_PluginCode",                  toCharLiteral (project.getPluginCodeString()));
    flags.set ("JucePlugin_IsSynth",                     boolToString (project.isPluginSynth()));
    flags.set ("JucePlugin_WantsMidiInput",              boolToString (project.pluginWantsMidiInput()));
    flags.set ("JucePlugin_ProducesMidiOutput",          boolToString (project.pluginProducesMidiOutput()));
    flags.set ("JucePlugin_IsMidiEffect",                boolToString (project.isPluginMidiEffect()));
    flags.set ("JucePlugin_EditorRequiresKeyboardFocus", boolToString (project.pluginEditorNeedsKeyFocus()));
    flags.set ("JucePlugin_Version",                     project.getVersionString());
    flags.set ("JucePlugin_VersionCode",                 project.getVersionAsHex());
    flags.set ("JucePlugin_VersionString",               toStringLiteral (project.getVersionString()));
    flags.set ("JucePlugin_VSTUniqueID",                 "JucePlugin_PluginCode");
    flags.set ("JucePlugin_VSTCategory",                 project.getVSTCategoryString());
    flags.set ("JucePlugin_Vst3Category",                toStringLiteral (project.getVST3CategoryString()));
    flags.set ("JucePlugin_AUMainType",                  project.getAUMainTypeString());
    flags.set ("JucePlugin_AUSubType",                   "JucePlugin_PluginCode");
    flags.set ("JucePlugin_AUExportPrefix",              project.getPluginAUExportPrefixString());
    flags.set ("JucePlugin_AUExportPrefixQuoted",        toStringLiteral (project.getPluginAUExportPrefixString()));
    flags.set ("JucePlugin_AUManufacturerCode",          "JucePlugin_ManufacturerCode");
    flags.set ("JucePlugin_CFBundleIdentifier",          project.getBundleIdentifierString());
    flags.set ("JucePlugin_RTASCategory",                String (project.getRTASCategory()));
    flags.set ("JucePlugin_RTASManufacturerCode",        "JucePlugin_ManufacturerCode");
    flags.set ("JucePlugin_RTASProductId",               "JucePlugin_PluginCode");
    flags.set ("JucePlugin_RTASDisableBypass",           boolToString (project.isPluginRTASBypassDisabled()));
    flags.set ("JucePlugin_RTASDisableMultiMono",        boolToString (project.isPluginRTASMultiMonoDisabled()));
    flags.set ("JucePlugin_AAXIdentifier",               project.getAAXIdentifierString());
    flags.set ("JucePlugin_AAXManufacturerCode",         "JucePlugin_ManufacturerCode");
    flags.set ("JucePlugin_AAXProductId",                "JucePlugin_PluginCode");
    flags.set ("JucePlugin_AAXCategory",                 String (project.getAAXCategory()));
    flags.set ("JucePlugin_AAXDisableBypass",            boolToString (project.isPluginAAXBypassDisabled()));
    flags.set ("JucePlugin_AAXDisableMultiMono",         boolToString (project.isPluginAAXMultiMonoDisabled()));
    flags.set ("JucePlugin_IAAType",                     toCharLiteral (project.getIAATypeCode()));
    flags.set ("JucePlugin_IAASubType",                  "JucePlugin_PluginCode");
    flags.set ("JucePlugin_IAAName",                     project.getIAAPluginName().quoted());
    flags.set ("JucePlugin_VSTNumMidiInputs",            project.getVSTNumMIDIInputsString());
    flags.set ("JucePlugin_VSTNumMidiOutputs",           project.getVSTNumMIDIOutputsString());

    {
        String plugInChannelConfig = project.getPluginChannelConfigsString();

        if (plugInChannelConfig.isNotEmpty())
        {
            flags.set ("JucePlugin_MaxNumInputChannels",            String (countMaxPluginChannels (plugInChannelConfig, true)));
            flags.set ("JucePlugin_MaxNumOutputChannels",           String (countMaxPluginChannels (plugInChannelConfig, false)));
            flags.set ("JucePlugin_PreferredChannelConfigurations", plugInChannelConfig);
        }
    }

    MemoryOutputStream mem;
    mem.setNewLineString (projectLineFeed);

    mem << "//==============================================================================" << newLine
        << "// Audio plugin settings.." << newLine
        << newLine;

    for (int i = 0; i < flags.size(); ++i)
    {
        mem << "#ifndef  " << flags.getAllKeys()[i] << newLine
            << " #define " << flags.getAllKeys()[i].paddedRight (' ', 32) << "  "
                           << flags.getAllValues()[i] << newLine
            << "#endif" << newLine;
    }

    setExtraAppConfigFileContent (mem.toString());
}
Exemplo n.º 10
0
PopupMenu SAMApplication::MainMenuModel::getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/)
{
	PopupMenu menu;
    if (topLevelMenuIndex == 0)
    {
        menu.addCommandItem (commandManager, CommandIDs::newFile);
        menu.addCommandItem (commandManager, CommandIDs::open);

        PopupMenu recentFiles;
        StoredSettings::getInstance()->recentFiles
            .createPopupMenuItems(recentFiles, recentProjectsBaseID, true, true);

        menu.addSubMenu(TRANS("Open Recent File"), recentFiles);

        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::closeDocument);
        menu.addCommandItem (commandManager, CommandIDs::saveDocument);
        menu.addCommandItem (commandManager, CommandIDs::saveDocumentAs);
        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::showMDLProperties);
        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::saveDocumentAsImage);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::showPrefs);

#if ! JUCE_MAC
        menu.addSeparator();
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::quit);
#endif

    }
    else if (topLevelMenuIndex == 1)
    {
        menu.addCommandItem (commandManager, CommandIDs::undo);
        menu.addCommandItem (commandManager, CommandIDs::redo);
        menu.addSeparator();
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::cut);
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::copy);
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::paste);
        menu.addSeparator();
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::selectAll);
        menu.addCommandItem (commandManager, StandardApplicationCommandIDs::deselectAll);
        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::defineFaustcode);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::reverseDirection);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::tidyObjects);
        menu.addSeparator();

        PopupMenu redrawModelMenu;
        redrawModelMenu.addCommandItem(commandManager, CommandIDs::toggleRedrawIncludeMisc);
        redrawModelMenu.addSeparator();
        redrawModelMenu.addCommandItem(commandManager, CommandIDs::redrawCircle);
        redrawModelMenu.addSeparator();
        redrawModelMenu.addCommandItem(commandManager, CommandIDs::redrawForceDirected);
        redrawModelMenu.addCommandItem(commandManager, CommandIDs::showRedrawOptions);
        menu.addSubMenu(TRANS("Redraw Model"), redrawModelMenu);
    }
    else if (topLevelMenuIndex == 2)
    {
    	menu.addCommandItem(commandManager, CommandIDs::insertMass);
    	menu.addCommandItem(commandManager, CommandIDs::insertGround);
    	menu.addCommandItem(commandManager, CommandIDs::insertResonator);
    	menu.addCommandItem(commandManager, CommandIDs::insertPort);
    	menu.addSeparator();
    	menu.addCommandItem(commandManager, CommandIDs::insertLink);
    	menu.addCommandItem(commandManager, CommandIDs::insertTouch);
    	menu.addCommandItem(commandManager, CommandIDs::insertPluck);
    	menu.addCommandItem(commandManager, CommandIDs::insertPulsetouch);
    	menu.addCommandItem(commandManager, CommandIDs::insertDetent);
    	menu.addCommandItem(commandManager, CommandIDs::insertSofteningLink);
    	menu.addCommandItem(commandManager, CommandIDs::insertStiffeningLink);
    	menu.addSeparator();
    	menu.addCommandItem(commandManager, CommandIDs::insertAudioOutput);
        menu.addCommandItem(commandManager, CommandIDs::insertAudioConnection);
        menu.addCommandItem(commandManager, CommandIDs::insertDisplay);
        menu.addCommandItem(commandManager, CommandIDs::insertDisplayConnection);
    	menu.addSeparator();
    	menu.addCommandItem(commandManager, CommandIDs::insertWaveguide);
    	menu.addCommandItem(commandManager, CommandIDs::insertTermination);
        menu.addCommandItem(commandManager, CommandIDs::insertJunction);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::insertComment);
    }
    else if (topLevelMenuIndex == 3)
    {
    	menu.addCommandItem(commandManager, CommandIDs::generateFaust);
        menu.addSeparator();
    	menu.addCommandItem(commandManager, CommandIDs::generateExternal);
        menu.addSeparator();
        StringPairArray spa = StoredSettings::getInstance()->getExporters().getAllProperties();
        String currExporter = StoredSettings::getInstance()->getCurrentExporter();
        for (int i = 0; i < spa.size(); ++i)
        {
            bool isTicked = false;
            if(spa.getAllKeys()[i].compare(currExporter) == 0)
                isTicked = true;
            menu.addItem(exportersBaseID + i, spa.getAllKeys()[i],true,isTicked);
        }
    }
    else if (topLevelMenuIndex == 4)
    {
        menu.addCommandItem(commandManager, CommandIDs::cleanDataDir);
        menu.addCommandItem(commandManager, CommandIDs::cleanDataDirAll);
      	menu.addSeparator();
    	menu.addCommandItem(commandManager, CommandIDs::openDataDir);
        menu.addCommandItem(commandManager, CommandIDs::openMdlFileExtern);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::printSAMLog);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::printMDL);
#ifdef _DEBUG
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::writeMDLFileAsXml);
#endif
    }
    else if (topLevelMenuIndex == 5)
    {
        menu.addCommandItem (commandManager, CommandIDs::zoomIn);
        menu.addCommandItem (commandManager, CommandIDs::zoomOut);
        menu.addCommandItem (commandManager, CommandIDs::zoomNormal);
        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::segmentedConnectors);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::showAudioConnections);
        menu.addCommandItem(commandManager, CommandIDs::showObjectNames);
        menu.addSeparator();
        menu.addCommandItem (commandManager, CommandIDs::showGrid);
        menu.addCommandItem (commandManager, CommandIDs::enableSnapToGrid);

        const int currentSnapSize = getApp()->getActiveHolderComponent() != 0
            ? getApp()->getActiveHolderComponent()->getSnappingGridSize() : 0;

        PopupMenu m;
        for (int i = 0; i < numElementsInArray (snapSizes); ++i)
            m.addItem (snappingSizesBaseID + i,
                       String(snapSizes[i]) + " " + TRANS("pixels"),
                       true, snapSizes[i] == currentSnapSize);

        menu.addSubMenu(TRANS("Grid Size"), m, getApp()->getActiveHolderComponent() != 0);
    }
    else if (topLevelMenuIndex == 6)
    {
        menu.addCommandItem(commandManager, CommandIDs::showPostWindow);
        menu.addCommandItem(commandManager, CommandIDs::clearOutputConsole);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::showPropertiesWindow);
        menu.addCommandItem(commandManager, CommandIDs::propertiesWindowOnTop);
        menu.addSeparator();
        menu.addCommandItem(commandManager, CommandIDs::showPreviousWindow);
        menu.addCommandItem(commandManager, CommandIDs::showNextWindow);
        menu.addSeparator();

        const int numDocs = jmin (50, SAMApplication::getApp()->mainWindows.size());

        for (int i = 0; i < numDocs; ++i)
        {
            MDLFile* mdl = SAMApplication::getApp()->mainWindows[i]->getMDLFile();
            menu.addItem (activeMDLsBaseID + i, mdl->getName());
        }
    }
    else if (topLevelMenuIndex == 7)
    {
    	menu.addCommandItem(commandManager, CommandIDs::showHelp);
    }

	return menu;
}
Exemplo n.º 11
0
bool ProjucerAnalyticsDestination::logBatchedEvents (const Array<AnalyticsEvent>& events)
{
    String appData ("v=1&aip=1&tid=" + apiKey);

    StringArray postData;

    for (auto& event : events)
    {
        StringPairArray data;

        data.set ("t", "event");
        data.set ("cid", event.userID);

        switch (event.eventType)
        {
            case ProjucerAnalyticsEvent::appEvent:
            {
                data.set ("ec", "App");
                setData (event, data);

                break;
            }

            case ProjucerAnalyticsEvent::projectEvent:
            {
                data.set ("ec", "Project");
                setData (event, data);

                break;
            }

            case ProjucerAnalyticsEvent::userEvent:
            {
                data.set ("ec", "User");
                setData (event, data);

                break;
            }

            case ProjucerAnalyticsEvent::exampleEvent:
            {
                data.set ("ec", "Example");
                setData (event, data);

                break;
            }

            default:
            {
                // unknown event type!
                jassertfalse;
                break;
            }
        }

        StringArray eventData;

        for (auto& key : data.getAllKeys())
            eventData.add (key + "=" + URL::addEscapeChars (data[key], true));

        postData.add (appData + "&" + eventData.joinIntoString ("&"));
    }

    auto url = URL ("https://www.google-analytics.com/batch")
                   .withPOSTData (postData.joinIntoString ("\n"));

    {
        const ScopedLock lock (webStreamCreation);

        if (shouldExit)
            return false;

        webStream.reset (new WebInputStream (url, true));
    }

    auto success = webStream->connect (nullptr);

    // Do an exponential backoff if we failed to connect.
    if (success)
        periodMs = initialPeriodMs;
    else
        periodMs *= 2;

    setBatchPeriod (periodMs);

    return success;
}