#pragma once
#include "audioclip.h"
#include "biquad.h"
#include "buffer.h"
#include "marshalvector.h"
#include "meter.h"
#include "rendercontext.h"
#include <memory>
#include <vector>

class Track {
private:
  const std::vector<std::shared_ptr<AudioClip>> clips;
  BufferF32 tempBuffer, silentBuffer;

  float gain;
  float pan;
  uint32_t muted;

public:
  Track(int sampleRate, float vuAlpha, float gain, float pan, bool muted,
        const std::shared_ptr<Meter> &meter,
        const std::shared_ptr<FilterChain> &filterChain,
        const std::vector<std::shared_ptr<AudioClip>> &clips);

  float getGain() const;
  void setGain(float gain);
  float getPan() const;
  void setPan(float pan);
  bool isMuted() const;
  void setMuted(bool muted);

  int getClipCount() const { return clips.size(); }
  std::shared_ptr<AudioClip> getClip(int index) const;
  void readSegment(const RenderContext *renderContext, BufferF32 output);
  void progressSegment(int channelCount, int frameCount);

  const std::shared_ptr<Meter> meter;
  const std::shared_ptr<FilterChain> filterChain;
};