Stephan Aßmus <superstippi@xxxxxx> wrote: > Please just go ahead and discuss the changes you need to do or > consider doing as you face them! I can send you the code I did, > but it doesn't take proper care of boundary samples (which I > suppose are the needed architectural changes you're talking about). The problem I've run into is a bit different. The existing 'Resampler' class uses only two integer values to determine the resampling factor -- the input frame count, and the output frame count. As the buffers get smaller and smaller, it's no longer possible to maintain the correct ratio by the input and output sizes alone (e.g. if the output is 48kHz and the input is at 44.1kHz, the minimum output buffer size would be 480 frames, input=441). Trying to maintain the correct ratio by setting up a cadence (e.g., output 240 frames, inputting 220 or 221 every other cycle) doesn't work perfectly because of the pitch modulation it causes. In other projects, I've worked around this problem in one of two ways: 1) Implement a resampler which takes a callback function, a desired output sample frame count, and a floating point ratio. The resampler fetches its own samples (an arbitrary number of them) as and when it needs them, by calling the callback. Vice-versa (the function is called to "push" samples down the chain) is also possible. 2) Implement a resampling-FIFO class, which samples are pushed into, and samples are popped out of. The resampling ratio (floating point) can be set and adjusted using a method function. Under this scheme, the input and output are completely disconnected, although the calling function will need to check available space in the FIFO before pushing, and check for sufficient samples before popping. I'm not sure how either of these could be implemented in the existing Media Kit Mixer, if it's possible at all? Marcus Overhagen <marcusoverhagen@xxxxxxxx> wrote: > Can't this be implemented by overloading the Resampler class? Due to the above issue (input/output ratio), I can't see how this can be done easily without incurring pitch modulation effects with small buffers. If you've got any ideas, I'd be very interested in hearing them! One thing that did cross my mind is to implement a PLL-controlled resampler; the resampler acts as a FIFO, and the resampling ratio is a time-averaged (aggressively low-pass-filtered) version of the input and output ratios. If the internal FIFO is big enough, and the PLL filter steep enough, it would eliminate most of the pitch modulation effects. This seems like overkill though, to implement something that could be implemented more easily using the basic resampling-FIFO approach, and it would also introduce some issues with control loop stabilization time at startup. If it's really the only way without major restructuring, then I'll do it. It's certainly easy to slot into the existing code, but it will require a fair bit of hand-tuning to optimize stabilization time vs. modulation effects vs. latency. It will also require some modifications to report the correct latency back to the media kit (the internal FIFO will grow and shrink, adding a significant variable delay). Also, there is another thing I'm wondering about the Media Kit Mixer. What's the "double rate mixing" for, even if it's currently turned off? > haiku-development would be better. Ah, thanks Marcus. Stephan -- would you prefer if I moved it there?