#pragma once

#include <cstdint>
#include <vector>

namespace aptt {

enum class ChannelAssignment {
  kAllChannels,
  kLeftOnly,
  kRightOnly,
  kAlternatingLeftRight,
};

struct PcmSineConfig {
  std::uint32_t sample_rate_hz = 48000;
  std::uint32_t channel_count = 2;
  double frequency_hz = 1000.0;
  double amplitude_dbfs = -20.0;
  ChannelAssignment channel_assignment = ChannelAssignment::kAllChannels;
  bool invert_left = false;
  bool invert_right = false;
  double right_channel_phase_offset_degrees = 0.0;
};

double DbfsToLinear(double dbfs);

class PcmSineGenerator {
 public:
  void ResetPhase();
  std::vector<float> GenerateInterleavedFloat32(const PcmSineConfig& config,
                                                std::uint32_t frame_count);
  double phase_radians() const { return phase_radians_; }

 private:
  double phase_radians_ = 0.0;
};

std::vector<float> GenerateInterleavedSilenceFloat32(std::uint32_t frame_count,
                                                     std::uint32_t channel_count);

}  // namespace aptt
