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