Skip to content

Instantly share code, notes, and snippets.

@GRGSIBERIA
Created July 19, 2016 05:22
Show Gist options
  • Save GRGSIBERIA/5c181cdd3cff6ce64e18f13cc2a988ac to your computer and use it in GitHub Desktop.
Save GRGSIBERIA/5c181cdd3cff6ce64e18f13cc2a988ac to your computer and use it in GitHub Desktop.
#pragma once
#include <Siv3D.hpp>
#include <TinyASIO.hpp>
namespace inst
{
class RecController : public asio::ControllerBase
{
static asio::InputBuffer *inbuf;
static asio::OutputBuffer *outbufR, *outbufL;
static void BufferSwitch(long index, asio::ASIOBool)
{
void* input = inbuf->GetBuffer(index);
void* outR = outbufR->GetBuffer(index);
void* outL = outbufL->GetBuffer(index);
memcpy(outR, input, BufferSize());
memcpy(outL, input, BufferSize());
inbuf->Store(input, BufferLength());
}
public:
RecController(const String& cntName, const int inputCh, const int outputR, const int outputL)
: ControllerBase(cntName.narrow())
{
auto& mng = asio::Driver::Get().ChannelManager();
auto& input = mng.Inputs(inputCh);
auto& outR = mng.Outputs(outputR);
auto& outL = mng.Outputs(outputL);
CreateBuffer({ input, outR, outL }, &BufferSwitch);
inbuf = &bufferManager->Inputs(0);
outbufR = &bufferManager->Outputs(0);
outbufL = &bufferManager->Outputs(1);
}
asio::StreamPtr Fetch()
{
return inbuf->Fetch();
}
};
asio::InputBuffer *RecController::inbuf = nullptr;
asio::OutputBuffer *RecController::outbufL = nullptr;
asio::OutputBuffer *RecController::outbufR = nullptr;
typedef std::shared_ptr<inst::RecController> RecControllerPtr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment