예제 #1
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;
}
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();
		}
	}
}