refactor: complex functions#1047
Conversation
| auto onBufferConsumed = [this, graphManager]( | ||
| size_t bufferId, | ||
| std::shared_ptr<AudioBuffer> buffer, | ||
| bool isLastInQueue, | ||
| bool fireBufferEndedEvent) { |
There was a problem hiding this comment.
use FatFunction here, because it will allocate on audio thread likely
| SingleBufferProcessor processor( | ||
| buffer_.get(), vReadIndex_, loop_, playbackRate, startFrame, endFrame); |
There was a problem hiding this comment.
i think there is no need to create a processor each render quantum, it can wrap some not frequently changed variables, such as buffer and loop
| [[nodiscard]] const AudioBuffer *getBuffer() const override; | ||
| [[nodiscard]] const AudioBuffer *getNextBuffer() const override; |
There was a problem hiding this comment.
let's try to minimize the usage of raw ptrs
There was a problem hiding this comment.
| auto framesNeededToStretch = std::abs(static_cast<int>(playbackRate * static_cast<float>(framesToProcess))); |
has to be like that to allow negative playback rate values
mdydek
left a comment
There was a problem hiding this comment.
another argument against using #include <something> not #include "something" is that formatter is behaving differently when using "" and it looks very off
|
|
||
| #include <cstddef> | ||
| #include <memory> | ||
| #include "audioapi/core/utils/buffer/SingleBufferProcessor.h" |
There was a problem hiding this comment.
| #include "audioapi/core/utils/buffer/SingleBufferProcessor.h" | |
| #include <audioapi/core/utils/buffer/SingleBufferProcessor.h> |
| const float currentSample = source[state.index]; | ||
| const float nextSample = nextSource[state.nextIndex]; | ||
| destination[writeIndex] = currentSample + state.factor * (nextSample - currentSample); | ||
|
|
| #include <algorithm> | ||
| #include <cstddef> | ||
| #include <memory> | ||
| #include "audioapi/core/utils/buffer/BufferProcessingDirection.h" |
There was a problem hiding this comment.
| #include "audioapi/core/utils/buffer/BufferProcessingDirection.h" | |
| #include <audioapi/core/utils/buffer/BufferProcessingDirection.h> |
| #include <list> | ||
| #include <memory> | ||
| #include <utility> | ||
| #include "audioapi/utils/FatFunction.hpp" |
There was a problem hiding this comment.
| #include "audioapi/utils/FatFunction.hpp" | |
| #include <audioapi/utils/FatFunction.hpp> |
pls be aware of it
| [[nodiscard]] const AudioBuffer *getBuffer() const override; | ||
| [[nodiscard]] const AudioBuffer *getNextBuffer() const override; |
| #include <audioapi/utils/Macros.h> | ||
| #include <cstddef> | ||
| #include <memory> | ||
| #include "audioapi/core/utils/buffer/BufferProcessingDirection.h" |
There was a problem hiding this comment.
| #include "audioapi/core/utils/buffer/BufferProcessingDirection.h" | |
| #include <audioapi/core/utils/buffer/BufferProcessingDirection.h> |
| // queue buffer source | ||
| inline constexpr size_t ON_BUFFER_CONSUMED_CALLBACK_SIZE = 64; | ||
|
|
There was a problem hiding this comment.
I think it can be safely moved to queue buffer source file, for sure it won't be used anywhere else and also is very "local"
| #include <audioapi/core/utils/buffer/BufferProcessorBase.h> | ||
|
|
||
| #include <cstddef> | ||
| #include "audioapi/utils/AudioBuffer.hpp" |
There was a problem hiding this comment.
| #include "audioapi/utils/AudioBuffer.hpp" | |
| #include <audioapi/utils/AudioBuffer.hpp> |
| processor_->setBuffer(buffer_.get()); | ||
| processor_->setLoop(loop_); |
There was a problem hiding this comment.
those values are not changing each render quantum, you can move those calls to appropriate node setters (f.e. update loop in processor only after setLoop is called on node)
Closes #
Introduced changes
Checklist