MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ download_audio_from_gpu()

MAYAFLUX_API void MayaFlux::Buffers::download_audio_from_gpu ( const std::shared_ptr< VKBuffer > &  gpu_buffer,
const std::shared_ptr< AudioBuffer > &  audio_buffer,
const std::shared_ptr< VKBuffer > &  staging = nullptr 
)

Download GPU buffer to AudioBuffer (expects double precision)

Parameters
gpu_bufferSource GPU buffer (should contain double precision data)
audio_bufferTarget audio buffer (always double[])
stagingOptional staging buffer (auto-created if needed)

Downloads GPU data and copies to AudioBuffer. If the GPU buffer contains float data instead of double, DataAccess will handle the upconversion (though this is not recommended for audio precision).

Definition at line 950 of file StagingUtils.cpp.

954{
955 Kakshya::DataVariant downloaded_data;
956
957 auto dimensions = std::vector<Kakshya::DataDimension> {
958 Kakshya::DataDimension::time(
959 gpu_buffer->get_size_bytes() / sizeof(double),
960 "samples")
961 };
962 Kakshya::DataAccess accessor = download_to_view<double>(
963 gpu_buffer, downloaded_data, dimensions,
964 Kakshya::DataModality::AUDIO_1D, staging);
965
966 auto double_view = accessor.view<double>();
967
968 audio_buffer->get_data() = std::vector<double>(double_view.begin(), double_view.end());
969
970 MF_DEBUG(Journal::Component::Buffers, Journal::Context::BufferProcessing,
971 "Downloaded {} samples of double-precision audio from GPU", double_view.size());
972}
#define MF_DEBUG(comp, ctx,...)
auto view() const
Get explicit typed view of data.
Type-erased accessor for NDData with semantic view construction.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:70

References MayaFlux::Kakshya::AUDIO_1D, MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MF_DEBUG, MayaFlux::Kakshya::DataDimension::time(), and MayaFlux::Kakshya::DataAccess::view().

Referenced by MayaFlux::Buffers::TransferProcessor::process_gpu_to_audio().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: