mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add a data structure for serializing audio buffers
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <bitsery/ext/std_optional.h>
|
||||
#include <bitsery/traits/array.h>
|
||||
#include <bitsery/traits/string.h>
|
||||
#include <bitsery/traits/vector.h>
|
||||
#include <vestige/aeffect.h>
|
||||
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@@ -29,6 +30,17 @@
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
// These are for the serialization done by bitsery
|
||||
|
||||
/**
|
||||
* The maximum number of audio channels supported.
|
||||
*/
|
||||
constexpr size_t max_audio_channels = 32;
|
||||
/**
|
||||
* The maximum number of samples in a buffer.
|
||||
*/
|
||||
|
||||
constexpr size_t max_buffer_size = 16384;
|
||||
/**
|
||||
* The maximum size in bytes of a string or buffer passed through a void pointer
|
||||
* in one of the dispatch functions. This is used as a buffer size and also as a
|
||||
@@ -143,6 +155,24 @@ struct ParameterResult {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A buffer of audio for the plugin to process, or the response of that
|
||||
* processing. The number of samples is encoded in each audio buffer's length.
|
||||
*/
|
||||
struct AudioBuffer {
|
||||
/**
|
||||
* An audio buffer for each of the plugin's audio channels. The number of
|
||||
* samples is equal to `buffers[0].size()`.
|
||||
*/
|
||||
std::vector<std::vector<float>> buffers;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.container(buffers, max_audio_channels,
|
||||
[](S& s, auto& v) { s.container4b(v, max_buffer_size); });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The serialization function for `AEffect` structs. This will s serialize all
|
||||
* of the values but it will not touch any of the pointer fields. That way you
|
||||
|
||||
Reference in New Issue
Block a user