soundvision/UnityProject/Assets/Scripts/PdConnection/SpectrumArrayContainer.cs

40 lines
1 KiB
C#
Raw Normal View History

2019-09-29 19:53:47 +00:00
namespace cylvester
{
2019-10-04 13:35:23 +00:00
public interface ISpectrumArrayContainer
2019-09-29 19:53:47 +00:00
{
IPdArray this[int index] { get; }
}
public interface IUpdater
{
2019-09-29 19:53:47 +00:00
void Update();
}
public class SpectrumArrayContainer : ISpectrumArrayContainer, IUpdater
2019-09-29 19:53:47 +00:00
{
private readonly IPdArray[] arrays_;
private readonly IUpdater[] updaters_;
2019-09-29 19:53:47 +00:00
2019-10-04 13:35:23 +00:00
public SpectrumArrayContainer()
2019-09-29 19:53:47 +00:00
{
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];
}
2019-09-29 19:53:47 +00:00
}
public void Update()
{
foreach (var updater in updaters_)
2019-09-29 19:53:47 +00:00
{
updater.Update();
2019-09-29 19:53:47 +00:00
}
}
public IPdArray this[int index] => arrays_[index];
}
}