Exemplo n.º 1
0
void IRBrowserComponent::selectionChanged()
{
  if (_infoLabel)
  {
    juce::String infoText;
    
    const juce::File file = _fileTreeComponent ? _fileTreeComponent->getSelectedFile() : juce::File::nonexistent;

    if (!file.isDirectory() && _processor)
    {
      size_t channelCount = 0;
      size_t sampleCount = 0;
      double sampleRate = 0.0;
      if (readAudioFileInfo(file, channelCount, sampleCount, sampleRate))
      {
        infoText += juce::String("Name: ") + file.getFileName();
        infoText += juce::String("\n");
        infoText += juce::String("\nSamples: ") + juce::String(static_cast<int>(sampleCount));
        if (sampleRate > 0.00001)
        {
          const double seconds = static_cast<double>(sampleCount) / sampleRate;
          infoText += juce::String("\nDuration: ") + juce::String(seconds, 2) + juce::String("s");
        }
        infoText += juce::String("\nChannels: ") + juce::String(static_cast<int>(channelCount));
        infoText += juce::String("\nSample Rate: ") + juce::String(static_cast<int>(sampleRate)) + juce::String("Hz");

        if (_processor->getNumInputChannels() >= 2 && _processor->getNumOutputChannels() >= 2)
        {
          const TrueStereoPairs trueStereoPairs = findTrueStereoPairs(file, sampleCount, sampleRate);        
          for (size_t i=0; i<trueStereoPairs.size(); ++i)
          {
            if (trueStereoPairs[i].first != file && trueStereoPairs[i].first != juce::File::nonexistent)
            {
              infoText += juce::String("\n");
              infoText += juce::String("\nFile Pair For True-Stereo:");
              infoText += juce::String("\n - ") + file.getFileName();
              infoText += juce::String("\n - ") + trueStereoPairs[i].first.getFileName();
              break;
            }
          }
        }
      }
      else
      {
        infoText += juce::String("\n\nError!\n\nNo information available.");
      }
    }
    
    _infoLabel->setJustificationType(juce::Justification(juce::Justification::topLeft));
    _infoLabel->setText(infoText, sendNotification);
  }
}
Exemplo n.º 2
0
void CodeFileList::addDirectory (const juce::File& file)
{
    if (file.isDirectory())
    {
        juce::Array<juce::File> results;
        file.findChildFiles (results, juce::File::findFiles, true, wildcards);

        for (int i = results.size(); --i >= 0;)
            files.addIfNotAlreadyThere (results.getReference (i).getFullPathName()); //N.B.: Don't use addFile() - it will be a redundant check to see if the file is valid
    }
    else
    {
        addFile (file.getFullPathName());
    }
}
Exemplo n.º 3
0
IRBrowserComponent::TrueStereoPairs IRBrowserComponent::findTrueStereoPairs(const juce::File& file, size_t sampleCount, double sampleRate) const
{
  if (file == juce::File::nonexistent || file.isDirectory())
  {
    return TrueStereoPairs();
  }

  const juce::File directory = file.getParentDirectory();
  if (file == juce::File::nonexistent || file.isDirectory())
  {
    return TrueStereoPairs();
  }

  const juce::String fileNameBody = file.getFileNameWithoutExtension();
  const juce::String fileNameExt = file.getFileExtension();

  // Left => Right
  static std::vector<std::pair<juce::String, juce::String> > pairsLeft;
  if (pairsLeft.empty())
  {
    pairsLeft.push_back(std::make_pair(juce::String("L"),    juce::String("R")));
    pairsLeft.push_back(std::make_pair(juce::String("l"),    juce::String("r")));
    pairsLeft.push_back(std::make_pair(juce::String("Left"), juce::String("Right")));
    pairsLeft.push_back(std::make_pair(juce::String("left"), juce::String("right")));
    pairsLeft.push_back(std::make_pair(juce::String("LEFT"), juce::String("RIGHT")));
  }
  for (size_t i=0; i<pairsLeft.size(); ++i)
  {
    const juce::File matchingFile = checkMatchingTrueStereoFile(fileNameBody,
                                                                fileNameExt,
                                                                directory,
                                                                pairsLeft[i].first,
                                                                pairsLeft[i].second,
                                                                sampleCount,
                                                                sampleRate);
    if (matchingFile != juce::File::nonexistent)
    {
      TrueStereoPairs trueStereoPairs;
      trueStereoPairs.push_back(std::make_pair(file, 0));
      trueStereoPairs.push_back(std::make_pair(file, 1));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 0));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 1));
      return trueStereoPairs;
    }
  }

  static std::vector<std::pair<juce::String, juce::String> > pairsRight;
  if (pairsRight.empty())
  {
    pairsRight.push_back(std::make_pair(juce::String("R"),     juce::String("L")));
    pairsRight.push_back(std::make_pair(juce::String("r"),     juce::String("l")));
    pairsRight.push_back(std::make_pair(juce::String("Right"), juce::String("Left")));
    pairsRight.push_back(std::make_pair(juce::String("right"), juce::String("left")));
    pairsRight.push_back(std::make_pair(juce::String("RIGHT"), juce::String("LEFT")));
  }
  for (size_t i=0; i<pairsRight.size(); ++i)
  {
    const juce::File matchingFile = checkMatchingTrueStereoFile(fileNameBody,
                                                                fileNameExt,
                                                                directory,
                                                                pairsRight[i].first,
                                                                pairsRight[i].second,
                                                                sampleCount,
                                                                sampleRate);
    if (matchingFile != juce::File::nonexistent)
    {
      TrueStereoPairs trueStereoPairs;
      trueStereoPairs.push_back(std::make_pair(matchingFile, 0));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 1));
      trueStereoPairs.push_back(std::make_pair(file, 0));
      trueStereoPairs.push_back(std::make_pair(file, 1));
      return trueStereoPairs;
    }
  }

  return TrueStereoPairs();
}