73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#include "wrapper.h"
|
|
#include <string>
|
|
#include <iostream>
|
|
|
|
MadHeader * mad_header_create()
|
|
{
|
|
MadHeader* header = new MadHeader;
|
|
mad_header_init(header);
|
|
return header;
|
|
}
|
|
|
|
MadFrame * mad_frame_create()
|
|
{
|
|
MadFrame* frame = new MadFrame;
|
|
mad_frame_init(frame);
|
|
return frame;
|
|
}
|
|
|
|
emscripten::val MadFrame::getOverlap() const
|
|
{
|
|
unsigned char* ptr = (unsigned char(*))*overlap;
|
|
return emscripten::val(typed_memory_view(sizeof *overlap, ptr));
|
|
}
|
|
|
|
emscripten::val MadFrame::getSbsample() const
|
|
{
|
|
unsigned char* ptr = (unsigned char(*))sbsample;
|
|
return emscripten::val(typed_memory_view(sizeof sbsample, ptr));
|
|
}
|
|
|
|
MadStream* mad_stream_create() {
|
|
MadStream* stream = new MadStream;
|
|
mad_stream_init(stream);
|
|
return stream;
|
|
}
|
|
|
|
emscripten::val MadStream::mainData()
|
|
{
|
|
return emscripten::val(typed_memory_view(MAD_BUFFER_MDLEN, (unsigned char(*))main_data));
|
|
}
|
|
|
|
void MadStream::setBuffer(intptr_t bufferPtr, unsigned long length)
|
|
{
|
|
mad_stream_buffer(this, (const unsigned char(*))bufferPtr, length);
|
|
}
|
|
|
|
int MadFrame::decode(mad_stream* stream)
|
|
{
|
|
return mad_frame_decode(this, stream);
|
|
}
|
|
|
|
emscripten::val MadPCM::samples() const
|
|
{
|
|
mad_fixed_t* ptr = (mad_fixed_t(*))mad_pcm::samples;
|
|
return emscripten::val(typed_memory_view(sizeof mad_pcm::samples, ptr));
|
|
}
|
|
|
|
MadPCM* mad_pcm_create() {
|
|
MadPCM* pcm = new MadPCM();
|
|
return pcm;
|
|
}
|
|
|
|
MadSynth* mad_synth_create() {
|
|
MadSynth* synth = new MadSynth();
|
|
mad_synth_init(synth);
|
|
return synth;
|
|
}
|
|
|
|
void MadSynth::frame(const mad_frame* frame)
|
|
{
|
|
mad_synth_frame(this, frame);
|
|
}
|