ptr_vector
こうしたかったのだ。
boost::ptr_vector<WAVEFORMATEX> WASAPI::impl::wave_formats_ =
ptr_list_of<WAVEFORMATEX<
( WAVE_FORMAT_PCM, 2, 192000,768000, 4, 16, 0 )
( WAVE_FORMAT_PCM, 2, 96000, 384000, 4, 16, 0 ) // 96-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 48000, 192000, 4, 16, 0 ) // 48-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0 ) // 44.1-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 32000, 128000, 4, 16, 0 ) // 32-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 8000, 32000, 4, 16, 0 ) // 8-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 48000, 96000, 2, 8, 0 ) // 48-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 44100, 88200, 2, 8, 0 ) // 44.1-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 32000, 64000, 2, 8, 0 ) // 32-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 8000, 16000, 2, 8, 0 );// // 8-kHz, 8-bit stereo
四苦八苦した結果、下記のとおりにすればできることがわかった。
(1)WAVEFORMATEXを継承した構造体、sf:WAVEFORMATEXを作成してコンストラクタを実装する。
(2)#define BOOST_ASSIGN_MAX_PARAMS 7をptr_list_of.hppをインクルードする前に入れる。
#define BOOST_ASSIGN_MAX_PARAMS 7
#include <boost/assign.hpp>
#include <oost/assign/ptr_list_of.hpp>
namespace sf {
struct WAVEFORMATEX : public ::WAVEFORMATEX {
WAVEFORMATEX(
WORD FormatTag = 0, /* format type */
WORD Channels = 0, /* number of channels (i.e. mono, stereo...) */
DWORD SamplesPerSec = 0, /* sample rate */
DWORD AvgBytesPerSec = 0, /* for buffer estimation */
WORD BlockAlign = 0, /* block size of data */
WORD BitsPerSample = 0, /* number of bits per sample of mono data */
WORD Size = sizeof(::WAVEFORMATEX) /* the count in bytes of the size of */
)
{
wFormatTag = FormatTag;
nChannels = Channels;
nSamplesPerSec = SamplesPerSec;
nAvgBytesPerSec = AvgBytesPerSec;
nBlockAlign = BlockAlign;
wBitsPerSample = BitsPerSample;
cbSize = Size;
};
};
boost::ptr_vector<sf::WAVEFORMATEX> WASAPI::impl::wave_formats_ =
ptr_list_of<sf::WAVEFORMATEX>
( WAVE_FORMAT_PCM, 2, 192000,768000, 4, 16, 0 )
( WAVE_FORMAT_PCM, 2, 96000, 384000, 4, 16, 0 ) // 96-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 48000, 192000, 4, 16, 0 ) // 48-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0 ) // 44.1-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 32000, 128000, 4, 16, 0 ) // 32-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 8000, 32000, 4, 16, 0 ) // 8-kHz, 16-bit stereo
( WAVE_FORMAT_PCM, 2, 48000, 96000, 2, 8, 0 ) // 48-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 44100, 88200, 2, 8, 0 ) // 44.1-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 32000, 64000, 2, 8, 0 ) // 32-kHz, 8-bit stereo
( WAVE_FORMAT_PCM, 2, 8000, 16000, 2, 8, 0 );// // 8-kHz, 8-bit stereo