From 07a23077e7f9e2d9797a64d9a69368a8943b8c2c Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 20 Jun 2008 10:58:35 +0000 Subject: [PATCH] --- juce_amalgamated.cpp | 197 ++++++++++++++++--------------------------- juce_amalgamated.h | 9 +- 2 files changed, 78 insertions(+), 128 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 033e6de10b..34c2ed6c82 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -31564,7 +31564,7 @@ private: } else { - jassert (bufferNum > 0 && bufferNum < nodeIds.size()); + jassert (bufferNum >= 0 && bufferNum < nodeIds.size()); nodeIds.set (bufferNum, nodeId); channels.set (bufferNum, outputIndex); @@ -31648,7 +31648,7 @@ void AudioProcessorGraph::buildRenderingSequence() VoidArray oldRenderingOps (renderingOps); { - // swap over to the new set of rendering sequence.. + // swap over to the new rendering sequence.. const ScopedLock sl (renderLock); renderingBuffers.setSize (numRenderingBuffersNeeded, getBlockSize()); @@ -31675,7 +31675,7 @@ void AudioProcessorGraph::handleAsyncUpdate() void AudioProcessorGraph::prepareToPlay (double /*sampleRate*/, int estimatedSamplesPerBlock) { currentAudioInputBuffer = 0; - currentAudioOutputBuffer.setSize (getNumOutputChannels(), estimatedSamplesPerBlock); + currentAudioOutputBuffer.setSize (jmax (1, getNumOutputChannels()), estimatedSamplesPerBlock); currentMidiInputBuffer = 0; currentMidiOutputBuffer.clear(); @@ -31704,7 +31704,7 @@ void AudioProcessorGraph::processBlock (AudioSampleBuffer& buffer, MidiBuffer& m const ScopedLock sl (renderLock); currentAudioInputBuffer = &buffer; - currentAudioOutputBuffer.setSize (buffer.getNumChannels(), numSamples); + currentAudioOutputBuffer.setSize (jmax (1, buffer.getNumChannels()), numSamples); currentAudioOutputBuffer.clear(); currentMidiInputBuffer = &midiMessages; currentMidiOutputBuffer.clear(); @@ -31840,7 +31840,7 @@ void AudioProcessorGraph::AudioGraphIOProcessor::processBlock (AudioSampleBuffer for (int i = jmin (graph->currentAudioInputBuffer->getNumChannels(), buffer.getNumChannels()); --i >= 0;) { - buffer.addFrom (i, 0, *graph->currentAudioInputBuffer, i, 0, buffer.getNumSamples()); + buffer.copyFrom (i, 0, *graph->currentAudioInputBuffer, i, 0, buffer.getNumSamples()); } break; @@ -31952,8 +31952,8 @@ void AudioProcessorGraph::AudioGraphIOProcessor::setParentGraph (AudioProcessorG if (graph != 0) { - setPlayConfigDetails (type == audioOutputNode ? graph->getNumInputChannels() : 0, - type == audioInputNode ? graph->getNumOutputChannels() : 0, + setPlayConfigDetails (type == audioOutputNode ? graph->getNumOutputChannels() : 0, + type == audioInputNode ? graph->getNumInputChannels() : 0, getSampleRate(), getBlockSize()); @@ -32008,9 +32008,9 @@ void AudioProcessorPlayer::setProcessor (AudioProcessor* const processorToPlay) } void AudioProcessorPlayer::audioDeviceIOCallback (const float** inputChannelData, - int totalNumInputChannels, + int numInputChannels, float** outputChannelData, - int totalNumOutputChannels, + int numOutputChannels, int numSamples) { // these should have been prepared by audioDeviceAboutToStart()... @@ -32018,71 +32018,48 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** inputChannelData incomingMidi.clear(); messageCollector.removeNextBlockOfMessages (incomingMidi, numSamples); + int i, totalNumChans = 0; - int i, numActiveChans = 0, numInputs = 0, numOutputs = 0; - - // messy stuff needed to compact the channels down into an array - // of non-zero pointers.. - for (i = 0; i < totalNumInputChannels; ++i) - { - if (inputChannelData[i] != 0) - { - inputChans [numInputs++] = inputChannelData[i]; - if (numInputs >= numElementsInArray (inputChans)) - break; - } - } - - for (i = 0; i < totalNumOutputChannels; ++i) - { - if (outputChannelData[i] != 0) - { - outputChans [numOutputs++] = outputChannelData[i]; - if (numOutputs >= numElementsInArray (outputChans)) - break; - } - } - - if (numInputs > numOutputs) + if (numInputChannels > numOutputChannels) { // if there aren't enough output channels for the number of // inputs, we need to create some temporary extra ones (can't // use the input data in case it gets written to) - tempBuffer.setSize (numInputs - numOutputs, numSamples, + tempBuffer.setSize (numInputChannels - numOutputChannels, numSamples, false, false, true); - for (i = 0; i < numOutputs; ++i) + for (i = 0; i < numOutputChannels; ++i) { - channels[numActiveChans] = outputChans[i]; - memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * numSamples); - ++numActiveChans; + channels[totalNumChans] = outputChannelData[i]; + memcpy (channels[totalNumChans], inputChannelData[i], sizeof (float) * numSamples); + ++totalNumChans; } - for (i = numOutputs; i < numInputs; ++i) + for (i = numOutputChannels; i < numInputChannels; ++i) { - channels[numActiveChans] = tempBuffer.getSampleData (i - numOutputs, 0); - memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * numSamples); - ++numActiveChans; + channels[totalNumChans] = tempBuffer.getSampleData (i - numOutputChannels, 0); + memcpy (channels[totalNumChans], inputChannelData[i], sizeof (float) * numSamples); + ++totalNumChans; } } else { - for (i = 0; i < numInputs; ++i) + for (i = 0; i < numInputChannels; ++i) { - channels[numActiveChans] = outputChans[i]; - memcpy (channels[numActiveChans], inputChans[i], sizeof (float) * numSamples); - ++numActiveChans; + channels[totalNumChans] = outputChannelData[i]; + memcpy (channels[totalNumChans], inputChannelData[i], sizeof (float) * numSamples); + ++totalNumChans; } - for (i = numInputs; i < numOutputs; ++i) + for (i = numInputChannels; i < numOutputChannels; ++i) { - channels[numActiveChans] = outputChans[i]; - zeromem (channels[numActiveChans], sizeof (float) * numSamples); - ++numActiveChans; + channels[totalNumChans] = outputChannelData[i]; + zeromem (channels[totalNumChans], sizeof (float) * numSamples); + ++totalNumChans; } } - AudioSampleBuffer buffer (channels, numActiveChans, numSamples); + AudioSampleBuffer buffer (channels, totalNumChans, numSamples); const ScopedLock sl (lock); @@ -36137,7 +36114,7 @@ void Component::addChildComponent (Component* const child, int zOrder) if (! child->isAlwaysOnTop()) { - if (zOrder < 0) + if (zOrder < 0 || zOrder > childComponentList_.size()) zOrder = childComponentList_.size(); while (zOrder > 0) @@ -47826,11 +47803,11 @@ public: owner (owner_), height (height_) { - for (int i = owner_.getNumChildComponents(); --i >= 0;) + for (int i = owner_.items.size(); --i >= 0;) { - ToolbarItemComponent* const tc = dynamic_cast (owner_.getChildComponent (i)); + ToolbarItemComponent* const tc = owner_.items.getUnchecked(i); - if (tc != 0 && dynamic_cast (tc) == 0 && ! tc->isVisible()) + if (dynamic_cast (tc) == 0 && ! tc->isVisible()) { oldIndexes.insert (0, i); addAndMakeVisible (tc, 0); @@ -47852,7 +47829,9 @@ public: if (tc != 0) { tc->setVisible (false); - owner.addChildComponent (tc, oldIndexes.remove (i)); + const int index = oldIndexes.remove (i); + owner.items.insert (index, tc); + owner.addChildComponent (tc, index); --i; } } @@ -47939,11 +47918,11 @@ void Toolbar::setVertical (const bool shouldBeVertical) void Toolbar::clear() { - for (int i = getNumChildComponents(); --i >= 0;) + for (int i = items.size(); --i >= 0;) { - ToolbarItemComponent* const tc = dynamic_cast (getChildComponent (i)); - if (tc != 0) - delete tc; + ToolbarItemComponent* const tc = items.getUnchecked(i); + items.remove (i); + delete tc; } resized(); @@ -47981,6 +47960,7 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory, jassert (allowedIds.contains (itemId)); #endif + items.insert (insertIndex, tc); addAndMakeVisible (tc, insertIndex); } } @@ -48012,6 +47992,7 @@ void Toolbar::removeToolbarItem (const int itemIndex) if (tc != 0) { + items.removeValue (tc); delete tc; resized(); } @@ -48019,7 +48000,7 @@ void Toolbar::removeToolbarItem (const int itemIndex) int Toolbar::getNumItems() const throw() { - return getNumChildComponents() - 1; + return items.size(); } int Toolbar::getItemId (const int itemIndex) const throw() @@ -48030,10 +48011,7 @@ int Toolbar::getItemId (const int itemIndex) const throw() ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const throw() { - if (itemIndex < getNumItems()) - return dynamic_cast (getChildComponent (itemIndex)); - - return 0; + return items [itemIndex]; } ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delta) const @@ -48125,40 +48103,31 @@ void Toolbar::updateAllItemPositions (const bool animate) { StretchableObjectResizer resizer; - const int numComponents = getNumChildComponents(); - Array activeComps; - int i; - for (i = 0; i < numComponents; ++i) + for (i = 0; i < items.size(); ++i) { - ToolbarItemComponent* const tc = dynamic_cast (getChildComponent (i)); - - // have you added a component directly to the toolbar? That's not advisable! Only use addCustomToolbarItem()! - jassert (tc != 0 || getChildComponent(i) == missingItemsButton); + ToolbarItemComponent* const tc = items.getUnchecked(i); - if (tc != 0) - { - tc->setEditingMode (isEditingActive ? ToolbarItemComponent::editableOnToolbar - : ToolbarItemComponent::normalMode); + tc->setEditingMode (isEditingActive ? ToolbarItemComponent::editableOnToolbar + : ToolbarItemComponent::normalMode); - tc->setStyle (toolbarStyle); + tc->setStyle (toolbarStyle); - ToolbarSpacerComp* const spacer = dynamic_cast (tc); + ToolbarSpacerComp* const spacer = dynamic_cast (tc); - int preferredSize = 1, minSize = 1, maxSize = 1; + int preferredSize = 1, minSize = 1, maxSize = 1; - if (tc->getToolbarItemSizes (getThickness(), isVertical(), - preferredSize, minSize, maxSize)) - { - tc->isActive = true; - resizer.addItem (preferredSize, minSize, maxSize, - spacer != 0 ? spacer->getResizeOrder() : 2); - } - else - { - tc->isActive = false; - tc->setVisible (false); - } + if (tc->getToolbarItemSizes (getThickness(), isVertical(), + preferredSize, minSize, maxSize)) + { + tc->isActive = true; + resizer.addItem (preferredSize, minSize, maxSize, + spacer != 0 ? spacer->getResizeOrder() : 2); + } + else + { + tc->isActive = false; + tc->setVisible (false); } } @@ -48188,11 +48157,11 @@ void Toolbar::updateAllItemPositions (const bool animate) : getLength(); int pos = 0, activeIndex = 0; - for (i = 0; i < getNumChildComponents(); ++i) + for (i = 0; i < items.size(); ++i) { - ToolbarItemComponent* const tc = dynamic_cast (getChildComponent (i)); + ToolbarItemComponent* const tc = items.getUnchecked(i); - if (tc != 0 && tc->isActive) + if (tc->isActive) { const int size = (int) resizer.getItemSize (activeIndex++); @@ -48259,6 +48228,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in jassert (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar); } + items.add (tc); addChildComponent (tc); updateAllItemPositions (false); } @@ -48282,6 +48252,7 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in jassert (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar); } + items.add (tc); addChildComponent (tc); currentIndex = getIndexOfChildComponent (tc); updateAllItemPositions (true); @@ -48320,8 +48291,10 @@ void Toolbar::itemDragMove (const String&, Component* sourceComponent, int x, in if (newIndex != currentIndex) { + items.removeValue (tc); removeChildComponent (tc); addChildComponent (tc, newIndex); + items.insert (newIndex, tc); updateAllItemPositions (true); } else @@ -48341,6 +48314,7 @@ void Toolbar::itemDragExit (const String&, Component* sourceComponent) { if (isParentOf (tc)) { + items.removeValue (tc); removeChildComponent (tc); updateAllItemPositions (true); } @@ -236343,32 +236317,7 @@ public: double sampleRate, int bufferSizeSamples) { - BitArray ins, outs; - - if (deviceIndex >= 0) - { - if (outputChannels[0]) - outs.setBit (2 * deviceIndex); - - if (outputChannels[1]) - outs.setBit (2 * deviceIndex + 1); - - if (inputIndex >= 0) - { - if (inputChannels[0]) - ins.setBit (2 * inputIndex); - - if (inputChannels[1]) - ins.setBit (2 * inputIndex + 1); - } - } - else - { - ins = inputChannels; - outs = outputChannels; - } - - lastError = openDevice (ins, outs, sampleRate, bufferSizeSamples); + lastError = openDevice (inputChannels, outputChannels, sampleRate, bufferSizeSamples); isOpen_ = lastError.isEmpty(); return lastError; @@ -236904,7 +236853,7 @@ const String DSoundAudioIODevice::openDevice (const BitArray& inputChannels, numInputBuffers = enabledInputs.countNumberOfSetBits(); inputBuffers = new float* [numInputBuffers + 2]; - zeromem (inputBuffers, sizeof (inputBuffers)); + zeromem (inputBuffers, sizeof (float*) * numInputBuffers + 2); int i, numIns = 0; for (i = 0; i <= enabledInputs.getHighestBit(); i += 2) @@ -236932,7 +236881,7 @@ const String DSoundAudioIODevice::openDevice (const BitArray& inputChannels, numOutputBuffers = enabledOutputs.countNumberOfSetBits(); outputBuffers = new float* [numOutputBuffers + 2]; - zeromem (outputBuffers, sizeof (outputBuffers)); + zeromem (outputBuffers, sizeof (float*) * numOutputBuffers + 2); int numOuts = 0; for (i = 0; i <= enabledOutputs.getHighestBit(); i += 2) diff --git a/juce_amalgamated.h b/juce_amalgamated.h index b03fe807f5..8a4da91796 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -196,12 +196,12 @@ /** Enabling this builds support for VST audio plugins. @see VSTPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_AU */ -//#define JUCE_PLUGINHOST_VST 1 +#define JUCE_PLUGINHOST_VST 1 /** Enabling this builds support for AudioUnit audio plugins. @see AudioUnitPluginFormat, AudioPluginFormat, AudioPluginFormatManager, JUCE_PLUGINHOST_VST */ -//#define JUCE_PLUGINHOST_AU 1 +#define JUCE_PLUGINHOST_AU 1 /** Disabling this will avoid linking to any UI code. This is handy for writing command-line utilities, e.g. on linux boxes which don't have some @@ -29208,8 +29208,6 @@ private: int numInputChans, numOutputChans; float* channels [128]; - float* outputChans [128]; - const float* inputChans [128]; AudioSampleBuffer tempBuffer; MidiBuffer incomingMidi; @@ -41403,6 +41401,7 @@ private: class ToolbarItemComponent; class ToolbarItemFactory; +class MissingItemsComponent; /** A toolbar component. @@ -41661,6 +41660,8 @@ private: bool vertical, isEditingActive; ToolbarItemStyle toolbarStyle; ComponentAnimator animator; + friend class MissingItemsComponent; + Array items; friend class ItemDragAndDropOverlayComponent; static const tchar* const toolbarDragDescriptor;