Accessing Array functions with an OwnedArray


#1

Hey
So Im trying to get his bit of code to work:

      [code]   // Find the Sounds directory
            File appDirectory = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory();
            File soundsDirectory = appDirectory.getChildFile(("../../../sounds"));

			
            //Add debug to Check to see if the sounds directory is there
            
            // find all the .aif files in our sounds directory and store them in the audioFiles
            soundsDirectory.findChildFiles(audioFiles, File::findFiles, false, ("*.aif"));
            soundsDirectory.findChildFiles(audioFiles, File::findFiles, false, ("*.wav"));

[/code]
but in my header, I’ve used OwnedArray to define audiofiles, since Array can’t hold non primitive data.
The issue is findChildFiles() requires the first parameter to be an Array type.

How do I get around this? I’d appreciate any help!!

Thanks


#2

You can use an Array, I do that all the time. In fact, I can’t think of any reason why you’d ever use an OwnedArray…


#3

That’s what I did!
But it causes an external linker error (or so I think)
…I was just attempting to solve any issues I could think of.

Could you help me with the error then?

My Code:[code]

LoopportPluginAudioProcessorEditor::LoopportPluginAudioProcessorEditor (LoopportPluginAudioProcessor* ownerFilter)
: AudioProcessorEditor (ownerFilter),
midiKeyboard (ownerFilter->keyboardState, MidiKeyboardComponent::horizontalKeyboard),
infoLabel (String::empty),
gainLabel ("", “Throughput level:”),
delayLabel ("", “Delay:”),
drop1Label ("", “Kicks:”),
drop2Label ("", “Snares:”)
{

////AudioPlayer stuff///
addAndMakeVisible(startButton = new TextButton(("Start"), ("Start the player")));
startButton->setConnectedEdges(Button::ConnectedOnRight);
startButton->setColour(TextButton::buttonColourId, Colours::green);
//startButton->addListener(this);
   
addAndMakeVisible(pauseButton = new TextButton(("Pause"), ("Pause the audio")));
pauseButton->setConnectedEdges(Button::ConnectedOnRight + Button::ConnectedOnLeft);
pauseButton->setColour(TextButton::buttonColourId, Colours::orange);
pauseButton->setClickingTogglesState(true);
//pauseButton->addListener(this);

addAndMakeVisible(stopButton = new TextButton(("Stop"), ("Stop the player")));
stopButton->setConnectedEdges(Button::ConnectedOnLeft);
stopButton->setColour(TextButton::buttonColourId, Colours::red);
//stopButton->addListener(this);
   
addAndMakeVisible(audioSettingButton = new TextButton(("Audio Settings"), ("Display the audio settings")));
//audioSettingButton->addListener(this);


// Initialise the audio device
const String error (audioDeviceManager.initialise (1, /* number of input channels */
                                                   2, /* number of output channels */
                                                    0, /* no XML settings.. */
                                                   true  /* select default device on failure */));

// Initialise the audio device
const String error (audioDeviceManager.initialise (1, /* number of input channels /
2, /
number of output channels /
0, /
no XML settings… /
true /
select default device on failure */));

if (error.isNotEmpty())
    {
            AlertWindow::showMessageBox (AlertWindow::WarningIcon,
                                          ("Loopport Plugin"),
                                          ("Couldn't open an output device!\n\n") + error);
    }
    else
    {
            // Connect the mixer to our source player.
            audioSourcePlayer.setSource (&mixerSource);
           
            // Start the IO device pulling its data from our callback..
            audioDeviceManager.addAudioCallback(this); //might be setAudioCallback
           
            // Find the Sounds directory
            File appDirectory = File::getSpecialLocation(File::currentApplicationFile).getParentDirectory();
            File soundsDirectory = appDirectory.getChildFile(("../../../sounds"));

			
            //Add debug to Check to see if the sounds directory is there
            
            // find all the .aif files in our sounds directory and store them in the audioFiles
            soundsDirectory.findChildFiles(audioFiles, File::findFiles, false, ("*.aif"));
            soundsDirectory.findChildFiles(audioFiles, File::findFiles, false, ("*.wav"));

			 const String& soundFilePath = audioFiles[0].getFullPathName();
			 String fileName = audioFiles[0].getFileName();
			 String name = fileName.substring(0, 3);
			 String const tooltipString = "Useful";

			 currentFilePlayer = new AudioFilePlayer(soundFilePath, name, tooltipString); 
             currentFilePlayer->setConnectedEdges(TextButton::ConnectedOnLeft + TextButton::ConnectedOnRight);
             currentFilePlayer->setClickingTogglesState(true);
             currentFilePlayer->setRadioGroupId(1);
             //currentFilePlayer->addChangeListener(this);
             //currentFilePlayer->addButtonListener(this);
             addAndMakeVisible(currentFilePlayer);                 
             mixerSource.addInputSource (currentFilePlayer, false);
           
    }


// add the triangular resizer component for the bottom-right of the UI
// crashes if not there...
addAndMakeVisible (resizer = new ResizableCornerComponent (this, &resizeLimits));
resizeLimits.setSizeLimits (875, 598, 875, 598);

// set our component's initial size to be the last one that was stored in the filter's settings
setSize (ownerFilter->lastUIWidth,
         ownerFilter->lastUIHeight);

startTimer (50);

}
[/code]


#4

The error should be unrelated to using Array. You have the AudioFilePlayer class declared but the linker can’t find the definition. Probably a missing .cpp file.

Chris