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

Function require_power_of_two_log2

src/models/vevo2/components.cpp:71–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71int64_t conv1d_output_frames(int64_t frames, int64_t kernel, int64_t stride, int64_t padding, int64_t dilation = 1) {
72 return (frames + 2 * padding - dilation * (kernel - 1) - 1) / stride + 1;
73}
74
75int64_t coco_output_frames(int64_t input_frames, int64_t downsample_rate) {
76 int64_t frames = input_frames;
77 int64_t remaining = downsample_rate;
78 while (remaining > 1 && remaining % 2 == 0) {
79 frames = conv1d_output_frames(frames, 3, 2, 1);
80 remaining /= 2;
81 }
82 if (remaining != 1) {
83 throw std::runtime_error("Vevo2 Coco downsample_rate must be a positive power of two");
84 }

Callers 2

coco_output_framesFunction · 0.70

Calls 1

stringFunction · 0.50

Tested by

no test coverage detected