void setText (const String& newText)
 {
     if (isWidth)
         document.setInitialSize  (newText.getIntValue(), document.getInitialHeight());
     else
         document.setInitialSize  (document.getInitialWidth(), newText.getIntValue());
 }
Example #2
0
void CDPlayer::restoreFromXml(const XmlElement& element, const File& /*projectDirectory*/)
{
    setColor(Colour::fromString(element.getStringAttribute("color", "0xffffffff")));
    repaint();

    XmlElement* boundsXml = element.getChildByName("Bounds");

    if (boundsXml)
    {
        String x = boundsXml->getStringAttribute("x", "0");
        String y = boundsXml->getStringAttribute("y", "0");
        String width = boundsXml->getStringAttribute("width", "150");
        String height = boundsXml->getStringAttribute("height", "150");
        getParentComponent()->setBounds(x.getIntValue(), y.getIntValue(), width.getIntValue(), height.getIntValue());
    }
    else
    {
        XmlElement* mdiDocumentPosXml = element.getChildByName("MdiDocumentPos");
        if (mdiDocumentPosXml->getNumChildElements() > 0 && mdiDocumentPosXml->getFirstChildElement()->isTextElement())
        {
            getProperties().set("mdiDocumentPos_", mdiDocumentPosXml->getFirstChildElement()->getText());
        }
    }

    XmlElement* nameXml = element.getChildByName("Name");
    setName(nameXml->getAllSubText().trim());

    XmlElement* driveXml = element.getChildByName("Drive");
    m_availableCDsComboBox.selectDrive(driveXml->getAllSubText().trim());
}
Example #3
0
void OSCHandler::ProcessMessage(const osc::ReceivedMessage& m, const IpEndpointName& /*remoteEndpoint*/)
{
    const String stripWildcard = OSCPrefix + "strip/*";

    try
    {
        String msgPattern = m.AddressPattern();

        if (msgPattern.equalsIgnoreCase(OSCPrefix + "press"))
        {
            // we need three arguments for button presses
            const int numArgs = m.ArgumentCount();
            if (numArgs != 3) throw osc::Exception();

            osc::ReceivedMessageArgumentStream args = m.ArgumentStream();

            // unpack the monome button, row and state (button up or down)
            osc::int32 row, col, state;
            args >> row >> col >> state >> osc::EndMessage;
            buttonPressCallback(row, col, state == 1);
        }
        else if (msgPattern.matchesWildcard(stripWildcard, false))
        {
            // strip off the /mlrvst/strip/ part of the message
            msgPattern = msgPattern.substring(stripWildcard.length() - 1);

            // and extract the SampleStrip rowID from the message
            const String rowIDStr = msgPattern.upToFirstOccurrenceOf("/", false, false);

            const int stripID = rowIDStr.getIntValue();

            handleStripMessage(stripID, m);
        }
    }
Example #4
0
void WdmChMapComponent::itemDropped (const SourceDetails& dragSourceDetails)
{
	// an example valid drag sourceDescription is:
	//  WDM 2 (Front Right)
	//	 where the number indicates the item's 1-based index
	int map_src_index = dragSourceDetails.description.toString().substring(4,6).getIntValue() - 1;  // convert to zero-based

	if ((map_src_index < 0) || (map_src_index > 15))
	{
		m_dragging = false;
		return;
	}

	// a drop here means we're unmapping a channel
	if (m_bus)
	{
		Component *sourceComp = dragSourceDetails.sourceComponent;
		String sourceName = sourceComp->getName();
		if (sourceName.contains("clist"))
		{
			String rowName = sourceName.fromFirstOccurrenceOf("clist ", false, false);

			try
			{
				m_bus->speaker_map(m_out, (uint32)map_src_index, (uint32)-1);
				m_bus->ready_wait();

				int row_num = rowName.getIntValue();
				if (m_out)
				{
					m_out_map_names.set(row_num, " -");
				}
				else
				{
					m_out_map_names.set(row_num, " -");
				}

				String eventStr = String::empty;
				eventStr << "unmapped wdm " << (m_out ? "out" : "in") << " ch " << map_src_index << ", dev ch " << row_num << " (zero-based)";
				EventLogger::getInstance()->logMessage(eventStr);

				update_speaker_map(0,0);	// update the channel list asynchronously
			}
			catch (...)
			{
				EventLogger::getInstance()->logMessage("ch unmap exception");
			}
		}
	}	
	m_dragging = false;
}
Example #5
0
void LR_IPC_IN::processLine(const String& line)
{
	// process input into [parameter] [Value]
	line.trimEnd();
	String command = line.upToFirstOccurrenceOf(" ", false, false);
	String valueString = line.replace(line.upToFirstOccurrenceOf(" ", true, true), "", true);
	auto value = valueString.getIntValue();

	// store updates in map
	parameterMap[command] = value;

	// send associated CC messages to MIDI OUT devices
	if (CommandMap::getInstance().commandHasAssociatedMessage(command))
	{
		const MIDI_Message& msg = CommandMap::getInstance().getMessageForCommand(command);
		MIDISender::getInstance().sendCC(msg.channel, msg.controller, value);
	}
}
Example #6
0
void Config::setRpcIpAndOptionalPort (std::string const& newAddress)
{
    String const s (newAddress.c_str ());
    
    int const colonPosition = s.lastIndexOfChar (':');

    if (colonPosition != -1)
    {
        String const ipPart = s.substring (0, colonPosition);
        String const portPart = s.substring (colonPosition + 1, s.length ());

        setRpcIP (ipPart.toRawUTF8 ());
        setRpcPort (portPart.getIntValue ());
    }
    else
    {
        setRpcIP (newAddress);
    }
}
Example #7
0
 /** this will validate playAfterStop message
     @param[in]  message         message string
     @param[in]  indexList       No of rows that are delete from mediaArray
     @return     bool            true if playAfterStop message */
 bool isDeleteInPlayList(const String & message, Array<int> & indexList)
 {
     String tempMessage = message;
     if(tempMessage.contains(deleteInPlayListID))
     {
         // SOme logic needed here to convert String to Array
         tempMessage = tempMessage.fromFirstOccurrenceOf(messageSeparator, false, false);
         String index;
         while(tempMessage != "")
         {
             index = tempMessage.upToFirstOccurrenceOf(messageSeparator, false, false);
             tempMessage = tempMessage.fromFirstOccurrenceOf(messageSeparator, false, false);
             indexList.add(index.getIntValue());
         }
         return true;
     }
     else
         return false;
 }
Example #8
0
void ApplicationSettingsComponent::buttonClicked (Button* buttonThatWasClicked)
{
    //[UserbuttonClicked_Pre]
    //[/UserbuttonClicked_Pre]

    if (buttonThatWasClicked == connectButton)
    {
        //[UserButtonCode_connectButton] -- add your button handler code here..
      ApplicationConfiguration::getBlipClient()->disconnect();
      String port = serialPortComboBox->getText();
      String speed = serialSpeedComboBox->getText();
      ApplicationConfiguration::getBlipClient()->setPort(port);
      ApplicationConfiguration::getBlipClient()->setSpeed(speed.getIntValue());
      ApplicationConfiguration::getBlipClient()->connect();
      std::cout << "connected: " << ApplicationConfiguration::getBlipClient()->isConnected() << std::endl;
        //[/UserButtonCode_connectButton]
    }
    else if (buttonThatWasClicked == okButton)
    {
        //[UserButtonCode_okButton] -- add your button handler code here..
      saveSettingsToFile();
      setVisible(false);
      DialogWindow* dw = findParentComponentOfClass((DialogWindow*)nullptr);
      if(dw != nullptr)
	dw->exitModalState(1);
        //[/UserButtonCode_okButton]
    }
    else if (buttonThatWasClicked == cancelButton)
    {
        //[UserButtonCode_cancelButton] -- add your button handler code here..
      setVisible(false);
      DialogWindow* dw = findParentComponentOfClass((DialogWindow*)nullptr);
      if(dw != nullptr)
	dw->exitModalState(0);
        //[/UserButtonCode_cancelButton]
    }

    //[UserbuttonClicked_Post]
    //[/UserbuttonClicked_Post]
}
Example #9
0
AudioChannelSet::ChannelType AudioChannelSet::getChannelTypeFromAbbreviation (const String& abbr)
{
    if (abbr.length() > 0 && (abbr[0] >= '0' && abbr[0] <= '9'))
        return static_cast<AudioChannelSet::ChannelType> (static_cast<int> (discreteChannel0)
                                                               + abbr.getIntValue() + 1);

    if      (abbr == "L")    return left;
    else if (abbr == "R")    return right;
    else if (abbr == "C")    return centre;
    else if (abbr == "Lfe")  return LFE;
    else if (abbr == "Ls")   return leftSurround;
    else if (abbr == "Rs")   return rightSurround;
    else if (abbr == "Lc")   return leftCentre;
    else if (abbr == "Rc")   return rightCentre;
    else if (abbr == "Cs")   return centreSurround;
    else if (abbr == "Lrs")  return leftSurroundRear;
    else if (abbr == "Rrs")  return rightSurroundRear;
    else if (abbr == "Tm")   return topMiddle;
    else if (abbr == "Tfl")  return topFrontLeft;
    else if (abbr == "Tfc")  return topFrontCentre;
    else if (abbr == "Tfr")  return topFrontRight;
    else if (abbr == "Trl")  return topRearLeft;
    else if (abbr == "Trc")  return topRearCentre;
    else if (abbr == "Trr")  return topRearRight;
    else if (abbr == "Wl")   return wideLeft;
    else if (abbr == "Wr")   return wideRight;
    else if (abbr == "Lfe2") return LFE2;
    else if (abbr == "Lss")  return leftSurroundSide;
    else if (abbr == "Rss")  return rightSurroundSide;
    else if (abbr == "W")    return ambisonicW;
    else if (abbr == "X")    return ambisonicX;
    else if (abbr == "Y")    return ambisonicY;
    else if (abbr == "Z")    return ambisonicZ;

    return unknown;
}
 void setText (const String& newText)
 {
     document.perform (new SetFocusOrderAction (component, *document.getComponentLayout(), jmax (0, newText.getIntValue())),
                       "Change focus order");
 }
float AudioParameterInt::getValueForText (const String& text) const      { return convertTo0to1 (text.getIntValue()); }
Example #12
0
    //==============================================================================
    void initialise (const String& commandLine) override
    {
        // This method is where you should put your application's initialisation code..

		String romName;
		String descriptorName;
		String midiNumberStr;
		String output;

		LPWSTR *szArglist;
		int nArgs;

		szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);

		for (int x = 0; x < nArgs; x++)
		{
			String commandLineStr = String(szArglist[x]);
			commandLineStr = commandLineStr.trim();
			
			if (commandLineStr.startsWith("-rom="))
			{
				romName = commandLineStr.substring(commandLineStr.indexOf("-rom=")+5);
				romName = romName.trim();
			}

			else if (commandLineStr.contains("-descriptor="))
			{
				descriptorName = commandLineStr.substring(commandLineStr.indexOf("-descriptor=")+12);
				descriptorName = descriptorName.trim();
			}
			else if (commandLineStr.contains("-midi="))
			{
				midiNumberStr = commandLineStr.substring(commandLineStr.indexOf("-midi=")+6);
				midiNumberStr = midiNumberStr.trim();
			}
			else if (commandLineStr.contains("-output="))
			{
				output = commandLineStr.substring(commandLineStr.indexOf("-output=")+8);
				output = output.trim();
			}
		}

		int midiNumber = midiNumberStr.getIntValue();

        mainWindow = new MainWindow();

		mainWindow->mainComponent->romfile = File(romName);
		mainWindow->mainComponent->romdescfile = File(descriptorName);

		mainWindow->setName("seq64");

		mainWindow->mainComponent->menuItemSelected(1, 0);
		mainWindow->mainComponent->menuItemSelected(11, 0);

		for (int x = 0; x < mainWindow->mainComponent->filespane->kfilelistnode.getNumChildren(); x++)
		{
			ValueTree selkfile = mainWindow->mainComponent->filespane->kfilelistnode.getChild(x);
			String type = selkfile.getProperty("type", "Unsupported");
			if (type == "Audioseq Index")
			{
				mainWindow->mainComponent->filespane->lstKFiles->selectRow(x);
				mainWindow->mainComponent->filespane->rowSelected(mainWindow->mainComponent->filespane->lsmKFiles, x);
				break;
			}
		}

		//mainWindow->mainComponent->filespane->lstIndex->selectRow(0);
		
		mainWindow->mainComponent->filespane->rowSelected(mainWindow->mainComponent->filespane->lsmIndex, midiNumber);
		
		mainWindow->mainComponent->filespane->buttonClicked(mainWindow->mainComponent->filespane->btnLoadEntry);

		mainWindow->mainComponent->midipane->dest = output;
		mainWindow->mainComponent->midipane->buttonClicked(mainWindow->mainComponent->midipane->btnMIDIExport);

		JUCEApplication::getInstance()->systemRequestedQuit();
    }
float AudioParameterBool::getValueForText (const String& text) const     { return text.getIntValue() != 0 ? 1.0f : 0.0f; }
Example #14
0
// TODO what is this doing in Processor? Should be in MLScale.
void MLPluginProcessor::loadScale(const File& f) 
{
	MLScale* pScale = mEngine.getScale();
	if (!pScale) return;

	String scaleName = f.getFileNameWithoutExtension();
	String scaleDir = f.getParentDirectory().getFileNameWithoutExtension();
	String scaleStr = f.loadFileAsString();
	const String delim = "\n\r";
	int a, b;
	int contentLines = 0;
	int ratios = 0;

	// debug() << "MLPluginProcessor: loading scale " << scaleDir << "/" << scaleName << "\n";		

	a = b = 0;
	while(b >= 0)
	{
		b = scaleStr.indexOfAnyOf(delim, a, false);
		
//		debug() << "[" << a << ", " << b << "] > " << scaleStr.substring(a, b) << "\n";
		String inputLine = scaleStr.substring(a, b);
		
		if (inputLine[0] != '!')
		{
			contentLines++;
			
			switch(contentLines)
			{
				case 1:
				{
					const char* descStr = inputLine.toUTF8();
					pScale->setDescription(descStr);
					const char* nameStr = scaleName.toUTF8();
					pScale->setName(nameStr);
				}
				break;
				
				case 2:
				{
//					int notes = inputLine.getIntValue(); // unused
					pScale->clear();
				}
				break;
				
				default: // after 2nd line, add ratios.
				{
					// 
					if (inputLine.contains("."))
					{
						double ratio = inputLine.getDoubleValue();
						ratios++;
						pScale->addRatio(ratio);
					}
					else
					{
						if (inputLine.containsChar('/'))
						{
							int s = inputLine.indexOfChar('/');
							String numStr = inputLine.substring(0, s);
							String denomStr = inputLine.substring(s + 1, inputLine.length());
							int num = numStr.getIntValue();
							int denom = denomStr.getIntValue();
//	debug() << "n:" << num << " denom: " << denom << "\n";
							if ((num > 0) && (denom > 0))
							{
								ratios++;
								pScale->addRatio(num, denom);
							}
						}
						else
						{
							int num = inputLine.getIntValue();
							if (num > 0)
							{
								ratios++;
								pScale->addRatio(num, 1);
							}
						}
					}
				}
				break;			
			}
		}
		
		a = b + 2;	
	}
	
	if (ratios > 0)
	{
		// TODO load .kbm mapping file if one exists
		pScale->setDefaultMapping();
		pScale->recalcRatios();		
	}
	
	broadcastScale(pScale);
}
Example #15
0
SmugID SmugMug::uploadFile(int queue, int index)
{
	SmugID retval;

	lock.enter();
	UploadFile& uf = uploadQueue[queue]->getImageFileInfo(index);
	lock.exit();

	int64 bytesDone = 0;
	MD5 md5(uf.file);

	Time start = Time::getCurrentTime();

	startTimer(LOGOUT_TIMER);

	String headers;
    String filename = uf.file.getFileName();
    headers = "PUT http://upload.smugmug.com/" + URL::addEscapeChars(filename, false) + " HTTP/1.1\r\n" +
		      "Host: upload.smugmug.com\r\n" +
			  "Content-Length: " + String(uf.file.getSize()) + "\r\n" +
		      "Content-MD5: " + md5.toHexString() + "\r\n" +
			  "X-Smug-SessionID: " + sessionId + "\r\n" +
			  "X-Smug-Version: 1.2.2\r\n" +
			  "X-Smug-ResponseType: REST\r\n" +
			  "X-Smug-AlbumID: " + String(uploadQueue[queue]->getAlbumId().id) + "\r\n" +
			  "X-Smug-FileName: " + filename + "\r\n\r\n";

#ifdef JUCE_DEBUG
	Logger::outputDebugString(headers);
#endif

	const char* headerUtf8 = headers.toUTF8();

	StreamingSocket soc;

	if (soc.connect("upload.smugmug.com", 80))
	{
		int bytesWritten = soc.write(headerUtf8, (int)strlen(headerUtf8));
		if (bytesWritten == -1)
		{
			uf.status = UploadFile::Failed;
			return retval;
		}

		FileInputStream* fos = uf.file.createInputStream();
		if (fos)
		{
			char buffer[1024 * 8];
			while (!fos->isExhausted())
			{
				int in = fos->read(buffer, sizeof(buffer));
				int out = soc.write(buffer, in);

				startTimer(LOGOUT_TIMER);

				if (in != out)
				{
					delete fos;
					uf.status = UploadFile::Failed;
					return retval;
				}
				else
				{
					bytesDone += in;
					uf.complete = float(bytesDone)/float(uf.file.getSize());
				}

				if (uf.status == UploadFile::Cancelled)
				{
					delete fos;
					return retval;
				}
			}
			delete fos;
		}
		else
		{
			uf.status = UploadFile::Failed;
			return retval;
		}

		String response;
		response.preallocateBytes(1024);

		while (1)
		{
			char buffer;
			int read = soc.read(&buffer, 1, true);
			if (read == -1)
				break;

			response += buffer;

			if (response.endsWith(("\r\n\r\n")) || response.endsWith(("\n\n")))
			{
				String len = response.fromFirstOccurrenceOf(("Content-Length: "), false, true);
				if (len.isNotEmpty())
				{
					// normal mode
					String num;

					int i = 0;
					while (CharacterFunctions::isDigit(len[i]))
						num += len[i++];
					
					int bytes = num.getIntValue();

					char* buffer = new char[bytes + 1];
					soc.read(buffer, bytes, true);
					buffer[bytes] = 0;

					response += buffer;
					delete[] buffer;
				}
				else
				{
					// chunked
					while (1)
					{
						String line;
						char ch;
						while (!line.endsWith("\r\n"))
						{
							soc.read(&ch, 1, true);
							line += ch;
						}

						int sz = line.getHexValue32();
						if (sz == 0)
							break;

						char* buf = new char[sz + 1];
						soc.read(buf, sz, true);
						buf[sz] = 0;

						response += buf;
						delete buf;

						soc.read(&ch, 1, true);
						soc.read(&ch, 1, true);
					}
				}

#ifdef JUCE_DEBUG				
				Logger::outputDebugString(response);
#endif
				soc.close();

				String xml = response.fromFirstOccurrenceOf(("<?xml"), true, true); 
				XmlDocument doc(xml);
				XmlElement* e = doc.getDocumentElement();
				if (e)
				{
					XmlElement* image = e->getChildByName(("Image"));
					if (image)
					{
						int val = image->getIntAttribute(("id"));
						if (val >= 0)
						{
							uf.status = UploadFile::Finished;
							uf.complete = 1.0f;
							uf.url = image->getStringAttribute("URL");

							Time end = Time::getCurrentTime();
							RelativeTime diff = end - start;

							addLogEntry(("Info: ") + uf.file.getFileName() + (" uploaded in ") + String(int(diff.inSeconds())) + (" seconds [") + String(uf.file.getSize() / 1024 / diff.inSeconds(), 1) + ("KB/s]"));

							retval.id  = val;
							retval.key = image->getStringAttribute(("Key"));
								
							delete e;
							return retval;
						}
					}
					delete e;
				}
			}
		} 		
	}

	uf.status = UploadFile::Failed;
	return retval;
}
SettingsPageComponent::SettingsPageComponent(LauncherComponent* lc) {
  bgColor = Colour(0xffd23c6d);
  bgImage = createImageFromFile(assetFile("settingsBackground.png"));
  mainPage = new Component();
  addAndMakeVisible(mainPage);
  mainPage->toBack();
  ChildProcess child{};

  /* Adding the personalize button */
  advancedPage = new AdvancedSettingsPage(lc);
  advanced = new TextButton("Advanced Settings");
  advanced->addListener(this);
  addAndMakeVisible(advanced);
  
  brightness = 8;
  #if JUCE_LINUX
     // Get initial brightness value
     if(child.start("cat /sys/class/backlight/backlight/brightness")) {
    	String result{child.readAllProcessOutput()};
	brightness = result.getIntValue();
     };
  #endif


  volume = 90;
  
  #if JUCE_LINUX
    // Get initial volume value
    StringArray cmd{ "amixer","sget","Power Amplifier" };
    if(child.start(cmd)) {
      const String result (child.readAllProcessOutput());
      int resultIndex = result.indexOf("[")+1;
      child.waitForProcessToFinish (5 * 1000);
      char buff[4];
      for (int i = 0; i<4; i++) {
	      char c = result[resultIndex+i];
	      if( c >= '0' && c <= '9' ) {
		       buff[i]=c;
      	} else {
		     buff[i]=(char)0;
      	}
      }
      String newVol = String(buff);
      volume = newVol.getIntValue();
    }
  #endif

  ScopedPointer<Drawable> brightLo = Drawable::createFromImageFile(assetFile("brightnessIconLo.png"));
  ScopedPointer<Drawable> brightHi = Drawable::createFromImageFile(assetFile("brightnessIconHi.png"));
  screenBrightnessSlider =
      ScopedPointer<IconSliderComponent>(new IconSliderComponent(*brightLo, *brightHi));
  screenBrightnessSlider->addListener(this);
  screenBrightnessSlider->slider->setValue(1+(brightness-0.09)*10);

  ScopedPointer<Drawable> volLo =
      Drawable::createFromImageFile(assetFile("volumeIconLo.png"));
  ScopedPointer<Drawable> volHi =
      Drawable::createFromImageFile(assetFile("volumeIconHi.png"));
  volumeSlider = ScopedPointer<IconSliderComponent>(new IconSliderComponent(*volLo, *volHi));
  volumeSlider->addListener(this);
  volumeSlider->slider->setValue(volume);

  // create back button
  backButton = createImageButton(
                                 "Back", createImageFromFile(assetFile("backIcon.png")));
  backButton->addListener(this);
  backButton->setAlwaysOnTop(true);
  addAndMakeVisible(backButton);

  wifiCategoryItem = new WifiCategoryItemComponent();
  wifiCategoryItem->button->addListener(this);
  addAndMakeVisible(wifiCategoryItem);
  getWifiStatus().addListener(wifiCategoryItem);

  addAndMakeVisible(screenBrightnessSlider);
  addAndMakeVisible(volumeSlider);

  wifiPage = new SettingsPageWifiComponent();
}
    //==============================================================================
    void parsePathString (Path& path, const String& pathString) const
    {
        String::CharPointerType d (pathString.getCharPointer().findEndOfWhitespace());

        Point<float> subpathStart, last, last2, p1, p2, p3;
        juce_wchar lastCommandChar = 0;
        bool isRelative = true;
        bool carryOn = true;

        const CharPointer_ASCII validCommandChars ("MmLlHhVvCcSsQqTtAaZz");

        while (! d.isEmpty())
        {
            if (validCommandChars.indexOf (*d) >= 0)
            {
                lastCommandChar = d.getAndAdvance();
                isRelative = (lastCommandChar >= 'a' && lastCommandChar <= 'z');
            }

            switch (lastCommandChar)
            {
            case 'M':
            case 'm':
            case 'L':
            case 'l':
                if (parseCoordsOrSkip (d, p1, false))
                {
                    if (isRelative)
                        p1 += last;

                    if (lastCommandChar == 'M' || lastCommandChar == 'm')
                    {
                        subpathStart = p1;
                        path.startNewSubPath (p1);
                        lastCommandChar = 'l';
                    }
                    else
                        path.lineTo (p1);

                    last2 = last;
                    last = p1;
                }
                break;

            case 'H':
            case 'h':
                if (parseCoord (d, p1.x, false, true))
                {
                    if (isRelative)
                        p1.x += last.x;

                    path.lineTo (p1.x, last.y);

                    last2.x = last.x;
                    last.x = p1.x;
                }
                else
                {
                    ++d;
                }
                break;

            case 'V':
            case 'v':
                if (parseCoord (d, p1.y, false, false))
                {
                    if (isRelative)
                        p1.y += last.y;

                    path.lineTo (last.x, p1.y);

                    last2.y = last.y;
                    last.y = p1.y;
                }
                else
                {
                    ++d;
                }
                break;

            case 'C':
            case 'c':
                if (parseCoordsOrSkip (d, p1, false)
                     && parseCoordsOrSkip (d, p2, false)
                     && parseCoordsOrSkip (d, p3, false))
                {
                    if (isRelative)
                    {
                        p1 += last;
                        p2 += last;
                        p3 += last;
                    }

                    path.cubicTo (p1, p2, p3);

                    last2 = p2;
                    last = p3;
                }
                break;

            case 'S':
            case 's':
                if (parseCoordsOrSkip (d, p1, false)
                     && parseCoordsOrSkip (d, p3, false))
                {
                    if (isRelative)
                    {
                        p1 += last;
                        p3 += last;
                    }

                    p2 = last + (last - last2);
                    path.cubicTo (p2, p1, p3);

                    last2 = p1;
                    last = p3;
                }
                break;

            case 'Q':
            case 'q':
                if (parseCoordsOrSkip (d, p1, false)
                     && parseCoordsOrSkip (d, p2, false))
                {
                    if (isRelative)
                    {
                        p1 += last;
                        p2 += last;
                    }

                    path.quadraticTo (p1, p2);

                    last2 = p1;
                    last = p2;
                }
                break;

            case 'T':
            case 't':
                if (parseCoordsOrSkip (d, p1, false))
                {
                    if (isRelative)
                        p1 += last;

                    p2 = last + (last - last2);
                    path.quadraticTo (p2, p1);

                    last2 = p2;
                    last = p1;
                }
                break;

            case 'A':
            case 'a':
                if (parseCoordsOrSkip (d, p1, false))
                {
                    String num;

                    if (parseNextNumber (d, num, false))
                    {
                        const float angle = num.getFloatValue() * (180.0f / float_Pi);

                        if (parseNextNumber (d, num, false))
                        {
                            const bool largeArc = num.getIntValue() != 0;

                            if (parseNextNumber (d, num, false))
                            {
                                const bool sweep = num.getIntValue() != 0;

                                if (parseCoordsOrSkip (d, p2, false))
                                {
                                    if (isRelative)
                                        p2 += last;

                                    if (last != p2)
                                    {
                                        double centreX, centreY, startAngle, deltaAngle;
                                        double rx = p1.x, ry = p1.y;

                                        endpointToCentreParameters (last.x, last.y, p2.x, p2.y,
                                                                    angle, largeArc, sweep,
                                                                    rx, ry, centreX, centreY,
                                                                    startAngle, deltaAngle);

                                        path.addCentredArc ((float) centreX, (float) centreY,
                                                            (float) rx, (float) ry,
                                                            angle, (float) startAngle, (float) (startAngle + deltaAngle),
                                                            false);

                                        path.lineTo (p2);
                                    }

                                    last2 = last;
                                    last = p2;
                                }
                            }
                        }
                    }
                }

                break;

            case 'Z':
            case 'z':
                path.closeSubPath();
                last = last2 = subpathStart;
                d = d.findEndOfWhitespace();
                lastCommandChar = 'M';
                break;

            default:
                carryOn = false;
                break;
            }

            if (! carryOn)
                break;
        }

        // paths that finish back at their start position often seem to be
        // left without a 'z', so need to be closed explicitly..
        if (path.getCurrentPosition() == subpathStart)
            path.closeSubPath();
    }
Example #18
0
void SqueezerAudioProcessorEditor::actionListenerCallback(
    const String &Message)
{
    // "PC" ==> parameter changed, followed by a hash and the
    // parameter's ID
    if (Message.startsWith("PC#"))
    {
        String StringIndex = Message.substring(3);
        int Index = StringIndex.getIntValue();
        jassert(Index >= 0);
        jassert(Index < PluginProcessor_->getNumParameters());

        if (PluginProcessor_->hasChanged(Index))
        {
            updateParameter(Index);
        }
    }
    // "UM" ==> update meters
    else if (!Message.compare("UM"))
    {
        // prevent meter updates during initialisation
        if (!IsInitialising_)
        {
            for (int Channel = 0; Channel < NumberOfChannels_; ++Channel)
            {
                float AverageInputLevel =
                    PluginProcessor_->getAverageMeterInputLevel(Channel);
                float MaximumInputLevel =
                    PluginProcessor_->getMaximumInputLevel(Channel);

                float PeakInputLevel =
                    PluginProcessor_->getPeakMeterInputLevel(Channel);
                float PeakInputPeakLevel =
                    PluginProcessor_->getPeakMeterPeakInputLevel(Channel);

                InputLevelMeters_[Channel]->setLevels(
                    AverageInputLevel, MaximumInputLevel,
                    PeakInputLevel, PeakInputPeakLevel);

                float AverageOutputLevel =
                    PluginProcessor_->getAverageMeterOutputLevel(Channel);
                float MaximumOutputLevel =
                    PluginProcessor_->getMaximumOutputLevel(Channel);

                float PeakOutputLevel =
                    PluginProcessor_->getPeakMeterOutputLevel(Channel);
                float PeakOutputPeakLevel =
                    PluginProcessor_->getPeakMeterPeakOutputLevel(Channel);

                OutputLevelMeters_[Channel]->setLevels(
                    AverageOutputLevel, MaximumOutputLevel,
                    PeakOutputLevel, PeakOutputPeakLevel);

                float GainReduction =
                    PluginProcessor_->getGainReduction(Channel);
                float GainReductionMeterPeak =
                    PluginProcessor_->getGainReductionMeterPeak(Channel);

                // make sure gain reduction meter doesn't show anything
                // while there is no gain reduction
                GainReduction -= 0.01f;
                GainReductionMeterPeak -= 0.01f;

                GainReductionMeters_[Channel]->setNormalLevels(
                    GainReduction, GainReductionMeterPeak);
            }
        }
    }
    else
    {
        DBG("[Squeezer] Received unknown action message \"" + Message + "\".");
    }
}
Example #19
0
/*==============================================================================
Function Name:  Str2Int
Summary      :  字符串转换为数字
Input        :
                @a_strInput 字符串
Output       :
Return value :  数字
==============================================================================*/
int CSPIniReadWrite::str2Int(const String& str)
{
    return str.getIntValue();
}