⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 floating_point_test.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 2 页
字号:
} /* float_short_little_test */static voidfloat_short_big_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("float_short_big_test", filename) ;	gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (short_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (float_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)		if (abs (short_data [k]) > max)			max = abs (short_data [k]) ;	if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* float_short_big_test */static voidfloat_int_little_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("float_int_little_test", filename) ;	gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (int_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_FLOAT ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (float_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)		if (abs (int_data [k]) > max)			max = abs (int_data [k]) ;	if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* float_int_little_test */static voidfloat_int_big_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("float_int_big_test", filename) ;	gen_windowed_sine_float (float_data, ARRAY_LEN (float_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (int_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_FLOAT ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_float_or_die (file, 0, float_data, ARRAY_LEN (float_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (float_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)		if (abs (int_data [k]) > max)			max = abs (int_data [k]) ;	if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* float_int_big_test */static voiddouble_short_little_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("double_short_little_test", filename) ;	gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (short_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (double_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)		if (abs (short_data [k]) > max)			max = abs (short_data [k]) ;	if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* double_short_little_test */static voiddouble_short_big_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("double_short_big_test", filename) ;	gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (short_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (double_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_short_or_die (file, 0, short_data, ARRAY_LEN (short_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (short_data) ; k++)		if (abs (short_data [k]) > max)			max = abs (short_data [k]) ;	if (1.0 * abs (max - 0x7FFF) / 0x7FFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* double_short_big_test */static voiddouble_int_little_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("double_int_little_test", filename) ;	gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (int_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_LITTLE | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (double_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)		if (abs (int_data [k]) > max)			max = abs (int_data [k]) ;	if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* double_int_little_test */static voiddouble_int_big_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("double_int_big_test", filename) ;	gen_windowed_sine_double (double_data, ARRAY_LEN (double_data), 0.98) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= ARRAY_LEN (int_data) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_ENDIAN_BIG | SF_FORMAT_AU | SF_FORMAT_DOUBLE ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, ARRAY_LEN (double_data), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.frames != ARRAY_LEN (double_data))	{	printf ("\n\nLine %d: Incorrect number of frames in file (too short). (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), DFT_DATA_LENGTH) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;		exit (1) ;		} ;	sf_command (file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;	test_read_int_or_die (file, 0, int_data, ARRAY_LEN (int_data), __LINE__) ;	sf_close (file) ;	max = 0 ;	for (k = 0 ; k < ARRAY_LEN (int_data) ; k++)		if (abs (int_data [k]) > max)			max = abs (int_data [k]) ;	if (1.0 * abs (max - 0x7FFFFFFF) / 0x7FFFFFFF > 0.01)	{	printf ("\n\nLine %d: Bad maximum (%d should be %d).\n\n", __LINE__, max, 0x7FFFFFFF) ;		exit (1) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* double_int_big_test */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -