Skip to content

Commit 9b984c5

Browse files
fix: fixed my processor node implementation in the guide and template
1 parent c9cfa78 commit 9b984c5

3 files changed

Lines changed: 8 additions & 19 deletions

File tree

packages/audiodocs/docs/guides/create-your-own-effect.mdx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ namespace audioapi {
4949

5050
class MyProcessorNode : public AudioNode {
5151
public:
52-
explicit MyProcessorNode(const std::shared_ptr<BaseAudioContext> &context, );
52+
explicit MyProcessorNode(const std::shared_ptr<BaseAudioContext> &context);
5353

5454
protected:
55-
std::shared_ptr<DSPAudioBuffer>
56-
processNode(const std::shared_ptr<DSPAudioBuffer> &buffer,
57-
int framesToProcess) override;
55+
void processNode(int framesToProcess) override;
5856

5957
// highlight-start
6058
private:
@@ -76,14 +74,11 @@ private:
7674
namespace audioapi {
7775
MyProcessorNode::MyProcessorNode(const std::shared_ptr<BaseAudioContext> &context)
7876
//highlight-next-line
79-
: AudioNode(context), gain(0.5) {
80-
isInitialized_.store(true, std::memory_order_release);
81-
}
77+
: AudioNode(context), gain(0.5) {}
8278

83-
std::shared_ptr<DSPAudioBuffer> MyProcessorNode::processNode(const std::shared_ptr<DSPAudioBuffer> &buffer,
84-
int framesToProcess) {
79+
void MyProcessorNode::processNode(int framesToProcess) {
8580
// highlight-start
86-
for (int channel = 0; channel < buffer->getNumberOfChannels(); ++channel) {
81+
for (int channel = 0; channel < audioBuffer_->getNumberOfChannels(); ++channel) {
8782
auto *audioArray = bus->getChannel(channel);
8883
for (size_t i = 0; i < framesToProcess; ++i) {
8984
// Apply gain to each sample in the audio array

packages/custom-node-generator/templates/basic/shared/MyProcessorNode.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
namespace audioapi {
44
MyProcessorNode::MyProcessorNode(
55
const std::shared_ptr<BaseAudioContext> &context)
6-
: AudioNode(context) {
7-
isInitialized_.store(true, std::memory_order_release);
8-
}
6+
: AudioNode(context) {}
97

10-
std::shared_ptr<DSPAudioBuffer>
11-
MyProcessorNode::processNode(const std::shared_ptr<DSPAudioBuffer> &buffer,
12-
int framesToProcess) {
8+
void MyProcessorNode::processNode(int framesToProcess) {
139
// put your processing logic here
1410
}
1511
} // namespace audioapi

packages/custom-node-generator/templates/basic/shared/MyProcessorNode.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class MyProcessorNode : public AudioNode {
1010
explicit MyProcessorNode(const std::shared_ptr<BaseAudioContext> &context);
1111

1212
protected:
13-
std::shared_ptr<DSPAudioBuffer>
14-
processNode(const std::shared_ptr<DSPAudioBuffer> &buffer,
15-
int framesToProcess) override;
13+
void processNode(int framesToProcess) override;
1614
};
1715
} // namespace audioapi

0 commit comments

Comments
 (0)