@@ -32,9 +32,7 @@ class LatencyTester : public AudioIODeviceCallback, | |||||
{ | { | ||||
public: | public: | ||||
LatencyTester (TextEditor& resultsBox_) | LatencyTester (TextEditor& resultsBox_) | ||||
: testSound (1, 1), | |||||
recordedSound (1, 1), | |||||
playingSampleNum (0), | |||||
: playingSampleNum (0), | |||||
recordedSampleNum (-1), | recordedSampleNum (-1), | ||||
sampleRate (0), | sampleRate (0), | ||||
testIsRunning (false), | testIsRunning (false), | ||||
@@ -22,13 +22,20 @@ | |||||
============================================================================== | ============================================================================== | ||||
*/ | */ | ||||
AudioSampleBuffer::AudioSampleBuffer() noexcept | |||||
: numChannels (0), size (0), allocatedBytes (0), | |||||
channels (static_cast<float**> (preallocatedChannelSpace)), | |||||
isClear (false) | |||||
{ | |||||
} | |||||
AudioSampleBuffer::AudioSampleBuffer (const int numChans, | AudioSampleBuffer::AudioSampleBuffer (const int numChans, | ||||
const int numSamples) noexcept | const int numSamples) noexcept | ||||
: numChannels (numChans), | : numChannels (numChans), | ||||
size (numSamples) | size (numSamples) | ||||
{ | { | ||||
jassert (numSamples >= 0); | jassert (numSamples >= 0); | ||||
jassert (numChans > 0); | |||||
jassert (numChans >= 0); | |||||
allocateData(); | allocateData(); | ||||
} | } | ||||
@@ -63,7 +70,7 @@ void AudioSampleBuffer::allocateData() | |||||
const size_t channelListSize = sizeof (float*) * (size_t) (numChannels + 1); | const size_t channelListSize = sizeof (float*) * (size_t) (numChannels + 1); | ||||
allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (float) + channelListSize + 32; | allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (float) + channelListSize + 32; | ||||
allocatedData.malloc (allocatedBytes); | allocatedData.malloc (allocatedBytes); | ||||
channels = reinterpret_cast <float**> (allocatedData.getData()); | |||||
channels = reinterpret_cast<float**> (allocatedData.getData()); | |||||
float* chan = (float*) (allocatedData + channelListSize); | float* chan = (float*) (allocatedData + channelListSize); | ||||
for (int i = 0; i < numChannels; ++i) | for (int i = 0; i < numChannels; ++i) | ||||
@@ -83,7 +90,8 @@ AudioSampleBuffer::AudioSampleBuffer (float* const* dataToReferTo, | |||||
size (numSamples), | size (numSamples), | ||||
allocatedBytes (0) | allocatedBytes (0) | ||||
{ | { | ||||
jassert (numChans > 0); | |||||
jassert (dataToReferTo != nullptr); | |||||
jassert (numChans >= 0); | |||||
allocateChannels (dataToReferTo, 0); | allocateChannels (dataToReferTo, 0); | ||||
} | } | ||||
@@ -96,7 +104,8 @@ AudioSampleBuffer::AudioSampleBuffer (float* const* dataToReferTo, | |||||
allocatedBytes (0), | allocatedBytes (0), | ||||
isClear (false) | isClear (false) | ||||
{ | { | ||||
jassert (numChans > 0); | |||||
jassert (dataToReferTo != nullptr); | |||||
jassert (numChans >= 0); | |||||
allocateChannels (dataToReferTo, startSample); | allocateChannels (dataToReferTo, startSample); | ||||
} | } | ||||
@@ -104,7 +113,8 @@ void AudioSampleBuffer::setDataToReferTo (float** dataToReferTo, | |||||
const int newNumChannels, | const int newNumChannels, | ||||
const int newNumSamples) noexcept | const int newNumSamples) noexcept | ||||
{ | { | ||||
jassert (newNumChannels > 0); | |||||
jassert (dataToReferTo != nullptr); | |||||
jassert (newNumChannels >= 0); | |||||
allocatedBytes = 0; | allocatedBytes = 0; | ||||
allocatedData.free(); | allocatedData.free(); | ||||
@@ -121,12 +131,12 @@ void AudioSampleBuffer::allocateChannels (float* const* const dataToReferTo, int | |||||
// (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools) | // (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools) | ||||
if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) | if (numChannels < (int) numElementsInArray (preallocatedChannelSpace)) | ||||
{ | { | ||||
channels = static_cast <float**> (preallocatedChannelSpace); | |||||
channels = static_cast<float**> (preallocatedChannelSpace); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
allocatedData.malloc ((size_t) numChannels + 1, sizeof (float*)); | allocatedData.malloc ((size_t) numChannels + 1, sizeof (float*)); | ||||
channels = reinterpret_cast <float**> (allocatedData.getData()); | |||||
channels = reinterpret_cast<float**> (allocatedData.getData()); | |||||
} | } | ||||
for (int i = 0; i < numChannels; ++i) | for (int i = 0; i < numChannels; ++i) | ||||
@@ -171,7 +181,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels, | |||||
const bool clearExtraSpace, | const bool clearExtraSpace, | ||||
const bool avoidReallocating) noexcept | const bool avoidReallocating) noexcept | ||||
{ | { | ||||
jassert (newNumChannels > 0); | |||||
jassert (newNumChannels >= 0); | |||||
jassert (newNumSamples >= 0); | jassert (newNumSamples >= 0); | ||||
if (newNumSamples != size || newNumChannels != numChannels) | if (newNumSamples != size || newNumChannels != numChannels) | ||||
@@ -34,6 +34,10 @@ | |||||
class JUCE_API AudioSampleBuffer | class JUCE_API AudioSampleBuffer | ||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | |||||
/** Creates an empty buffer with 0 channels and 0 length. */ | |||||
AudioSampleBuffer() noexcept; | |||||
//============================================================================== | //============================================================================== | ||||
/** Creates a buffer with a specified number of channels and samples. | /** Creates a buffer with a specified number of channels and samples. | ||||
@@ -93,12 +97,12 @@ public: | |||||
using an external data buffer, in which case boths buffers will just point to the same | using an external data buffer, in which case boths buffers will just point to the same | ||||
shared block of data. | shared block of data. | ||||
*/ | */ | ||||
AudioSampleBuffer (const AudioSampleBuffer& other) noexcept; | |||||
AudioSampleBuffer (const AudioSampleBuffer&) noexcept; | |||||
/** Copies another buffer onto this one. | /** Copies another buffer onto this one. | ||||
This buffer's size will be changed to that of the other buffer. | This buffer's size will be changed to that of the other buffer. | ||||
*/ | */ | ||||
AudioSampleBuffer& operator= (const AudioSampleBuffer& other) noexcept; | |||||
AudioSampleBuffer& operator= (const AudioSampleBuffer&) noexcept; | |||||
/** Destructor. | /** Destructor. | ||||
This will free any memory allocated by the buffer. | This will free any memory allocated by the buffer. | ||||
@@ -31,7 +31,6 @@ BufferingAudioSource::BufferingAudioSource (PositionableAudioSource* s, | |||||
backgroundThread (thread), | backgroundThread (thread), | ||||
numberOfSamplesToBuffer (jmax (1024, bufferSizeSamples)), | numberOfSamplesToBuffer (jmax (1024, bufferSizeSamples)), | ||||
numberOfChannels (numChannels), | numberOfChannels (numChannels), | ||||
buffer (numChannels, 0), | |||||
bufferValidStart (0), | bufferValidStart (0), | ||||
bufferValidEnd (0), | bufferValidEnd (0), | ||||
nextPlayPos (0), | nextPlayPos (0), | ||||
@@ -25,8 +25,7 @@ | |||||
ChannelRemappingAudioSource::ChannelRemappingAudioSource (AudioSource* const source_, | ChannelRemappingAudioSource::ChannelRemappingAudioSource (AudioSource* const source_, | ||||
const bool deleteSourceWhenDeleted) | const bool deleteSourceWhenDeleted) | ||||
: source (source_, deleteSourceWhenDeleted), | : source (source_, deleteSourceWhenDeleted), | ||||
requiredNumberOfChannels (2), | |||||
buffer (2, 16) | |||||
requiredNumberOfChannels (2) | |||||
{ | { | ||||
remappedInfo.buffer = &buffer; | remappedInfo.buffer = &buffer; | ||||
remappedInfo.startSample = 0; | remappedInfo.startSample = 0; | ||||
@@ -23,9 +23,7 @@ | |||||
*/ | */ | ||||
MixerAudioSource::MixerAudioSource() | MixerAudioSource::MixerAudioSource() | ||||
: tempBuffer (2, 0), | |||||
currentSampleRate (0.0), | |||||
bufferSizeExpected (0) | |||||
: currentSampleRate (0.0), bufferSizeExpected (0) | |||||
{ | { | ||||
} | } | ||||
@@ -28,14 +28,12 @@ ResamplingAudioSource::ResamplingAudioSource (AudioSource* const inputSource, | |||||
: input (inputSource, deleteInputWhenDeleted), | : input (inputSource, deleteInputWhenDeleted), | ||||
ratio (1.0), | ratio (1.0), | ||||
lastRatio (1.0), | lastRatio (1.0), | ||||
buffer (numChannels_, 0), | |||||
bufferPos (0), | bufferPos (0), | ||||
sampsInBuffer (0), | sampsInBuffer (0), | ||||
subSampleOffset (0), | subSampleOffset (0), | ||||
numChannels (numChannels_) | numChannels (numChannels_) | ||||
{ | { | ||||
jassert (input != nullptr); | jassert (input != nullptr); | ||||
zeromem (coefficients, sizeof (coefficients)); | zeromem (coefficients, sizeof (coefficients)); | ||||
} | } | ||||
@@ -95,7 +95,6 @@ AudioDeviceManager::AudioDeviceManager() | |||||
useInputNames (false), | useInputNames (false), | ||||
inputLevel (0), | inputLevel (0), | ||||
testSoundPosition (0), | testSoundPosition (0), | ||||
tempBuffer (2, 2), | |||||
cpuUsageMs (0), | cpuUsageMs (0), | ||||
timeToCpuScale (0) | timeToCpuScale (0) | ||||
{ | { | ||||
@@ -1026,8 +1026,7 @@ public: | |||||
AudioIODeviceCombiner (const String& deviceName) | AudioIODeviceCombiner (const String& deviceName) | ||||
: AudioIODevice (deviceName, "CoreAudio"), | : AudioIODevice (deviceName, "CoreAudio"), | ||||
Thread (deviceName), callback (nullptr), | Thread (deviceName), callback (nullptr), | ||||
currentSampleRate (0), currentBufferSize (0), active (false), | |||||
fifos (1, 1) | |||||
currentSampleRate (0), currentBufferSize (0), active (false) | |||||
{ | { | ||||
} | } | ||||
@@ -731,8 +731,6 @@ public: | |||||
isStarted (false), | isStarted (false), | ||||
bufferSizeSamples (0), | bufferSizeSamples (0), | ||||
sampleRate (0.0), | sampleRate (0.0), | ||||
inputBuffers (1, 1), | |||||
outputBuffers (1, 1), | |||||
callback (nullptr) | callback (nullptr) | ||||
{ | { | ||||
if (outputDeviceIndex_ >= 0) | if (outputDeviceIndex_ >= 0) | ||||
@@ -871,8 +869,8 @@ private: | |||||
bool isStarted; | bool isStarted; | ||||
String lastError; | String lastError; | ||||
OwnedArray <DSoundInternalInChannel> inChans; | |||||
OwnedArray <DSoundInternalOutChannel> outChans; | |||||
OwnedArray<DSoundInternalInChannel> inChans; | |||||
OwnedArray<DSoundInternalOutChannel> outChans; | |||||
WaitableEvent startEvent; | WaitableEvent startEvent; | ||||
int bufferSizeSamples; | int bufferSizeSamples; | ||||
@@ -26,7 +26,6 @@ AudioSourcePlayer::AudioSourcePlayer() | |||||
: source (nullptr), | : source (nullptr), | ||||
sampleRate (0), | sampleRate (0), | ||||
bufferSize (0), | bufferSize (0), | ||||
tempBuffer (2, 8), | |||||
lastGain (1.0f), | lastGain (1.0f), | ||||
gain (1.0f) | gain (1.0f) | ||||
{ | { | ||||
@@ -104,7 +104,6 @@ class FlacReader : public AudioFormatReader | |||||
public: | public: | ||||
FlacReader (InputStream* const in) | FlacReader (InputStream* const in) | ||||
: AudioFormatReader (in, flacFormatName), | : AudioFormatReader (in, flacFormatName), | ||||
reservoir (2, 0), | |||||
reservoirStart (0), | reservoirStart (0), | ||||
samplesInReservoir (0), | samplesInReservoir (0), | ||||
scanningForLength (false) | scanningForLength (false) | ||||
@@ -106,7 +106,6 @@ class OggReader : public AudioFormatReader | |||||
public: | public: | ||||
OggReader (InputStream* const inp) | OggReader (InputStream* const inp) | ||||
: AudioFormatReader (inp, oggFormatName), | : AudioFormatReader (inp, oggFormatName), | ||||
reservoir (2, 4096), | |||||
reservoirStart (0), | reservoirStart (0), | ||||
samplesInReservoir (0) | samplesInReservoir (0) | ||||
{ | { | ||||
@@ -140,8 +139,7 @@ public: | |||||
bitsPerSample = 16; | bitsPerSample = 16; | ||||
sampleRate = info->rate; | sampleRate = info->rate; | ||||
reservoir.setSize ((int) numChannels, | |||||
(int) jmin (lengthInSamples, (int64) reservoir.getNumSamples())); | |||||
reservoir.setSize ((int) numChannels, (int) jmin (lengthInSamples, (int64) 4096)); | |||||
} | } | ||||
} | } | ||||
@@ -923,9 +923,7 @@ void AudioProcessorGraph::Node::setParentGraph (AudioProcessorGraph* const graph | |||||
//============================================================================== | //============================================================================== | ||||
AudioProcessorGraph::AudioProcessorGraph() | AudioProcessorGraph::AudioProcessorGraph() | ||||
: lastNodeId (0), | : lastNodeId (0), | ||||
renderingBuffers (1, 1), | |||||
currentAudioInputBuffer (nullptr), | currentAudioInputBuffer (nullptr), | ||||
currentAudioOutputBuffer (1, 1), | |||||
currentMidiInputBuffer (nullptr) | currentMidiInputBuffer (nullptr) | ||||
{ | { | ||||
} | } | ||||
@@ -28,8 +28,7 @@ AudioProcessorPlayer::AudioProcessorPlayer() | |||||
blockSize (0), | blockSize (0), | ||||
isPrepared (false), | isPrepared (false), | ||||
numInputChans (0), | numInputChans (0), | ||||
numOutputChans (0), | |||||
tempBuffer (1, 1) | |||||
numOutputChans (0) | |||||
{ | { | ||||
} | } | ||||