Created
July 19, 2016 05:22
-
-
Save GRGSIBERIA/5c181cdd3cff6ce64e18f13cc2a988ac to your computer and use it in GitHub Desktop.
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
#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