No audio formats found


#1

 

I'm trying to write a basic command-line program to print out all the vst's installed on the computer.

 

The problem is that when I call audioFormatManager.getNumFormats(), it always returns 0.

 

I am initializing the AudioFormatManager object by calling audioFormatManager.addDefaultFormats().

 

I'm building this on mac (the latest macbook pro if that matters), using the auto-generated "command-line" xcode project without any modification (besides filling in Main.cpp).

 

Full code:

 

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../JuceLibraryCode/JuceHeader.h"

juce::AudioPluginFormatManager audioFormatManager;
juce::KnownPluginList knownPluginList;

void ScanForPlugins() {
  printf("Scanning for plugins...\n");
  for (int i = 0; i < audioFormatManager.getNumFormats(); ++i) {
    auto format = audioFormatManager.getFormat(i);
    auto scanner = new juce::PluginDirectoryScanner(
        knownPluginList                       /* listToAddResultsTo */,
        *format                               /* formatToLookFor */,
        format->getDefaultLocationsToSearch() /* directoriesToSearch */,
        true                                  /* searchRecursively */,
        juce::File::nonexistent                     /* deadMansPedalFile */);
    juce::String pluginName;
    while (scanner->scanNextFile(true /* dontRescanIfAlreadyInList */, pluginName));
  }
}

void Initialize() {
  audioFormatManager.addDefaultFormats();
  ScanForPlugins();
}

void ListPlugins() {
  Initialize();
  if (knownPluginList.getNumTypes() == 0) {
    printf("No plugins detected\n");
    return;
  }
  printf("Installed plugins:\n");
  for (auto i : knownPluginList) {
    printf("  %s\n", i->name.toRawUTF8());
  }
}

int main(int argc, char *argv[]) {
  static_assert(__cplusplus > 199711L, "Program requires C++11 capable compiler");
  ListPlugins();
  return 0;
}

 


#2

Each format can be turned on/off with a flag, using the tickboxes in the introjucer project settings. Maybe you didn't actually enable any formats?


#3

Thanks, I didn't realize I had to do that. The code is working now :)