Conversion functions¶
convert
function¶
template <typename Tout, typename Tin,
typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void convert(Tout *out, const Tin *in, size_t size)
Converts audio samples (both formats are known at compile time)
Source code
template <typename Tout, typename Tin, typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void convert(Tout* out, const Tin* in, size_t size)
{
for (size_t i = 0; i < size; ++i)
{
out[i] = convert_sample<Tout, Tin, Tout_traits, Tin_traits>(in[i]);
}
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L255
template <typename Tout,
typename Tout_traits = audio_sample_traits<Tout>>
void convert(Tout *out, const void *in,
audio_sample_type in_type, size_t size)
Converts audio samples (input format is known at runtime)
Source code
template <typename Tout, typename Tout_traits = audio_sample_traits<Tout>>
void convert(Tout* out, const void* in, audio_sample_type in_type, size_t size)
{
cswitch(audio_sample_type_clist{}, in_type, [&](auto t) {
using type = typename audio_sample_get_type<val_of(decltype(t)())>::type;
convert(out, reinterpret_cast<const type*>(in), size);
});
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L265
template <typename Tin,
typename Tin_traits = audio_sample_traits<Tin>>
void convert(void *out, audio_sample_type out_type,
const Tin *in, size_t size)
Converts audio samples (output format is known at runtime)
Source code
template <typename Tin, typename Tin_traits = audio_sample_traits<Tin>>
void convert(void* out, audio_sample_type out_type, const Tin* in, size_t size)
{
cswitch(audio_sample_type_clist{}, out_type, [&](auto t) {
using type = typename audio_sample_get_type<val_of(decltype(t)())>::type;
convert(reinterpret_cast<type*>(out), in, size);
});
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L275
deinterleave
function¶
template <typename Tout, typename Tin,
typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void deinterleave(Tout *out[], const Tin *in,
size_t channels, size_t size)
Deinterleaves and converts audio samples
Source code
template <typename Tout, typename Tin, typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void deinterleave(Tout* out[], const Tin* in, size_t channels, size_t size)
{
for (size_t i = 0; i < size; ++i)
{
for (size_t ch = 0; ch < channels; ++ch)
out[ch][i] = convert_sample<Tout, Tin, Tout_traits, Tin_traits>(in[i * channels + ch]);
}
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L192
template <typename Tout, univector_tag Tag1,
univector_tag Tag2, typename Tin,
univector_tag Tag3>
void deinterleave(univector2d<Tout, Tag1, Tag2> &out,
const univector<Tin, Tag3> &in)
Deinterleaves and converts audio samples
Source code
template <typename Tout, univector_tag Tag1, univector_tag Tag2, typename Tin, univector_tag Tag3>
void deinterleave(univector2d<Tout, Tag1, Tag2>& out, const univector<Tin, Tag3>& in)
{
if (in.empty() || out.empty())
return;
std::vector<Tout*> ptrs(out.size());
for (size_t i = 0; i < out.size(); ++i)
{
ptrs[i] = out[i].data();
}
return deinterleave(ptrs.data(), in.data(), out.size(), in.size() / out.size());
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L203
interleave
function¶
template <typename Tout, typename Tin,
typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void interleave(Tout *out, const Tin *in[], size_t channels,
size_t size)
Interleaves and converts audio samples
Source code
template <typename Tout, typename Tin, typename Tout_traits = audio_sample_traits<Tout>,
typename Tin_traits = audio_sample_traits<Tin>>
void interleave(Tout* out, const Tin* in[], size_t channels, size_t size)
{
for (size_t i = 0; i < size; ++i)
{
for (size_t ch = 0; ch < channels; ++ch)
out[i * channels + ch] = convert_sample<Tout, Tin, Tout_traits, Tin_traits>(in[ch][i]);
}
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L218
template <typename Tout, univector_tag Tag1, typename Tin,
univector_tag Tag2, univector_tag Tag3>
void interleave(univector<Tout, Tag1> &out,
const univector2d<Tin, Tag2, Tag3> &in)
Interleaves and converts audio samples
Source code
template <typename Tout, univector_tag Tag1, typename Tin, univector_tag Tag2, univector_tag Tag3>
void interleave(univector<Tout, Tag1>& out, const univector2d<Tin, Tag2, Tag3>& in)
{
if (in.empty() || out.empty())
return;
std::vector<const Tin*> ptrs(in.size());
for (size_t i = 0; i < in.size(); ++i)
{
ptrs[i] = in[i].data();
}
return interleave(out.data(), ptrs.data(), in.size(), out.size() / in.size());
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L229
template <typename Tin, univector_tag Tag1,
univector_tag Tag2>
univector<Tin>
interleave(const univector2d<Tin, Tag1, Tag2> &in)
Interleaves and converts audio samples
Source code
template <typename Tin, univector_tag Tag1, univector_tag Tag2>
univector<Tin> interleave(const univector2d<Tin, Tag1, Tag2>& in)
{
if (in.empty())
return {};
univector<Tin> result(in.size() * in[0].size());
interleave(result, in);
return result;
}
https://github.com/kfrlib/kfr/blob//include/kfr/base/conversion.hpp#L243
Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/