mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
fix weed warnings.
add compost library.
This commit is contained in:
parent
ac80a04970
commit
d01ee064e2
31 changed files with 1566 additions and 120 deletions
80
sprout/compost/sources/source.hpp
Normal file
80
sprout/compost/sources/source.hpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#ifndef SPROUT_COMPOST_SOURCES_SOURCE_HPP
|
||||
#define SPROUT_COMPOST_SOURCES_SOURCE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
|
||||
//
|
||||
// COMPOST_LOAD_SOURCE
|
||||
//
|
||||
#define COMPOST_LOAD_SOURCE <sprout/compost/load/source.hpp>
|
||||
|
||||
//
|
||||
// COMPOST_SRC_VERSION
|
||||
//
|
||||
#define COMPOST_SRC_VERSION(NUM) NUM
|
||||
|
||||
namespace sprout {
|
||||
namespace compost {
|
||||
namespace sources {
|
||||
//
|
||||
// version_type
|
||||
//
|
||||
typedef unsigned long version_type;
|
||||
//
|
||||
// info_type
|
||||
//
|
||||
struct info_type {
|
||||
public:
|
||||
std::uint16_t format_tag; // フォーマットID
|
||||
std::uint16_t channels; // チャンネル数
|
||||
std::uint32_t samples_per_sec; // サンプリングレート
|
||||
std::uint32_t bytes_per_sec; // データ速度 (Byte/sec)
|
||||
std::uint16_t block_size; // ブロックサイズ (Byte/sample*チャンネル数)
|
||||
std::uint16_t bits_per_sample; // サンプルあたりのビット数 (bit/sample)
|
||||
std::size_t size; // 要素数
|
||||
};
|
||||
//
|
||||
// sound_type
|
||||
//
|
||||
template<std::size_t Size, typename Elem = double>
|
||||
struct sound_type {
|
||||
public:
|
||||
typedef Elem element_type;
|
||||
typedef element_type value_type;
|
||||
typedef std::size_t size_type;
|
||||
SPROUT_STATIC_CONSTEXPR size_type static_size = Size;
|
||||
typedef sprout::array<value_type, static_size> elements_type;
|
||||
private:
|
||||
elements_type elements_;
|
||||
public:
|
||||
template<typename... Elems>
|
||||
SPROUT_CONSTEXPR sound_type(info_type const& info, Elems const&... elems)
|
||||
: elements_{{
|
||||
(static_cast<typename std::make_signed<Elems>::type>(elems) / static_cast<value_type>(32768.0))...
|
||||
}}
|
||||
{
|
||||
static_assert(sizeof...(Elems) == static_size, "sound_type<>: unmatch source size");
|
||||
}
|
||||
SPROUT_CONSTEXPR value_type const&
|
||||
operator()(size_type x) const {
|
||||
return elements_[x];
|
||||
}
|
||||
SPROUT_CONSTEXPR size_type
|
||||
size() const {
|
||||
return static_size;
|
||||
}
|
||||
SPROUT_CONSTEXPR elements_type const&
|
||||
elements() const {
|
||||
return elements_;
|
||||
}
|
||||
};
|
||||
template<std::size_t Size, typename Elem>
|
||||
SPROUT_CONSTEXPR_OR_CONST typename sprout::compost::sources::sound_type<Size, Elem>::size_type
|
||||
sprout::compost::sources::sound_type<Size, Elem>::static_size;
|
||||
} // namespace sources
|
||||
} // namespace compost
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_COMPOST_SOURCES_SOURCE_HPP
|
Loading…
Add table
Add a link
Reference in a new issue