Loading...
Searching...
No Matches
RenderedISFUtils.hpp
1#pragma once
2
3#include <Gfx/Graph/NodeRenderer.hpp>
4#include <Gfx/Graph/Utils.hpp>
5
6#include <ossia/audio/fft.hpp>
7#include <ossia/detail/small_flat_map.hpp>
8#include <ossia/detail/variant.hpp>
9#include <ossia/math/math_expression.hpp>
10
11namespace score::gfx
12{
14{
15 QRhiSampler* sampler{};
16 QRhiTexture* textures[2]{nullptr, nullptr};
17};
18using PassOutput = ossia::variant<PersistSampler, TextureRenderTarget>;
19
23inline bool
24advanceFrameIndex(int32_t& frameIndex, int64_t& lastFrame, int64_t frame) noexcept
25{
26 if(lastFrame == frame)
27 return false;
28 if(lastFrame >= 0 || frameIndex > 0)
29 frameIndex++;
30 lastFrame = frame;
31 return true;
32}
33
35{
36 explicit AudioTextureUpload();
37
38 void
39 process(AudioTexture& audio, QRhiResourceUpdateBatch& res, QRhiTexture* rhiTexture);
40
41 void processTemporal(
42 AudioTexture& audio, QRhiResourceUpdateBatch& res, QRhiTexture* rhiTexture);
43
44 void processHistogram(
45 AudioTexture& audio, QRhiResourceUpdateBatch& res, QRhiTexture* rhiTexture);
46
47 void processSpectral(
48 AudioTexture& audio, QRhiResourceUpdateBatch& res, QRhiTexture* rhiTexture);
49
50 [[nodiscard]] std::optional<Sampler> updateAudioTexture(
51 AudioTexture& audio, RenderList& renderer, char* materialData,
52 QRhiResourceUpdateBatch& res);
53
54 static std::size_t fftSize(std::size_t samples) noexcept;
55
56private:
57 ossia::fft_complex* executeFFT(const float* samples, std::size_t count);
58
59 std::vector<float> m_scratchpad;
61 std::vector<float> m_binRow;
62 std::vector<float> m_fftInput;
63 ossia::hash_map<const AudioTexture*, std::vector<float>> m_histograms;
64 ossia::hash_map<const AudioTexture*, int64_t> m_uploadedFrame;
65 ossia::fft m_fft;
66 std::size_t m_fftSize{};
67};
68
69}
List of nodes to be rendered to an output.
Definition RenderList.hpp:36
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
bool advanceFrameIndex(int32_t &frameIndex, int64_t &lastFrame, int64_t frame) noexcept
Definition RenderedISFUtils.hpp:24
Data model for audio data being sent to the GPU.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:190
Definition RenderedISFUtils.hpp:35
Definition RenderedISFUtils.hpp:14