コード例 #1
0
ファイル: Enums.cpp プロジェクト: yvanvds/pianola
IDENTITY toIdentity(const juce::String & s) {
  if (s.compareIgnoreCase("none"  ) == 0) return I_NONE  ;
  if (s.compareIgnoreCase("igor"  ) == 0) return I_IGOR  ;
  if (s.compareIgnoreCase("george") == 0) return I_GEORGE;
  if (s.compareIgnoreCase("all"   ) == 0) return I_ALL   ;
  return I_INVALID;
}
コード例 #2
0
ファイル: RPCServer.cpp プロジェクト: sangun/RigidSpectreNET
void RPCServer::SetServerVersion(juce::String& version) noexcept
{
	version = version.trim().substring(0, maxlength_version);
	if (version.containsNonWhitespaceChars())//if name is actually set
	{
		this->version = version;
	}
}
コード例 #3
0
ファイル: juce_Block.cpp プロジェクト: mtytel/JUCE
static Block::UID getBlockUIDFromSerialNumber (const juce::String& serial) noexcept
{
    if (serial.length() < (int) sizeof (BlocksProtocol::BlockSerialNumber))
    {
        jassertfalse;
        return getBlockUIDFromSerialNumber (serial.paddedRight ('0', sizeof (BlocksProtocol::BlockSerialNumber)));
    }

    return getBlockUIDFromSerialNumber ((const uint8*) serial.toRawUTF8());
}
コード例 #4
0
    bool ValueSuffixDisplayDelegate::fromText(const juce::String& inText,
                                              float& outValue) const
    {
        char buffer[128];
        std::memset(buffer, 0, 128);
        std::strncpy(buffer, inText.toUTF8(), 128);

        char* temp = buffer;
        while ((temp = std::strchr(temp, ',')) != 0)
        {
            *temp++ = '.';
        }

        float factor = 1.;
        if (std::strchr(buffer, 'K') != 0 || std::strchr(buffer, 'k') != 0)
        {
            factor = 1000.;
        }

        float plainValue;
        if (sscanf(buffer, "%g %*s", &plainValue) == 1)
        {
            outValue = ranged(0.f, 1.f, mTaper->getNormalized(factor * plainValue));
            return true;
        }
        return false;
    }
コード例 #5
0
//==============================================================================
void TrailingWhitespaceCleaner::cleanLine (juce::String& line)
{
    line = line.trimEnd()
               .trimCharactersAtEnd ("\t")
               .trimEnd()
               .trimCharactersAtEnd ("\t");
}
コード例 #6
0
//==============================================================================
bool CodeFileList::isValid (const juce::String& filepath)
{
    if (filepath.isNotEmpty())
        return juce::File (filepath).hasFileExtension (wildcards);

    return false;
}
コード例 #7
0
ファイル: OAuth2Client.cpp プロジェクト: jrlanglois/JOAuth
//==============================================================================
juce::var OAuth2Client::getJSON (const OAuthSource& source)
{
    if (accessToken.id.isEmpty())
        return juce::var::null;

    juce::URL url (source.getWebsiteAddress().trim());

    if (! url.isWellFormed())
    {
        jassertfalse;
        return juce::var::null;
    }

    url = url.withParameter ("client_id", accessToken.id)
             .withParameter ("client_secret", accessToken.secret);

    if (accessToken.username.isNotEmpty()
        && accessToken.password.isNotEmpty())
    {
        url = url.withParameter ("username", accessToken.username)
                 .withParameter ("password", accessToken.password);
    }

    if (! url.isWellFormed())
    {
        jassertfalse;
        return juce::var::null;
    }

    const juce::String textStream (url.readEntireTextStream().trim());

    if (textStream.isEmpty()
        || (textStream.containsIgnoreCase ("errors")
            && textStream.containsIgnoreCase ("error_message")))
    {
        jassertfalse;
        return juce::var::null;
    }

    juce::var result (juce::JSON::parse (textStream));

    jassert (result != juce::var::null);
    jassert (! result.isUndefined() && ! result.isVoid());

    return result;
}
コード例 #8
0
ファイル: RPCServer.cpp プロジェクト: sangun/RigidSpectreNET
void RPCServer::SetServerDescription(juce::String& description) noexcept
{
	description = version.trim().substring(0, maxlength_description);
	if (description.containsNonWhitespaceChars())//if name is actually set
	{
		this->description = description;
	}
}
コード例 #9
0
ファイル: RPCServer.cpp プロジェクト: sangun/RigidSpectreNET
void RPCServer::SetServerName(juce::String& name) noexcept
{
	name = version.trim().substring(0, maxlength_name);
	if (name.containsNonWhitespaceChars())//if name is actually set
	{
		this->name = name;
	}
}
コード例 #10
0
void InterfaceComponent::buttonClicked (juce::Button* button)
{
    if (button == &btnBrowse)
    {
        juce::FileChooser chooser ("Select the folder which contains the code files you want to modularise");
        
        if (chooser.browseForDirectory())
        {
            const juce::File folder (chooser.getResult());

            txtSourceFileFolder.setText (folder.getFullPathName().trim(), juce::sendNotification);
            txtDestinationFolder.setText (folder.getParentDirectory().getFullPathName().trim(), juce::sendNotification);

            files = Modulariser (folder, true).getFiles();

            fileListBox.setSelectedRows (juce::SparseSet<int>());
            fileListBox.updateContent();
        }
    }
    else if (button == &btnRefresh)
    {
        refresh();
    }
    else if (button == &btnGenerate)
    {
        const juce::String srcFolder (txtSourceFileFolder.getText().trim());
        const juce::String destFolder (txtDestinationFolder.getText().trim());

        if (srcFolder.isNotEmpty()
            && destFolder.isNotEmpty()
            && juce::File::isAbsolutePath (srcFolder)
            && juce::File::isAbsolutePath (destFolder))
        {
            Modulariser modulariser (files);

            modulariser.saveTo (juce::File (destFolder),
                                srcFolder,
                                txtModuleFilename.getText().trim(),
                                txtHeaderGuard.getText().trim(),
                                txtNamespace.getText().trim());
        }
    }
}
コード例 #11
0
ファイル: Track.cpp プロジェクト: L-Naej/VirtuOSE-Project
juce::String Track::extractInstrumentNameFromTrackName(const juce::String& trackName)
{
  //On regarde les noms des fichiers .fxp dans le répertoire fxp
  //Si la trackName contient un de ces noms, c'est l'instrument qu'on cherche !
  juce::Array<juce::File> fxpFiles;
  juce::File fxpDirectory = juce::File::getCurrentWorkingDirectory().getChildFile("../fxp").getFullPathName();
  fxpDirectory.findChildFiles(fxpFiles, juce::File::findFiles, true, "*.fxp");
  for(int i = 0; i < fxpFiles.size(); ++i)
  {
    if (trackName.containsIgnoreCase(fxpFiles[i].getFileNameWithoutExtension()))
      return fxpFiles[i].getFileNameWithoutExtension();
  }
  return juce::String::empty;
}
コード例 #12
0
void InterfaceComponent::refresh()
{
    const juce::String folderPath (txtSourceFileFolder.getText().trim());

    if (folderPath.isNotEmpty()
        && juce::File::isAbsolutePath (folderPath))
    {
        const juce::File folder (folderPath);

        if (folder.isDirectory())
        {
            txtDestinationFolder.setText (folder.getParentDirectory().getFullPathName().trim(), juce::sendNotification);

            const juce::StringArray fileList = Modulariser (folder, true).getFiles();

            if (fileList != files)
            {
                files = fileList;
                fileListBox.setSelectedRows (juce::SparseSet<int>());
                fileListBox.updateContent();
            }
        }
    }
}
コード例 #13
0
ファイル: Enums.cpp プロジェクト: yvanvds/pianola
ACTION toAction(const juce::String & s) {
  if (s.compareIgnoreCase("none"     ) == 0) return A_NONE     ;
  if (s.compareIgnoreCase("servo1"   ) == 0) return A_SERVO1   ;
  if (s.compareIgnoreCase("servo2"   ) == 0) return A_SERVO2   ;
  if (s.compareIgnoreCase("servo3"   ) == 0) return A_SERVO3   ;
  if (s.compareIgnoreCase("servo4"   ) == 0) return A_SERVO4   ;
  if (s.compareIgnoreCase("servo5"   ) == 0) return A_SERVO5   ;
  if (s.compareIgnoreCase("servo6"   ) == 0) return A_SERVO6   ;
  if (s.compareIgnoreCase("servo7"   ) == 0) return A_SERVO7   ;
  if (s.compareIgnoreCase("servo8"   ) == 0) return A_SERVO8   ;
  if (s.compareIgnoreCase("nod"      ) == 0) return A_NOD      ;
  if (s.compareIgnoreCase("idle"     ) == 0) return A_IDLE     ;
  return A_INVALID;
}
コード例 #14
0
juce::File IRBrowserComponent::checkMatchingTrueStereoFile(const juce::String& fileNameBody,
                                                           const juce::String& fileNameExt,
                                                           const juce::File& directory,
                                                           const juce::String& pattern,
                                                           const juce::String& replacement,
                                                           const size_t sampleCount,
                                                           const double sampleRate) const
{
  std::vector<juce::String> candidateNames;
  if (fileNameBody.startsWith(pattern))
  {
    candidateNames.push_back(replacement + fileNameBody.substring(pattern.length(), fileNameBody.length()) + fileNameExt);
  }
  if (fileNameBody.endsWith(pattern))
  {
    candidateNames.push_back(fileNameBody.substring(0, fileNameBody.length()-pattern.length()) + replacement + fileNameExt);
  }

  for (size_t i=0; i<candidateNames.size(); ++i)
  {
    const juce::String& candidateName = candidateNames[i];
    if (directory.getNumberOfChildFiles(juce::File::findFiles|juce::File::ignoreHiddenFiles, candidateName) == 1)
    {
      const juce::File candidateFile = directory.getChildFile(candidateName);
      size_t candidateChannelCount = 0;
      size_t candidateSampleCount = 0;
      double candidateSampleRate = 0.0;
      const bool fileInfoSuccess = readAudioFileInfo(candidateFile, candidateChannelCount, candidateSampleCount, candidateSampleRate);
      if (fileInfoSuccess &&
          candidateChannelCount == 2 &&
          candidateSampleCount == sampleCount &&
          ::fabs(candidateSampleRate - sampleRate) < 0.000001)
      {
        return candidateFile;
      }
    }
  }

  return juce::File::nonexistent;
}
コード例 #15
0
void OscOutputManagerComponent::oscOutputAdded(juce::String newHostname)
{
	//this gets called to add a oscoutput to the list
	
	//only add it if it's a validly formatted ipaddress or .local
	if ( IPAddress ( newHostname).toString() == newHostname || newHostname.endsWith( ".local") )
	{
		
		if ( !hostnameList.contains( newHostname) )
		{
			//let the mainComponent know to create a new OscSender
			Component::BailOutChecker checker ( this );
			if (!checker.shouldBailOut() )
				listeners.callChecked( checker, &OscOutputManagerComponent::Listener::oscOutputAdded, newHostname, 7000 );
			
			//we only need to add the ip to the list,
			//the listbox takes care of creating and destroying the components
			hostnameList.add( newHostname);
			hostnameListBox.updateContent();
		}
	}
}
コード例 #16
0
//==============================================================================
void TrailingWhitespaceCleaner::cleanFile (const juce::File& file,
                                           const bool removeDocumentStartWhitespace,
                                           const WhitespaceRemovalOptions documentEndOptions)
{
    if (! file.hasWriteAccess())
        return;

    juce::StringArray lines;
    file.readLines (lines);

    if (lines.size() <= 0)
        return;

    while (lines.strings.getLast().trim().isEmpty())
        lines.remove (lines.size() - 1);

    lines.minimiseStorageOverheads();

    cleanRange (lines, 0, lines.size());

    if (removeDocumentStartWhitespace)
    {
        for (int i = 0; i < lines.size(); ++i)
        {
            if (lines[i].isEmpty())
            {
                lines.remove (i);
                --i;
            }
            else
            {
                break;
            }
        }
    }

    //Remove empty lines at the end of the file:
    for (int i = lines.size(); --i >= 0;)
    {
        if (lines[i].isEmpty())
            lines.remove (i);
        else
            break;
    }
#if 0
    if (documentEndOptions == KeepOneBlankLine)
    {
        const juce::String last (lines.strings[lines.size() - 1].trim());

        if (lines.size() == 0)
        {
            lines.add (juce::newLine);
        }
        else
        {
            if (last.isNotEmpty())
            {
                if (last == "\r" || last == "\n" || last == "\n\r" || last == "\r\n")
                    lines.strings.getReference (lines.size() - 1) = juce::newLine;
                else
                    lines.add (juce::newLine);
            }
            else
            {
                lines.strings.getReference (lines.size() - 1) = juce::newLine;
            }
        }
    }
#endif
    juce::ScopedPointer<juce::FileOutputStream> stream (file.createOutputStream());

    if (stream != nullptr)
        writeLinesToStream (stream, lines);
}
コード例 #17
0
void LufsPluginEditor::exportToText( bool useCommasForDigitSeparation )
{
    LufsAudioProcessor* processor = getProcessor();

    const int updateSize = processor->m_lufsProcessor.getValidSize();

    const juce::String saveDirString( "saveDirectory" );
    const juce::String saveDir = getProcessor()->m_settings.getUserSettings()->getValue( saveDirString );

    juce::File directory;
    if ( saveDir.length() )
        directory = juce::File( directory );
    if ( !directory.exists() )
        directory = juce::File::getSpecialLocation( juce::File::userHomeDirectory );

    juce::FileChooser fileChooser( "Select text output file", directory, "*.txt" );
    if ( fileChooser.browseForFileToSave( true ) )
    {
        juce::File file( fileChooser.getResult() );
        if ( ! file.deleteFile() )
        {
            juce::AlertWindow::showMessageBox( juce::AlertWindow::NoIcon, "Unable to delete existing file, not saving.", "" );
            return;
        }

        // save chosen directory
        getProcessor()->m_settings.getUserSettings()->getValue( saveDirString, file.getParentDirectory().getFullPathName() );

        juce::FileOutputStream outputStream( file );

        juce::String text = "Time\tMomentary\tShort Term\tIntegrated\n";

        for ( int tens = 0; tens < updateSize ; tens += 10 )
        {
            // add time 
            const int seconds = tens / 10;
            const int hours = seconds / 3600;
            const int minutes = ( seconds - hours * 60 ) / 60;
            int shownSeconds = seconds - hours * 3600 - minutes * 60;
            juce::String line( hours );
            line << ":";
            if ( minutes < 10 )
                line << "0";
            line << minutes;
            line << ":";
            if ( shownSeconds < 10 )
                line << "0";
            line << shownSeconds;
            line << "\t";

            // add momentary
            line << juce::String( processor->m_lufsProcessor.getMomentaryVolumeArray()[ tens ], 1 );
            line << "\t";

            // add short term
            line << juce::String( processor->m_lufsProcessor.getShortTermVolumeArray()[ tens ], 1 );
            line << "\t";

            // add integrated
            line << juce::String( processor->m_lufsProcessor.getIntegratedVolumeArray()[ tens ], 1 );
            line << "\n";

            if ( useCommasForDigitSeparation )
                line = line.replaceCharacter( '.', ',' );

            text << line;
        }

        outputStream.writeText( text, false, false );
    }
}
コード例 #18
0
ファイル: PluginProcessor.cpp プロジェクト: gtbts/MIDItoOSC
//==============================================================================
void MiditoOscAudioProcessor::setOSCConnection (const juce::String address, const uint16_t port)
{
    transmitSocket.Connect( IpEndpointName(address.getCharPointer(), port) );
}
コード例 #19
0
void ClientByListenerExample::UnicodeSend(juce::String data)//possibly unicode string
{
	return Send(data.toStdString());
}