MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / base64_encode

Function base64_encode

app/server/runtime.cpp:135–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 const auto pcm = static_cast<int16_t>(std::lrint(sample * 32767.0F));
134 append_bytes(&pcm, sizeof(pcm));
135 }
136 return out;
137}
138
139std::vector<uint8_t> encode_pcm16_samples(const engine::runtime::AudioBuffer & audio) {
140 if (audio.sample_rate <= 0) {
141 throw std::runtime_error("audio output sample rate must be positive");
142 }
143 if (audio.channels <= 0) {
144 throw std::runtime_error("audio output channel count must be positive");
145 }
146 if (audio.samples.size() % static_cast<size_t>(audio.channels) != 0) {
147 throw std::runtime_error("audio output sample count must be divisible by channel count");
148 }
149
150 std::vector<uint8_t> out;
151 out.reserve(audio.samples.size() * sizeof(int16_t));
152 auto append_bytes = [&](const void * data, size_t size) {
153 const auto * bytes = static_cast<const uint8_t *>(data);

Callers 2

task_result_jsonFunction · 0.85
handle_speechMethod · 0.85

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected