-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include "signalflow/core/constants.h" | ||
#include "signalflow/node/node.h" | ||
|
||
#include <list> | ||
|
||
namespace signalflow | ||
{ | ||
|
||
/**--------------------------------------------------------------------------------* | ||
* Offsets the input by a specified number of channels. With an N-channel input | ||
* and an offset of M, the output will have M+N channels. | ||
*---------------------------------------------------------------------------------*/ | ||
class ChannelOffset : public UnaryOpNode | ||
{ | ||
|
||
public: | ||
ChannelOffset(int offset = 0, NodeRef input = nullptr); | ||
|
||
virtual void process(Buffer &out, int num_frames); | ||
|
||
private: | ||
PropertyRef offset; | ||
}; | ||
|
||
REGISTER(ChannelOffset, "channel-offset") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "signalflow/node/operators/channel-offset.h" | ||
|
||
namespace signalflow | ||
{ | ||
|
||
ChannelOffset::ChannelOffset(int offset, NodeRef input) | ||
: UnaryOpNode(input), offset(offset) | ||
{ | ||
if (!input) | ||
{ | ||
throw std::runtime_error("ChannelOffset: No input specified"); | ||
} | ||
|
||
this->name = "channel-offset"; | ||
|
||
this->create_property("offset", this->offset); | ||
|
||
this->set_channels(this->input->get_num_output_channels(), | ||
this->input->get_num_output_channels() + this->offset->int_value()); | ||
} | ||
|
||
void ChannelOffset::process(Buffer &out, int num_frames) | ||
{ | ||
int output_channel = 0; | ||
for (int channel = 0; channel < this->offset->int_value(); channel++) | ||
{ | ||
memset(out[output_channel], 0, num_frames * sizeof(sample)); | ||
output_channel++; | ||
} | ||
for (int channel = 0; channel < this->input->get_num_output_channels(); channel++) | ||
{ | ||
memcpy(out[output_channel], this->input->out[channel], num_frames * sizeof(sample)); | ||
output_channel++; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters