soundvision/UnityProject/Assets/Scripts/PdConnection/SpectrumArrayContainer.cs
2019-10-05 11:38:46 +02:00

40 lines
No EOL
1 KiB
C#

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