| @@ -64,7 +64,7 @@ public: | |||||
| void audioDeviceIOCallback (const float **/*inputChannelData*/, int /*numInputChannels*/, | void audioDeviceIOCallback (const float **/*inputChannelData*/, int /*numInputChannels*/, | ||||
| float **outputChannelData, int numOutputChannels, int numSamples) override | float **outputChannelData, int numOutputChannels, int numSamples) override | ||||
| { | { | ||||
| AudioSampleBuffer sampleBuffer = AudioSampleBuffer (outputChannelData, numOutputChannels, numSamples); | |||||
| AudioBuffer<float> sampleBuffer (outputChannelData, numOutputChannels, numSamples); | |||||
| sampleBuffer.clear(); | sampleBuffer.clear(); | ||||
| synthesiser.renderNextBlock (sampleBuffer, MidiBuffer(), 0, numSamples); | synthesiser.renderNextBlock (sampleBuffer, MidiBuffer(), 0, numSamples); | ||||
| @@ -75,7 +75,7 @@ public: | |||||
| amplitude.setValue (newChannelPressureValue / 127.0); | amplitude.setValue (newChannelPressureValue / 127.0); | ||||
| } | } | ||||
| void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override | |||||
| void renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override | |||||
| { | { | ||||
| while (--numSamples >= 0) | while (--numSamples >= 0) | ||||
| { | { | ||||
| @@ -164,7 +164,7 @@ void DspModulePluginDemoAudioProcessor::process (dsp::ProcessContextReplacing<fl | |||||
| outputVolume.process (context); | outputVolume.process (context); | ||||
| } | } | ||||
| void DspModulePluginDemoAudioProcessor::processBlock (AudioSampleBuffer& inoutBuffer, MidiBuffer&) | |||||
| void DspModulePluginDemoAudioProcessor::processBlock (AudioBuffer<float>& inoutBuffer, MidiBuffer&) | |||||
| { | { | ||||
| auto totalNumInputChannels = getTotalNumInputChannels(); | auto totalNumInputChannels = getTotalNumInputChannels(); | ||||
| auto totalNumOutputChannels = getTotalNumOutputChannels(); | auto totalNumOutputChannels = getTotalNumOutputChannels(); | ||||
| @@ -46,7 +46,7 @@ public: | |||||
| #endif | #endif | ||||
| void prepareToPlay (double sampleRate, int samplesPerBlock) override; | void prepareToPlay (double sampleRate, int samplesPerBlock) override; | ||||
| void releaseResources() override; | void releaseResources() override; | ||||
| void processBlock (AudioSampleBuffer&, MidiBuffer&) override; | |||||
| void processBlock (AudioBuffer<float>&, MidiBuffer&) override; | |||||
| void reset() override; | void reset() override; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -172,7 +172,7 @@ public: | |||||
| } | } | ||||
| private: | private: | ||||
| AudioSampleBuffer testSound, recordedSound; | |||||
| AudioBuffer<float> testSound, recordedSound; | |||||
| Array<int> spikePositions; | Array<int> spikePositions; | ||||
| int playingSampleNum, recordedSampleNum; | int playingSampleNum, recordedSampleNum; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| @@ -211,7 +211,7 @@ private: | |||||
| } | } | ||||
| // Searches a buffer for a set of spikes that matches those in the test sound | // 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<float>& buffer) const | |||||
| { | { | ||||
| const float minSpikeLevel = 5.0f; | const float minSpikeLevel = 5.0f; | ||||
| const double smooth = 0.975; | const double smooth = 0.975; | ||||
| @@ -124,8 +124,8 @@ public: | |||||
| { | { | ||||
| activeWriter->write (inputChannelData, numSamples); | 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<float**> (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<float> buffer (const_cast<float**> (inputChannelData), thumbnail.getNumChannels(), numSamples); | |||||
| thumbnail.addBlock (nextSampleNum, buffer, 0, numSamples); | thumbnail.addBlock (nextSampleNum, buffer, 0, numSamples); | ||||
| nextSampleNum += numSamples; | nextSampleNum += numSamples; | ||||
| } | } | ||||
| @@ -42,9 +42,7 @@ struct SineWaveSound : public SynthesiserSound | |||||
| /** Our demo synth voice just plays a sine wave.. */ | /** Our demo synth voice just plays a sine wave.. */ | ||||
| struct SineWaveVoice : public SynthesiserVoice | struct SineWaveVoice : public SynthesiserVoice | ||||
| { | { | ||||
| SineWaveVoice() : currentAngle (0), angleDelta (0), level (0), tailOff (0) | |||||
| { | |||||
| } | |||||
| SineWaveVoice() {} | |||||
| bool canPlaySound (SynthesiserSound* sound) override | bool canPlaySound (SynthesiserSound* sound) override | ||||
| { | { | ||||
| @@ -94,7 +92,7 @@ struct SineWaveVoice : public SynthesiserVoice | |||||
| // not interested in controllers in this case. | // not interested in controllers in this case. | ||||
| } | } | ||||
| void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override | |||||
| void renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override | |||||
| { | { | ||||
| if (angleDelta != 0.0) | if (angleDelta != 0.0) | ||||
| { | { | ||||
| @@ -102,7 +100,7 @@ struct SineWaveVoice : public SynthesiserVoice | |||||
| { | { | ||||
| while (--numSamples >= 0) | 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;) | for (int i = outputBuffer.getNumChannels(); --i >= 0;) | ||||
| outputBuffer.addSample (i, startSample, currentSample); | outputBuffer.addSample (i, startSample, currentSample); | ||||
| @@ -125,7 +123,7 @@ struct SineWaveVoice : public SynthesiserVoice | |||||
| { | { | ||||
| while (--numSamples >= 0) | 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;) | for (int i = outputBuffer.getNumChannels(); --i >= 0;) | ||||
| outputBuffer.addSample (i, startSample, currentSample); | outputBuffer.addSample (i, startSample, currentSample); | ||||
| @@ -138,7 +136,7 @@ struct SineWaveVoice : public SynthesiserVoice | |||||
| } | } | ||||
| private: | private: | ||||
| double currentAngle, angleDelta, level, tailOff; | |||||
| double currentAngle = 0, angleDelta = 0, level = 0, tailOff = 0; | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -57,16 +57,16 @@ public: | |||||
| void releaseResources() override {} | void releaseResources() override {} | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midi) override | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override | |||||
| { | { | ||||
| // the audio buffer in a midi effect will have zero channels! | // the audio buffer in a midi effect will have zero channels! | ||||
| jassert (buffer.getNumChannels() == 0); | jassert (buffer.getNumChannels() == 0); | ||||
| // however we use the buffer to get timing information | // however we use the buffer to get timing information | ||||
| const int numSamples = buffer.getNumSamples(); | |||||
| auto numSamples = buffer.getNumSamples(); | |||||
| // get note duration | // get note duration | ||||
| const int noteDuration = static_cast<int> (std::ceil (rate * 0.25f * (0.1f + (1.0f - (*speed))))); | |||||
| auto noteDuration = static_cast<int> (std::ceil (rate * 0.25f * (0.1f + (1.0f - (*speed))))); | |||||
| MidiMessage msg; | MidiMessage msg; | ||||
| int ignore; | int ignore; | ||||
| @@ -81,7 +81,7 @@ public: | |||||
| if ((time + numSamples) >= noteDuration) | 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) | if (lastNoteValue > 0) | ||||
| { | { | ||||
| @@ -105,8 +105,8 @@ public: | |||||
| bool isMidiEffect() const override { return true; } | 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"; } | const String getName() const override { return "Arpeggiator"; } | ||||
| @@ -133,9 +133,6 @@ public: | |||||
| speed->setValueNotifyingHost (MemoryInputStream (data, static_cast<size_t> (sizeInBytes), false).readFloat()); | speed->setValueNotifyingHost (MemoryInputStream (data, static_cast<size_t> (sizeInBytes), false).readFloat()); | ||||
| } | } | ||||
| //============================================================================== | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| AudioParameterFloat* speed; | AudioParameterFloat* speed; | ||||
| @@ -48,7 +48,7 @@ public: | |||||
| void prepareToPlay (double, int) override {} | void prepareToPlay (double, int) override {} | ||||
| void releaseResources() override {} | void releaseResources() override {} | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer&) override | |||||
| { | { | ||||
| buffer.applyGain (*gain); | buffer.applyGain (*gain); | ||||
| } | } | ||||
| @@ -114,14 +114,14 @@ bool IAAEffectProcessor::isBusesLayoutSupported (const BusesLayout& layouts) con | |||||
| return true; | return true; | ||||
| } | } | ||||
| void IAAEffectProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&) | |||||
| void IAAEffectProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer&) | |||||
| { | { | ||||
| const float gain = *parameters.getRawParameterValue ("gain"); | 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) | for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) | ||||
| buffer.clear (i, 0, buffer.getNumSamples()); | buffer.clear (i, 0, buffer.getNumSamples()); | ||||
| @@ -164,6 +164,7 @@ void IAAEffectProcessor::getStateInformation (MemoryBlock& destData) | |||||
| void IAAEffectProcessor::setStateInformation (const void* data, int sizeInBytes) | void IAAEffectProcessor::setStateInformation (const void* data, int sizeInBytes) | ||||
| { | { | ||||
| auto xmlState = std::unique_ptr<XmlElement> (getXmlFromBinary (data, sizeInBytes)); | auto xmlState = std::unique_ptr<XmlElement> (getXmlFromBinary (data, sizeInBytes)); | ||||
| if (xmlState.get() != nullptr) | if (xmlState.get() != nullptr) | ||||
| if (xmlState->hasTagName (parameters.state.getType())) | if (xmlState->hasTagName (parameters.state.getType())) | ||||
| parameters.state = ValueTree::fromXml (*xmlState); | parameters.state = ValueTree::fromXml (*xmlState); | ||||
| @@ -44,7 +44,7 @@ public: | |||||
| bool isBusesLayoutSupported (const BusesLayout& layouts) const override; | bool isBusesLayoutSupported (const BusesLayout& layouts) const override; | ||||
| void processBlock (AudioSampleBuffer&, MidiBuffer&) override; | |||||
| void processBlock (AudioBuffer<float>&, MidiBuffer&) override; | |||||
| //============================================================================== | //============================================================================== | ||||
| AudioProcessorEditor* createEditor() override; | AudioProcessorEditor* createEditor() override; | ||||
| @@ -90,13 +90,14 @@ public: | |||||
| void releaseResources() override {} | void releaseResources() override {} | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) override | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) override | |||||
| { | { | ||||
| const int busCount = getBusCount (false); | |||||
| auto busCount = getBusCount (false); | |||||
| for (int busNr = 0; busNr < busCount; ++busNr) | for (int busNr = 0; busNr < busCount; ++busNr) | ||||
| { | { | ||||
| MidiBuffer midiChannelBuffer = filterMidiMessagesForChannel (midiBuffer, busNr + 1); | 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()); | synth [busNr]->renderNextBlock (audioBusBuffer, midiChannelBuffer, 0, audioBusBuffer.getNumSamples()); | ||||
| } | } | ||||
| @@ -33,9 +33,9 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| //============================================================================== | //============================================================================== | ||||
| NoiseGate() | 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 (threshold = new AudioParameterFloat ("threshold", "Threshold", 0.0f, 1.0f, 0.5f)); | ||||
| addParameter (alpha = new AudioParameterFloat ("alpha", "Alpha", 0.0f, 1.0f, 0.8f)); | addParameter (alpha = new AudioParameterFloat ("alpha", "Alpha", 0.0f, 1.0f, 0.8f)); | ||||
| @@ -47,18 +47,18 @@ public: | |||||
| bool isBusesLayoutSupported (const BusesLayout& layouts) const override | 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 | // 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 prepareToPlay (double /*sampleRate*/, int /*maxBlockSize*/) override { lowPassCoeff = 0.0f; sampleCountDown = 0; } | ||||
| void releaseResources() override {} | void releaseResources() override {} | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override | |||||
| void processBlock (AudioBuffer<float>& 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 alphaCopy = *alpha; | ||||
| float thresholdCopy = *threshold; | float thresholdCopy = *threshold; | ||||
| @@ -66,6 +66,7 @@ public: | |||||
| for (int j = 0; j < buffer.getNumSamples(); ++j) | for (int j = 0; j < buffer.getNumSamples(); ++j) | ||||
| { | { | ||||
| float mixedSamples = 0.0f; | float mixedSamples = 0.0f; | ||||
| for (int i = 0; i < sideChainInput.getNumChannels(); ++i) | for (int i = 0; i < sideChainInput.getNumChannels(); ++i) | ||||
| mixedSamples += sideChainInput.getReadPointer (i) [j]; | mixedSamples += sideChainInput.getReadPointer (i) [j]; | ||||
| @@ -60,7 +60,7 @@ public: | |||||
| void releaseResources() override { reset(); } | void releaseResources() override { reset(); } | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer&) override | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer&) override | |||||
| { | { | ||||
| for (int ch = 0; ch < buffer.getNumChannels(); ++ch) | for (int ch = 0; ch < buffer.getNumChannels(); ++ch) | ||||
| { | { | ||||
| @@ -79,8 +79,8 @@ public: | |||||
| channelTime = jmax (0, channelTime - buffer.getNumSamples()); | channelTime = jmax (0, channelTime - buffer.getNumSamples()); | ||||
| } | } | ||||
| const int fillSamples = jmin (static_cast<int> (std::ceil (getSampleRate())) - sampleOffset, | |||||
| buffer.getNumSamples()); | |||||
| auto fillSamples = jmin (static_cast<int> (std::ceil (getSampleRate())) - sampleOffset, | |||||
| buffer.getNumSamples()); | |||||
| if (isPositiveAndBelow (channelClicked, buffer.getNumChannels())) | if (isPositiveAndBelow (channelClicked, buffer.getNumChannels())) | ||||
| { | { | ||||
| @@ -126,7 +126,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| void getStateInformation (MemoryBlock&) override {} | void getStateInformation (MemoryBlock&) override {} | ||||
| void setStateInformation (const void* , int) override {} | |||||
| void setStateInformation (const void*, int) override {} | |||||
| void channelButtonClicked (int channelIndex) override | void channelButtonClicked (int channelIndex) override | ||||
| { | { | ||||
| @@ -141,8 +141,8 @@ public: | |||||
| void handleAsyncUpdate() override | void handleAsyncUpdate() override | ||||
| { | { | ||||
| if (AudioProcessorEditor* editor = getActiveEditor()) | |||||
| if (SurroundEditor* surroundEditor = dynamic_cast<SurroundEditor*> (editor)) | |||||
| if (auto* editor = getActiveEditor()) | |||||
| if (auto* surroundEditor = dynamic_cast<SurroundEditor*> (editor)) | |||||
| surroundEditor->updateGUI(); | surroundEditor->updateGUI(); | ||||
| } | } | ||||
| @@ -151,6 +151,7 @@ private: | |||||
| Array<float> alphaCoeffs; | Array<float> alphaCoeffs; | ||||
| int channelClicked; | int channelClicked; | ||||
| int sampleOffset; | int sampleOffset; | ||||
| //============================================================================== | //============================================================================== | ||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SurroundProcessor) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SurroundProcessor) | ||||
| }; | }; | ||||
| @@ -94,7 +94,7 @@ public: | |||||
| // not implemented for the purposes of this demo! | // not implemented for the purposes of this demo! | ||||
| } | } | ||||
| void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override | |||||
| void renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override | |||||
| { | { | ||||
| if (angleDelta != 0.0) | if (angleDelta != 0.0) | ||||
| { | { | ||||
| @@ -5709,11 +5709,11 @@ static const unsigned char temp_binary_data_28[] = | |||||
| "}\r\n" | "}\r\n" | ||||
| "#endif\r\n" | "#endif\r\n" | ||||
| "\r\n" | "\r\n" | ||||
| "void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)\r\n" | |||||
| "void FILTERCLASSNAME::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)\r\n" | |||||
| "{\r\n" | "{\r\n" | ||||
| " ScopedNoDenormals noDenormals;\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" | "\r\n" | ||||
| " // In case we have more outputs than inputs, this code clears any output\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" | " // 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" | " bool isBusesLayoutSupported (const BusesLayout& layouts) const override;\r\n" | ||||
| " #endif\r\n" | " #endif\r\n" | ||||
| "\r\n" | "\r\n" | ||||
| " void processBlock (AudioSampleBuffer&, MidiBuffer&) override;\r\n" | |||||
| " void processBlock (AudioBuffer<float>&, MidiBuffer&) override;\r\n" | |||||
| "\r\n" | "\r\n" | ||||
| " //==============================================================================\r\n" | " //==============================================================================\r\n" | ||||
| " AudioProcessorEditor* createEditor() override;\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 0xafccbd3f: numBytes = 3141; return jucer_AudioComponentTemplate_cpp; | ||||
| case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; | case 0x27c5a93a: numBytes = 1310; return jucer_AudioPluginEditorTemplate_cpp; | ||||
| case 0x4d0721bf: numBytes = 938; return jucer_AudioPluginEditorTemplate_h; | 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 0xabad7041: numBytes = 2151; return jucer_ComponentTemplate_cpp; | ||||
| case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; | case 0xfc72fe86: numBytes = 2064; return jucer_ComponentTemplate_h; | ||||
| case 0x0b66646c: numBytes = 1029; return jucer_ContentCompTemplate_cpp; | case 0x0b66646c: numBytes = 1029; return jucer_ContentCompTemplate_cpp; | ||||
| @@ -93,10 +93,10 @@ namespace BinaryData | |||||
| const int jucer_AudioPluginEditorTemplate_hSize = 938; | const int jucer_AudioPluginEditorTemplate_hSize = 938; | ||||
| extern const char* jucer_AudioPluginFilterTemplate_cpp; | extern const char* jucer_AudioPluginFilterTemplate_cpp; | ||||
| const int jucer_AudioPluginFilterTemplate_cppSize = 5647; | |||||
| const int jucer_AudioPluginFilterTemplate_cppSize = 5638; | |||||
| extern const char* jucer_AudioPluginFilterTemplate_h; | extern const char* jucer_AudioPluginFilterTemplate_h; | ||||
| const int jucer_AudioPluginFilterTemplate_hSize = 2245; | |||||
| const int jucer_AudioPluginFilterTemplate_hSize = 2246; | |||||
| extern const char* jucer_ComponentTemplate_cpp; | extern const char* jucer_ComponentTemplate_cpp; | ||||
| const int jucer_ComponentTemplate_cppSize = 2151; | const int jucer_ComponentTemplate_cppSize = 2151; | ||||
| @@ -129,11 +129,11 @@ bool FILTERCLASSNAME::isBusesLayoutSupported (const BusesLayout& layouts) const | |||||
| } | } | ||||
| #endif | #endif | ||||
| void FILTERCLASSNAME::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) | |||||
| void FILTERCLASSNAME::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) | |||||
| { | { | ||||
| ScopedNoDenormals noDenormals; | 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 | // In case we have more outputs than inputs, this code clears any output | ||||
| // channels that didn't contain input data, (because these aren't | // channels that didn't contain input data, (because these aren't | ||||
| @@ -31,7 +31,7 @@ public: | |||||
| bool isBusesLayoutSupported (const BusesLayout& layouts) const override; | bool isBusesLayoutSupported (const BusesLayout& layouts) const override; | ||||
| #endif | #endif | ||||
| void processBlock (AudioSampleBuffer&, MidiBuffer&) override; | |||||
| void processBlock (AudioBuffer<float>&, MidiBuffer&) override; | |||||
| //============================================================================== | //============================================================================== | ||||
| AudioProcessorEditor* createEditor() override; | AudioProcessorEditor* createEditor() override; | ||||
| @@ -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 <typename Type> | template <typename Type> | ||||
| class AudioBuffer | class AudioBuffer | ||||
| @@ -27,7 +27,7 @@ namespace juce | |||||
| /** | /** | ||||
| Holds a sequence of time-stamped midi events. | 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. | 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 | If you're working with a sequence of midi events that may need to be manipulated | ||||
| @@ -35,7 +35,7 @@ struct JUCE_API AudioSourceChannelInfo | |||||
| } | } | ||||
| /** Creates an AudioSourceChannelInfo. */ | /** Creates an AudioSourceChannelInfo. */ | ||||
| AudioSourceChannelInfo (AudioSampleBuffer* bufferToUse, | |||||
| AudioSourceChannelInfo (AudioBuffer<float>* bufferToUse, | |||||
| int startSampleOffset, int numSamplesToUse) noexcept | int startSampleOffset, int numSamplesToUse) noexcept | ||||
| : buffer (bufferToUse), | : buffer (bufferToUse), | ||||
| startSample (startSampleOffset), | startSample (startSampleOffset), | ||||
| @@ -47,7 +47,7 @@ struct JUCE_API AudioSourceChannelInfo | |||||
| Note that the buffer provided must not be deleted while the | Note that the buffer provided must not be deleted while the | ||||
| AudioSourceChannelInfo is still using it. | AudioSourceChannelInfo is still using it. | ||||
| */ | */ | ||||
| explicit AudioSourceChannelInfo (AudioSampleBuffer& bufferToUse) noexcept | |||||
| explicit AudioSourceChannelInfo (AudioBuffer<float>& bufferToUse) noexcept | |||||
| : buffer (&bufferToUse), | : buffer (&bufferToUse), | ||||
| startSample (0), | startSample (0), | ||||
| numSamples (bufferToUse.getNumSamples()) | numSamples (bufferToUse.getNumSamples()) | ||||
| @@ -70,7 +70,7 @@ struct JUCE_API AudioSourceChannelInfo | |||||
| The number of channels in the buffer could be anything, so the AudioSource | 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. | must cope with this in whatever way is appropriate for its function. | ||||
| */ | */ | ||||
| AudioSampleBuffer* buffer; | |||||
| AudioBuffer<float>* buffer; | |||||
| /** The first sample in the buffer from which the callback is expected | /** The first sample in the buffer from which the callback is expected | ||||
| to write data. */ | to write data. */ | ||||
| @@ -100,7 +100,7 @@ private: | |||||
| OptionalScopedPointer<PositionableAudioSource> source; | OptionalScopedPointer<PositionableAudioSource> source; | ||||
| TimeSliceThread& backgroundThread; | TimeSliceThread& backgroundThread; | ||||
| int numberOfSamplesToBuffer, numberOfChannels; | int numberOfSamplesToBuffer, numberOfChannels; | ||||
| AudioSampleBuffer buffer; | |||||
| AudioBuffer<float> buffer; | |||||
| CriticalSection bufferStartPosLock; | CriticalSection bufferStartPosLock; | ||||
| WaitableEvent bufferReadyEvent; | WaitableEvent bufferReadyEvent; | ||||
| int64 volatile bufferValidStart, bufferValidEnd, nextPlayPos; | int64 volatile bufferValidStart, bufferValidEnd, nextPlayPos; | ||||
| @@ -129,7 +129,7 @@ private: | |||||
| Array<int> remappedInputs, remappedOutputs; | Array<int> remappedInputs, remappedOutputs; | ||||
| int requiredNumberOfChannels; | int requiredNumberOfChannels; | ||||
| AudioSampleBuffer buffer; | |||||
| AudioBuffer<float> buffer; | |||||
| AudioSourceChannelInfo remappedInfo; | AudioSourceChannelInfo remappedInfo; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| @@ -87,7 +87,7 @@ private: | |||||
| Array<AudioSource*> inputs; | Array<AudioSource*> inputs; | ||||
| BigInteger inputsToDelete; | BigInteger inputsToDelete; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| AudioSampleBuffer tempBuffer; | |||||
| AudioBuffer<float> tempBuffer; | |||||
| double currentSampleRate; | double currentSampleRate; | ||||
| int bufferSizeExpected; | int bufferSizeExpected; | ||||
| @@ -75,7 +75,7 @@ private: | |||||
| //============================================================================== | //============================================================================== | ||||
| OptionalScopedPointer<AudioSource> input; | OptionalScopedPointer<AudioSource> input; | ||||
| double ratio, lastRatio; | double ratio, lastRatio; | ||||
| AudioSampleBuffer buffer; | |||||
| AudioBuffer<float> buffer; | |||||
| int bufferPos, sampsInBuffer; | int bufferPos, sampsInBuffer; | ||||
| double subSampleOffset; | double subSampleOffset; | ||||
| double coefficients[6]; | double coefficients[6]; | ||||
| @@ -970,7 +970,7 @@ double AudioDeviceManager::LevelMeter::getCurrentLevel() const noexcept | |||||
| void AudioDeviceManager::playTestSound() | void AudioDeviceManager::playTestSound() | ||||
| { | { | ||||
| { // cunningly nested to swap, unlock and delete in that order. | { // cunningly nested to swap, unlock and delete in that order. | ||||
| ScopedPointer<AudioSampleBuffer> oldSound; | |||||
| ScopedPointer<AudioBuffer<float>> oldSound; | |||||
| { | { | ||||
| const ScopedLock sl (audioCallbackLock); | const ScopedLock sl (audioCallbackLock); | ||||
| @@ -990,7 +990,7 @@ void AudioDeviceManager::playTestSound() | |||||
| const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); | const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); | ||||
| AudioSampleBuffer* const newSound = new AudioSampleBuffer (1, soundLength); | |||||
| auto* newSound = new AudioBuffer<float> (1, soundLength); | |||||
| for (int i = 0; i < soundLength; ++i) | for (int i = 0; i < soundLength; ++i) | ||||
| newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); | newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); | ||||
| @@ -458,7 +458,7 @@ private: | |||||
| BigInteger inputChannels, outputChannels; | BigInteger inputChannels, outputChannels; | ||||
| ScopedPointer<XmlElement> lastExplicitSettings; | ScopedPointer<XmlElement> lastExplicitSettings; | ||||
| mutable bool listNeedsScanning; | mutable bool listNeedsScanning; | ||||
| AudioSampleBuffer tempBuffer; | |||||
| AudioBuffer<float> tempBuffer; | |||||
| struct MidiCallbackInfo | struct MidiCallbackInfo | ||||
| { | { | ||||
| @@ -474,7 +474,7 @@ private: | |||||
| ScopedPointer<MidiOutput> defaultMidiOutput; | ScopedPointer<MidiOutput> defaultMidiOutput; | ||||
| CriticalSection audioCallbackLock, midiCallbackLock; | CriticalSection audioCallbackLock, midiCallbackLock; | ||||
| ScopedPointer<AudioSampleBuffer> testSound; | |||||
| ScopedPointer<AudioBuffer<float>> testSound; | |||||
| int testSoundPosition; | int testSoundPosition; | ||||
| double cpuUsageMs, timeToCpuScale, msPerBlock; | double cpuUsageMs, timeToCpuScale, msPerBlock; | ||||
| @@ -423,7 +423,7 @@ private: | |||||
| String lastError; | String lastError; | ||||
| BigInteger activeOutputChans, activeInputChans; | BigInteger activeOutputChans, activeInputChans; | ||||
| GlobalRef outputDevice, inputDevice; | GlobalRef outputDevice, inputDevice; | ||||
| AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; | |||||
| AudioBuffer<float> inputChannelBuffer, outputChannelBuffer; | |||||
| jmethodID getUnderrunCount = 0; | jmethodID getUnderrunCount = 0; | ||||
| void closeDevices() | void closeDevices() | ||||
| @@ -166,9 +166,9 @@ struct BufferHelpers<int16> | |||||
| dataFormat.representation = 0; | dataFormat.representation = 0; | ||||
| } | } | ||||
| static void prepareCallbackBuffer (AudioSampleBuffer&, int16*) {} | |||||
| static void prepareCallbackBuffer (AudioBuffer<float>&, int16*) {} | |||||
| static void convertFromOpenSL (const int16* srcInterleaved, AudioSampleBuffer& audioBuffer) | |||||
| static void convertFromOpenSL (const int16* srcInterleaved, AudioBuffer<float>& audioBuffer) | |||||
| { | { | ||||
| for (int i = 0; i < audioBuffer.getNumChannels(); ++i) | for (int i = 0; i < audioBuffer.getNumChannels(); ++i) | ||||
| { | { | ||||
| @@ -181,7 +181,7 @@ struct BufferHelpers<int16> | |||||
| } | } | ||||
| } | } | ||||
| static void convertToOpenSL (const AudioSampleBuffer& audioBuffer, int16* dstInterleaved) | |||||
| static void convertToOpenSL (const AudioBuffer<float>& audioBuffer, int16* dstInterleaved) | |||||
| { | { | ||||
| for (int i = 0; i < audioBuffer.getNumChannels(); ++i) | for (int i = 0; i < audioBuffer.getNumChannels(); ++i) | ||||
| { | { | ||||
| @@ -215,13 +215,13 @@ struct BufferHelpers<float> | |||||
| dataFormat.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT; | dataFormat.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT; | ||||
| } | } | ||||
| static void prepareCallbackBuffer (AudioSampleBuffer& audioBuffer, float* native) | |||||
| static void prepareCallbackBuffer (AudioBuffer<float>& audioBuffer, float* native) | |||||
| { | { | ||||
| if (audioBuffer.getNumChannels() == 1) | if (audioBuffer.getNumChannels() == 1) | ||||
| audioBuffer.setDataToReferTo (&native, 1, audioBuffer.getNumSamples()); | audioBuffer.setDataToReferTo (&native, 1, audioBuffer.getNumSamples()); | ||||
| } | } | ||||
| static void convertFromOpenSL (const float* srcInterleaved, AudioSampleBuffer& audioBuffer) | |||||
| static void convertFromOpenSL (const float* srcInterleaved, AudioBuffer<float>& audioBuffer) | |||||
| { | { | ||||
| if (audioBuffer.getNumChannels() == 1) | if (audioBuffer.getNumChannels() == 1) | ||||
| { | { | ||||
| @@ -240,7 +240,7 @@ struct BufferHelpers<float> | |||||
| } | } | ||||
| } | } | ||||
| static void convertToOpenSL (const AudioSampleBuffer& audioBuffer, float* dstInterleaved) | |||||
| static void convertToOpenSL (const AudioBuffer<float>& audioBuffer, float* dstInterleaved) | |||||
| { | { | ||||
| if (audioBuffer.getNumChannels() == 1) | if (audioBuffer.getNumChannels() == 1) | ||||
| { | { | ||||
| @@ -374,7 +374,7 @@ public: | |||||
| int numChannels; | int numChannels; | ||||
| HeapBlock<T> nativeBuffer; | HeapBlock<T> nativeBuffer; | ||||
| AudioSampleBuffer scratchBuffer, sampleBuffer; | |||||
| AudioBuffer<float> scratchBuffer, sampleBuffer; | |||||
| Atomic<int> nextBlock, numBlocksOut; | Atomic<int> nextBlock, numBlocksOut; | ||||
| }; | }; | ||||
| @@ -310,7 +310,7 @@ public: | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| bool writeToOutputDevice (AudioSampleBuffer& outputChannelBuffer, const int numSamples) | |||||
| bool writeToOutputDevice (AudioBuffer<float>& outputChannelBuffer, const int numSamples) | |||||
| { | { | ||||
| jassert (numChannelsRunning <= outputChannelBuffer.getNumChannels()); | jassert (numChannelsRunning <= outputChannelBuffer.getNumChannels()); | ||||
| float* const* const data = outputChannelBuffer.getArrayOfWritePointers(); | float* const* const data = outputChannelBuffer.getArrayOfWritePointers(); | ||||
| @@ -348,7 +348,7 @@ public: | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool readFromInputDevice (AudioSampleBuffer& inputChannelBuffer, const int numSamples) | |||||
| bool readFromInputDevice (AudioBuffer<float>& inputChannelBuffer, const int numSamples) | |||||
| { | { | ||||
| jassert (numChannelsRunning <= inputChannelBuffer.getNumChannels()); | jassert (numChannelsRunning <= inputChannelBuffer.getNumChannels()); | ||||
| float* const* const data = inputChannelBuffer.getArrayOfWritePointers(); | float* const* const data = inputChannelBuffer.getArrayOfWritePointers(); | ||||
| @@ -801,7 +801,7 @@ private: | |||||
| CriticalSection callbackLock; | CriticalSection callbackLock; | ||||
| AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; | |||||
| AudioBuffer<float> inputChannelBuffer, outputChannelBuffer; | |||||
| Array<const float*> inputChannelDataForCallback; | Array<const float*> inputChannelDataForCallback; | ||||
| Array<float*> outputChannelDataForCallback; | Array<float*> outputChannelDataForCallback; | ||||
| @@ -209,7 +209,7 @@ public: | |||||
| }; | }; | ||||
| // returns the number of actual available channels | // returns the number of actual available channels | ||||
| StringArray getChannelInfo (const bool input, Array<CallbackDetailsForChannel>& newChannelInfo) const | |||||
| StringArray getChannelInfo (bool input, Array<CallbackDetailsForChannel>& newChannelInfo) const | |||||
| { | { | ||||
| StringArray newNames; | StringArray newNames; | ||||
| int chanNum = 0; | int chanNum = 0; | ||||
| @@ -300,7 +300,7 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| if (newSampleRates.size() == 0 && sampleRate > 0) | |||||
| if (newSampleRates.isEmpty() && sampleRate > 0) | |||||
| newSampleRates.add (sampleRate); | newSampleRates.add (sampleRate); | ||||
| return newSampleRates; | return newSampleRates; | ||||
| @@ -342,7 +342,7 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| if (newBufferSizes.size() == 0 && bufferSize > 0) | |||||
| if (newBufferSizes.isEmpty() && bufferSize > 0) | |||||
| newBufferSizes.add (bufferSize); | newBufferSizes.add (bufferSize); | ||||
| return newBufferSizes; | return newBufferSizes; | ||||
| @@ -419,21 +419,21 @@ public: | |||||
| // this collects all the new details from the device without any locking, then | // this collects all the new details from the device without any locking, then | ||||
| // locks + swaps them afterwards. | // locks + swaps them afterwards. | ||||
| const double newSampleRate = getNominalSampleRate(); | |||||
| const int newBufferSize = getFrameSizeFromDevice(); | |||||
| auto newSampleRate = getNominalSampleRate(); | |||||
| auto newBufferSize = getFrameSizeFromDevice(); | |||||
| Array<int> newBufferSizes = getBufferSizesFromDevice(); | |||||
| Array<double> 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<CallbackDetailsForChannel> newInChans, newOutChans; | Array<CallbackDetailsForChannel> newInChans, newOutChans; | ||||
| auto newInNames = isInputDevice ? getChannelInfo (true, newInChans) : StringArray(); | auto newInNames = isInputDevice ? getChannelInfo (true, newInChans) : StringArray(); | ||||
| auto newOutNames = isOutputDevice ? getChannelInfo (false, newOutChans) : 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); | const ScopedLock sl (callbackLock); | ||||
| @@ -467,7 +467,7 @@ public: | |||||
| { | { | ||||
| StringArray s; | StringArray s; | ||||
| HeapBlock<OSType> types; | HeapBlock<OSType> types; | ||||
| const int num = getAllDataSourcesForDevice (deviceID, types); | |||||
| auto num = getAllDataSourcesForDevice (deviceID, types); | |||||
| for (int i = 0; i < num; ++i) | for (int i = 0; i < num; ++i) | ||||
| { | { | ||||
| @@ -722,11 +722,10 @@ public: | |||||
| { | { | ||||
| for (int i = numInputChans; --i >= 0;) | 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 | if (stride != 0) // if this is zero, info is invalid | ||||
| { | { | ||||
| @@ -746,11 +745,10 @@ public: | |||||
| for (int i = numOutputChans; --i >= 0;) | 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 | if (stride != 0) // if this is zero, info is invalid | ||||
| { | { | ||||
| @@ -1145,8 +1143,8 @@ public: | |||||
| { | { | ||||
| Array<AudioIODevice*> devs; | Array<AudioIODevice*> 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; | return devs; | ||||
| } | } | ||||
| @@ -1155,8 +1153,8 @@ public: | |||||
| { | { | ||||
| StringArray names; | 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); | names.appendNumbersToDuplicates (false, true); | ||||
| return names; | return names; | ||||
| @@ -1166,8 +1164,8 @@ public: | |||||
| { | { | ||||
| StringArray names; | 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); | names.appendNumbersToDuplicates (false, true); | ||||
| return names; | return names; | ||||
| @@ -1176,15 +1174,21 @@ public: | |||||
| Array<double> getAvailableSampleRates() override | Array<double> getAvailableSampleRates() override | ||||
| { | { | ||||
| Array<double> commonRates; | Array<double> commonRates; | ||||
| bool first = true; | |||||
| for (int i = 0; i < devices.size(); ++i) | |||||
| for (auto* d : devices) | |||||
| { | { | ||||
| Array<double> rates (devices.getUnchecked(i)->device->getAvailableSampleRates()); | |||||
| auto rates = d->device->getAvailableSampleRates(); | |||||
| if (i == 0) | |||||
| if (first) | |||||
| { | |||||
| first = false; | |||||
| commonRates = rates; | commonRates = rates; | ||||
| } | |||||
| else | else | ||||
| { | |||||
| commonRates.removeValuesNotIn (rates); | commonRates.removeValuesNotIn (rates); | ||||
| } | |||||
| } | } | ||||
| return commonRates; | return commonRates; | ||||
| @@ -1193,15 +1197,21 @@ public: | |||||
| Array<int> getAvailableBufferSizes() override | Array<int> getAvailableBufferSizes() override | ||||
| { | { | ||||
| Array<int> commonSizes; | Array<int> commonSizes; | ||||
| bool first = true; | |||||
| for (int i = 0; i < devices.size(); ++i) | |||||
| for (auto* d : devices) | |||||
| { | { | ||||
| Array<int> sizes (devices.getUnchecked(i)->device->getAvailableBufferSizes()); | |||||
| auto sizes = d->device->getAvailableBufferSizes(); | |||||
| if (i == 0) | |||||
| if (first) | |||||
| { | |||||
| first = false; | |||||
| commonSizes = sizes; | commonSizes = sizes; | ||||
| } | |||||
| else | else | ||||
| { | |||||
| commonSizes.removeValuesNotIn (sizes); | commonSizes.removeValuesNotIn (sizes); | ||||
| } | |||||
| } | } | ||||
| return commonSizes; | return commonSizes; | ||||
| @@ -1216,8 +1226,8 @@ public: | |||||
| { | { | ||||
| int depth = 32; | 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; | return depth; | ||||
| } | } | ||||
| @@ -1226,8 +1236,8 @@ public: | |||||
| { | { | ||||
| int size = 0; | 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; | return size; | ||||
| } | } | ||||
| @@ -1244,7 +1254,7 @@ public: | |||||
| if (sampleRate <= 0) | if (sampleRate <= 0) | ||||
| { | { | ||||
| Array<double> rates (getAvailableSampleRates()); | |||||
| auto rates = getAvailableSampleRates(); | |||||
| for (int i = 0; i < rates.size() && sampleRate < 44100.0; ++i) | for (int i = 0; i < rates.size() && sampleRate < 44100.0; ++i) | ||||
| sampleRate = rates.getUnchecked(i); | sampleRate = rates.getUnchecked(i); | ||||
| @@ -1257,21 +1267,19 @@ public: | |||||
| int totalInputChanIndex = 0, totalOutputChanIndex = 0; | int totalInputChanIndex = 0, totalOutputChanIndex = 0; | ||||
| int chanIndex = 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 ins (inputChannels >> totalInputChanIndex); | ||||
| BigInteger outs (outputChannels >> totalOutputChanIndex); | 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; | totalInputChanIndex += numIns; | ||||
| totalOutputChanIndex += numOuts; | 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()) | if (err.isNotEmpty()) | ||||
| { | { | ||||
| @@ -1280,7 +1288,7 @@ public: | |||||
| return err; | return err; | ||||
| } | } | ||||
| chanIndex += d.numInputChans + d.numOutputChans; | |||||
| chanIndex += d->numInputChans + d->numOutputChans; | |||||
| } | } | ||||
| fifos.setSize (chanIndex, fifoSize); | fifos.setSize (chanIndex, fifoSize); | ||||
| @@ -1297,8 +1305,8 @@ public: | |||||
| fifos.clear(); | fifos.clear(); | ||||
| active = false; | active = false; | ||||
| for (int i = 0; i < devices.size(); ++i) | |||||
| devices.getUnchecked(i)->close(); | |||||
| for (auto* d : devices) | |||||
| d->close(); | |||||
| } | } | ||||
| BigInteger getActiveOutputChannels() const override | BigInteger getActiveOutputChannels() const override | ||||
| @@ -1306,13 +1314,13 @@ public: | |||||
| BigInteger chans; | BigInteger chans; | ||||
| int start = 0; | 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) | if (numChans > 0) | ||||
| { | { | ||||
| chans |= (devices.getUnchecked(i)->device->getActiveOutputChannels() << start); | |||||
| chans |= (d->device->getActiveOutputChannels() << start); | |||||
| start += numChans; | start += numChans; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1325,13 +1333,13 @@ public: | |||||
| BigInteger chans; | BigInteger chans; | ||||
| int start = 0; | 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) | if (numChans > 0) | ||||
| { | { | ||||
| chans |= (devices.getUnchecked(i)->device->getActiveInputChannels() << start); | |||||
| chans |= (d->device->getActiveInputChannels() << start); | |||||
| start += numChans; | start += numChans; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1343,8 +1351,8 @@ public: | |||||
| { | { | ||||
| int lat = 0; | 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; | return lat + currentBufferSize * 2; | ||||
| } | } | ||||
| @@ -1353,8 +1361,8 @@ public: | |||||
| { | { | ||||
| int lat = 0; | 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; | return lat + currentBufferSize * 2; | ||||
| } | } | ||||
| @@ -1366,8 +1374,8 @@ public: | |||||
| stop(); | stop(); | ||||
| fifos.clear(); | fifos.clear(); | ||||
| for (int i = 0; i < devices.size(); ++i) | |||||
| devices.getUnchecked(i)->start(); | |||||
| for (auto* d : devices) | |||||
| d->start(); | |||||
| if (newCallback != nullptr) | if (newCallback != nullptr) | ||||
| newCallback->audioDeviceAboutToStart (this); | newCallback->audioDeviceAboutToStart (this); | ||||
| @@ -1392,34 +1400,31 @@ private: | |||||
| int currentBufferSize = 0; | int currentBufferSize = 0; | ||||
| bool active = false; | bool active = false; | ||||
| String lastError; | String lastError; | ||||
| AudioSampleBuffer fifos; | |||||
| AudioBuffer<float> fifos; | |||||
| void run() override | void run() override | ||||
| { | { | ||||
| const int numSamples = currentBufferSize; | |||||
| auto numSamples = currentBufferSize; | |||||
| AudioSampleBuffer buffer (fifos.getNumChannels(), numSamples); | |||||
| AudioBuffer<float> buffer (fifos.getNumChannels(), numSamples); | |||||
| buffer.clear(); | buffer.clear(); | ||||
| Array<const float*> inputChans; | Array<const float*> inputChans; | ||||
| Array<float*> outputChans; | Array<float*> 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); | inputChans.add (nullptr); | ||||
| outputChans.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()); | jassert (numInputChans + numOutputChans == buffer.getNumChannels()); | ||||
| @@ -1462,8 +1467,8 @@ private: | |||||
| std::swap (callback, lastCallback); | 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) | if (lastCallback != nullptr) | ||||
| { | { | ||||
| @@ -1476,36 +1481,31 @@ private: | |||||
| void reset() | void reset() | ||||
| { | { | ||||
| for (int i = 0; i < devices.size(); ++i) | |||||
| devices.getUnchecked(i)->reset(); | |||||
| for (auto* d : devices) | |||||
| d->reset(); | |||||
| } | } | ||||
| void underrun() | void underrun() | ||||
| { | { | ||||
| } | } | ||||
| void readInput (AudioSampleBuffer& buffer, const int numSamples, const int blockSizeMs) | |||||
| void readInput (AudioBuffer<float>& 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;;) | for (int tries = 5;;) | ||||
| { | { | ||||
| bool anyRemaining = false; | 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 | else | ||||
| anyRemaining = true; | anyRemaining = true; | ||||
| @@ -1521,38 +1521,29 @@ private: | |||||
| wait (blockSizeMs); | 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<float>& 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;;) | for (int tries = 5;;) | ||||
| { | { | ||||
| bool anyRemaining = false; | 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 | else | ||||
| anyRemaining = true; | anyRemaining = true; | ||||
| @@ -1572,28 +1563,39 @@ private: | |||||
| auto newSampleRate = device->getCurrentSampleRate(); | auto newSampleRate = device->getCurrentSampleRate(); | ||||
| auto commonRates = getAvailableSampleRates(); | auto commonRates = getAvailableSampleRates(); | ||||
| if (! commonRates.contains (newSampleRate)) | if (! commonRates.contains (newSampleRate)) | ||||
| { | { | ||||
| commonRates.sort(); | commonRates.sort(); | ||||
| if (newSampleRate < commonRates.getFirst() || newSampleRate > commonRates.getLast()) | if (newSampleRate < commonRates.getFirst() || newSampleRate > commonRates.getLast()) | ||||
| { | |||||
| newSampleRate = jlimit (commonRates.getFirst(), commonRates.getLast(), newSampleRate); | newSampleRate = jlimit (commonRates.getFirst(), commonRates.getLast(), newSampleRate); | ||||
| } | |||||
| else | else | ||||
| { | |||||
| for (auto it = commonRates.begin(); it < commonRates.end() - 1; ++it) | for (auto it = commonRates.begin(); it < commonRates.end() - 1; ++it) | ||||
| { | |||||
| if (it[0] < newSampleRate && it[1] > newSampleRate) | if (it[0] < newSampleRate && it[1] > newSampleRate) | ||||
| { | { | ||||
| newSampleRate = newSampleRate - it[0] < it[1] - newSampleRate ? it[0] : it[1]; | newSampleRate = newSampleRate - it[0] < it[1] - newSampleRate ? it[0] : it[1]; | ||||
| break; | break; | ||||
| } | } | ||||
| } | |||||
| } | |||||
| } | } | ||||
| currentSampleRate = newSampleRate; | |||||
| currentSampleRate = newSampleRate; | |||||
| bool anySampleRateChanges = false; | 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; | anySampleRateChanges = true; | ||||
| } | } | ||||
| } | |||||
| if (anySampleRateChanges) | if (anySampleRateChanges) | ||||
| owner.audioDeviceListChanged(); | owner.audioDeviceListChanged(); | ||||
| @@ -1609,9 +1611,8 @@ private: | |||||
| struct DeviceWrapper : private AudioIODeviceCallback | struct DeviceWrapper : private AudioIODeviceCallback | ||||
| { | { | ||||
| DeviceWrapper (AudioIODeviceCombiner& cd, CoreAudioIODevice* d, bool useIns, bool useOuts) | 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, | 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); | inputFifo.setTotalSize (fifoSize); | ||||
| outputFifo.setTotalSize (fifoSize); | outputFifo.setTotalSize (fifoSize); | ||||
| inputFifo.reset(); | inputFifo.reset(); | ||||
| outputFifo.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; | numInputChans = useInputs ? device->getActiveInputChannels().countNumberOfSetBits() : 0; | ||||
| numOutputChans = useOutputs ? device->getActiveOutputChannels().countNumberOfSetBits() : 0; | numOutputChans = useOutputs ? device->getActiveOutputChannels().countNumberOfSetBits() : 0; | ||||
| @@ -1668,7 +1667,7 @@ private: | |||||
| return numInputChans == 0 || inputFifo.getNumReady() >= numSamples; | return numInputChans == 0 || inputFifo.getNumReady() >= numSamples; | ||||
| } | } | ||||
| void readInput (AudioSampleBuffer& destBuffer, int numSamples) | |||||
| void readInput (AudioBuffer<float>& destBuffer, int numSamples) | |||||
| { | { | ||||
| if (numInputChans == 0) | if (numInputChans == 0) | ||||
| return; | return; | ||||
| @@ -1678,9 +1677,9 @@ private: | |||||
| for (int i = 0; i < numInputChans; ++i) | 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 (size1 > 0) FloatVectorOperations::copy (dest, src + start1, size1); | ||||
| if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); | if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); | ||||
| @@ -1694,7 +1693,7 @@ private: | |||||
| return numOutputChans == 0 || outputFifo.getFreeSpace() >= numSamples; | return numOutputChans == 0 || outputFifo.getFreeSpace() >= numSamples; | ||||
| } | } | ||||
| void pushOutputData (AudioSampleBuffer& srcBuffer, int numSamples) | |||||
| void pushOutputData (AudioBuffer<float>& srcBuffer, int numSamples) | |||||
| { | { | ||||
| if (numOutputChans == 0) | if (numOutputChans == 0) | ||||
| return; | return; | ||||
| @@ -1704,9 +1703,9 @@ private: | |||||
| for (int i = 0; i < numOutputChans; ++i) | 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 (size1 > 0) FloatVectorOperations::copy (dest + start1, src, size1); | ||||
| if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); | if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); | ||||
| @@ -1719,7 +1718,7 @@ private: | |||||
| float** outputChannelData, int numOutputChannels, | float** outputChannelData, int numOutputChannels, | ||||
| int numSamples) override | int numSamples) override | ||||
| { | { | ||||
| AudioSampleBuffer& buf = owner.fifos; | |||||
| auto& buf = owner.fifos; | |||||
| if (numInputChannels > 0) | if (numInputChannels > 0) | ||||
| { | { | ||||
| @@ -1734,8 +1733,8 @@ private: | |||||
| for (int i = 0; i < numInputChannels; ++i) | 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 (size1 > 0) FloatVectorOperations::copy (dest + start1, src, size1); | ||||
| if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); | if (size2 > 0) FloatVectorOperations::copy (dest + start2, src + size1, size2); | ||||
| @@ -1765,8 +1764,8 @@ private: | |||||
| for (int i = 0; i < numOutputChannels; ++i) | 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 (size1 > 0) FloatVectorOperations::copy (dest, src + start1, size1); | ||||
| if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); | if (size2 > 0) FloatVectorOperations::copy (dest + size1, src + start2, size2); | ||||
| @@ -1795,10 +1794,10 @@ private: | |||||
| AudioIODeviceCombiner& owner; | AudioIODeviceCombiner& owner; | ||||
| ScopedPointer<CoreAudioIODevice> device; | ScopedPointer<CoreAudioIODevice> 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) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DeviceWrapper) | ||||
| }; | }; | ||||
| @@ -1814,9 +1813,7 @@ class CoreAudioIODeviceType : public AudioIODeviceType, | |||||
| private AsyncUpdater | private AsyncUpdater | ||||
| { | { | ||||
| public: | public: | ||||
| CoreAudioIODeviceType() | |||||
| : AudioIODeviceType ("CoreAudio"), | |||||
| hasScanned (false) | |||||
| CoreAudioIODeviceType() : AudioIODeviceType ("CoreAudio") | |||||
| { | { | ||||
| AudioObjectPropertyAddress pa; | AudioObjectPropertyAddress pa; | ||||
| pa.mSelector = kAudioHardwarePropertyDevices; | pa.mSelector = kAudioHardwarePropertyDevices; | ||||
| @@ -1860,18 +1857,19 @@ public: | |||||
| if (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, nullptr, &size, devs) == noErr) | 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) | for (int i = 0; i < num; ++i) | ||||
| { | { | ||||
| char name [1024]; | |||||
| char name[1024]; | |||||
| size = sizeof (name); | size = sizeof (name); | ||||
| pa.mSelector = kAudioDevicePropertyDeviceName; | pa.mSelector = kAudioDevicePropertyDeviceName; | ||||
| if (AudioObjectGetPropertyData (devs[i], &pa, 0, nullptr, &size, name) == noErr) | 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) | if (numIns > 0) | ||||
| { | { | ||||
| @@ -1940,17 +1938,15 @@ public: | |||||
| { | { | ||||
| jassert (hasScanned); // need to call scanForDevices() before doing this | jassert (hasScanned); // need to call scanForDevices() before doing this | ||||
| if (CoreAudioIODevice* const d = dynamic_cast<CoreAudioIODevice*> (device)) | |||||
| if (auto* d = dynamic_cast<CoreAudioIODevice*> (device)) | |||||
| return asInput ? d->inputIndex | return asInput ? d->inputIndex | ||||
| : d->outputIndex; | : d->outputIndex; | ||||
| if (AudioIODeviceCombiner* const d = dynamic_cast<AudioIODeviceCombiner*> (device)) | |||||
| if (auto* d = dynamic_cast<AudioIODeviceCombiner*> (device)) | |||||
| { | { | ||||
| const Array<AudioIODevice*> 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) | if (index >= 0) | ||||
| return index; | return index; | ||||
| @@ -1967,16 +1963,17 @@ public: | |||||
| { | { | ||||
| jassert (hasScanned); // need to call scanForDevices() before doing this | 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) | if (inputDeviceID == 0 && outputDeviceID == 0) | ||||
| return nullptr; | return nullptr; | ||||
| String combinedName (outputDeviceName.isEmpty() ? inputDeviceName : outputDeviceName); | |||||
| auto combinedName = outputDeviceName.isEmpty() ? inputDeviceName | |||||
| : outputDeviceName; | |||||
| if (inputDeviceID == outputDeviceID) | if (inputDeviceID == outputDeviceID) | ||||
| return new CoreAudioIODevice (*this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex); | return new CoreAudioIODevice (*this, combinedName, inputDeviceID, inputIndex, outputDeviceID, outputIndex); | ||||
| @@ -2014,7 +2011,7 @@ private: | |||||
| StringArray inputDeviceNames, outputDeviceNames; | StringArray inputDeviceNames, outputDeviceNames; | ||||
| Array<AudioDeviceID> inputIds, outputIds; | Array<AudioDeviceID> inputIds, outputIds; | ||||
| bool hasScanned; | |||||
| bool hasScanned = false; | |||||
| static int getNumChannels (AudioDeviceID deviceID, bool input) | static int getNumChannels (AudioDeviceID deviceID, bool input) | ||||
| { | { | ||||
| @@ -2033,13 +2030,10 @@ private: | |||||
| if (AudioObjectGetPropertyData (deviceID, &pa, 0, nullptr, &size, bufList) == noErr) | 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) | for (int i = 0; i < numStreams; ++i) | ||||
| { | |||||
| const ::AudioBuffer& b = bufList->mBuffers[i]; | |||||
| total += b.mNumberChannels; | |||||
| } | |||||
| total += bufList->mBuffers[i].mNumberChannels; | |||||
| } | } | ||||
| } | } | ||||
| @@ -892,7 +892,7 @@ private: | |||||
| int bufferSizeSamples = 0; | int bufferSizeSamples = 0; | ||||
| double sampleRate = 0; | double sampleRate = 0; | ||||
| BigInteger enabledInputs, enabledOutputs; | BigInteger enabledInputs, enabledOutputs; | ||||
| AudioSampleBuffer inputBuffers, outputBuffers; | |||||
| AudioBuffer<float> inputBuffers, outputBuffers; | |||||
| AudioIODeviceCallback* callback = nullptr; | AudioIODeviceCallback* callback = nullptr; | ||||
| CriticalSection startStopLock; | CriticalSection startStopLock; | ||||
| @@ -1246,8 +1246,8 @@ public: | |||||
| const int numOutputBuffers = getActiveOutputChannels().countNumberOfSetBits(); | const int numOutputBuffers = getActiveOutputChannels().countNumberOfSetBits(); | ||||
| bool sampleRateHasChanged = false; | bool sampleRateHasChanged = false; | ||||
| AudioSampleBuffer ins (jmax (1, numInputBuffers), bufferSize + 32); | |||||
| AudioSampleBuffer outs (jmax (1, numOutputBuffers), bufferSize + 32); | |||||
| AudioBuffer<float> ins (jmax (1, numInputBuffers), bufferSize + 32); | |||||
| AudioBuffer<float> outs (jmax (1, numOutputBuffers), bufferSize + 32); | |||||
| float** const inputBuffers = ins.getArrayOfWritePointers(); | float** const inputBuffers = ins.getArrayOfWritePointers(); | ||||
| float** const outputBuffers = outs.getArrayOfWritePointers(); | float** const outputBuffers = outs.getArrayOfWritePointers(); | ||||
| ins.clear(); | ins.clear(); | ||||
| @@ -24,11 +24,6 @@ namespace juce | |||||
| { | { | ||||
| AudioSourcePlayer::AudioSourcePlayer() | 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) | if (source != newSource) | ||||
| { | { | ||||
| AudioSource* const oldSource = source; | |||||
| auto* oldSource = source; | |||||
| if (newSource != nullptr && bufferSize > 0 && sampleRate > 0) | if (newSource != nullptr && bufferSize > 0 && sampleRate > 0) | ||||
| newSource->prepareToPlay (bufferSize, sampleRate); | newSource->prepareToPlay (bufferSize, sampleRate); | ||||
| @@ -137,7 +132,7 @@ void AudioSourcePlayer::audioDeviceIOCallback (const float** inputChannelData, | |||||
| } | } | ||||
| } | } | ||||
| AudioSampleBuffer buffer (channels, numActiveChans, numSamples); | |||||
| AudioBuffer<float> buffer (channels, numActiveChans, numSamples); | |||||
| AudioSourceChannelInfo info (&buffer, 0, numSamples); | AudioSourceChannelInfo info (&buffer, 0, numSamples); | ||||
| source->getNextAudioBlock (info); | source->getNextAudioBlock (info); | ||||
| @@ -96,14 +96,14 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| CriticalSection readLock; | 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<float> tempBuffer; | |||||
| float lastGain = 1.0f, gain = 1.0f; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSourcePlayer) | ||||
| }; | }; | ||||
| @@ -366,7 +366,7 @@ public: | |||||
| private: | private: | ||||
| FlacNamespace::FLAC__StreamDecoder* decoder; | FlacNamespace::FLAC__StreamDecoder* decoder; | ||||
| AudioSampleBuffer reservoir; | |||||
| AudioBuffer<float> reservoir; | |||||
| int reservoirStart = 0, samplesInReservoir = 0; | int reservoirStart = 0, samplesInReservoir = 0; | ||||
| bool ok = false, scanningForLength = false; | bool ok = false, scanningForLength = false; | ||||
| @@ -263,7 +263,7 @@ public: | |||||
| private: | private: | ||||
| OggVorbisNamespace::OggVorbis_File ovFile; | OggVorbisNamespace::OggVorbis_File ovFile; | ||||
| OggVorbisNamespace::ov_callbacks callbacks; | OggVorbisNamespace::ov_callbacks callbacks; | ||||
| AudioSampleBuffer reservoir; | |||||
| AudioBuffer<float> reservoir; | |||||
| int reservoirStart = 0, samplesInReservoir = 0; | int reservoirStart = 0, samplesInReservoir = 0; | ||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggReader) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggReader) | ||||
| @@ -1838,7 +1838,7 @@ struct WaveAudioFormatTests : public UnitTest | |||||
| 32, metadataValues, 0)); | 32, metadataValues, 0)); | ||||
| expect (writer != nullptr); | expect (writer != nullptr); | ||||
| AudioSampleBuffer buffer (numTestAudioBufferChannels, numTestAudioBufferSamples); | |||||
| AudioBuffer<float> buffer (numTestAudioBufferChannels, numTestAudioBufferSamples); | |||||
| buffer.clear(); | buffer.clear(); | ||||
| beginTest ("Writing audio data to the basic wave writer"); | beginTest ("Writing audio data to the basic wave writer"); | ||||
| @@ -100,10 +100,8 @@ bool AudioFormatReader::read (int* const* destSamples, | |||||
| return true; | 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<float>* buffer, | |||||
| int startSample, int numSamples, int64 readerStartSample, int numTargetChannels) | |||||
| { | { | ||||
| for (int j = 0; j < numTargetChannels; ++j) | for (int j = 0; j < numTargetChannels; ++j) | ||||
| chans[j] = reinterpret_cast<int*> (buffer->getWritePointer (j, startSample)); | chans[j] = reinterpret_cast<int*> (buffer->getWritePointer (j, startSample)); | ||||
| @@ -112,7 +110,7 @@ static void readChannels (AudioFormatReader& reader, | |||||
| reader.read (chans, numTargetChannels, readerStartSample, numSamples, true); | reader.read (chans, numTargetChannels, readerStartSample, numSamples, true); | ||||
| } | } | ||||
| void AudioFormatReader::read (AudioSampleBuffer* buffer, | |||||
| void AudioFormatReader::read (AudioBuffer<float>* buffer, | |||||
| int startSample, | int startSample, | ||||
| int numSamples, | int numSamples, | ||||
| int64 readerStartSample, | int64 readerStartSample, | ||||
| @@ -186,16 +184,17 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples | |||||
| return; | return; | ||||
| } | } | ||||
| const int bufferSize = (int) jmin (numSamples, (int64) 4096); | |||||
| AudioSampleBuffer tempSampleBuffer ((int) channelsToRead, bufferSize); | |||||
| auto bufferSize = (int) jmin (numSamples, (int64) 4096); | |||||
| AudioBuffer<float> tempSampleBuffer ((int) channelsToRead, bufferSize); | |||||
| float* const* const floatBuffer = tempSampleBuffer.getArrayOfWritePointers(); | |||||
| int* const* intBuffer = reinterpret_cast<int* const*> (floatBuffer); | |||||
| auto floatBuffer = tempSampleBuffer.getArrayOfWritePointers(); | |||||
| auto intBuffer = reinterpret_cast<int* const*> (floatBuffer); | |||||
| bool isFirstBlock = true; | bool isFirstBlock = true; | ||||
| while (numSamples > 0) | 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)) | if (! read (intBuffer, channelsToRead, startSampleInFile, numToDo, false)) | ||||
| break; | break; | ||||
| @@ -209,7 +208,7 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| Range<int> intRange (Range<int>::findMinAndMax (intBuffer[i], numToDo)); | |||||
| auto intRange = Range<int>::findMinAndMax (intBuffer[i], numToDo); | |||||
| r = Range<float> (intRange.getStart() / (float) std::numeric_limits<int>::max(), | r = Range<float> (intRange.getStart() / (float) std::numeric_limits<int>::max(), | ||||
| intRange.getEnd() / (float) std::numeric_limits<int>::max()); | intRange.getEnd() / (float) std::numeric_limits<int>::max()); | ||||
| @@ -248,9 +247,9 @@ void AudioFormatReader::readMaxLevels (int64 startSampleInFile, int64 numSamples | |||||
| int64 AudioFormatReader::searchForLevel (int64 startSample, | int64 AudioFormatReader::searchForLevel (int64 startSample, | ||||
| int64 numSamplesToSearch, | int64 numSamplesToSearch, | ||||
| const double magnitudeRangeMinimum, | |||||
| const double magnitudeRangeMaximum, | |||||
| const int minimumConsecutiveSamples) | |||||
| double magnitudeRangeMinimum, | |||||
| double magnitudeRangeMaximum, | |||||
| int minimumConsecutiveSamples) | |||||
| { | { | ||||
| if (numSamplesToSearch == 0) | if (numSamplesToSearch == 0) | ||||
| return -1; | return -1; | ||||
| @@ -111,14 +111,14 @@ public: | |||||
| int numSamplesToRead, | int numSamplesToRead, | ||||
| bool fillLeftoverChannelsWithCopies); | 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 | This will convert the reader's fixed- or floating-point data to | ||||
| the buffer's floating-point format, and will try to intelligently | the buffer's floating-point format, and will try to intelligently | ||||
| cope with mismatches between the number of channels in the reader | cope with mismatches between the number of channels in the reader | ||||
| and the buffer. | and the buffer. | ||||
| */ | */ | ||||
| void read (AudioSampleBuffer* buffer, | |||||
| void read (AudioBuffer<float>* buffer, | |||||
| int startSampleInDestBuffer, | int startSampleInDestBuffer, | ||||
| int numSamples, | int numSamples, | ||||
| int64 readerStartSample, | int64 readerStartSample, | ||||
| @@ -84,9 +84,9 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, | |||||
| int64 numSamplesToRead) | int64 numSamplesToRead) | ||||
| { | { | ||||
| const int bufferSize = 16384; | const int bufferSize = 16384; | ||||
| AudioSampleBuffer tempBuffer ((int) numChannels, bufferSize); | |||||
| AudioBuffer<float> tempBuffer ((int) numChannels, bufferSize); | |||||
| int* buffers [128] = { 0 }; | |||||
| int* buffers[128] = { 0 }; | |||||
| for (int i = tempBuffer.getNumChannels(); --i >= 0;) | for (int i = tempBuffer.getNumChannels(); --i >= 0;) | ||||
| buffers[i] = reinterpret_cast<int*> (tempBuffer.getWritePointer (i, 0)); | buffers[i] = reinterpret_cast<int*> (tempBuffer.getWritePointer (i, 0)); | ||||
| @@ -128,11 +128,11 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, | |||||
| bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, int numSamplesToRead, const int samplesPerBlock) | bool AudioFormatWriter::writeFromAudioSource (AudioSource& source, int numSamplesToRead, const int samplesPerBlock) | ||||
| { | { | ||||
| AudioSampleBuffer tempBuffer (getNumChannels(), samplesPerBlock); | |||||
| AudioBuffer<float> tempBuffer (getNumChannels(), samplesPerBlock); | |||||
| while (numSamplesToRead > 0) | while (numSamplesToRead > 0) | ||||
| { | { | ||||
| const int numToDo = jmin (numSamplesToRead, samplesPerBlock); | |||||
| auto numToDo = jmin (numSamplesToRead, samplesPerBlock); | |||||
| AudioSourceChannelInfo info (&tempBuffer, 0, numToDo); | AudioSourceChannelInfo info (&tempBuffer, 0, numToDo); | ||||
| info.clearActiveBufferRegion(); | info.clearActiveBufferRegion(); | ||||
| @@ -156,8 +156,8 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int | |||||
| if (isFloatingPoint()) | if (isFloatingPoint()) | ||||
| return write ((const int**) channels, numSamples); | return write ((const int**) channels, numSamples); | ||||
| int* chans [256]; | |||||
| int scratch [4096]; | |||||
| int* chans[256]; | |||||
| int scratch[4096]; | |||||
| jassert (numSourceChannels < numElementsInArray (chans)); | jassert (numSourceChannels < numElementsInArray (chans)); | ||||
| const int maxSamples = (int) (numElementsInArray (scratch) / numSourceChannels); | const int maxSamples = (int) (numElementsInArray (scratch) / numSourceChannels); | ||||
| @@ -185,15 +185,15 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioSampleBuffer& source, int startSample, int numSamples) | |||||
| bool AudioFormatWriter::writeFromAudioSampleBuffer (const AudioBuffer<float>& source, int startSample, int numSamples) | |||||
| { | { | ||||
| const int numSourceChannels = source.getNumChannels(); | |||||
| auto numSourceChannels = source.getNumChannels(); | |||||
| jassert (startSample >= 0 && startSample + numSamples <= source.getNumSamples() && numSourceChannels > 0); | jassert (startSample >= 0 && startSample + numSamples <= source.getNumSamples() && numSourceChannels > 0); | ||||
| if (startSample == 0) | if (startSample == 0) | ||||
| return writeFromFloatArrays (source.getArrayOfReadPointers(), numSourceChannels, numSamples); | return writeFromFloatArrays (source.getArrayOfReadPointers(), numSourceChannels, numSamples); | ||||
| const float* chans [256]; | |||||
| const float* chans[256]; | |||||
| jassert ((int) numChannels < numElementsInArray (chans)); | jassert ((int) numChannels < numElementsInArray (chans)); | ||||
| for (int i = 0; i < numSourceChannels; ++i) | for (int i = 0; i < numSourceChannels; ++i) | ||||
| @@ -326,7 +326,7 @@ public: | |||||
| private: | private: | ||||
| AbstractFifo fifo; | AbstractFifo fifo; | ||||
| AudioSampleBuffer buffer; | |||||
| AudioBuffer<float> buffer; | |||||
| TimeSliceThread& timeSliceThread; | TimeSliceThread& timeSliceThread; | ||||
| ScopedPointer<AudioFormatWriter> writer; | ScopedPointer<AudioFormatWriter> writer; | ||||
| CriticalSection thumbnailLock; | CriticalSection thumbnailLock; | ||||
| @@ -96,7 +96,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Writes a set of samples to the audio stream. | /** 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(). | can use writeFromAudioSampleBuffer(). | ||||
| @param samplesToWrite an array of arrays containing the sample data for | @param samplesToWrite an array of arrays containing the sample data for | ||||
| @@ -154,8 +154,8 @@ public: | |||||
| int samplesPerBlock = 2048); | int samplesPerBlock = 2048); | ||||
| /** Writes some samples from an AudioSampleBuffer. */ | |||||
| bool writeFromAudioSampleBuffer (const AudioSampleBuffer& source, | |||||
| /** Writes some samples from an AudioBuffer. */ | |||||
| bool writeFromAudioSampleBuffer (const AudioBuffer<float>& source, | |||||
| int startSample, int numSamples); | int startSample, int numSamples); | ||||
| /** Writes some samples from a set of float data channels. */ | /** Writes some samples from a set of float data channels. */ | ||||
| @@ -217,7 +217,7 @@ public: | |||||
| virtual ~IncomingDataReceiver() {} | virtual ~IncomingDataReceiver() {} | ||||
| virtual void reset (int numChannels, double sampleRate, int64 totalSamplesInSource) = 0; | 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<float>& newData, | |||||
| int startOffsetInBuffer, int numSamples) = 0; | int startOffsetInBuffer, int numSamples) = 0; | ||||
| }; | }; | ||||
| @@ -78,7 +78,7 @@ private: | |||||
| BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples); | BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples); | ||||
| Range<int64> range; | Range<int64> range; | ||||
| AudioSampleBuffer buffer; | |||||
| AudioBuffer<float> buffer; | |||||
| }; | }; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| @@ -44,7 +44,7 @@ SamplerSound::SamplerSound (const String& soundName, | |||||
| length = jmin ((int) source.lengthInSamples, | length = jmin ((int) source.lengthInSamples, | ||||
| (int) (maxSampleLengthSeconds * sourceSampleRate)); | (int) (maxSampleLengthSeconds * sourceSampleRate)); | ||||
| data = new AudioSampleBuffer (jmin (2, (int) source.numChannels), length + 4); | |||||
| data = new AudioBuffer<float> (jmin (2, (int) source.numChannels), length + 4); | |||||
| source.read (data, 0, length + 4, 0, true, true); | 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::controllerMoved (int /*controllerNumber*/, int /*newValue*/) {} | ||||
| //============================================================================== | //============================================================================== | ||||
| void SamplerVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) | |||||
| void SamplerVoice::renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples) | |||||
| { | { | ||||
| if (auto* playingSound = static_cast<SamplerSound*> (getCurrentlyPlayingSound().get())) | if (auto* playingSound = static_cast<SamplerSound*> (getCurrentlyPlayingSound().get())) | ||||
| { | { | ||||
| @@ -79,7 +79,7 @@ public: | |||||
| /** Returns the audio sample data. | /** Returns the audio sample data. | ||||
| This could return nullptr if there was a problem loading the data. | This could return nullptr if there was a problem loading the data. | ||||
| */ | */ | ||||
| AudioSampleBuffer* getAudioData() const noexcept { return data; } | |||||
| AudioBuffer<float>* getAudioData() const noexcept { return data; } | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -92,7 +92,7 @@ private: | |||||
| friend class SamplerVoice; | friend class SamplerVoice; | ||||
| String name; | String name; | ||||
| ScopedPointer<AudioSampleBuffer> data; | |||||
| ScopedPointer<AudioBuffer<float>> data; | |||||
| double sourceSampleRate; | double sourceSampleRate; | ||||
| BigInteger midiNotes; | BigInteger midiNotes; | ||||
| int length = 0, attackSamples = 0, releaseSamples = 0; | int length = 0, attackSamples = 0, releaseSamples = 0; | ||||
| @@ -130,7 +130,7 @@ public: | |||||
| void pitchWheelMoved (int newValue) override; | void pitchWheelMoved (int newValue) override; | ||||
| void controllerMoved (int controllerNumber, int newValue) override; | void controllerMoved (int controllerNumber, int newValue) override; | ||||
| void renderNextBlock (AudioSampleBuffer&, int startSample, int numSamples) override; | |||||
| void renderNextBlock (AudioBuffer<float>&, int startSample, int numSamples) override; | |||||
| private: | private: | ||||
| @@ -1237,7 +1237,7 @@ namespace AAXClasses | |||||
| void process (float* const* channels, const int numChans, const int bufferSize, | void process (float* const* channels, const int numChans, const int bufferSize, | ||||
| const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut) | const bool bypass, AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut) | ||||
| { | { | ||||
| AudioSampleBuffer buffer (channels, numChans, bufferSize); | |||||
| AudioBuffer<float> buffer (channels, numChans, bufferSize); | |||||
| midiBuffer.clear(); | midiBuffer.clear(); | ||||
| @@ -1690,7 +1690,7 @@ private: | |||||
| } | } | ||||
| } | } | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) noexcept | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) noexcept | |||||
| { | { | ||||
| const ScopedLock sl (juceFilter->getCallbackLock()); | const ScopedLock sl (juceFilter->getCallbackLock()); | ||||
| @@ -1056,7 +1056,7 @@ private: | |||||
| AudioBufferList* bufferList = nullptr; | AudioBufferList* bufferList = nullptr; | ||||
| int maxFrames, numberOfChannels; | int maxFrames, numberOfChannels; | ||||
| bool isInterleaved; | bool isInterleaved; | ||||
| AudioSampleBuffer scratchBuffer; | |||||
| AudioBuffer<float> scratchBuffer; | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -1357,7 +1357,7 @@ private: | |||||
| return noErr; | return noErr; | ||||
| } | } | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiBuffer) noexcept | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) noexcept | |||||
| { | { | ||||
| auto& processor = getAudioProcessor(); | auto& processor = getAudioProcessor(); | ||||
| const ScopedLock sl (processor.getCallbackLock()); | const ScopedLock sl (processor.getCallbackLock()); | ||||
| @@ -599,7 +599,7 @@ public: | |||||
| channels [i] = inputs [i]; | channels [i] = inputs [i]; | ||||
| } | } | ||||
| AudioSampleBuffer chans (channels, totalChans, numSamples); | |||||
| AudioBuffer<float> chans (channels, totalChans, numSamples); | |||||
| if (mBypassed) | if (mBypassed) | ||||
| juceFilter->processBlockBypassed (chans, midiEvents); | juceFilter->processBlockBypassed (chans, midiEvents); | ||||
| @@ -384,7 +384,7 @@ public: | |||||
| // avoid feedback loop by default | // avoid feedback loop by default | ||||
| bool processorHasPotentialFeedbackLoop = true; | bool processorHasPotentialFeedbackLoop = true; | ||||
| Value shouldMuteInput; | Value shouldMuteInput; | ||||
| AudioSampleBuffer emptyBuffer; | |||||
| AudioBuffer<float> emptyBuffer; | |||||
| bool autoOpenMidiDevices; | bool autoOpenMidiDevices; | ||||
| ScopedPointer<AudioDeviceManager::AudioDeviceSetup> options; | ScopedPointer<AudioDeviceManager::AudioDeviceSetup> options; | ||||
| @@ -213,7 +213,7 @@ struct AudioUnitHelpers | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| AudioSampleBuffer& getBuffer (UInt32 frames) noexcept | |||||
| AudioBuffer<float>& getBuffer (UInt32 frames) noexcept | |||||
| { | { | ||||
| jassert (pushIdx == scratch.getNumChannels()); | jassert (pushIdx == scratch.getNumChannels()); | ||||
| @@ -240,9 +240,7 @@ struct AudioUnitHelpers | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| AudioSampleBuffer scratch; | |||||
| AudioSampleBuffer mutableBuffer; | |||||
| AudioBuffer<float> scratch, mutableBuffer; | |||||
| HeapBlock<float*> channels; | HeapBlock<float*> channels; | ||||
| int pushIdx, popIdx; | int pushIdx, popIdx; | ||||
| }; | }; | ||||
| @@ -787,9 +787,9 @@ public: | |||||
| for (int i = 0; i < getBusCount (false); ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, static_cast<UInt32> (i)); | for (int i = 0; i < getBusCount (false); ++i) AudioUnitReset (audioUnit, kAudioUnitScope_Output, static_cast<UInt32> (i)); | ||||
| } | } | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) override | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override | |||||
| { | { | ||||
| const int numSamples = buffer.getNumSamples(); | |||||
| auto numSamples = buffer.getNumSamples(); | |||||
| if (prepared) | if (prepared) | ||||
| { | { | ||||
| @@ -816,6 +816,7 @@ public: | |||||
| { | { | ||||
| int chIdx = 0; | int chIdx = 0; | ||||
| numOutputBuses = getBusCount (false); | numOutputBuses = getBusCount (false); | ||||
| for (int i = 0; i < numOutputBuses; ++i) | for (int i = 0; i < numOutputBuses; ++i) | ||||
| { | { | ||||
| if (AUBuffer* buf = outputBufferList[i]) | if (AUBuffer* buf = outputBufferList[i]) | ||||
| @@ -1298,7 +1299,7 @@ private: | |||||
| OwnedArray<AUBuffer> outputBufferList; | OwnedArray<AUBuffer> outputBufferList; | ||||
| AudioTimeStamp timeStamp; | AudioTimeStamp timeStamp; | ||||
| AudioSampleBuffer* currentBuffer; | |||||
| AudioBuffer<float>* currentBuffer; | |||||
| Array<Array<AudioChannelSet>> supportedInLayouts, supportedOutLayouts; | Array<Array<AudioChannelSet>> supportedInLayouts, supportedOutLayouts; | ||||
| int numChannelInfos; | int numChannelInfos; | ||||
| @@ -1464,10 +1465,9 @@ private: | |||||
| { | { | ||||
| // if this ever happens, might need to add extra handling | // if this ever happens, might need to add extra handling | ||||
| jassert (inNumberFrames == (UInt32) currentBuffer->getNumSamples()); | jassert (inNumberFrames == (UInt32) currentBuffer->getNumSamples()); | ||||
| AudioSampleBuffer buffer = | |||||
| (static_cast<int> (inBusNumber) < getBusCount (true) | |||||
| ? getBusBuffer (*currentBuffer, true, static_cast<int> (inBusNumber)) | |||||
| : AudioSampleBuffer()); | |||||
| auto buffer = static_cast<int> (inBusNumber) < getBusCount (true) | |||||
| ? getBusBuffer (*currentBuffer, true, static_cast<int> (inBusNumber)) | |||||
| : AudioBuffer<float>(); | |||||
| for (int i = 0; i < static_cast<int> (ioData->mNumberBuffers); ++i) | for (int i = 0; i < static_cast<int> (ioData->mNumberBuffers); ++i) | ||||
| { | { | ||||
| @@ -286,9 +286,9 @@ public: | |||||
| tempBuffer.setSize (1, 1); | tempBuffer.setSize (1, 1); | ||||
| } | } | ||||
| void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) | |||||
| void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) | |||||
| { | { | ||||
| const int numSamples = buffer.getNumSamples(); | |||||
| auto numSamples = buffer.getNumSamples(); | |||||
| if (initialised && plugin != nullptr && handle != nullptr) | if (initialised && plugin != nullptr && handle != nullptr) | ||||
| { | { | ||||
| @@ -484,7 +484,7 @@ private: | |||||
| String name; | String name; | ||||
| CriticalSection lock; | CriticalSection lock; | ||||
| bool initialised; | bool initialised; | ||||
| AudioSampleBuffer tempBuffer; | |||||
| AudioBuffer<float> tempBuffer; | |||||
| Array<int> inputs, outputs, parameters; | Array<int> inputs, outputs, parameters; | ||||
| struct ParameterValue | struct ParameterValue | ||||
| @@ -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, float** raw) { vstBuffers.channelBuffers32 = raw; } | ||||
| static inline void assignRawPointer (Steinberg::Vst::AudioBusBuffers& vstBuffers, double** raw) { vstBuffers.channelBuffers64 = 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, | static void associateBufferTo (Steinberg::Vst::AudioBusBuffers& vstBuffers, | ||||
| Bus& bus, | Bus& bus, | ||||
| @@ -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<float>& buffer) noexcept | |||||
| { | { | ||||
| vstBuffers.channelBuffers32 = buffer.getArrayOfWritePointers(); | vstBuffers.channelBuffers32 = buffer.getArrayOfWritePointers(); | ||||
| vstBuffers.numChannels = buffer.getNumChannels(); | vstBuffers.numChannels = buffer.getNumChannels(); | ||||
| @@ -441,7 +441,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the position of a bus's channels within the processBlock buffer. | /** 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. | maps onto a specific bus's channel. | ||||
| */ | */ | ||||
| int getChannelIndexInProcessBlockBuffer (int channelIndex) const noexcept; | int getChannelIndexInProcessBlockBuffer (int channelIndex) const noexcept; | ||||
| @@ -449,7 +449,7 @@ public: | |||||
| /** Returns an AudioBuffer containing a set of channel pointers for a specific bus. | /** 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 | 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 <typename FloatType> | template <typename FloatType> | ||||
| AudioBuffer<FloatType> getBusBuffer (AudioBuffer<FloatType>& processBlockBuffer) const | AudioBuffer<FloatType> getBusBuffer (AudioBuffer<FloatType>& processBlockBuffer) const | ||||
| @@ -605,7 +605,7 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the position of a bus's channels within the processBlock buffer. | /** 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. | maps onto a specific bus's channel. | ||||
| */ | */ | ||||
| int getChannelIndexInProcessBlockBuffer (bool isInput, int busIndex, int channelIndex) const noexcept; | 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. | /** 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 | 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 <typename FloatType> | template <typename FloatType> | ||||
| AudioBuffer<FloatType> getBusBuffer (AudioBuffer<FloatType>& processBlockBuffer, bool isInput, int busIndex) const | AudioBuffer<FloatType> getBusBuffer (AudioBuffer<FloatType>& processBlockBuffer, bool isInput, int busIndex) const | ||||
| @@ -693,7 +693,7 @@ int64 AudioThumbnail::getHashCode() const | |||||
| return source == nullptr ? 0 : source->hashCode; | return source == nullptr ? 0 : source->hashCode; | ||||
| } | } | ||||
| void AudioThumbnail::addBlock (const int64 startSample, const AudioSampleBuffer& incoming, | |||||
| void AudioThumbnail::addBlock (int64 startSample, const AudioBuffer<float>& incoming, | |||||
| int startOffsetInBuffer, int numSamples) | int startOffsetInBuffer, int numSamples) | ||||
| { | { | ||||
| jassert (startSample >= 0 | jassert (startSample >= 0 | ||||
| @@ -107,7 +107,7 @@ public: | |||||
| /** Adds a block of level data to the thumbnail. | /** Adds a block of level data to the thumbnail. | ||||
| Call reset() before using this, to tell the thumbnail about the data format. | 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<float>& newData, | |||||
| int startOffsetInBuffer, int numSamples) override; | int startOffsetInBuffer, int numSamples) override; | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -129,7 +129,7 @@ void AudioVisualiserComponent::pushBuffer (const float** d, int numChannels, int | |||||
| channels.getUnchecked(i)->pushSamples (d[i], num); | channels.getUnchecked(i)->pushSamples (d[i], num); | ||||
| } | } | ||||
| void AudioVisualiserComponent::pushBuffer (const AudioSampleBuffer& buffer) | |||||
| void AudioVisualiserComponent::pushBuffer (const AudioBuffer<float>& buffer) | |||||
| { | { | ||||
| pushBuffer (buffer.getArrayOfReadPointers(), | pushBuffer (buffer.getArrayOfReadPointers(), | ||||
| buffer.getNumChannels(), | buffer.getNumChannels(), | ||||
| @@ -74,7 +74,7 @@ public: | |||||
| The number of channels provided here is expected to match the number of channels | The number of channels provided here is expected to match the number of channels | ||||
| that this AudioVisualiserComponent has been told to use. | that this AudioVisualiserComponent has been told to use. | ||||
| */ | */ | ||||
| void pushBuffer (const AudioSampleBuffer& bufferToPush); | |||||
| void pushBuffer (const AudioBuffer<float>& bufferToPush); | |||||
| /** Pushes a buffer of channels data. | /** Pushes a buffer of channels data. | ||||
| The number of channels provided here is expected to match the number of channels | The number of channels provided here is expected to match the number of channels | ||||
| @@ -129,7 +129,7 @@ private: | |||||
| if (numSamples > 0) | if (numSamples > 0) | ||||
| { | { | ||||
| AudioSampleBuffer tempBuffer (2, numSamples); | |||||
| AudioBuffer<float> tempBuffer (2, numSamples); | |||||
| AudioSourceChannelInfo info (tempBuffer); | AudioSourceChannelInfo info (tempBuffer); | ||||
| source->source->getNextAudioBlock (info); | source->source->getNextAudioBlock (info); | ||||
| @@ -373,7 +373,7 @@ bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples) | |||||
| hr = pimpl->redbook->CreateAudioTrack ((long) numSamples / (bytesPerBlock * 4)); | hr = pimpl->redbook->CreateAudioTrack ((long) numSamples / (bytesPerBlock * 4)); | ||||
| HeapBlock<byte> buffer (bytesPerBlock); | HeapBlock<byte> buffer (bytesPerBlock); | ||||
| AudioSampleBuffer sourceBuffer (2, samplesPerBlock); | |||||
| AudioBuffer<float> sourceBuffer (2, samplesPerBlock); | |||||
| int samplesDone = 0; | int samplesDone = 0; | ||||
| source->prepareToPlay (samplesPerBlock, 44100.0); | source->prepareToPlay (samplesPerBlock, 44100.0); | ||||
| @@ -141,7 +141,7 @@ void AudioProcessorPlayer::audioDeviceIOCallback (const float** const inputChann | |||||
| } | } | ||||
| } | } | ||||
| AudioSampleBuffer buffer (channels, totalNumChans, numSamples); | |||||
| AudioBuffer<float> buffer (channels, totalNumChans, numSamples); | |||||
| { | { | ||||
| const ScopedLock sl (lock); | const ScopedLock sl (lock); | ||||
| @@ -85,12 +85,11 @@ private: | |||||
| }; | }; | ||||
| // An AudioSource which simply outputs a buffer | // An AudioSource which simply outputs a buffer | ||||
| class AudioSampleBufferSource : public PositionableAudioSource | |||||
| class AudioBufferSource : public PositionableAudioSource | |||||
| { | { | ||||
| public: | public: | ||||
| AudioSampleBufferSource (AudioSampleBuffer* audioBuffer, bool ownBuffer, bool playOnAllChannels) | |||||
| AudioBufferSource (AudioBuffer<float>* audioBuffer, bool ownBuffer, bool playOnAllChannels) | |||||
| : buffer (audioBuffer, ownBuffer), | : buffer (audioBuffer, ownBuffer), | ||||
| position (0), looping (false), | |||||
| playAcrossAllChannels (playOnAllChannels) | playAcrossAllChannels (playOnAllChannels) | ||||
| {} | {} | ||||
| @@ -144,11 +143,11 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| OptionalScopedPointer<AudioSampleBuffer> buffer; | |||||
| int position; | |||||
| bool looping, playAcrossAllChannels; | |||||
| OptionalScopedPointer<AudioBuffer<float>> 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() | SoundPlayer::SoundPlayer() | ||||
| @@ -185,10 +184,10 @@ void SoundPlayer::play (AudioFormatReader* reader, bool deleteWhenFinished) | |||||
| play (new AudioFormatReaderSource (reader, deleteWhenFinished), true, reader->sampleRate); | play (new AudioFormatReaderSource (reader, deleteWhenFinished), true, reader->sampleRate); | ||||
| } | } | ||||
| void SoundPlayer::play (AudioSampleBuffer* buffer, bool deleteWhenFinished, bool playOnAllOutputChannels) | |||||
| void SoundPlayer::play (AudioBuffer<float>* buffer, bool deleteWhenFinished, bool playOnAllOutputChannels) | |||||
| { | { | ||||
| if (buffer != nullptr) | 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) | 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); | const double phasePerSample = double_Pi * 2.0 / (sampleRate / frequency); | ||||
| AudioSampleBuffer* newSound = new AudioSampleBuffer (1, soundLength); | |||||
| auto* newSound = new AudioBuffer<float> (1, soundLength); | |||||
| for (int i = 0; i < soundLength; ++i) | for (int i = 0; i < soundLength; ++i) | ||||
| newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); | newSound->setSample (0, i, amplitude * (float) std::sin (i * phasePerSample)); | ||||
| @@ -96,7 +96,7 @@ public: | |||||
| multiple outputs so that something is sent to all output channels. If it | 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. | is false, then the buffer will just be played on the first output channels. | ||||
| */ | */ | ||||
| void play (AudioSampleBuffer* buffer, | |||||
| void play (AudioBuffer<float>* buffer, | |||||
| bool deleteWhenFinished = false, | bool deleteWhenFinished = false, | ||||
| bool playOnAllOutputChannels = false); | bool playOnAllOutputChannels = false); | ||||
| @@ -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 | 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 | 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 | 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 | responsible for making sure that the data doesn't get deleted while there's | ||||
| still an AudioBlock using it. | still an AudioBlock using it. | ||||
| */ | */ | ||||