* Updated README

* Recoded converters (in a cleaner way)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
2000-02-12 12:11:23 +00:00
parent 9bb3479c68
commit ef366f3523
7 changed files with 123 additions and 178 deletions

View File

@@ -2,7 +2,7 @@
// Name: sndcpcm.cpp
// Purpose:
// Date: 08/11/1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
// CVSID: $Id$
// --------------------------------------------------------------------------
#ifdef __GNUG__
@@ -26,72 +26,49 @@ wxSoundStreamPcm::~wxSoundStreamPcm()
}
#define SWAP_BYTES 0
#include "converter.def"
#undef SWAP_BYTES
#define SWAP_BYTES 1
#include "converter.def"
#undef SWAP_BYTES
wxSoundStreamPcm::ConverterType s_convert_out_16_to_8[] = {
Convert_16to8_16_no,
Convert_16to8_U2S_16_no,
wxSoundStreamPcm::ConverterType s_converters[] = {
NULL,
Convert_8_8_sign, /* 8 -> 8 sign */
NULL,
NULL,
Convert_16to8_U2S_16_yes,
Convert_16to8_16_yes
NULL,
NULL,
Convert_8_16, /* 8 -> 16 */
Convert_8_16_sign, /* 8 -> 16 sign */
Convert_8_16_swap, /* 8 -> 16 swapped */
Convert_8_16_sign_swap, /* 8 -> 16 sign swapped */
NULL,
NULL,
Convert_16_8, /* 16 -> 8 */
Convert_16_8_sign, /* 16 -> 8 sign */
Convert_16_swap_8, /* 16 swapped -> 8 */
Convert_16_swap_8_sign, /* 16 swapped -> 8 sign */
NULL,
NULL,
NULL, /* 16 -> 16 */
Convert_16_sign, /* 16 -> 16 sign */
Convert_16_swap, /* 16 swapped -> 16 */
Convert_16_swap_16_sign, /* 16 swapped -> 16 sign */
Convert_16_sign_16_swap, /* 16 sign -> 16 swapped */
Convert_16_swap_16_sign_swap /* 16 swapped -> 16 sign swapped */
};
wxSoundStreamPcm::ConverterType s_convert_out_16[] = {
NULL,
Convert_U2S_16_no,
Convert_U2S_SWAP_16_no,
Convert_U2S_SWAP_16_yes,
Convert_U2S_16_yes,
Convert_SWAP_16_no
};
#define CONVERT_BPS 0
#define CONVERT_SIGN 1
#define CONVERT_SWAP 2
#define CONVERT_SIGN_SWAP 3
#define CONVERT_SWAP_SIGN 4
#define CONVERT_SWAP_SIGN_SWAP 5
wxSoundStreamPcm::ConverterType s_convert_out_8[] = {
NULL,
Convert_U2S_8,
Convert_U2S_8,
Convert_U2S_8,
Convert_U2S_8,
NULL
/*,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_S2M_8 */
};
wxSoundStreamPcm::ConverterType s_convert_in_8_to_16[] = {
Convert_8to16_8,
Convert_8to16_U2S_8,
Convert_8to16_U2S_SWAP_8,
NULL,
NULL,
Convert_8to16_SWAP_8
};
wxSoundStreamPcm::ConverterType *s_convert_in_16 = s_convert_out_16;
wxSoundStreamPcm::ConverterType *s_convert_in_8 = s_convert_out_8;
#define CONVERTER 0
#define CONVERTER_SIGN 1
#define CONVERTER_SIGN_SWAP 2
#define CONVERTER_SWAP_SIGN_SWAP 3
#define CONVERTER_SWAP_SIGN 4
#define CONVERTER_SWAP 5
#define CONVERTER_SIGN_STEREO_MONO 6
#define CONVERTER_SIGN_SWAP_STEREO_MONO 7
#define CONVERTER_SWAP_SIGN_SWAP_STEREO_MONO 8
#define CONVERTER_SWAP_SIGN_STEREO_MONO 9
#define CONVERTER_SWAP_STEREO_MONO 10
#define CONVERTER_STEREO_MONO 11
#define CONVERT_BASE_8_8 0
#define CONVERT_BASE_8_16 6
#define CONVERT_BASE_16_8 12
#define CONVERT_BASE_16_16 18
//
// TODO: Read() and Write() aren't really safe. If you give it a buffer which
@@ -178,14 +155,19 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
m_16_to_8 = FALSE;
if (pcm_format->GetBPS() != pcm_format2->GetBPS()) {
m_16_to_8 = TRUE;
current_table_out = s_convert_out_16_to_8;
current_table_in = s_convert_in_8_to_16;
if (pcm_format2->GetBPS() == 8) {
current_table_out = &s_converters[CONVERT_BASE_16_8];
current_table_in = &s_converters[CONVERT_BASE_8_16];
} else {
current_table_out = &s_converters[CONVERT_BASE_8_16];
current_table_in = &s_converters[CONVERT_BASE_16_8];
}
} else if (pcm_format->GetBPS() == 16) {
current_table_out = s_convert_out_16;
current_table_in = s_convert_in_16;
current_table_out = &s_converters[CONVERT_BASE_16_16];
current_table_in = &s_converters[CONVERT_BASE_16_16];
} else {
current_table_out = s_convert_out_8;
current_table_in = s_convert_in_8;
current_table_out = &s_converters[CONVERT_BASE_8_8];
current_table_in = &s_converters[CONVERT_BASE_8_8];
}
change_sign = (pcm_format2->Signed() != pcm_format->Signed());
@@ -199,22 +181,25 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
if (pcm_format->GetOrder() == OTHER_ORDER &&
pcm_format2->GetOrder() == OTHER_ORDER && change_sign)
index = CONVERTER_SWAP_SIGN_SWAP;
index = CONVERT_SWAP_SIGN_SWAP;
else if (pcm_format->GetOrder() == OTHER_ORDER &&
pcm_format2->GetOrder() == MY_ORDER && change_sign)
index = CONVERTER_SWAP_SIGN;
index = CONVERT_SWAP_SIGN;
else if (pcm_format->GetOrder() == MY_ORDER &&
pcm_format->GetOrder() == OTHER_ORDER && change_sign)
index = CONVERTER_SIGN_SWAP;
index = CONVERT_SIGN_SWAP;
else if (change_sign)
index = CONVERT_SIGN;
else if (!change_sign &&
pcm_format->GetOrder() != pcm_format2->GetOrder())
index = CONVERTER_SWAP;
index = CONVERT_SWAP;
else
index = CONVERTER;
index = CONVERT_BPS;
m_function_out = current_table_out[index];
m_function_in = current_table_in[index];