Mixer loading problem

Making a mixer that has arrays of multiple source objects and it doesn’t seem to want to load. I keep getting thread errors from bad access

it has the following items

juce::OwnedArrayjuce::AudioFormatReader* Readers;
std::unique_ptr<juce::OwnedArrayjuce::AudioFormatReaderSource> Sources;
juce::OwnedArrayjuce::AudioFormatManager FileManagers;
juce::OwnedArrayjuce::AudioTransportSource Transports;

void MixerComponent::loadButtonClicked(int channel)
juce::FileChooser Chooser {“Choose File”, juce::File::getSpecialLocation(juce::File::userDesktopDirectory), “.wav;.mp3;.aiff;.ogg” , true , false};

if (Chooser.browseForFileToOpen())
    juce::File File;
    File = Chooser.getResult();
    juce::AudioFormatReader* reader = FileManagers[channel]->createReaderFor(File);
    Readers.insert(channel, &reader);
    Sources->insert(channel, new juce::AudioFormatReaderSource(reader, true));
    myMixer.addInputSource(Transports[channel], false);


the MixerComponent is in another Window from the MainComponent in the Main Window and I need to be able to load the files from the mixerComponent Window and into the MainComponents getNextAudioBlock

I’m not seeing where the transports are created. Just an empty array.

Also not sure why you need a pointer to the array of sources? And you don’t seem to create the sources array either.

I had created the arrays in another area of the code, but my apologies I solved this problem about 2 days ago and should have updated it with the solution I’ve just been very busy. The solution I found was to switch from a OwnedArray to a

juce::AudioTransportSource transports[amoutOfTransports];

which juce seemed to like more.

That is not ‘more juce like’, that is an old style C array… very un-JUCE-esque…

well, at least the transports actually exist that way :wink:

Either way it worked over the OwnedArray which I had been struggling with but if you know of a better way to get the values from the OwnedArray of transport sources then please let me know. Id rather deal with a scalable owned array then an array with a definite maximum number of transports. Also the relay from the referenced values across the windows to the main component.cpp proved difficult as well without the old style c array. Ill keep digging and let you guys know if I find anything or if you find anything please let me know. But thanks for any feed back ill take them into consideration with the creation and scalability of my product.

I’ve not been following the thread… but I am pretty sure the container is not an issue. If nothing else replace that raw array with with an std::array… which can be used like a raw array, but does not have the same usage issues…

ok ill give that a shot and get back to you!

not sure what you mean by this… :slight_smile:

when you create an old school array like the one below

object array

it actually creates objects as if they were using the “new” keywords instead of just a pointer link in the juce::Array, which holds references to objects not the actual concrete objects. in other words the objects are abstract in those types of arrays and not concrete like in the raw array.

atleast that’s what I though he meant correct me if im wrong.

1 Like

and that’s supposed to be

object array[number]

not a square with a checkmark… I was not away the forum would convert that to a picture…

Right. the allocation would be a static (not dynamic) allocation. Which, if there were only a fixed number of them, would be the preferred method. ie. prefer static to dynamic allocation.

Do you guys know how to take the bufferToFill from getNextAudioBlock and get it to where I can tie in buffered sources. example im trying to make a mixer which accepts both transport sources from file readers but I also want to tie in there custom GUI components that control different objects like oscillators and wavetables, apply panning functions to the inputs that go into the mixers as well. How would I go about taking the transports from the mixer inputs and taking the transportAudioSource and splitting the source to the left and right channels like the buffer in buffer to fill???

I think perhaps toneaudiosource would be best option

And then just apply effects to that audio source like the adsr etc etc