#include "randomaccessaudioreadable.h"
#include <emscripten/bind.h>

EMSCRIPTEN_BINDINGS(randomaccessaudioreadable) {
  using namespace emscripten;
  class_<RandomAccessAudioReadable>("RandomAccessAudioReadable")
      .smart_ptr<std::shared_ptr<RandomAccessAudioReadable>>(
          "RandomAccessAudioReadable")
      .property("sampleRate", &RandomAccessAudioReadable::getSampleRate)
      .property("channelCount", &RandomAccessAudioReadable::getChannelCount)
      .property("frameCount", &RandomAccessAudioReadable::getFrameCount)
      .function("read(offset, outputBuffer)",
                select_overload<void(int, std::shared_ptr<BufferF32>)>(
                    &RandomAccessAudioReadable::read));

  class_<OffsetView, base<RandomAccessAudioReadable>>("OffsetView")
      .smart_ptr_constructor<std::shared_ptr<OffsetView>,
                             std::shared_ptr<RandomAccessAudioReadable> &&,
                             int &&, int &&>("OffsetView",
                                             &std::make_shared<OffsetView>);
};