diff --git a/examples/BLOCKS/BlocksSynth/Source/Audio.h b/examples/BLOCKS/BlocksSynth/Source/Audio.h index 3067069154..b353547f71 100644 --- a/examples/BLOCKS/BlocksSynth/Source/Audio.h +++ b/examples/BLOCKS/BlocksSynth/Source/Audio.h @@ -64,7 +64,7 @@ public: void audioDeviceIOCallback (const float **/*inputChannelData*/, int /*numInputChannels*/, float **outputChannelData, int numOutputChannels, int numSamples) override { - AudioSampleBuffer sampleBuffer = AudioSampleBuffer (outputChannelData, numOutputChannels, numSamples); + AudioBuffer sampleBuffer (outputChannelData, numOutputChannels, numSamples); sampleBuffer.clear(); synthesiser.renderNextBlock (sampleBuffer, MidiBuffer(), 0, numSamples); diff --git a/examples/BLOCKS/BlocksSynth/Source/Oscillators.h b/examples/BLOCKS/BlocksSynth/Source/Oscillators.h index 1589f721f7..66936ce44f 100644 --- a/examples/BLOCKS/BlocksSynth/Source/Oscillators.h +++ b/examples/BLOCKS/BlocksSynth/Source/Oscillators.h @@ -75,7 +75,7 @@ public: amplitude.setValue (newChannelPressureValue / 127.0); } - void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override + void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override { while (--numSamples >= 0) { diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.cpp b/examples/DSP module plugin demo/Source/PluginProcessor.cpp index b05febfd4c..34dee8ad87 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.cpp +++ b/examples/DSP module plugin demo/Source/PluginProcessor.cpp @@ -164,7 +164,7 @@ void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing& inoutBuffer, MidiBuffer&) { auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); diff --git a/examples/DSP module plugin demo/Source/PluginProcessor.h b/examples/DSP module plugin demo/Source/PluginProcessor.h index 4574cb33a7..3a13dccd20 100644 --- a/examples/DSP module plugin demo/Source/PluginProcessor.h +++ b/examples/DSP module plugin demo/Source/PluginProcessor.h @@ -46,7 +46,7 @@ public: #endif void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; - void processBlock (AudioSampleBuffer&, MidiBuffer&) override; + void processBlock (AudioBuffer&, MidiBuffer&) override; void reset() override; //============================================================================== diff --git a/examples/Demo/Source/Demos/AudioLatencyDemo.cpp b/examples/Demo/Source/Demos/AudioLatencyDemo.cpp index c2103c76c4..fb0e4041bd 100644 --- a/examples/Demo/Source/Demos/AudioLatencyDemo.cpp +++ b/examples/Demo/Source/Demos/AudioLatencyDemo.cpp @@ -172,7 +172,7 @@ public: } private: - AudioSampleBuffer testSound, recordedSound; + AudioBuffer testSound, recordedSound; Array spikePositions; int playingSampleNum, recordedSampleNum; CriticalSection lock; @@ -211,7 +211,7 @@ private: } // Searches a buffer for a set of spikes that matches those in the test sound - int findOffsetOfSpikes (const AudioSampleBuffer& buffer) const + int findOffsetOfSpikes (const AudioBuffer& buffer) const { const float minSpikeLevel = 5.0f; const double smooth = 0.975; diff --git a/examples/Demo/Source/Demos/AudioRecordingDemo.cpp b/examples/Demo/Source/Demos/AudioRecordingDemo.cpp index b45a1f1ea0..0df121f624 100644 --- a/examples/Demo/Source/Demos/AudioRecordingDemo.cpp +++ b/examples/Demo/Source/Demos/AudioRecordingDemo.cpp @@ -124,8 +124,8 @@ public: { activeWriter->write (inputChannelData, numSamples); - // Create an AudioSampleBuffer to wrap our incoming data, note that this does no allocations or copies, it simply references our input data - const AudioSampleBuffer buffer (const_cast (inputChannelData), thumbnail.getNumChannels(), numSamples); + // Create an AudioBuffer to wrap our incoming data, note that this does no allocations or copies, it simply references our input data + AudioBuffer buffer (const_cast (inputChannelData), thumbnail.getNumChannels(), numSamples); thumbnail.addBlock (nextSampleNum, buffer, 0, numSamples); nextSampleNum += numSamples; } diff --git a/examples/Demo/Source/Demos/AudioSynthesiserDemo.cpp b/examples/Demo/Source/Demos/AudioSynthesiserDemo.cpp index 9b8e2a0ac1..5730ee71ec 100644 --- a/examples/Demo/Source/Demos/AudioSynthesiserDemo.cpp +++ b/examples/Demo/Source/Demos/AudioSynthesiserDemo.cpp @@ -42,9 +42,7 @@ struct SineWaveSound : public SynthesiserSound /** Our demo synth voice just plays a sine wave.. */ struct SineWaveVoice : public SynthesiserVoice { - SineWaveVoice() : currentAngle (0), angleDelta (0), level (0), tailOff (0) - { - } + SineWaveVoice() {} bool canPlaySound (SynthesiserSound* sound) override { @@ -94,7 +92,7 @@ struct SineWaveVoice : public SynthesiserVoice // not interested in controllers in this case. } - void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override + void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override { if (angleDelta != 0.0) { @@ -102,7 +100,7 @@ struct SineWaveVoice : public SynthesiserVoice { while (--numSamples >= 0) { - const float currentSample = (float) (std::sin (currentAngle) * level * tailOff); + auto currentSample = (float) (std::sin (currentAngle) * level * tailOff); for (int i = outputBuffer.getNumChannels(); --i >= 0;) outputBuffer.addSample (i, startSample, currentSample); @@ -125,7 +123,7 @@ struct SineWaveVoice : public SynthesiserVoice { while (--numSamples >= 0) { - const float currentSample = (float) (std::sin (currentAngle) * level); + auto currentSample = (float) (std::sin (currentAngle) * level); for (int i = outputBuffer.getNumChannels(); --i >= 0;) outputBuffer.addSample (i, startSample, currentSample); @@ -138,7 +136,7 @@ struct SineWaveVoice : public SynthesiserVoice } private: - double currentAngle, angleDelta, level, tailOff; + double currentAngle = 0, angleDelta = 0, level = 0, tailOff = 0; }; //============================================================================== diff --git a/examples/PlugInSamples/Arpeggiator/Source/Arpeggiator.cpp b/examples/PlugInSamples/Arpeggiator/Source/Arpeggiator.cpp index 9801eff7f0..582fb2fc88 100644 --- a/examples/PlugInSamples/Arpeggiator/Source/Arpeggiator.cpp +++ b/examples/PlugInSamples/Arpeggiator/Source/Arpeggiator.cpp @@ -57,16 +57,16 @@ public: void releaseResources() override {} - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midi) override + void processBlock (AudioBuffer& buffer, MidiBuffer& midi) override { // the audio buffer in a midi effect will have zero channels! jassert (buffer.getNumChannels() == 0); // however we use the buffer to get timing information - const int numSamples = buffer.getNumSamples(); + auto numSamples = buffer.getNumSamples(); // get note duration - const int noteDuration = static_cast (std::ceil (rate * 0.25f * (0.1f + (1.0f - (*speed))))); + auto noteDuration = static_cast (std::ceil (rate * 0.25f * (0.1f + (1.0f - (*speed))))); MidiMessage msg; int ignore; @@ -81,7 +81,7 @@ public: if ((time + numSamples) >= noteDuration) { - const int offset = jmax (0, jmin ((int) (noteDuration - time), numSamples - 1)); + auto offset = jmax (0, jmin ((int) (noteDuration - time), numSamples - 1)); if (lastNoteValue > 0) { @@ -105,8 +105,8 @@ public: bool isMidiEffect() const override { return true; } //============================================================================== - AudioProcessorEditor* createEditor() override { return new GenericEditor (*this); } - bool hasEditor() const override { return true; } + AudioProcessorEditor* createEditor() override { return new GenericEditor (*this); } + bool hasEditor() const override { return true; } //============================================================================== const String getName() const override { return "Arpeggiator"; } @@ -133,9 +133,6 @@ public: speed->setValueNotifyingHost (MemoryInputStream (data, static_cast (sizeInBytes), false).readFloat()); } - //============================================================================== - - private: //============================================================================== AudioParameterFloat* speed; diff --git a/examples/PlugInSamples/GainPlugIn/Source/GainProcessor.cpp b/examples/PlugInSamples/GainPlugIn/Source/GainProcessor.cpp index 5cbe6f7366..8b92eaeba5 100644 --- a/examples/PlugInSamples/GainPlugIn/Source/GainProcessor.cpp +++ b/examples/PlugInSamples/GainPlugIn/Source/GainProcessor.cpp @@ -48,7 +48,7 @@ public: void prepareToPlay (double, int) override {} void releaseResources() override {} - void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override + void processBlock (AudioBuffer& buffer, MidiBuffer&) override { buffer.applyGain (*gain); } diff --git a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.cpp b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.cpp index 5f2526318c..a8e331a00b 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.cpp +++ b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.cpp @@ -114,14 +114,14 @@ bool IAAEffectProcessor::isBusesLayoutSupported (const BusesLayout& layouts) con return true; } -void IAAEffectProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&) +void IAAEffectProcessor::processBlock (AudioBuffer& buffer, MidiBuffer&) { const float gain = *parameters.getRawParameterValue ("gain"); - const int totalNumInputChannels = getTotalNumInputChannels(); - const int totalNumOutputChannels = getTotalNumOutputChannels(); + auto totalNumInputChannels = getTotalNumInputChannels(); + auto totalNumOutputChannels = getTotalNumOutputChannels(); - const int numSamples = buffer.getNumSamples(); + auto numSamples = buffer.getNumSamples(); for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); @@ -164,6 +164,7 @@ void IAAEffectProcessor::getStateInformation (MemoryBlock& destData) void IAAEffectProcessor::setStateInformation (const void* data, int sizeInBytes) { auto xmlState = std::unique_ptr (getXmlFromBinary (data, sizeInBytes)); + if (xmlState.get() != nullptr) if (xmlState->hasTagName (parameters.state.getType())) parameters.state = ValueTree::fromXml (*xmlState); diff --git a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.h b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.h index daeb5ca552..043de32e3f 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.h +++ b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectProcessor.h @@ -44,7 +44,7 @@ public: bool isBusesLayoutSupported (const BusesLayout& layouts) const override; - void processBlock (AudioSampleBuffer&, MidiBuffer&) override; + void processBlock (AudioBuffer&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; diff --git a/examples/PlugInSamples/MultiOutSynth/Source/MultiOutSynth.cpp b/examples/PlugInSamples/MultiOutSynth/Source/MultiOutSynth.cpp index c27bcb606a..189bf5e370 100644 --- a/examples/PlugInSamples/MultiOutSynth/Source/MultiOutSynth.cpp +++ b/examples/PlugInSamples/MultiOutSynth/Source/MultiOutSynth.cpp @@ -90,13 +90,14 @@ public: void releaseResources() override {} - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) override + void processBlock (AudioBuffer& buffer, MidiBuffer& midiBuffer) override { - const int busCount = getBusCount (false); + auto busCount = getBusCount (false); + for (int busNr = 0; busNr < busCount; ++busNr) { MidiBuffer midiChannelBuffer = filterMidiMessagesForChannel (midiBuffer, busNr + 1); - AudioSampleBuffer audioBusBuffer = getBusBuffer (buffer, false, busNr); + auto audioBusBuffer = getBusBuffer (buffer, false, busNr); synth [busNr]->renderNextBlock (audioBusBuffer, midiChannelBuffer, 0, audioBusBuffer.getNumSamples()); } diff --git a/examples/PlugInSamples/NoiseGate/Source/NoiseGate.cpp b/examples/PlugInSamples/NoiseGate/Source/NoiseGate.cpp index 1f8cf7b1ea..a46e57198b 100644 --- a/examples/PlugInSamples/NoiseGate/Source/NoiseGate.cpp +++ b/examples/PlugInSamples/NoiseGate/Source/NoiseGate.cpp @@ -33,9 +33,9 @@ public: //============================================================================== //============================================================================== NoiseGate() - : AudioProcessor (BusesProperties().withInput ("Input", AudioChannelSet::stereo()) - .withOutput ("Output", AudioChannelSet::stereo()) - .withInput ("Sidechain", AudioChannelSet::stereo())) + : AudioProcessor (BusesProperties().withInput ("Input", AudioChannelSet::stereo()) + .withOutput ("Output", AudioChannelSet::stereo()) + .withInput ("Sidechain", AudioChannelSet::stereo())) { addParameter (threshold = new AudioParameterFloat ("threshold", "Threshold", 0.0f, 1.0f, 0.5f)); addParameter (alpha = new AudioParameterFloat ("alpha", "Alpha", 0.0f, 1.0f, 0.8f)); @@ -47,18 +47,18 @@ public: bool isBusesLayoutSupported (const BusesLayout& layouts) const override { // the sidechain can take any layout, the main bus needs to be the same on the input and output - return (layouts.getMainInputChannelSet() == layouts.getMainOutputChannelSet() && - (! layouts.getMainInputChannelSet().isDisabled())); + return layouts.getMainInputChannelSet() == layouts.getMainOutputChannelSet() + && ! layouts.getMainInputChannelSet().isDisabled(); } //============================================================================== void prepareToPlay (double /*sampleRate*/, int /*maxBlockSize*/) override { lowPassCoeff = 0.0f; sampleCountDown = 0; } void releaseResources() override {} - void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override + void processBlock (AudioBuffer& buffer, MidiBuffer&) override { - AudioSampleBuffer mainInputOutput = getBusBuffer(buffer, true, 0); - AudioSampleBuffer sideChainInput = getBusBuffer(buffer, true, 1); + auto mainInputOutput = getBusBuffer (buffer, true, 0); + auto sideChainInput = getBusBuffer (buffer, true, 1); float alphaCopy = *alpha; float thresholdCopy = *threshold; @@ -66,6 +66,7 @@ public: for (int j = 0; j < buffer.getNumSamples(); ++j) { float mixedSamples = 0.0f; + for (int i = 0; i < sideChainInput.getNumChannels(); ++i) mixedSamples += sideChainInput.getReadPointer (i) [j]; diff --git a/examples/PlugInSamples/Surround/Source/SurroundProcessor.cpp b/examples/PlugInSamples/Surround/Source/SurroundProcessor.cpp index 66c6805566..faeb4f28e5 100644 --- a/examples/PlugInSamples/Surround/Source/SurroundProcessor.cpp +++ b/examples/PlugInSamples/Surround/Source/SurroundProcessor.cpp @@ -60,7 +60,7 @@ public: void releaseResources() override { reset(); } - void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override + void processBlock (AudioBuffer& buffer, MidiBuffer&) override { for (int ch = 0; ch < buffer.getNumChannels(); ++ch) { @@ -79,8 +79,8 @@ public: channelTime = jmax (0, channelTime - buffer.getNumSamples()); } - const int fillSamples = jmin (static_cast (std::ceil (getSampleRate())) - sampleOffset, - buffer.getNumSamples()); + auto fillSamples = jmin (static_cast (std::ceil (getSampleRate())) - sampleOffset, + buffer.getNumSamples()); if (isPositiveAndBelow (channelClicked, buffer.getNumChannels())) { @@ -126,7 +126,7 @@ public: //============================================================================== void getStateInformation (MemoryBlock&) override {} - void setStateInformation (const void* , int) override {} + void setStateInformation (const void*, int) override {} void channelButtonClicked (int channelIndex) override { @@ -141,8 +141,8 @@ public: void handleAsyncUpdate() override { - if (AudioProcessorEditor* editor = getActiveEditor()) - if (SurroundEditor* surroundEditor = dynamic_cast (editor)) + if (auto* editor = getActiveEditor()) + if (auto* surroundEditor = dynamic_cast (editor)) surroundEditor->updateGUI(); } @@ -151,6 +151,7 @@ private: Array alphaCoeffs; int channelClicked; int sampleOffset; + //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SurroundProcessor) }; diff --git a/examples/audio plugin demo/Source/SinewaveSynth.h b/examples/audio plugin demo/Source/SinewaveSynth.h index 4bafd206e9..40f832f3d7 100644 --- a/examples/audio plugin demo/Source/SinewaveSynth.h +++ b/examples/audio plugin demo/Source/SinewaveSynth.h @@ -94,7 +94,7 @@ public: // not implemented for the purposes of this demo! } - void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override + void renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) override { if (angleDelta != 0.0) { diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.cpp b/extras/Projucer/JuceLibraryCode/BinaryData.cpp index e072c689e4..d9e8b5307c 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Projucer/JuceLibraryCode/BinaryData.cpp @@ -5709,11 +5709,11 @@ static const unsigned char temp_binary_data_28[] = "}\r\n" "#endif\r\n" "\r\n" -"void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" +"void FILTERCLASSNAME::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages)\r\n" "{\r\n" " ScopedNoDenormals noDenormals;\r\n" -" const int totalNumInputChannels = getTotalNumInputChannels();\r\n" -" const int totalNumOutputChannels = getTotalNumOutputChannels();\r\n" +" auto totalNumInputChannels = getTotalNumInputChannels();\r\n" +" auto totalNumOutputChannels = getTotalNumOutputChannels();\r\n" "\r\n" " // In case we have more outputs than inputs, this code clears any output\r\n" " // channels that didn't contain input data, (because these aren't\r\n" @@ -5803,7 +5803,7 @@ static const unsigned char temp_binary_data_29[] = " bool isBusesLayoutSupported (const BusesLayout& layouts) const override;\r\n" " #endif\r\n" "\r\n" -" void processBlock (AudioSampleBuffer&, MidiBuffer&) override;\r\n" +" void processBlock (AudioBuffer&, MidiBuffer&) override;\r\n" "\r\n" " //==============================================================================\r\n" " AudioProcessorEditor* createEditor() override;\r\n" @@ -7014,8 +7014,8 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw case 0xafccbd3f: numBytes = 3141; return jucer_AudioComponentTemplate_cpp; case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; case 0x4d0721bf: numBytes = 938; return jucer_AudioPluginEditorTemplate_h; - case 0x51b49ac5: numBytes = 5647; return jucer_AudioPluginFilterTemplate_cpp; - case 0x488afa0a: numBytes = 2245; return jucer_AudioPluginFilterTemplate_h; + case 0x51b49ac5: numBytes = 5638; return jucer_AudioPluginFilterTemplate_cpp; + case 0x488afa0a: numBytes = 2246; return jucer_AudioPluginFilterTemplate_h; case 0xabad7041: numBytes = 2151; return jucer_ComponentTemplate_cpp; case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; case 0x0b66646c: numBytes = 1029; return jucer_ContentCompTemplate_cpp; diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.h b/extras/Projucer/JuceLibraryCode/BinaryData.h index e32cec36c7..1af184a8a3 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.h +++ b/extras/Projucer/JuceLibraryCode/BinaryData.h @@ -93,10 +93,10 @@ namespace BinaryData const int jucer_AudioPluginEditorTemplate_hSize = 938; extern const char* jucer_AudioPluginFilterTemplate_cpp; - const int jucer_AudioPluginFilterTemplate_cppSize = 5647; + const int jucer_AudioPluginFilterTemplate_cppSize = 5638; extern const char* jucer_AudioPluginFilterTemplate_h; - const int jucer_AudioPluginFilterTemplate_hSize = 2245; + const int jucer_AudioPluginFilterTemplate_hSize = 2246; extern const char* jucer_ComponentTemplate_cpp; const int jucer_ComponentTemplate_cppSize = 2151; diff --git a/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.cpp b/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.cpp index bec4e61204..984c6bb56a 100644 --- a/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.cpp +++ b/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.cpp @@ -129,11 +129,11 @@ bool FILTERCLASSNAME::isBusesLayoutSupported (const BusesLayout& layouts) const } #endif -void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) +void FILTERCLASSNAME::processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) { ScopedNoDenormals noDenormals; - const int totalNumInputChannels = getTotalNumInputChannels(); - const int totalNumOutputChannels = getTotalNumOutputChannels(); + auto totalNumInputChannels = getTotalNumInputChannels(); + auto totalNumOutputChannels = getTotalNumOutputChannels(); // In case we have more outputs than inputs, this code clears any output // channels that didn't contain input data, (because these aren't diff --git a/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.h b/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.h index 9abc63a29d..9606483057 100644 --- a/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.h +++ b/extras/Projucer/Source/BinaryData/Templates/jucer_AudioPluginFilterTemplate.h @@ -31,7 +31,7 @@ public: bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif - void processBlock (AudioSampleBuffer&, MidiBuffer&) override; + void processBlock (AudioBuffer&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index d3cf8a9b2c..cfc63ac52b 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -25,9 +25,7 @@ namespace juce //============================================================================== /** - A multi-channel buffer of floating point audio samples. - - @see AudioSampleBuffer + A multi-channel buffer containing floating point audio samples. */ template class AudioBuffer diff --git a/modules/juce_audio_basics/midi/juce_MidiBuffer.h b/modules/juce_audio_basics/midi/juce_MidiBuffer.h index aa38384003..c7d534c3f6 100644 --- a/modules/juce_audio_basics/midi/juce_MidiBuffer.h +++ b/modules/juce_audio_basics/midi/juce_MidiBuffer.h @@ -27,7 +27,7 @@ namespace juce /** Holds a sequence of time-stamped midi events. - Analogous to the AudioSampleBuffer, this holds a set of midi events with + Analogous to the AudioBuffer, this holds a set of midi events with integer time-stamps. The buffer is kept sorted in order of the time-stamps. If you're working with a sequence of midi events that may need to be manipulated diff --git a/modules/juce_audio_basics/sources/juce_AudioSource.h b/modules/juce_audio_basics/sources/juce_AudioSource.h index 6e5ddba5df..f8478ba604 100644 --- a/modules/juce_audio_basics/sources/juce_AudioSource.h +++ b/modules/juce_audio_basics/sources/juce_AudioSource.h @@ -35,7 +35,7 @@ struct JUCE_API AudioSourceChannelInfo } /** Creates an AudioSourceChannelInfo. */ - AudioSourceChannelInfo (AudioSampleBuffer* bufferToUse, + AudioSourceChannelInfo (AudioBuffer* bufferToUse, int startSampleOffset, int numSamplesToUse) noexcept : buffer (bufferToUse), startSample (startSampleOffset), @@ -47,7 +47,7 @@ struct JUCE_API AudioSourceChannelInfo Note that the buffer provided must not be deleted while the AudioSourceChannelInfo is still using it. */ - explicit AudioSourceChannelInfo (AudioSampleBuffer& bufferToUse) noexcept + explicit AudioSourceChannelInfo (AudioBuffer& bufferToUse) noexcept : buffer (&bufferToUse), startSample (0), numSamples (bufferToUse.getNumSamples()) @@ -70,7 +70,7 @@ struct JUCE_API AudioSourceChannelInfo The number of channels in the buffer could be anything, so the AudioSource must cope with this in whatever way is appropriate for its function. */ - AudioSampleBuffer* buffer; + AudioBuffer* buffer; /** The first sample in the buffer from which the callback is expected to write data. */ diff --git a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h index 5624f5ceb7..2c70e00821 100644 --- a/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h @@ -100,7 +100,7 @@ private: OptionalScopedPointer source; TimeSliceThread& backgroundThread; int numberOfSamplesToBuffer, numberOfChannels; - AudioSampleBuffer buffer; + AudioBuffer buffer; CriticalSection bufferStartPosLock; WaitableEvent bufferReadyEvent; int64 volatile bufferValidStart, bufferValidEnd, nextPlayPos; diff --git a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h index b5a5cf058b..da73ae5c46 100644 --- a/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ChannelRemappingAudioSource.h @@ -129,7 +129,7 @@ private: Array remappedInputs, remappedOutputs; int requiredNumberOfChannels; - AudioSampleBuffer buffer; + AudioBuffer buffer; AudioSourceChannelInfo remappedInfo; CriticalSection lock; diff --git a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h index 0c2b6e22c7..820f0b2229 100644 --- a/modules/juce_audio_basics/sources/juce_MixerAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_MixerAudioSource.h @@ -87,7 +87,7 @@ private: Array inputs; BigInteger inputsToDelete; CriticalSection lock; - AudioSampleBuffer tempBuffer; + AudioBuffer tempBuffer; double currentSampleRate; int bufferSizeExpected; diff --git a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h index 9f8fcd239a..10cd357aa4 100644 --- a/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h +++ b/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h @@ -75,7 +75,7 @@ private: //============================================================================== OptionalScopedPointer input; double ratio, lastRatio; - AudioSampleBuffer buffer; + AudioBuffer buffer; int bufferPos, sampsInBuffer; double subSampleOffset; double coefficients[6]; diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 957f482087..78a70498e7 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -970,7 +970,7 @@ double AudioDeviceManager::LevelMeter::getCurrentLevel() const noexcept void AudioDeviceManager::playTestSound() { { // cunningly nested to swap, unlock and delete in that order. - ScopedPointer oldSound; + ScopedPointer> oldSound; { const ScopedLock sl (audioCallbackLock); @@ -990,7 +990,7 @@ void AudioDeviceManager::playTestSound() const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); - AudioSampleBuffer* const newSound = new AudioSampleBuffer (1, soundLength); + auto* newSound = new AudioBuffer (1, soundLength); for (int i = 0; i < soundLength; ++i) newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h index 6e5d682545..e0ea49fd44 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.h @@ -458,7 +458,7 @@ private: BigInteger inputChannels, outputChannels; ScopedPointer lastExplicitSettings; mutable bool listNeedsScanning; - AudioSampleBuffer tempBuffer; + AudioBuffer tempBuffer; struct MidiCallbackInfo { @@ -474,7 +474,7 @@ private: ScopedPointer defaultMidiOutput; CriticalSection audioCallbackLock, midiCallbackLock; - ScopedPointer testSound; + ScopedPointer> testSound; int testSoundPosition; double cpuUsageMs, timeToCpuScale, msPerBlock; diff --git a/modules/juce_audio_devices/native/juce_android_Audio.cpp b/modules/juce_audio_devices/native/juce_android_Audio.cpp index 42f6fdd98e..4a5d6bfb30 100644 --- a/modules/juce_audio_devices/native/juce_android_Audio.cpp +++ b/modules/juce_audio_devices/native/juce_android_Audio.cpp @@ -423,7 +423,7 @@ private: String lastError; BigInteger activeOutputChans, activeInputChans; GlobalRef outputDevice, inputDevice; - AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; + AudioBuffer inputChannelBuffer, outputChannelBuffer; jmethodID getUnderrunCount = 0; void closeDevices() diff --git a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp index 73444c051a..93187872d1 100644 --- a/modules/juce_audio_devices/native/juce_android_OpenSL.cpp +++ b/modules/juce_audio_devices/native/juce_android_OpenSL.cpp @@ -166,9 +166,9 @@ struct BufferHelpers dataFormat.representation = 0; } - static void prepareCallbackBuffer (AudioSampleBuffer&, int16*) {} + static void prepareCallbackBuffer (AudioBuffer&, int16*) {} - static void convertFromOpenSL (const int16* srcInterleaved, AudioSampleBuffer& audioBuffer) + static void convertFromOpenSL (const int16* srcInterleaved, AudioBuffer& audioBuffer) { for (int i = 0; i < audioBuffer.getNumChannels(); ++i) { @@ -181,7 +181,7 @@ struct BufferHelpers } } - static void convertToOpenSL (const AudioSampleBuffer& audioBuffer, int16* dstInterleaved) + static void convertToOpenSL (const AudioBuffer& audioBuffer, int16* dstInterleaved) { for (int i = 0; i < audioBuffer.getNumChannels(); ++i) { @@ -215,13 +215,13 @@ struct BufferHelpers dataFormat.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT; } - static void prepareCallbackBuffer (AudioSampleBuffer& audioBuffer, float* native) + static void prepareCallbackBuffer (AudioBuffer& audioBuffer, float* native) { if (audioBuffer.getNumChannels() == 1) audioBuffer.setDataToReferTo (&native, 1, audioBuffer.getNumSamples()); } - static void convertFromOpenSL (const float* srcInterleaved, AudioSampleBuffer& audioBuffer) + static void convertFromOpenSL (const float* srcInterleaved, AudioBuffer& audioBuffer) { if (audioBuffer.getNumChannels() == 1) { @@ -240,7 +240,7 @@ struct BufferHelpers } } - static void convertToOpenSL (const AudioSampleBuffer& audioBuffer, float* dstInterleaved) + static void convertToOpenSL (const AudioBuffer& audioBuffer, float* dstInterleaved) { if (audioBuffer.getNumChannels() == 1) { @@ -374,7 +374,7 @@ public: int numChannels; HeapBlock nativeBuffer; - AudioSampleBuffer scratchBuffer, sampleBuffer; + AudioBuffer scratchBuffer, sampleBuffer; Atomic nextBlock, numBlocksOut; }; diff --git a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp index b6ff24ecbb..85ae20fdb6 100644 --- a/modules/juce_audio_devices/native/juce_linux_ALSA.cpp +++ b/modules/juce_audio_devices/native/juce_linux_ALSA.cpp @@ -310,7 +310,7 @@ public: } //============================================================================== - bool writeToOutputDevice (AudioSampleBuffer& outputChannelBuffer, const int numSamples) + bool writeToOutputDevice (AudioBuffer& outputChannelBuffer, const int numSamples) { jassert (numChannelsRunning <= outputChannelBuffer.getNumChannels()); float* const* const data = outputChannelBuffer.getArrayOfWritePointers(); @@ -348,7 +348,7 @@ public: return true; } - bool readFromInputDevice (AudioSampleBuffer& inputChannelBuffer, const int numSamples) + bool readFromInputDevice (AudioBuffer& inputChannelBuffer, const int numSamples) { jassert (numChannelsRunning <= inputChannelBuffer.getNumChannels()); float* const* const data = inputChannelBuffer.getArrayOfWritePointers(); @@ -801,7 +801,7 @@ private: CriticalSection callbackLock; - AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; + AudioBuffer inputChannelBuffer, outputChannelBuffer; Array inputChannelDataForCallback; Array outputChannelDataForCallback; diff --git a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp index a3c3f069ce..f7f3e5585a 100644 --- a/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp +++ b/modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp @@ -209,7 +209,7 @@ public: }; // returns the number of actual available channels - StringArray getChannelInfo (const bool input, Array& newChannelInfo) const + StringArray getChannelInfo (bool input, Array& newChannelInfo) const { StringArray newNames; int chanNum = 0; @@ -300,7 +300,7 @@ public: } } - if (newSampleRates.size() == 0 && sampleRate > 0) + if (newSampleRates.isEmpty() && sampleRate > 0) newSampleRates.add (sampleRate); return newSampleRates; @@ -342,7 +342,7 @@ public: } } - if (newBufferSizes.size() == 0 && bufferSize > 0) + if (newBufferSizes.isEmpty() && bufferSize > 0) newBufferSizes.add (bufferSize); return newBufferSizes; @@ -419,21 +419,21 @@ public: // this collects all the new details from the device without any locking, then // locks + swaps them afterwards. - const double newSampleRate = getNominalSampleRate(); - const int newBufferSize = getFrameSizeFromDevice(); + auto newSampleRate = getNominalSampleRate(); + auto newBufferSize = getFrameSizeFromDevice(); - Array newBufferSizes = getBufferSizesFromDevice(); - Array newSampleRates = getSampleRatesFromDevice(); + auto newBufferSizes = getBufferSizesFromDevice(); + auto newSampleRates = getSampleRatesFromDevice(); - const int newInputLatency = getLatencyFromDevice (kAudioDevicePropertyScopeInput); - const int newOutputLatency = getLatencyFromDevice (kAudioDevicePropertyScopeOutput); + auto newInputLatency = getLatencyFromDevice (kAudioDevicePropertyScopeInput); + auto newOutputLatency = getLatencyFromDevice (kAudioDevicePropertyScopeOutput); Array newInChans, newOutChans; auto newInNames = isInputDevice ? getChannelInfo (true, newInChans) : StringArray(); auto newOutNames = isOutputDevice ? getChannelInfo (false, newOutChans) : StringArray(); - const int newBitDepth = jmax (getBitDepthFromDevice (kAudioDevicePropertyScopeInput), - getBitDepthFromDevice (kAudioDevicePropertyScopeOutput)); + auto newBitDepth = jmax (getBitDepthFromDevice (kAudioDevicePropertyScopeInput), + getBitDepthFromDevice (kAudioDevicePropertyScopeOutput)); { const ScopedLock sl (callbackLock); @@ -467,7 +467,7 @@ public: { StringArray s; HeapBlock types; - const int num = getAllDataSourcesForDevice (deviceID, types); + auto num = getAllDataSourcesForDevice (deviceID, types); for (int i = 0; i < num; ++i) { @@ -722,11 +722,10 @@ public: { for (int i = numInputChans; --i >= 0;) { - const CallbackDetailsForChannel& info = inputChannelInfo.getReference(i); - float* dest = tempInputBuffers [i]; - const float* src = ((const float*) inInputData->mBuffers[info.streamNum].mData) - + info.dataOffsetSamples; - const int stride = info.dataStrideSamples; + auto& info = inputChannelInfo.getReference(i); + auto dest = tempInputBuffers[i]; + auto src = ((const float*) inInputData->mBuffers[info.streamNum].mData) + info.dataOffsetSamples; + auto stride = info.dataStrideSamples; if (stride != 0) // if this is zero, info is invalid { @@ -746,11 +745,10 @@ public: for (int i = numOutputChans; --i >= 0;) { - const CallbackDetailsForChannel& info = outputChannelInfo.getReference(i); - const float* src = tempOutputBuffers [i]; - float* dest = ((float*) outOutputData->mBuffers[info.streamNum].mData) - + info.dataOffsetSamples; - const int stride = info.dataStrideSamples; + auto& info = outputChannelInfo.getReference(i); + auto src = tempOutputBuffers[i]; + auto dest = ((float*) outOutputData->mBuffers[info.streamNum].mData) + info.dataOffsetSamples; + auto stride = info.dataStrideSamples; if (stride != 0) // if this is zero, info is invalid { @@ -1145,8 +1143,8 @@ public: { Array devs; - for (int i = 0; i < devices.size(); ++i) - devs.add (devices.getUnchecked(i)->device); + for (auto* d : devices) + devs.add (d->device); return devs; } @@ -1155,8 +1153,8 @@ public: { StringArray names; - for (int i = 0; i < devices.size(); ++i) - names.addArray (devices.getUnchecked(i)->getOutputChannelNames()); + for (auto* d : devices) + names.addArray (d->getOutputChannelNames()); names.appendNumbersToDuplicates (false, true); return names; @@ -1166,8 +1164,8 @@ public: { StringArray names; - for (int i = 0; i < devices.size(); ++i) - names.addArray (devices.getUnchecked(i)->getInputChannelNames()); + for (auto* d : devices) + names.addArray (d->getInputChannelNames()); names.appendNumbersToDuplicates (false, true); return names; @@ -1176,15 +1174,21 @@ public: Array getAvailableSampleRates() override { Array commonRates; + bool first = true; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - Array rates (devices.getUnchecked(i)->device->getAvailableSampleRates()); + auto rates = d->device->getAvailableSampleRates(); - if (i == 0) + if (first) + { + first = false; commonRates = rates; + } else + { commonRates.removeValuesNotIn (rates); + } } return commonRates; @@ -1193,15 +1197,21 @@ public: Array getAvailableBufferSizes() override { Array commonSizes; + bool first = true; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - Array sizes (devices.getUnchecked(i)->device->getAvailableBufferSizes()); + auto sizes = d->device->getAvailableBufferSizes(); - if (i == 0) + if (first) + { + first = false; commonSizes = sizes; + } else + { commonSizes.removeValuesNotIn (sizes); + } } return commonSizes; @@ -1216,8 +1226,8 @@ public: { int depth = 32; - for (int i = 0; i < devices.size(); ++i) - depth = jmin (depth, devices.getUnchecked(i)->device->getCurrentBitDepth()); + for (auto* d : devices) + depth = jmin (depth, d->device->getCurrentBitDepth()); return depth; } @@ -1226,8 +1236,8 @@ public: { int size = 0; - for (int i = 0; i < devices.size(); ++i) - size = jmax (size, devices.getUnchecked(i)->device->getDefaultBufferSize()); + for (auto* d : devices) + size = jmax (size, d->device->getDefaultBufferSize()); return size; } @@ -1244,7 +1254,7 @@ public: if (sampleRate <= 0) { - Array rates (getAvailableSampleRates()); + auto rates = getAvailableSampleRates(); for (int i = 0; i < rates.size() && sampleRate < 44100.0; ++i) sampleRate = rates.getUnchecked(i); @@ -1257,21 +1267,19 @@ public: int totalInputChanIndex = 0, totalOutputChanIndex = 0; int chanIndex = 0; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - DeviceWrapper& d = *devices.getUnchecked(i); - BigInteger ins (inputChannels >> totalInputChanIndex); BigInteger outs (outputChannels >> totalOutputChanIndex); - int numIns = d.getInputChannelNames().size(); - int numOuts = d.getOutputChannelNames().size(); + int numIns = d->getInputChannelNames().size(); + int numOuts = d->getOutputChannelNames().size(); totalInputChanIndex += numIns; totalOutputChanIndex += numOuts; - String err = d.open (ins, outs, sampleRate, bufferSize, - chanIndex, fifoSize); + String err = d->open (ins, outs, sampleRate, bufferSize, + chanIndex, fifoSize); if (err.isNotEmpty()) { @@ -1280,7 +1288,7 @@ public: return err; } - chanIndex += d.numInputChans + d.numOutputChans; + chanIndex += d->numInputChans + d->numOutputChans; } fifos.setSize (chanIndex, fifoSize); @@ -1297,8 +1305,8 @@ public: fifos.clear(); active = false; - for (int i = 0; i < devices.size(); ++i) - devices.getUnchecked(i)->close(); + for (auto* d : devices) + d->close(); } BigInteger getActiveOutputChannels() const override @@ -1306,13 +1314,13 @@ public: BigInteger chans; int start = 0; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - const int numChans = devices.getUnchecked(i)->getOutputChannelNames().size(); + auto numChans = d->getOutputChannelNames().size(); if (numChans > 0) { - chans |= (devices.getUnchecked(i)->device->getActiveOutputChannels() << start); + chans |= (d->device->getActiveOutputChannels() << start); start += numChans; } } @@ -1325,13 +1333,13 @@ public: BigInteger chans; int start = 0; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - const int numChans = devices.getUnchecked(i)->getInputChannelNames().size(); + auto numChans = d->getInputChannelNames().size(); if (numChans > 0) { - chans |= (devices.getUnchecked(i)->device->getActiveInputChannels() << start); + chans |= (d->device->getActiveInputChannels() << start); start += numChans; } } @@ -1343,8 +1351,8 @@ public: { int lat = 0; - for (int i = 0; i < devices.size(); ++i) - lat = jmax (lat, devices.getUnchecked(i)->device->getOutputLatencyInSamples()); + for (auto* d : devices) + lat = jmax (lat, d->device->getOutputLatencyInSamples()); return lat + currentBufferSize * 2; } @@ -1353,8 +1361,8 @@ public: { int lat = 0; - for (int i = 0; i < devices.size(); ++i) - lat = jmax (lat, devices.getUnchecked(i)->device->getInputLatencyInSamples()); + for (auto* d : devices) + lat = jmax (lat, d->device->getInputLatencyInSamples()); return lat + currentBufferSize * 2; } @@ -1366,8 +1374,8 @@ public: stop(); fifos.clear(); - for (int i = 0; i < devices.size(); ++i) - devices.getUnchecked(i)->start(); + for (auto* d : devices) + d->start(); if (newCallback != nullptr) newCallback->audioDeviceAboutToStart (this); @@ -1392,34 +1400,31 @@ private: int currentBufferSize = 0; bool active = false; String lastError; - - AudioSampleBuffer fifos; + AudioBuffer fifos; void run() override { - const int numSamples = currentBufferSize; + auto numSamples = currentBufferSize; - AudioSampleBuffer buffer (fifos.getNumChannels(), numSamples); + AudioBuffer buffer (fifos.getNumChannels(), numSamples); buffer.clear(); Array inputChans; Array outputChans; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - DeviceWrapper& d = *devices.getUnchecked(i); - - for (int j = 0; j < d.numInputChans; ++j) inputChans.add (buffer.getReadPointer (d.inputIndex + j)); - for (int j = 0; j < d.numOutputChans; ++j) outputChans.add (buffer.getWritePointer (d.outputIndex + j)); + for (int j = 0; j < d->numInputChans; ++j) inputChans.add (buffer.getReadPointer (d->inputIndex + j)); + for (int j = 0; j < d->numOutputChans; ++j) outputChans.add (buffer.getWritePointer (d->outputIndex + j)); } - const int numInputChans = inputChans.size(); - const int numOutputChans = outputChans.size(); + auto numInputChans = inputChans.size(); + auto numOutputChans = outputChans.size(); inputChans.add (nullptr); outputChans.add (nullptr); - const int blockSizeMs = jmax (1, (int) (1000 * numSamples / currentSampleRate)); + auto blockSizeMs = jmax (1, (int) (1000 * numSamples / currentSampleRate)); jassert (numInputChans + numOutputChans == buffer.getNumChannels()); @@ -1462,8 +1467,8 @@ private: std::swap (callback, lastCallback); } - for (int i = 0; i < devices.size(); ++i) - devices.getUnchecked(i)->device->stop(); + for (auto* d : devices) + d->device->stop(); if (lastCallback != nullptr) { @@ -1476,36 +1481,31 @@ private: void reset() { - for (int i = 0; i < devices.size(); ++i) - devices.getUnchecked(i)->reset(); + for (auto* d : devices) + d->reset(); } void underrun() { } - void readInput (AudioSampleBuffer& buffer, const int numSamples, const int blockSizeMs) + void readInput (AudioBuffer& buffer, const int numSamples, const int blockSizeMs) { - for (int i = 0; i < devices.size(); ++i) - { - DeviceWrapper& d = *devices.getUnchecked(i); - d.done = (d.numInputChans == 0); - } + for (auto* d : devices) + d->done = (d->numInputChans == 0); for (int tries = 5;;) { bool anyRemaining = false; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - DeviceWrapper& d = *devices.getUnchecked(i); - - if (! d.done) + if (! d->done) { - if (d.isInputReady (numSamples)) + if (d->isInputReady (numSamples)) { - d.readInput (buffer, numSamples); - d.done = true; + d->readInput (buffer, numSamples); + d->done = true; } else anyRemaining = true; @@ -1521,38 +1521,29 @@ private: wait (blockSizeMs); } - for (int j = 0; j < devices.size(); ++j) - { - DeviceWrapper& d = *devices.getUnchecked(j); - - if (! d.done) - for (int i = 0; i < d.numInputChans; ++i) - buffer.clear (d.inputIndex + i, 0, numSamples); - } + for (auto* d : devices) + if (! d->done) + for (int i = 0; i < d->numInputChans; ++i) + buffer.clear (d->inputIndex + i, 0, numSamples); } - void pushOutputData (AudioSampleBuffer& buffer, const int numSamples, const int blockSizeMs) + void pushOutputData (AudioBuffer& buffer, const int numSamples, const int blockSizeMs) { - for (int i = 0; i < devices.size(); ++i) - { - DeviceWrapper& d = *devices.getUnchecked(i); - d.done = (d.numOutputChans == 0); - } + for (auto* d : devices) + d->done = (d->numOutputChans == 0); for (int tries = 5;;) { bool anyRemaining = false; - for (int i = 0; i < devices.size(); ++i) + for (auto* d : devices) { - DeviceWrapper& d = *devices.getUnchecked(i); - - if (! d.done) + if (! d->done) { - if (d.isOutputReady (numSamples)) + if (d->isOutputReady (numSamples)) { - d.pushOutputData (buffer, numSamples); - d.done = true; + d->pushOutputData (buffer, numSamples); + d->done = true; } else anyRemaining = true; @@ -1572,28 +1563,39 @@ private: auto newSampleRate = device->getCurrentSampleRate(); auto commonRates = getAvailableSampleRates(); + if (! commonRates.contains (newSampleRate)) { commonRates.sort(); + if (newSampleRate < commonRates.getFirst() || newSampleRate > commonRates.getLast()) + { newSampleRate = jlimit (commonRates.getFirst(), commonRates.getLast(), newSampleRate); + } else + { for (auto it = commonRates.begin(); it < commonRates.end() - 1; ++it) + { if (it[0] < newSampleRate && it[1] > newSampleRate) { newSampleRate = newSampleRate - it[0] < it[1] - newSampleRate ? it[0] : it[1]; break; } + } + } } - currentSampleRate = newSampleRate; + currentSampleRate = newSampleRate; bool anySampleRateChanges = false; - for (int i = 0; i < devices.size(); ++i) - if (devices.getUnchecked(i)->getCurrentSampleRate() != currentSampleRate) + + for (auto* d : devices) + { + if (d->getCurrentSampleRate() != currentSampleRate) { - devices.getUnchecked(i)->setCurrentSampleRate (currentSampleRate); + d->setCurrentSampleRate (currentSampleRate); anySampleRateChanges = true; } + } if (anySampleRateChanges) owner.audioDeviceListChanged(); @@ -1609,9 +1611,8 @@ private: struct DeviceWrapper : private AudioIODeviceCallback { DeviceWrapper (AudioIODeviceCombiner& cd, CoreAudioIODevice* d, bool useIns, bool useOuts) - : owner (cd), device (d), inputIndex (0), outputIndex (0), - useInputs (useIns), useOutputs (useOuts), - inputFifo (32), outputFifo (32), done (false) + : owner (cd), device (d), + useInputs (useIns), useOutputs (useOuts) { } @@ -1621,18 +1622,16 @@ private: } String open (const BigInteger& inputChannels, const BigInteger& outputChannels, - double sampleRate, int bufferSize, - int channelIndex, - int fifoSize) + double sampleRate, int bufferSize, int channelIndex, int fifoSize) { inputFifo.setTotalSize (fifoSize); outputFifo.setTotalSize (fifoSize); inputFifo.reset(); outputFifo.reset(); - String err (device->open (useInputs ? inputChannels : BigInteger(), - useOutputs ? outputChannels : BigInteger(), - sampleRate, bufferSize)); + auto err = device->open (useInputs ? inputChannels : BigInteger(), + useOutputs ? outputChannels : BigInteger(), + sampleRate, bufferSize); numInputChans = useInputs ? device->getActiveInputChannels().countNumberOfSetBits() : 0; numOutputChans = useOutputs ? device->getActiveOutputChannels().countNumberOfSetBits() : 0; @@ -1668,7 +1667,7 @@ private: return numInputChans == 0 || inputFifo.getNumReady() >= numSamples; } - void readInput (AudioSampleBuffer& destBuffer, int numSamples) + void readInput (AudioBuffer& destBuffer, int numSamples) { if (numInputChans == 0) return; @@ -1678,9 +1677,9 @@ private: for (int i = 0; i < numInputChans; ++i) { - const int index = inputIndex + i; - float* const dest = destBuffer.getWritePointer (index); - const float* const src = owner.fifos.getReadPointer (index); + auto index = inputIndex + i; + auto dest = destBuffer.getWritePointer (index); + auto src = owner.fifos.getReadPointer (index); if (size1 > 0) FloatVectorOperations::copy (dest, src + start1, size1); if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); @@ -1694,7 +1693,7 @@ private: return numOutputChans == 0 || outputFifo.getFreeSpace() >= numSamples; } - void pushOutputData (AudioSampleBuffer& srcBuffer, int numSamples) + void pushOutputData (AudioBuffer& srcBuffer, int numSamples) { if (numOutputChans == 0) return; @@ -1704,9 +1703,9 @@ private: for (int i = 0; i < numOutputChans; ++i) { - const int index = outputIndex + i; - float* const dest = owner.fifos.getWritePointer (index); - const float* const src = srcBuffer.getReadPointer (index); + auto index = outputIndex + i; + auto dest = owner.fifos.getWritePointer (index); + auto src = srcBuffer.getReadPointer (index); if (size1 > 0) FloatVectorOperations::copy (dest + start1, src, size1); if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); @@ -1719,7 +1718,7 @@ private: float** outputChannelData, int numOutputChannels, int numSamples) override { - AudioSampleBuffer& buf = owner.fifos; + auto& buf = owner.fifos; if (numInputChannels > 0) { @@ -1734,8 +1733,8 @@ private: for (int i = 0; i < numInputChannels; ++i) { - float* const dest = buf.getWritePointer (inputIndex + i); - const float* const src = inputChannelData[i]; + auto dest = buf.getWritePointer (inputIndex + i); + auto src = inputChannelData[i]; if (size1 > 0) FloatVectorOperations::copy (dest + start1, src, size1); if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); @@ -1765,8 +1764,8 @@ private: for (int i = 0; i < numOutputChannels; ++i) { - float* const dest = outputChannelData[i]; - const float* const src = buf.getReadPointer (outputIndex + i); + auto dest = outputChannelData[i]; + auto src = buf.getReadPointer (outputIndex + i); if (size1 > 0) FloatVectorOperations::copy (dest, src + start1, size1); if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); @@ -1795,10 +1794,10 @@ private: AudioIODeviceCombiner& owner; ScopedPointer device; - int inputIndex, numInputChans, outputIndex, numOutputChans; - bool useInputs, useOutputs; - AbstractFifo inputFifo, outputFifo; - bool done; + int inputIndex = 0, numInputChans = 0, outputIndex = 0, numOutputChans = 0; + bool useInputs = false, useOutputs = false; + AbstractFifo inputFifo { 32 }, outputFifo { 32 }; + bool done = false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DeviceWrapper) }; @@ -1814,9 +1813,7 @@ class CoreAudioIODeviceType : public AudioIODeviceType, private AsyncUpdater { public: - CoreAudioIODeviceType() - : AudioIODeviceType ("CoreAudio"), - hasScanned (false) + CoreAudioIODeviceType() : AudioIODeviceType ("CoreAudio") { AudioObjectPropertyAddress pa; pa.mSelector = kAudioHardwarePropertyDevices; @@ -1860,18 +1857,19 @@ public: if (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, nullptr, &size, devs) == noErr) { - const int num = size / (int) sizeof (AudioDeviceID); + auto num = (int) size / (int) sizeof (AudioDeviceID); + for (int i = 0; i < num; ++i) { - char name [1024]; + char name[1024]; size = sizeof (name); pa.mSelector = kAudioDevicePropertyDeviceName; if (AudioObjectGetPropertyData (devs[i], &pa, 0, nullptr, &size, name) == noErr) { - const String nameString (String::fromUTF8 (name, (int) strlen (name))); - const int numIns = getNumChannels (devs[i], true); - const int numOuts = getNumChannels (devs[i], false); + auto nameString = String::fromUTF8 (name, (int) strlen (name)); + auto numIns = getNumChannels (devs[i], true); + auto numOuts = getNumChannels (devs[i], false); if (numIns > 0) { @@ -1940,17 +1938,15 @@ public: { jassert (hasScanned); // need to call scanForDevices() before doing this - if (CoreAudioIODevice* const d = dynamic_cast (device)) + if (auto* d = dynamic_cast (device)) return asInput ? d->inputIndex : d->outputIndex; - if (AudioIODeviceCombiner* const d = dynamic_cast (device)) + if (auto* d = dynamic_cast (device)) { - const Array devs (d->getDevices()); - - for (int i = 0; i < devs.size(); ++i) + for (auto* dev : d->getDevices()) { - const int index = getIndexOfDevice (devs.getUnchecked(i), asInput); + auto index = getIndexOfDevice (dev, asInput); if (index >= 0) return index; @@ -1967,16 +1963,17 @@ public: { jassert (hasScanned); // need to call scanForDevices() before doing this - const int inputIndex = inputDeviceNames.indexOf (inputDeviceName); - const int outputIndex = outputDeviceNames.indexOf (outputDeviceName); + auto inputIndex = inputDeviceNames.indexOf (inputDeviceName); + auto outputIndex = outputDeviceNames.indexOf (outputDeviceName); - AudioDeviceID inputDeviceID = inputIds [inputIndex]; - AudioDeviceID outputDeviceID = outputIds [outputIndex]; + auto inputDeviceID = inputIds[inputIndex]; + auto outputDeviceID = outputIds[outputIndex]; if (inputDeviceID == 0 && outputDeviceID == 0) return nullptr; - String combinedName (outputDeviceName.isEmpty() ? inputDeviceName : outputDeviceName); + auto combinedName = outputDeviceName.isEmpty() ? inputDeviceName + : outputDeviceName; if (inputDeviceID == outputDeviceID) return new CoreAudioIODevice (*this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex); @@ -2014,7 +2011,7 @@ private: StringArray inputDeviceNames, outputDeviceNames; Array inputIds, outputIds; - bool hasScanned; + bool hasScanned = false; static int getNumChannels (AudioDeviceID deviceID, bool input) { @@ -2033,13 +2030,10 @@ private: if (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, bufList) == noErr) { - const int numStreams = (int) bufList->mNumberBuffers; + auto numStreams = (int) bufList->mNumberBuffers; for (int i = 0; i < numStreams; ++i) - { - const ::AudioBuffer& b = bufList->mBuffers[i]; - total += b.mNumberChannels; - } + total += bufList->mBuffers[i].mNumberChannels; } } diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 319e57cc50..670a906190 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -892,7 +892,7 @@ private: int bufferSizeSamples = 0; double sampleRate = 0; BigInteger enabledInputs, enabledOutputs; - AudioSampleBuffer inputBuffers, outputBuffers; + AudioBuffer inputBuffers, outputBuffers; AudioIODeviceCallback* callback = nullptr; CriticalSection startStopLock; diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index 4a5b4b9e41..2dc3fa5365 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -1246,8 +1246,8 @@ public: const int numOutputBuffers = getActiveOutputChannels().countNumberOfSetBits(); bool sampleRateHasChanged = false; - AudioSampleBuffer ins (jmax (1, numInputBuffers), bufferSize + 32); - AudioSampleBuffer outs (jmax (1, numOutputBuffers), bufferSize + 32); + AudioBuffer ins (jmax (1, numInputBuffers), bufferSize + 32); + AudioBuffer outs (jmax (1, numOutputBuffers), bufferSize + 32); float** const inputBuffers = ins.getArrayOfWritePointers(); float** const outputBuffers = outs.getArrayOfWritePointers(); ins.clear(); diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp index b03ca9a93f..8e055afbf5 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.cpp @@ -24,11 +24,6 @@ namespace juce { AudioSourcePlayer::AudioSourcePlayer() - : source (nullptr), - sampleRate (0), - bufferSize (0), - lastGain (1.0f), - gain (1.0f) { } @@ -41,7 +36,7 @@ void AudioSourcePlayer::setSource (AudioSource* newSource) { if (source != newSource) { - AudioSource* const oldSource = source; + auto* oldSource = source; if (newSource != nullptr && bufferSize > 0 && sampleRate > 0) newSource->prepareToPlay (bufferSize, sampleRate); @@ -137,7 +132,7 @@ void AudioSourcePlayer::audioDeviceIOCallback (const float** inputChannelData, } } - AudioSampleBuffer buffer (channels, numActiveChans, numSamples); + AudioBuffer buffer (channels, numActiveChans, numSamples); AudioSourceChannelInfo info (&buffer, 0, numSamples); source->getNextAudioBlock (info); diff --git a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h index d624b0a578..4637be4f3f 100644 --- a/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h +++ b/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h @@ -96,14 +96,14 @@ public: private: //============================================================================== CriticalSection readLock; - AudioSource* source; - double sampleRate; - int bufferSize; - float* channels [128]; - float* outputChans [128]; - const float* inputChans [128]; - AudioSampleBuffer tempBuffer; - float lastGain, gain; + AudioSource* source = nullptr; + double sampleRate = 0; + int bufferSize = 0; + float* channels[128]; + float* outputChans[128]; + const float* inputChans[128]; + AudioBuffer tempBuffer; + float lastGain = 1.0f, gain = 1.0f; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer) }; diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index 8cc6e65064..6134ebff35 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -366,7 +366,7 @@ public: private: FlacNamespace::FLAC__StreamDecoder* decoder; - AudioSampleBuffer reservoir; + AudioBuffer reservoir; int reservoirStart = 0, samplesInReservoir = 0; bool ok = false, scanningForLength = false; diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index 67b01abae9..0f661b7b32 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -263,7 +263,7 @@ public: private: OggVorbisNamespace::OggVorbis_File ovFile; OggVorbisNamespace::ov_callbacks callbacks; - AudioSampleBuffer reservoir; + AudioBuffer reservoir; int reservoirStart = 0, samplesInReservoir = 0; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggReader) diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index 86e43fd3c6..ad96b5fd90 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -1838,7 +1838,7 @@ struct WaveAudioFormatTests : public UnitTest 32, metadataValues, 0)); expect (writer != nullptr); - AudioSampleBuffer buffer (numTestAudioBufferChannels, numTestAudioBufferSamples); + AudioBuffer buffer (numTestAudioBufferChannels, numTestAudioBufferSamples); buffer.clear(); beginTest ("Writing audio data to the basic wave writer"); diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index 9435e36649..a21b0570e1 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -100,10 +100,8 @@ bool AudioFormatReader::read (int* const* destSamples, return true; } -static void readChannels (AudioFormatReader& reader, - int** const chans, AudioSampleBuffer* const buffer, - const int startSample, const int numSamples, - const int64 readerStartSample, const int numTargetChannels) +static void readChannels (AudioFormatReader& reader, int** chans, AudioBuffer* buffer, + int startSample, int numSamples, int64 readerStartSample, int numTargetChannels) { for (int j = 0; j < numTargetChannels; ++j) chans[j] = reinterpret_cast (buffer->getWritePointer (j, startSample)); @@ -112,7 +110,7 @@ static void readChannels (AudioFormatReader& reader, reader.read (chans, numTargetChannels, readerStartSample, numSamples, true); } -void AudioFormatReader::read (AudioSampleBuffer* buffer, +void AudioFormatReader::read (AudioBuffer* buffer, int startSample, int numSamples, int64 readerStartSample, @@ -186,16 +184,17 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples return; } - const int bufferSize = (int) jmin (numSamples, (int64) 4096); - AudioSampleBuffer tempSampleBuffer ((int) channelsToRead, bufferSize); + auto bufferSize = (int) jmin (numSamples, (int64) 4096); + AudioBuffer tempSampleBuffer ((int) channelsToRead, bufferSize); - float* const* const floatBuffer = tempSampleBuffer.getArrayOfWritePointers(); - int* const* intBuffer = reinterpret_cast (floatBuffer); + auto floatBuffer = tempSampleBuffer.getArrayOfWritePointers(); + auto intBuffer = reinterpret_cast (floatBuffer); bool isFirstBlock = true; while (numSamples > 0) { - const int numToDo = (int) jmin (numSamples, (int64) bufferSize); + auto numToDo = (int) jmin (numSamples, (int64) bufferSize); + if (! read (intBuffer, channelsToRead, startSampleInFile, numToDo, false)) break; @@ -209,7 +208,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples } else { - Range intRange (Range::findMinAndMax (intBuffer[i], numToDo)); + auto intRange = Range::findMinAndMax (intBuffer[i], numToDo); r = Range (intRange.getStart() / (float) std::numeric_limits::max(), intRange.getEnd() / (float) std::numeric_limits::max()); @@ -248,9 +247,9 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples int64 AudioFormatReader::searchForLevel (int64 startSample, int64 numSamplesToSearch, - const double magnitudeRangeMinimum, - const double magnitudeRangeMaximum, - const int minimumConsecutiveSamples) + double magnitudeRangeMinimum, + double magnitudeRangeMaximum, + int minimumConsecutiveSamples) { if (numSamplesToSearch == 0) return -1; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/modules/juce_audio_formats/format/juce_AudioFormatReader.h index 7ed40c5c8e..0351b06eac 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -111,14 +111,14 @@ public: int numSamplesToRead, bool fillLeftoverChannelsWithCopies); - /** Fills a section of an AudioSampleBuffer from this reader. + /** Fills a section of an AudioBuffer from this reader. This will convert the reader's fixed- or floating-point data to the buffer's floating-point format, and will try to intelligently cope with mismatches between the number of channels in the reader and the buffer. */ - void read (AudioSampleBuffer* buffer, + void read (AudioBuffer* buffer, int startSampleInDestBuffer, int numSamples, int64 readerStartSample, diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index c7ba031033..16ef5a4d7c 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -84,9 +84,9 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, int64 numSamplesToRead) { const int bufferSize = 16384; - AudioSampleBuffer tempBuffer ((int) numChannels, bufferSize); + AudioBuffer tempBuffer ((int) numChannels, bufferSize); - int* buffers [128] = { 0 }; + int* buffers[128] = { 0 }; for (int i = tempBuffer.getNumChannels(); --i >= 0;) buffers[i] = reinterpret_cast (tempBuffer.getWritePointer (i, 0)); @@ -128,11 +128,11 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, int numSamplesToRead, const int samplesPerBlock) { - AudioSampleBuffer tempBuffer (getNumChannels(), samplesPerBlock); + AudioBuffer tempBuffer (getNumChannels(), samplesPerBlock); while (numSamplesToRead > 0) { - const int numToDo = jmin (numSamplesToRead, samplesPerBlock); + auto numToDo = jmin (numSamplesToRead, samplesPerBlock); AudioSourceChannelInfo info (&tempBuffer, 0, numToDo); info.clearActiveBufferRegion(); @@ -156,8 +156,8 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int if (isFloatingPoint()) return write ((const int**) channels, numSamples); - int* chans [256]; - int scratch [4096]; + int* chans[256]; + int scratch[4096]; jassert (numSourceChannels < numElementsInArray (chans)); const int maxSamples = (int) (numElementsInArray (scratch) / numSourceChannels); @@ -185,15 +185,15 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int return true; } -bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioSampleBuffer& source, int startSample, int numSamples) +bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioBuffer& source, int startSample, int numSamples) { - const int numSourceChannels = source.getNumChannels(); + auto numSourceChannels = source.getNumChannels(); jassert (startSample >= 0 && startSample + numSamples <= source.getNumSamples() && numSourceChannels > 0); if (startSample == 0) return writeFromFloatArrays (source.getArrayOfReadPointers(), numSourceChannels, numSamples); - const float* chans [256]; + const float* chans[256]; jassert ((int) numChannels < numElementsInArray (chans)); for (int i = 0; i < numSourceChannels; ++i) @@ -326,7 +326,7 @@ public: private: AbstractFifo fifo; - AudioSampleBuffer buffer; + AudioBuffer buffer; TimeSliceThread& timeSliceThread; ScopedPointer writer; CriticalSection thumbnailLock; diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h index c817e0bc06..434484bd1d 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.h @@ -96,7 +96,7 @@ public: //============================================================================== /** Writes a set of samples to the audio stream. - Note that if you're trying to write the contents of an AudioSampleBuffer, you + Note that if you're trying to write the contents of an AudioBuffer, you can use writeFromAudioSampleBuffer(). @param samplesToWrite an array of arrays containing the sample data for @@ -154,8 +154,8 @@ public: int samplesPerBlock = 2048); - /** Writes some samples from an AudioSampleBuffer. */ - bool writeFromAudioSampleBuffer (const AudioSampleBuffer& source, + /** Writes some samples from an AudioBuffer. */ + bool writeFromAudioSampleBuffer (const AudioBuffer& source, int startSample, int numSamples); /** Writes some samples from a set of float data channels. */ @@ -217,7 +217,7 @@ public: virtual ~IncomingDataReceiver() {} virtual void reset (int numChannels, double sampleRate, int64 totalSamplesInSource) = 0; - virtual void addBlock (int64 sampleNumberInSource, const AudioSampleBuffer& newData, + virtual void addBlock (int64 sampleNumberInSource, const AudioBuffer& newData, int startOffsetInBuffer, int numSamples) = 0; }; diff --git a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h index c8a4e1d8e5..b16c3a757d 100644 --- a/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_BufferingAudioFormatReader.h @@ -78,7 +78,7 @@ private: BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples); Range range; - AudioSampleBuffer buffer; + AudioBuffer buffer; }; CriticalSection lock; diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.cpp b/modules/juce_audio_formats/sampler/juce_Sampler.cpp index bce2241bf6..bef61c0e60 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.cpp +++ b/modules/juce_audio_formats/sampler/juce_Sampler.cpp @@ -44,7 +44,7 @@ SamplerSound::SamplerSound (const String& soundName, length = jmin ((int) source.lengthInSamples, (int) (maxSampleLengthSeconds * sourceSampleRate)); - data = new AudioSampleBuffer (jmin (2, (int) source.numChannels), length + 4); + data = new AudioBuffer (jmin (2, (int) source.numChannels), length + 4); source.read (data, 0, length + 4, 0, true, true); @@ -129,7 +129,7 @@ void SamplerVoice::pitchWheelMoved (int /*newValue*/) {} void SamplerVoice::controllerMoved (int /*controllerNumber*/, int /*newValue*/) {} //============================================================================== -void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) +void SamplerVoice::renderNextBlock (AudioBuffer& outputBuffer, int startSample, int numSamples) { if (auto* playingSound = static_cast (getCurrentlyPlayingSound().get())) { diff --git a/modules/juce_audio_formats/sampler/juce_Sampler.h b/modules/juce_audio_formats/sampler/juce_Sampler.h index 3857a1ec43..c6f10ab928 100644 --- a/modules/juce_audio_formats/sampler/juce_Sampler.h +++ b/modules/juce_audio_formats/sampler/juce_Sampler.h @@ -79,7 +79,7 @@ public: /** Returns the audio sample data. This could return nullptr if there was a problem loading the data. */ - AudioSampleBuffer* getAudioData() const noexcept { return data; } + AudioBuffer* getAudioData() const noexcept { return data; } //============================================================================== @@ -92,7 +92,7 @@ private: friend class SamplerVoice; String name; - ScopedPointer data; + ScopedPointer> data; double sourceSampleRate; BigInteger midiNotes; int length = 0, attackSamples = 0, releaseSamples = 0; @@ -130,7 +130,7 @@ public: void pitchWheelMoved (int newValue) override; void controllerMoved (int controllerNumber, int newValue) override; - void renderNextBlock (AudioSampleBuffer&, int startSample, int numSamples) override; + void renderNextBlock (AudioBuffer&, int startSample, int numSamples) override; private: diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index d0dbb6c241..390ee661b1 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -1237,7 +1237,7 @@ namespace AAXClasses void process (float* const* channels, const int numChans, const int bufferSize, const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut) { - AudioSampleBuffer buffer (channels, numChans, bufferSize); + AudioBuffer buffer (channels, numChans, bufferSize); midiBuffer.clear(); diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 69d7e4b305..223aec685e 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -1690,7 +1690,7 @@ private: } } - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) noexcept + void processBlock (AudioBuffer& buffer, MidiBuffer& midiBuffer) noexcept { const ScopedLock sl (juceFilter->getCallbackLock()); diff --git a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm index 0d4afcff48..f396ef0f13 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm @@ -1056,7 +1056,7 @@ private: AudioBufferList* bufferList = nullptr; int maxFrames, numberOfChannels; bool isInterleaved; - AudioSampleBuffer scratchBuffer; + AudioBuffer scratchBuffer; }; //============================================================================== @@ -1357,7 +1357,7 @@ private: return noErr; } - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) noexcept + void processBlock (AudioBuffer& buffer, MidiBuffer& midiBuffer) noexcept { auto& processor = getAudioProcessor(); const ScopedLock sl (processor.getCallbackLock()); diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index 715b03e482..373a3e833c 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -599,7 +599,7 @@ public: channels [i] = inputs [i]; } - AudioSampleBuffer chans (channels, totalChans, numSamples); + AudioBuffer chans (channels, totalChans, numSamples); if (mBypassed) juceFilter->processBlockBypassed (chans, midiEvents); diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 8af8f849a8..0d32c829c2 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -384,7 +384,7 @@ public: // avoid feedback loop by default bool processorHasPotentialFeedbackLoop = true; Value shouldMuteInput; - AudioSampleBuffer emptyBuffer; + AudioBuffer emptyBuffer; bool autoOpenMidiDevices; ScopedPointer options; diff --git a/modules/juce_audio_processors/format_types/juce_AU_Shared.h b/modules/juce_audio_processors/format_types/juce_AU_Shared.h index 434326ff28..22b2ad938d 100644 --- a/modules/juce_audio_processors/format_types/juce_AU_Shared.h +++ b/modules/juce_audio_processors/format_types/juce_AU_Shared.h @@ -213,7 +213,7 @@ struct AudioUnitHelpers } //============================================================================== - AudioSampleBuffer& getBuffer (UInt32 frames) noexcept + AudioBuffer& getBuffer (UInt32 frames) noexcept { jassert (pushIdx == scratch.getNumChannels()); @@ -240,9 +240,7 @@ struct AudioUnitHelpers } //============================================================================== - AudioSampleBuffer scratch; - AudioSampleBuffer mutableBuffer; - + AudioBuffer scratch, mutableBuffer; HeapBlock channels; int pushIdx, popIdx; }; diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index ed3322e064..99b91c0ecc 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -787,9 +787,9 @@ public: for (int i = 0; i < getBusCount (false); ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, static_cast (i)); } - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) override + void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) override { - const int numSamples = buffer.getNumSamples(); + auto numSamples = buffer.getNumSamples(); if (prepared) { @@ -816,6 +816,7 @@ public: { int chIdx = 0; numOutputBuses = getBusCount (false); + for (int i = 0; i < numOutputBuses; ++i) { if (AUBuffer* buf = outputBufferList[i]) @@ -1298,7 +1299,7 @@ private: OwnedArray outputBufferList; AudioTimeStamp timeStamp; - AudioSampleBuffer* currentBuffer; + AudioBuffer* currentBuffer; Array> supportedInLayouts, supportedOutLayouts; int numChannelInfos; @@ -1464,10 +1465,9 @@ private: { // if this ever happens, might need to add extra handling jassert (inNumberFrames == (UInt32) currentBuffer->getNumSamples()); - AudioSampleBuffer buffer = - (static_cast (inBusNumber) < getBusCount (true) - ? getBusBuffer (*currentBuffer, true, static_cast (inBusNumber)) - : AudioSampleBuffer()); + auto buffer = static_cast (inBusNumber) < getBusCount (true) + ? getBusBuffer (*currentBuffer, true, static_cast (inBusNumber)) + : AudioBuffer(); for (int i = 0; i < static_cast (ioData->mNumberBuffers); ++i) { diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index ce71f45f8b..46e2ad115f 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -286,9 +286,9 @@ public: tempBuffer.setSize (1, 1); } - void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) + void processBlock (AudioBuffer& buffer, MidiBuffer& midiMessages) { - const int numSamples = buffer.getNumSamples(); + auto numSamples = buffer.getNumSamples(); if (initialised && plugin != nullptr && handle != nullptr) { @@ -484,7 +484,7 @@ private: String name; CriticalSection lock; bool initialised; - AudioSampleBuffer tempBuffer; + AudioBuffer tempBuffer; Array inputs, outputs, parameters; struct ParameterValue diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index 7ac3608aef..2b5dbc6a2a 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -537,10 +537,8 @@ struct VST3BufferExchange static inline void assignRawPointer (Steinberg::Vst::AudioBusBuffers& vstBuffers, float** raw) { vstBuffers.channelBuffers32 = raw; } static inline void assignRawPointer (Steinberg::Vst::AudioBusBuffers& vstBuffers, double** raw) { vstBuffers.channelBuffers64 = raw; } - /** Assigns a series of AudioSampleBuffer's channels to an AudioBusBuffers' - - @warning For speed, does not check the channel count and offsets - according to the AudioSampleBuffer + /** Assigns a series of AudioBuffer's channels to an AudioBusBuffers' + @warning For speed, does not check the channel count and offsets according to the AudioBuffer */ static void associateBufferTo (Steinberg::Vst::AudioBusBuffers& vstBuffers, Bus& bus, diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 29f7d1a55d..28c0915f4d 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -169,8 +169,8 @@ static void setStateForAllBusesOfType (Vst::IComponent* component, } //============================================================================== -/** Assigns a complete AudioSampleBuffer's channels to an AudioBusBuffers' */ -static void associateWholeBufferTo (Vst::AudioBusBuffers& vstBuffers, AudioSampleBuffer& buffer) noexcept +/** Assigns a complete AudioBuffer's channels to an AudioBusBuffers' */ +static void associateWholeBufferTo (Vst::AudioBusBuffers& vstBuffers, AudioBuffer& buffer) noexcept { vstBuffers.channelBuffers32 = buffer.getArrayOfWritePointers(); vstBuffers.numChannels = buffer.getNumChannels(); diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index 313c006da9..d28e290284 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -441,7 +441,7 @@ public: //============================================================================== /** Returns the position of a bus's channels within the processBlock buffer. - This can be called in processBlock to figure out which channel of the master AudioSampleBuffer + This can be called in processBlock to figure out which channel of the master AudioBuffer maps onto a specific bus's channel. */ int getChannelIndexInProcessBlockBuffer (int channelIndex) const noexcept; @@ -449,7 +449,7 @@ public: /** Returns an AudioBuffer containing a set of channel pointers for a specific bus. This can be called in processBlock to get a buffer containing a sub-group of the master - AudioSampleBuffer which contains all the plugin channels. + AudioBuffer which contains all the plugin channels. */ template AudioBuffer getBusBuffer (AudioBuffer& processBlockBuffer) const @@ -605,7 +605,7 @@ public: //============================================================================== /** Returns the position of a bus's channels within the processBlock buffer. - This can be called in processBlock to figure out which channel of the master AudioSampleBuffer + This can be called in processBlock to figure out which channel of the master AudioBuffer maps onto a specific bus's channel. */ int getChannelIndexInProcessBlockBuffer (bool isInput, int busIndex, int channelIndex) const noexcept; @@ -620,7 +620,7 @@ public: /** Returns an AudioBuffer containing a set of channel pointers for a specific bus. This can be called in processBlock to get a buffer containing a sub-group of the master - AudioSampleBuffer which contains all the plugin channels. + AudioBuffer which contains all the plugin channels. */ template AudioBuffer getBusBuffer (AudioBuffer& processBlockBuffer, bool isInput, int busIndex) const diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp index e90fe954e2..6aa1db2d24 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp @@ -693,7 +693,7 @@ int64 AudioThumbnail::getHashCode() const return source == nullptr ? 0 : source->hashCode; } -void AudioThumbnail::addBlock (const int64 startSample, const AudioSampleBuffer& incoming, +void AudioThumbnail::addBlock (int64 startSample, const AudioBuffer& incoming, int startOffsetInBuffer, int numSamples) { jassert (startSample >= 0 diff --git a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h index 3121ab2c63..ae40ef7f06 100644 --- a/modules/juce_audio_utils/gui/juce_AudioThumbnail.h +++ b/modules/juce_audio_utils/gui/juce_AudioThumbnail.h @@ -107,7 +107,7 @@ public: /** Adds a block of level data to the thumbnail. Call reset() before using this, to tell the thumbnail about the data format. */ - void addBlock (int64 sampleNumberInSource, const AudioSampleBuffer& newData, + void addBlock (int64 sampleNumberInSource, const AudioBuffer& newData, int startOffsetInBuffer, int numSamples) override; //============================================================================== diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp index f5beb5a85d..21b0fad66a 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.cpp @@ -129,7 +129,7 @@ void AudioVisualiserComponent::pushBuffer (const float** d, int numChannels, int channels.getUnchecked(i)->pushSamples (d[i], num); } -void AudioVisualiserComponent::pushBuffer (const AudioSampleBuffer& buffer) +void AudioVisualiserComponent::pushBuffer (const AudioBuffer& buffer) { pushBuffer (buffer.getArrayOfReadPointers(), buffer.getNumChannels(), diff --git a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h index 8abd76704a..ee3c5a9f52 100644 --- a/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h +++ b/modules/juce_audio_utils/gui/juce_AudioVisualiserComponent.h @@ -74,7 +74,7 @@ public: The number of channels provided here is expected to match the number of channels that this AudioVisualiserComponent has been told to use. */ - void pushBuffer (const AudioSampleBuffer& bufferToPush); + void pushBuffer (const AudioBuffer& bufferToPush); /** Pushes a buffer of channels data. The number of channels provided here is expected to match the number of channels diff --git a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm index bad7206d6c..3025eaa4cb 100644 --- a/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm +++ b/modules/juce_audio_utils/native/juce_mac_AudioCDBurner.mm @@ -129,7 +129,7 @@ private: if (numSamples > 0) { - AudioSampleBuffer tempBuffer (2, numSamples); + AudioBuffer tempBuffer (2, numSamples); AudioSourceChannelInfo info (tempBuffer); source->source->getNextAudioBlock (info); diff --git a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp index 89e6ec4e5a..d9009086bf 100644 --- a/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp +++ b/modules/juce_audio_utils/native/juce_win32_AudioCDBurner.cpp @@ -373,7 +373,7 @@ bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples) hr = pimpl->redbook->CreateAudioTrack ((long) numSamples / (bytesPerBlock * 4)); HeapBlock buffer (bytesPerBlock); - AudioSampleBuffer sourceBuffer (2, samplesPerBlock); + AudioBuffer sourceBuffer (2, samplesPerBlock); int samplesDone = 0; source->prepareToPlay (samplesPerBlock, 44100.0); diff --git a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp index 66112eb604..8112b1c76d 100644 --- a/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_AudioProcessorPlayer.cpp @@ -141,7 +141,7 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChann } } - AudioSampleBuffer buffer (channels, totalNumChans, numSamples); + AudioBuffer buffer (channels, totalNumChans, numSamples); { const ScopedLock sl (lock); diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp index 29a270d637..bf7090bda2 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.cpp +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.cpp @@ -85,12 +85,11 @@ private: }; // An AudioSource which simply outputs a buffer -class AudioSampleBufferSource : public PositionableAudioSource +class AudioBufferSource : public PositionableAudioSource { public: - AudioSampleBufferSource (AudioSampleBuffer* audioBuffer, bool ownBuffer, bool playOnAllChannels) + AudioBufferSource (AudioBuffer* audioBuffer, bool ownBuffer, bool playOnAllChannels) : buffer (audioBuffer, ownBuffer), - position (0), looping (false), playAcrossAllChannels (playOnAllChannels) {} @@ -144,11 +143,11 @@ public: private: //============================================================================== - OptionalScopedPointer buffer; - int position; - bool looping, playAcrossAllChannels; + OptionalScopedPointer> buffer; + int position = 0; + bool looping = false, playAcrossAllChannels; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSampleBufferSource) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioBufferSource) }; SoundPlayer::SoundPlayer() @@ -185,10 +184,10 @@ void SoundPlayer::play (AudioFormatReader* reader, bool deleteWhenFinished) play (new AudioFormatReaderSource (reader, deleteWhenFinished), true, reader->sampleRate); } -void SoundPlayer::play (AudioSampleBuffer* buffer, bool deleteWhenFinished, bool playOnAllOutputChannels) +void SoundPlayer::play (AudioBuffer* buffer, bool deleteWhenFinished, bool playOnAllOutputChannels) { if (buffer != nullptr) - play (new AudioSampleBufferSource (buffer, deleteWhenFinished, playOnAllOutputChannels), true); + play (new AudioBufferSource (buffer, deleteWhenFinished, playOnAllOutputChannels), true); } void SoundPlayer::play (PositionableAudioSource* audioSource, bool deleteWhenFinished, double fileSampleRate) @@ -232,7 +231,7 @@ void SoundPlayer::playTestSound() const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); - AudioSampleBuffer* newSound = new AudioSampleBuffer (1, soundLength); + auto* newSound = new AudioBuffer (1, soundLength); for (int i = 0; i < soundLength; ++i) newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); diff --git a/modules/juce_audio_utils/players/juce_SoundPlayer.h b/modules/juce_audio_utils/players/juce_SoundPlayer.h index 535c936ae4..8c9ca6db1c 100644 --- a/modules/juce_audio_utils/players/juce_SoundPlayer.h +++ b/modules/juce_audio_utils/players/juce_SoundPlayer.h @@ -96,7 +96,7 @@ public: multiple outputs so that something is sent to all output channels. If it is false, then the buffer will just be played on the first output channels. */ - void play (AudioSampleBuffer* buffer, + void play (AudioBuffer* buffer, bool deleteWhenFinished = false, bool playOnAllOutputChannels = false); diff --git a/modules/juce_dsp/containers/juce_AudioBlock.h b/modules/juce_dsp/containers/juce_AudioBlock.h index 54cd7c0ff6..c25647edfe 100644 --- a/modules/juce_dsp/containers/juce_AudioBlock.h +++ b/modules/juce_dsp/containers/juce_AudioBlock.h @@ -47,7 +47,7 @@ namespace SampleTypeHelpers // Internal classes needed for handling sample type This class doesn't own any of the data which it points to, it's simply a view into data that is owned elsewhere. You can construct one from some raw data that you've allocated yourself, or give it a HeapBlock to use, or give it - an AudioSampleBuffer which it can refer to, but in all cases the user is + an AudioBuffer which it can refer to, but in all cases the user is responsible for making sure that the data doesn't get deleted while there's still an AudioBlock using it. */