Skip to content

Commit adf307f

Browse files
committed
Update include
1 parent aea423a commit adf307f

File tree

118 files changed

+15340
-935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+15340
-935
lines changed

include/LabSound/LabSound.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
#define LABSOUND_H
88

99
// WebAudio Public API
10+
#include "LabSound/core/AudioDevice.h"
11+
#include "LabSound/core/NullDeviceNode.h"
12+
#include "LabSound/core/AudioHardwareDeviceNode.h"
13+
#include "LabSound/core/AudioHardwareInputNode.h"
1014
#include "LabSound/core/AnalyserNode.h"
1115
#include "LabSound/core/AudioBasicInspectorNode.h"
1216
#include "LabSound/core/AudioBasicProcessorNode.h"
1317
#include "LabSound/core/AudioContext.h"
14-
#include "LabSound/core/AudioDevice.h"
15-
#include "LabSound/core/AudioHardwareDeviceNode.h"
16-
#include "LabSound/core/AudioHardwareInputNode.h"
1718
#include "LabSound/core/AudioListener.h"
18-
#include "LabSound/core/AudioNode.h"
1919
#include "LabSound/core/AudioNodeInput.h"
2020
#include "LabSound/core/AudioNodeOutput.h"
21-
#include "LabSound/core/AudioParam.h"
2221
#include "LabSound/core/AudioScheduledSourceNode.h"
2322
#include "LabSound/core/BiquadFilterNode.h"
2423
#include "LabSound/core/ChannelMergerNode.h"
@@ -27,7 +26,6 @@
2726
#include "LabSound/core/DelayNode.h"
2827
#include "LabSound/core/DynamicsCompressorNode.h"
2928
#include "LabSound/core/GainNode.h"
30-
#include "LabSound/core/NullDeviceNode.h"
3129
#include "LabSound/core/OscillatorNode.h"
3230
#include "LabSound/core/PannerNode.h"
3331
#include "LabSound/core/SampledAudioNode.h"
@@ -43,32 +41,34 @@
4341
#include "LabSound/extended/GranulationNode.h"
4442
#include "LabSound/extended/NoiseNode.h"
4543
#include "LabSound/extended/PWMNode.h"
46-
#include "LabSound/extended/PdNode.h"
4744
#include "LabSound/extended/PeakCompNode.h"
4845
#include "LabSound/extended/PingPongDelayNode.h"
4946
#include "LabSound/extended/PowerMonitorNode.h"
5047
#include "LabSound/extended/RealtimeAnalyser.h"
5148
#include "LabSound/extended/RecorderNode.h"
52-
#include "LabSound/extended/SampledInstrumentNode.h"
53-
#include "LabSound/extended/SfxrNode.h"
5449
#include "LabSound/extended/SpatializationNode.h"
5550
#include "LabSound/extended/SpectralMonitorNode.h"
5651
#include "LabSound/extended/SupersawNode.h"
57-
58-
#include <memory>
52+
#include "LabSound/extended/SfxrNode.h"
53+
#include "LabSound/extended/PdNode.h"
54+
#include "LabSound/extended/PolyBLEPNode.h"
5955

6056
namespace lab
6157
{
62-
const std::vector<AudioDeviceInfo> MakeAudioDeviceList();
63-
const uint32_t GetDefaultOutputAudioDeviceIndex();
64-
const uint32_t GetDefaultInputAudioDeviceIndex();
58+
const std::vector<AudioDeviceInfo> MakeAudioDeviceList();
59+
const AudioDeviceIndex GetDefaultOutputAudioDeviceIndex();
60+
const AudioDeviceIndex GetDefaultInputAudioDeviceIndex();
61+
62+
std::unique_ptr<AudioContext> MakeRealtimeAudioContext(const AudioStreamConfig outputConfig, const AudioStreamConfig inputConfig);
63+
std::unique_ptr<AudioContext> MakeOfflineAudioContext(const AudioStreamConfig offlineConfig, double recordTimeMilliseconds);
6564

66-
std::unique_ptr<AudioContext> MakeRealtimeAudioContext(const AudioStreamConfig outputConfig, const AudioStreamConfig inputConfig);
67-
std::unique_ptr<AudioContext> MakeOfflineAudioContext(const AudioStreamConfig offlineConfig, float recordTimeMilliseconds);
65+
std::shared_ptr<AudioHardwareInputNode> MakeAudioHardwareInputNode(ContextRenderLock & r);
6866

69-
std::shared_ptr<AudioHardwareInputNode> MakeAudioHardwareInputNode(ContextRenderLock & r);
67+
AudioStreamConfig GetDefaultInputAudioDeviceConfiguration();
68+
AudioStreamConfig GetDefaultOutputAudioDeviceConfiguration();
7069

71-
char const * const * const AudioNodeNames();
70+
char const * const * const AudioNodeNames();
7271
}
7372

7473
#endif
74+

include/LabSound/core/AnalyserNode.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AudioSetting;
2020
//
2121
class AnalyserNode : public AudioBasicInspectorNode
2222
{
23-
void shared_construction(size_t fftSize);
23+
void shared_construction(int fftSize);
2424

2525
virtual double tailTime(ContextRenderLock & r) const override { return 0; }
2626
virtual double latencyTime(ContextRenderLock & r) const override { return 0; }
@@ -29,14 +29,17 @@ class AnalyserNode : public AudioBasicInspectorNode
2929
Detail * _detail = nullptr;
3030

3131
public:
32-
AnalyserNode();
33-
AnalyserNode(size_t fftSize);
32+
AnalyserNode(AudioContext & ac);
33+
AnalyserNode(AudioContext & ac, int fftSize);
3434
virtual ~AnalyserNode();
3535

36-
virtual void process(ContextRenderLock &, size_t framesToProcess) override;
36+
static const char* static_name() { return "Analyser"; }
37+
virtual const char* name() const override { return static_name(); }
38+
39+
virtual void process(ContextRenderLock &, int bufferSize) override;
3740
virtual void reset(ContextRenderLock &) override;
3841

39-
void setFftSize(ContextRenderLock &, size_t fftSize);
42+
void setFftSize(ContextRenderLock &, int fftSize);
4043
size_t fftSize() const;
4144

4245
// a value large enough to hold all the data return from get*FrequencyData

include/LabSound/core/AudioBasicInspectorNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ namespace lab
2525
class AudioBasicInspectorNode : public AudioNode
2626
{
2727
public:
28-
AudioBasicInspectorNode(int outputChannelCount);
29-
virtual ~AudioBasicInspectorNode() {}
28+
AudioBasicInspectorNode(AudioContext & ac, int outputChannelCount);
29+
virtual ~AudioBasicInspectorNode() = default;
3030

3131
// AudioNode
32-
virtual void pullInputs(ContextRenderLock & r, size_t framesToProcess) override;
32+
virtual void pullInputs(ContextRenderLock & r, int bufferSize) override;
3333
virtual void checkNumberOfChannelsForInput(ContextRenderLock &, AudioNodeInput *) override;
3434
};
3535

include/LabSound/core/AudioBasicProcessorNode.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class AudioNodeInput;
2020
class AudioBasicProcessorNode : public AudioNode
2121
{
2222
public:
23-
AudioBasicProcessorNode();
24-
virtual ~AudioBasicProcessorNode() {}
23+
AudioBasicProcessorNode(AudioContext &);
24+
virtual ~AudioBasicProcessorNode() = default;
2525

2626
// AudioNode
27-
virtual void process(ContextRenderLock &, size_t framesToProcess) override;
28-
virtual void pullInputs(ContextRenderLock &, size_t framesToProcess) override;
27+
virtual void process(ContextRenderLock &, int bufferSize) override;
28+
virtual void pullInputs(ContextRenderLock &, int bufferSize) override;
2929
virtual void reset(ContextRenderLock &) override;
3030
virtual void initialize() override;
3131
virtual void uninitialize() override;
@@ -34,7 +34,7 @@ class AudioBasicProcessorNode : public AudioNode
3434
virtual void checkNumberOfChannelsForInput(ContextRenderLock &, AudioNodeInput *) override;
3535

3636
// Returns the number of channels for both the input and the output.
37-
size_t numberOfChannels();
37+
int numberOfChannels();
3838

3939
protected:
4040
virtual double tailTime(ContextRenderLock & r) const override;

include/LabSound/core/AudioBus.h

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ class AudioBus
3333
// allocate indicates whether or not to initially have the AudioChannels created with managed storage.
3434
// Normal usage is to pass true here, in which case the AudioChannels will memory-manage their own storage.
3535
// If allocate is false then setChannelMemory() has to be called later on for each channel before the AudioBus is useable...
36-
AudioBus(size_t numberOfChannels, size_t length, bool allocate = true);
36+
AudioBus(int numberOfChannels, int length, bool allocate = true);
3737

3838
// Tells the given channel to use an externally allocated buffer.
39-
void setChannelMemory(size_t channelIndex, float * storage, size_t length);
39+
void setChannelMemory(int channelIndex, float * storage, int length);
4040

4141
// Channels
42-
size_t numberOfChannels() const { return m_channels.size(); }
42+
int numberOfChannels() const { return static_cast<int>(m_channels.size()); }
4343

4444
// Use this when looping over channels
45-
AudioChannel * channel(size_t channel) { return m_channels[channel].get(); }
45+
AudioChannel * channel(int channel) { return m_channels[channel].get(); }
4646

47-
const AudioChannel * channel(size_t channel) const
47+
const AudioChannel * channel(int channel) const
4848
{
4949
return const_cast<AudioBus *>(this)->m_channels[channel].get();
5050
}
@@ -54,11 +54,11 @@ class AudioBus
5454
const AudioChannel * channelByType(Channel type) const;
5555

5656
// Number of sample-frames
57-
size_t length() const { return m_length; }
57+
int length() const { return m_length; }
5858

5959
// resizeSmaller() can only be called with a new length <= the current length.
6060
// The data stored in the bus will remain undisturbed.
61-
void resizeSmaller(size_t newLength);
61+
void resizeSmaller(int newLength);
6262

6363
// Sample-rate : 0.0 if unknown or "don't care"
6464
float sampleRate() const { return m_sampleRate; }
@@ -76,21 +76,6 @@ class AudioBus
7676
// Returns true if the channel count and frame-size match.
7777
bool topologyMatches(const AudioBus & sourceBus) const;
7878

79-
// Creates a new buffer from a range in the source buffer.
80-
// 0 may be returned if the range does not fit in the sourceBuffer
81-
static std::unique_ptr<AudioBus> createBufferFromRange(const AudioBus * sourceBus, size_t startFrame, size_t endFrame);
82-
83-
// Creates a new AudioBus by sample-rate converting sourceBus to the newSampleRate.
84-
// setSampleRate() must have been previously called on sourceBus.
85-
static std::unique_ptr<AudioBus> createBySampleRateConverting(const AudioBus * sourceBus, bool mixToMono, float newSampleRate);
86-
87-
// Creates a new AudioBus by mixing all the channels down to mono.
88-
// If sourceBus is already mono, then the returned AudioBus will simply be a copy.
89-
static std::unique_ptr<AudioBus> createByMixingToMono(const AudioBus * sourceBus);
90-
91-
// Creates a new AudioBus by cloning an existing one
92-
static std::unique_ptr<AudioBus> createByCloning(const AudioBus * sourceBus);
93-
9479
// Scales all samples by the same amount.
9580
void scale(float scale);
9681

@@ -110,7 +95,7 @@ class AudioBus
11095
void copyWithGainFrom(const AudioBus & sourceBus, float * lastMixGain, float targetGain);
11196

11297
// Copies the sourceBus by scaling with sample-accurate gain values.
113-
void copyWithSampleAccurateGainValuesFrom(const AudioBus & sourceBus, float * gainValues, size_t numberOfGainValues);
98+
void copyWithSampleAccurateGainValuesFrom(const AudioBus & sourceBus, float * gainValues, int numberOfGainValues);
11499

115100
// Returns maximum absolute value across all channels (useful for normalization).
116101
float maxAbsValue() const;
@@ -120,7 +105,25 @@ class AudioBus
120105

121106
bool isFirstTime() { return m_isFirstTime; }
122107

108+
// Static Functions
109+
110+
// Creates a new buffer from a range in the source buffer.
111+
// 0 may be returned if the range does not fit in the sourceBuffer
112+
static std::unique_ptr<AudioBus> createBufferFromRange(const AudioBus * sourceBus, int startFrame, int endFrame);
113+
114+
// Creates a new AudioBus by sample-rate converting sourceBus to the newSampleRate.
115+
// setSampleRate() must have been previously called on sourceBus.
116+
static std::unique_ptr<AudioBus> createBySampleRateConverting(const AudioBus * sourceBus, bool mixToMono, float newSampleRate);
117+
118+
// Creates a new AudioBus by mixing all the channels down to mono.
119+
// If sourceBus is already mono, then the returned AudioBus will simply be a copy.
120+
static std::unique_ptr<AudioBus> createByMixingToMono(const AudioBus * sourceBus);
121+
122+
// Creates a new AudioBus by cloning an existing one
123+
static std::unique_ptr<AudioBus> createByCloning(const AudioBus * sourceBus);
124+
123125
protected:
126+
124127
AudioBus() = default;
125128

126129
void speakersCopyFrom(const AudioBus &);
@@ -130,18 +133,14 @@ class AudioBus
130133
void speakersSumFrom5_1_ToMono(const AudioBus &);
131134
void speakersSumFrom7_1_ToMono(const AudioBus &);
132135

133-
size_t m_length = 0;
134-
135-
std::vector<std::unique_ptr<AudioChannel>> m_channels;
136-
137-
int m_layout = LayoutCanonical;
138-
139-
float m_busGain = 1.0f;
140-
141136
std::unique_ptr<AudioFloatArray> m_dezipperGainValues;
137+
std::vector<std::unique_ptr<AudioChannel>> m_channels;
142138

143139
bool m_isFirstTime = true;
144140
float m_sampleRate = 0.0f;
141+
float m_busGain = 1.0f;
142+
int m_layout = LayoutCanonical;
143+
int m_length = 0;
145144
};
146145

147146
} // lab

include/LabSound/core/AudioChannel.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class AudioChannel
2222
// Memory can be externally referenced, or can be internally allocated with an AudioFloatArray.
2323

2424
// Reference an external buffer.
25-
AudioChannel(float * storage, size_t length)
25+
AudioChannel(float * storage, int length)
2626
: m_length(length)
2727
, m_rawPointer(storage)
2828
, m_silent(false)
2929
{
3030
}
3131

3232
// Manage storage for us.
33-
explicit AudioChannel(size_t length)
33+
explicit AudioChannel(int length)
3434
: m_length(length)
3535
, m_silent(true)
3636
{
@@ -46,7 +46,7 @@ class AudioChannel
4646

4747
// Redefine the memory for this channel.
4848
// storage represents external memory not managed by this object.
49-
void set(float * storage, size_t length)
49+
void set(float * storage, int length)
5050
{
5151
m_memBuffer.reset(); // clean up managed storage
5252
m_rawPointer = storage;
@@ -55,11 +55,11 @@ class AudioChannel
5555
}
5656

5757
// How many sample-frames do we contain?
58-
size_t length() const { return m_length; }
58+
int length() const { return m_length; }
5959

6060
// resizeSmaller() can only be called with a new length <= the current length.
6161
// The data stored in the bus will remain undisturbed.
62-
void resizeSmaller(size_t newLength);
62+
void resizeSmaller(int newLength);
6363

6464
// Direct access to PCM sample data. Non-const accessor clears silent flag.
6565
float * mutableData()
@@ -102,7 +102,7 @@ class AudioChannel
102102
void copyFrom(const AudioChannel * sourceChannel);
103103

104104
// Copies the given range from the source channel.
105-
void copyFromRange(const AudioChannel * sourceChannel, size_t startFrame, size_t endFrame);
105+
void copyFromRange(const AudioChannel * sourceChannel, int startFrame, int endFrame);
106106

107107
// Sums (with unity gain) from the source channel.
108108
void sumFrom(const AudioChannel * sourceChannel);
@@ -111,7 +111,7 @@ class AudioChannel
111111
float maxAbsValue() const;
112112

113113
private:
114-
size_t m_length = 0;
114+
int m_length = 0;
115115
float * m_rawPointer = nullptr;
116116
std::unique_ptr<AudioFloatArray> m_memBuffer;
117117
bool m_silent = true;

0 commit comments

Comments
 (0)