-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInputBackController.hpp
More file actions
87 lines (75 loc) · 2.64 KB
/
InputBackController.hpp
File metadata and controls
87 lines (75 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***********************************************************************
Copyright(C) 2014 Eiichi Takebuchi
TinyASIO is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
TinyASIO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TinyASIO.If not, see <http://www.gnu.org/licenses/>
***********************************************************************/
#pragma once
#include "ControllerBase.hpp"
namespace asio
{
/*
*入力信号を出力にそのまま返す
*/
class InputBackController : public ControllerBase
{
private:
static void BufferSwitch(long index, long)
{
void* outBuf = GetOutputMemory(0, index);
void* inBuf = GetInputMemory(0, index);
// 入力バッファの内容を出力バッファに書き換えたあと,
// 入力バッファの内容を入力ストリームに転送する
TransferMemoryAsStored(Input(0), inBuf, outBuf);
}
public:
/**
* 指定したチャンネルからコントローラを生成する
* @param[in] asioDriverName ASIOのドライバ名
* @param[in] inputChannel 入力を受け付けるチャンネル
* @param[in] outputChannel 入力された内容を流し込みたい出力チャンネル
*/
InputBackController(const std::string& asioDriverName, const InputChannel& inputChannel, const OutputChannel& outputChannel)
: ControllerBase(asioDriverName)
{
CreateBuffer({inputChannel, outputChannel}, &BufferSwitch);
}
/**
* 0番の入出力チャンネルからコントローラを生成する
* @note 0番の入出力同士をつなぐので,適当に音の出るチャンネルにジャックを挿してください
*/
InputBackController(const std::string& asioDriverName)
: ControllerBase(asioDriverName)
{
CreateBuffer({channelManager->Inputs(0), channelManager->Outputs(0)}, &BufferSwitch);
}
/**
* チャンネル番号からコントローラを生成する
*/
InputBackController(const std::string& asioDriverName, const long inputNum, const long outputNum)
: ControllerBase(asioDriverName)
{
CreateBuffer({ channelManager->Inputs(inputNum), channelManager->Outputs(outputNum) }, &BufferSwitch);
}
/**
* 入力ストリームに蓄積されたデータを取得する
* @return 入力ストリームに蓄積されたデータ
* @note 入力ストリームの内容は空になる
*/
StreamPtr Fetch()
{
return Input(0).Fetch();
}
/**
* ストリームの現在の長さを得る
*/
const long StreamLength() const { return Input(0).StreamLength();}
};
}