Files
TheM14 6edcabf777
ci / ubuntu-latest (push) Failing after 14s
ci / macos-latest (push) Canceled after 0s
ci / windows-latest (push) Canceled after 0s
ci / release (push) Canceled after 0s
Bump to 1.3.3 and add PCM layout streaming input
- Add JOC_STREAM_IN_PCM_LAYOUT for interleaved 48 kHz float32 PCM with
  2.0/5.1/7.1 auto layout detection.
- Isolate PCM channel mapping and fixed object positions in the new
  virtual_speaker module; the stream only schedules it.
- Apply the master gain once inside virtual_speaker for the PCM path, while
  the E-AC-3/JOC path keeps its existing rebuild gain.
- Add the multichannel binaural CLI, rational resampler and float32 WAV I/O.
- Extend tests for the multichannel/resampling paths.
2026-11-12 14:31:43 +08:00

58 lines
1.6 KiB
C++

// Virtual speaker input: ordinary multichannel PCM as fixed-direction JOC
// objects. It owns only the layout mapping and the PCM-to-objects16 shape;
// decoding, speaker rendering and binaural rendering stay in their own modules.
#pragma once
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
#include "foundation/status.h"
#include "oamd/oamd_parser.h"
namespace joc::virtual_speaker {
struct ChannelSpec {
bool lfe;
double x;
double y;
double z;
};
struct Layout {
const char* name;
int channels;
ChannelSpec channel_specs[8];
};
const Layout* find_layout(const std::string& name);
const Layout* detect_layout(int channels);
class Input {
public:
// gain_db is the module's master attenuation; it is applied to every
// mapped channel once, before the objects16 frame leaves the module.
Status configure(const std::string& layout_name, int channels, double gain_db = 0.0);
void reset();
const oamd::OamdUpdate& fixed_update() const { return fixed_update_; }
int channels() const { return channels_; }
const Layout* layout() const { return layout_; }
// Appends interleaved frames; take_frame() emits whole 1536-frame blocks.
Status append(const float* interleaved, std::size_t frames);
bool frame_ready() const;
Status take_frame(std::vector<float>* objects16);
private:
const Layout* layout_ = nullptr;
int channels_ = 0;
double gain_ = 1.0;
oamd::OamdUpdate fixed_update_{};
std::vector<float> pending_;
std::size_t read_offset_ = 0;
};
} // namespace joc::virtual_speaker