diff --git a/src/juce_appframework/application/juce_Application.cpp b/src/juce_appframework/application/juce_Application.cpp index 5a0011169b..10110caacd 100644 --- a/src/juce_appframework/application/juce_Application.cpp +++ b/src/juce_appframework/application/juce_Application.cpp @@ -292,9 +292,7 @@ int JUCEApplication::main (int argc, char* argv[], void JUCEApplication::actionListenerCallback (const String& message) { if (message.startsWith (getApplicationName() + "/")) - { - anotherInstanceStarted (message.fromFirstOccurrenceOf (T("/"), false, false)); - } + anotherInstanceStarted (message.substring (getApplicationName().length() + 1)); } //============================================================================== diff --git a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp index 91d1dffe2e..7bfd53093b 100644 --- a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp +++ b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp @@ -63,15 +63,38 @@ AudioSampleBuffer::AudioSampleBuffer (const int numChannels_, AudioSampleBuffer::AudioSampleBuffer (float** dataToReferTo, const int numChannels_, const int numSamples) throw() + : numChannels (numChannels_), + size (numSamples), + allocatedBytes (0), + allocatedData (0) { jassert (((unsigned int) numChannels_) <= (unsigned int) maxNumAudioSampleBufferChannels); + for (int i = 0; i < numChannels_; ++i) + { + // you have to pass in the same number of valid pointers as numChannels + jassert (dataToReferTo[i] != 0); + + channels[i] = dataToReferTo[i]; + } + + channels [numChannels_] = 0; +} + +void AudioSampleBuffer::setDataToReferTo (float** dataToReferTo, + const int numChannels_, + const int numSamples) throw() +{ + jassert (((unsigned int) numChannels_) <= (unsigned int) maxNumAudioSampleBufferChannels); + + juce_free (allocatedData); + allocatedData = 0; + allocatedBytes = 0; + numChannels = numChannels_; size = numSamples; - allocatedBytes = 0; - allocatedData = 0; - for (int i = numChannels_; --i >= 0;) + for (int i = 0; i < numChannels_; ++i) { // you have to pass in the same number of valid pointers as numChannels jassert (dataToReferTo[i] != 0); diff --git a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h index f4db36002c..3ac000ac1f 100644 --- a/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h +++ b/src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h @@ -59,6 +59,10 @@ public: /** Creates a buffer using a pre-allocated block of memory. + Note that if the buffer is resized or its number of channels is changed, it + will re-allocate memory internally and copy the existing data to this new area, + so it will then stop directly addressing this memory. + @param dataToReferTo a pre-allocated array containing pointers to the data for each channel that should be used by this buffer. The buffer will only refer to this memory, it won't try to delete @@ -137,6 +141,29 @@ public: const bool clearExtraSpace = false, const bool avoidReallocating = false) throw(); + + /** Makes this buffer point to a pre-allocated set of channel data arrays. + + There's also a constructor that lets you specify arrays like this, but this + lets you change the channels dynamically. + + Note that if the buffer is resized or its number of channels is changed, it + will re-allocate memory internally and copy the existing data to this new area, + so it will then stop directly addressing this memory. + + @param dataToReferTo a pre-allocated array containing pointers to the data + for each channel that should be used by this buffer. The + buffer will only refer to this memory, it won't try to delete + it when the buffer is deleted or resized. + @param numChannels the number of channels to use - this must correspond to the + number of elements in the array passed in + @param numSamples the number of samples to use - this must correspond to the + size of the arrays passed in + */ + void setDataToReferTo (float** dataToReferTo, + const int numChannels, + const int numSamples) throw(); + //============================================================================== /** Clears all the samples in all channels. */ void clear() throw();