Skip to content

Commit 72531fc

Browse files
authored
Merge branch 'main' into dev/audio_device_panel
2 parents 520fca6 + a118d14 commit 72531fc

51 files changed

Lines changed: 3698 additions & 589 deletions

File tree

Some content is hidden

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

examples/audiograph/source/AudioGraphApp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ void AudioGraphApp::audioDeviceAboutToStart (yup::AudioIODevice* device)
203203
nodeRegistry.setPluginScanner (scanner.get(), ctx);
204204
#endif
205205

206-
graph->prepareToPlay (static_cast<float> (device->getCurrentSampleRate()),
207-
device->getCurrentBufferSizeSamples());
206+
const auto spec = yup::AudioSpec (
207+
static_cast<float> (device->getCurrentSampleRate()),
208+
device->getCurrentBufferSizeSamples());
209+
graph->prepareToPlay (spec);
208210
}
209211

210212
void AudioGraphApp::audioDeviceStopped()

examples/audiograph/source/nodes/AnalyzerNodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class OscilloscopeProcessor final : public yup::AudioProcessor
155155
analyzerState.setOverlapFactor (0.0f);
156156
}
157157

158-
void prepareToPlay (float, int) override
158+
void prepareToPlay (const yup::AudioSpec&) override
159159
{
160160
analyzerState.reset();
161161
peakLevel.store (0.0f, std::memory_order_relaxed);
@@ -379,7 +379,7 @@ class SpectrumAnalyzerProcessor final : public yup::AudioProcessor
379379
analyzerState.setOverlapFactor (0.5f);
380380
}
381381

382-
void prepareToPlay (float, int) override
382+
void prepareToPlay (const yup::AudioSpec&) override
383383
{
384384
analyzerState.reset();
385385
peakLevel.store (0.0f, std::memory_order_relaxed);

examples/audiograph/source/nodes/DistortionNodes.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ class TanhDistortionProcessor final : public yup::AudioProcessor
4646
updateLatency();
4747
}
4848

49-
void prepareToPlay (float newSampleRate, int maxBlockSize) override
49+
void prepareToPlay (const yup::AudioSpec& spec) override
5050
{
51-
const auto sampleRate = yup::jmax (1.0f, newSampleRate);
52-
const auto blockSize = yup::jmax (1, maxBlockSize);
51+
const auto sampleRate = yup::jmax (1.0f, spec.sampleRate);
52+
const auto blockSize = yup::jmax (1, spec.maxBlockSize);
5353

5454
oversampler2x.prepare (sampleRate, maximumOversampledChannels, blockSize);
5555
oversampler4x.prepare (sampleRate, maximumOversampledChannels, blockSize);
5656
oversampler8x.prepare (sampleRate, maximumOversampledChannels, blockSize);
5757
oversamplersPrepared = true;
5858

59-
smoothedDrive.reset (newSampleRate, 0.02);
59+
smoothedDrive.reset (sampleRate, 0.02);
6060
smoothedDrive.setCurrentAndTargetValue (getDrive());
6161

6262
updateLatency();
@@ -279,14 +279,14 @@ class BlunterSoftClipperProcessor final : public yup::AudioProcessor
279279
addParameter (output);
280280
}
281281

282-
void prepareToPlay (float newSampleRate, int maxBlockSize) override
282+
void prepareToPlay (const yup::AudioSpec& spec) override
283283
{
284284
for (auto& clipper : clippers)
285-
clipper.prepare (newSampleRate, maxBlockSize);
285+
clipper.prepare (spec.sampleRate, spec.maxBlockSize);
286286

287-
smoothedDrive.reset (newSampleRate, 0.02);
287+
smoothedDrive.reset (spec.sampleRate, 0.02);
288288
smoothedDrive.setCurrentAndTargetValue (getDrive());
289-
smoothedOutput.reset (newSampleRate, 0.02);
289+
smoothedOutput.reset (spec.sampleRate, 0.02);
290290
smoothedOutput.setCurrentAndTargetValue (getOutput());
291291
}
292292

@@ -592,14 +592,14 @@ class AaIirHardClipperProcessor final : public yup::AudioProcessor
592592
addParameter (output);
593593
}
594594

595-
void prepareToPlay (float newSampleRate, int maxBlockSize) override
595+
void prepareToPlay (const yup::AudioSpec& spec) override
596596
{
597597
for (auto& clipper : clippers)
598-
clipper.prepare (static_cast<double> (newSampleRate), maxBlockSize);
598+
clipper.prepare (static_cast<double> (spec.sampleRate), spec.maxBlockSize);
599599

600-
smoothedDrive.reset (newSampleRate, 0.02);
600+
smoothedDrive.reset (spec.sampleRate, 0.02);
601601
smoothedDrive.setCurrentAndTargetValue (getDrive());
602-
smoothedOutput.reset (newSampleRate, 0.02);
602+
smoothedOutput.reset (spec.sampleRate, 0.02);
603603
smoothedOutput.setCurrentAndTargetValue (getOutput());
604604
}
605605

examples/audiograph/source/nodes/FractionalDelayNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class FractionalDelayProcessor final : public yup::AudioProcessor
4949
addParameter (dryWet);
5050
}
5151

52-
void prepareToPlay (float newSampleRate, int) override
52+
void prepareToPlay (const yup::AudioSpec& spec) override
5353
{
54-
sampleRate.store (yup::jmax (1.0f, newSampleRate), std::memory_order_relaxed);
54+
sampleRate.store (yup::jmax (1.0f, spec.sampleRate), std::memory_order_relaxed);
5555

5656
const int maxDelaySamples = yup::roundToInt (delayMillisecondsToSamples (maximumDelayMilliseconds));
5757
for (auto& delayLine : delayLines)

examples/audiograph/source/nodes/GainNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class GainProcessor final : public yup::AudioProcessor
3636
addParameter (gain);
3737
}
3838

39-
void prepareToPlay (float newSampleRate, int) override
39+
void prepareToPlay (const yup::AudioSpec& spec) override
4040
{
41-
smoothedGain.reset (newSampleRate, 0.02);
41+
smoothedGain.reset (spec.sampleRate, 0.02);
4242
smoothedGain.setCurrentAndTargetValue (getGain());
4343
}
4444

examples/audiograph/source/nodes/LatencyNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class LatencyProcessor final : public yup::AudioProcessor
4141
reportUpdatedLatency();
4242
}
4343

44-
void prepareToPlay (float newSampleRate, int maxBlockSize) override
44+
void prepareToPlay (const yup::AudioSpec& spec) override
4545
{
46-
sampleRate.store (yup::jmax (1.0f, newSampleRate), std::memory_order_relaxed);
46+
sampleRate.store (yup::jmax (1.0f, spec.sampleRate), std::memory_order_relaxed);
4747

4848
const int maxDelaySamples = delayMillisecondsToSamples (maximumDelayMilliseconds);
49-
history.setSize (2, maxDelaySamples + yup::jmax (1, maxBlockSize) + 1);
49+
history.setSize (2, maxDelaySamples + yup::jmax (1, spec.maxBlockSize) + 1);
5050
history.clear();
5151

5252
writePosition = 0;

examples/audiograph/source/nodes/NodeRegistry.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "PluginNodeView.h"
3737
#include "RecorderNode.h"
3838
#include "SamplePlayerNode.h"
39+
#include "SpectralPassthroughNode.h"
3940
#include "SubgraphNode.h"
4041

4142
//==============================================================================
@@ -87,6 +88,9 @@ class NodeRegistry
8788
/** Stable factory key for the built-in recorder node. */
8889
static constexpr const char* recorderIdentifier = "internal.recorder";
8990

91+
/** Stable factory key for the built-in spectral passthrough node. */
92+
static constexpr const char* spectralPassthroughIdentifier = "internal.spectralPassthrough";
93+
9094
/** Stable factory key for the built-in recursive subgraph node. */
9195
static constexpr const char* subgraphIdentifier = "internal.subgraph";
9296

@@ -305,6 +309,21 @@ class NodeRegistry
305309
}
306310
};
307311

312+
entries[spectralPassthroughIdentifier] = {
313+
[] (const yup::AudioGraphNodeProperties&) -> yup::ResultValue<std::unique_ptr<yup::AudioProcessor>>
314+
{
315+
return yup::makeResultValueOk (std::make_unique<SpectralPassthroughProcessor>());
316+
},
317+
[] (yup::AudioGraphNodeID nodeID, yup::AudioProcessor* proc, yup::AudioGraphProcessor*) -> std::unique_ptr<yup::AudioGraphNodeView>
318+
{
319+
auto* spectral = dynamic_cast<SpectralPassthroughProcessor*> (proc);
320+
if (spectral == nullptr)
321+
return nullptr;
322+
323+
return std::make_unique<SpectralPassthroughNodeView> (nodeID, *spectral);
324+
}
325+
};
326+
308327
entries[subgraphIdentifier] = {
309328
[this] (const yup::AudioGraphNodeProperties& props) -> yup::ResultValue<std::unique_ptr<yup::AudioProcessor>>
310329
{
@@ -528,6 +547,7 @@ class NodeRegistry
528547
oscilloscopeIdentifier,
529548
recorderIdentifier,
530549
samplePlayerIdentifier,
550+
spectralPassthroughIdentifier,
531551
spectrumAnalyzerIdentifier,
532552
subgraphIdentifier,
533553
svfIdentifier,
@@ -581,6 +601,9 @@ class NodeRegistry
581601
if (id == recorderIdentifier)
582602
return "Recorder";
583603

604+
if (id == spectralPassthroughIdentifier)
605+
return "Spectral Passthrough";
606+
584607
if (id == subgraphIdentifier)
585608
return "Subgraph";
586609

examples/audiograph/source/nodes/OscillatorNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class OscillatorProcessor final : public yup::AudioProcessor
4141
addParameter (sweepEnabled);
4242
}
4343

44-
void prepareToPlay (float newSampleRate, int) override
44+
void prepareToPlay (const yup::AudioSpec& spec) override
4545
{
46-
sampleRate = newSampleRate;
46+
sampleRate = spec.sampleRate;
4747
phase = 0.0;
4848
sweepPositionSeconds = 0.0;
4949
wasSweepActive = false;

examples/audiograph/source/nodes/RecorderNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class RecorderProcessor final : public yup::AudioProcessor
8383
fifoBuffer.resize (fifoCapacity);
8484
}
8585

86-
void prepareToPlay (float sampleRate, int) override
86+
void prepareToPlay (const yup::AudioSpec& spec) override
8787
{
88-
currentSampleRate.store (sampleRate > 0.0f ? sampleRate : 44100.0f, std::memory_order_relaxed);
88+
currentSampleRate.store (spec.sampleRate > 0.0f ? spec.sampleRate : 44100.0f, std::memory_order_relaxed);
8989
}
9090

9191
void releaseResources() override {}

examples/audiograph/source/nodes/SamplePlayerNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class SamplePlayerProcessor final : public yup::AudioProcessor
4646
{
4747
}
4848

49-
void prepareToPlay (float newSampleRate, int) override
49+
void prepareToPlay (const yup::AudioSpec& spec) override
5050
{
51-
playbackSampleRate.store (newSampleRate > 0.0f ? newSampleRate : 44100.0f, std::memory_order_relaxed);
51+
playbackSampleRate.store (spec.sampleRate > 0.0f ? spec.sampleRate : 44100.0f, std::memory_order_relaxed);
5252
}
5353

5454
void releaseResources() override {}

0 commit comments

Comments
 (0)