Example #1
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 #2
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 #3
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");
 }
    //==============================================================================
    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;
        }
    }
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();
}
Example #7
0
/*==============================================================================
Function Name:  Str2Int
Summary      :  字符串转换为数字
Input        :
                @a_strInput 字符串
Output       :
Return value :  数字
==============================================================================*/
int CSPIniReadWrite::str2Int(const String& str)
{
    return str.getIntValue();
}