soundvision/UnityProject/Assets/Scripts/PdConnection/PdArrayContainer.cs
Chikashi Miyama cb599bf5ca refer #62
2019-10-05 18:09:24 +02:00

40 lines
No EOL
1 KiB
C#

namespace cylvester
{
public interface IPdArrayContainer
{
IPdArray this[int index] { get; }
}
public interface IUpdater
{
void Update();
}
public class PdArrayContainer : IPdArrayContainer, IUpdater
{
private readonly IPdArray[] arrays_;
private readonly IUpdater[] updaters_;
public PdArrayContainer(string prefix)
{
arrays_ = new IPdArray[PdConstant.NumMaxInputChannels];
updaters_ = new IUpdater[PdConstant.NumMaxInputChannels];
for (var i = 0; i < PdConstant.NumMaxInputChannels; ++i)
{
arrays_[i] = new PdArray(prefix + i, PdConstant.BlockSize);
updaters_[i] = (IUpdater) arrays_[i];
}
}
public void Update()
{
foreach (var updater in updaters_)
{
updater.Update();
}
}
public IPdArray this[int index] => arrays_[index];
}
}