您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ test_open_file_or_die函数代码示例

51自学网 2021-06-03 08:45:39
  C++
这篇教程C++ test_open_file_or_die函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中test_open_file_or_die函数的典型用法代码示例。如果您正苦于以下问题:C++ test_open_file_or_die函数的具体用法?C++ test_open_file_or_die怎么用?C++ test_open_file_or_die使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了test_open_file_or_die函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: zero_data_test

static void	zero_data_test (char *filename, int typemajor){	SNDFILE		*file ;	SF_INFO		sfinfo ;	int			k, frames ;	printf ("    zero_data_test      : %s ", filename) ;	fflush (stdout) ;		k = abs (18 - strlen (filename)) ;	PUT_DOTS (k) ;		sfinfo.samplerate  = 44100 ;	sfinfo.format 	   = (typemajor | SF_FORMAT_PCM_16) ;	sfinfo.channels    = 1 ;	sfinfo.frames     = 0 ;	frames = BUFFER_LEN / sfinfo.channels ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, __LINE__) ;		sf_close (file) ;		memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* zero_data_test */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:32,


示例2: zero_data_test

static voidzero_data_test (const char *filename, int format){	SNDFILE		*file ;	SF_INFO		sfinfo ;	switch (format & SF_FORMAT_TYPEMASK)	{	case SF_FORMAT_OGG :			if (HAVE_EXTERNAL_XIPH_LIBS == 0)				return ;			break ;		default :			break ;		} ;	print_test_name ("zero_data_test", filename) ;	sfinfo.samplerate = 44100 ;	sfinfo.format = format ;	sfinfo.channels = 1 ;	sfinfo.frames = 0 ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	sf_close (file) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* zero_data_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:34,


示例3: software_string_test

static voidsoftware_string_test (const char *filename){	size_t k ;	print_test_name (__func__, filename) ;	for (k = 0 ; k < 50 ; k++)	{	const char *result ;		char sfname [64] = "" ;		SNDFILE *file ;		SF_INFO info ;		sf_info_setup (&info, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 44100, 1) ;		file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_TRUE, __LINE__) ;		snprintf (sfname, MIN (k, sizeof (sfname)), "%s", "abcdefghijklmnopqrestvwxyz0123456789abcdefghijklmnopqrestvwxyz") ;		exit_if_true (sf_set_string (file, SF_STR_SOFTWARE, sfname),			"/n/nLine %d : sf_set_string (f, SF_STR_SOFTWARE, '%s') failed : %s/n", __LINE__, sfname, sf_strerror (file)) ;		sf_close (file) ;		file = test_open_file_or_die (filename, SFM_READ, &info, SF_TRUE, __LINE__) ;		result = sf_get_string (file, SF_STR_SOFTWARE) ;		exit_if_true (result == NULL, "/n/nLine %d : sf_get_string (file, SF_STR_SOFTWARE) returned NULL./n/n", __LINE__) ;		exit_if_true (strstr (result, sfname) != result,			"/n/nLine %d : Can't fine string '%s' in '%s'/n/n", __LINE__, sfname, result) ;		sf_close (file) ;		} ;	unlink (filename) ;	puts ("ok") ;} /* software_string_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:35,


示例4: wavex_amb_test

static voidwavex_amb_test (const char *filename){	static short buffer [800] ;	SNDFILE	*file ;	SF_INFO	sfinfo ;	sf_count_t	frames ;	print_test_name (__func__, filename) ;	sfinfo.samplerate = 44100 ;	sfinfo.format = SF_FORMAT_WAVEX | SF_FORMAT_PCM_16 ;	sfinfo.channels = 4 ;	frames = ARRAY_LEN (buffer) / sfinfo.channels ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	sf_command (file, SFC_WAVEX_SET_AMBISONIC, NULL, SF_AMBISONIC_B_FORMAT) ;	test_writef_short_or_die (file, 0, buffer, frames, __LINE__) ;	sf_close (file) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (		sf_command (file, SFC_WAVEX_GET_AMBISONIC, NULL, 0) != SF_AMBISONIC_B_FORMAT,		"/n/nLine %d : Error, this file should be in Ambisonic B format./n", __LINE__		) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* wavex_amb_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:34,


示例5: headerless_test

static voidheaderless_test (const char * filename, int format, int expected){	static	short	buffer [BUFFER_SIZE] ;	SNDFILE		*file ;	SF_INFO		sfinfo ;	int			k ;	format &= SF_FORMAT_SUBMASK ;	print_test_name (__func__, filename) ;	for (k = 0 ; k < BUFFER_SIZE ; k++)		buffer [k] = k ;	sfinfo.samplerate	= 8000 ;	sfinfo.frames		= 0 ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_FORMAT_RAW | format ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	if ((k = sf_write_short (file, buffer, BUFFER_SIZE)) != BUFFER_SIZE)	{	printf ("Line %d: sf_write_short failed with short write (%d => %d)./n", __LINE__, BUFFER_SIZE, k) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	sf_close (file) ;	memset (buffer, 0, sizeof (buffer)) ;	/* We should be able to detect these so clear sfinfo. */	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if (sfinfo.format != expected)	{	printf ("Line %d: Returned format incorrect (0x%08X => 0x%08X)./n", __LINE__, expected, sfinfo.format) ;		exit (1) ;		} ;	if (sfinfo.frames < BUFFER_SIZE)	{	printf ("Line %d: Incorrect number of.frames in file. (%d => %ld)/n", __LINE__, BUFFER_SIZE, SF_COUNT_TO_LONG (sfinfo.frames)) ;		exit (1) ;		} ;	if (sfinfo.channels != 1)	{	printf ("Line %d: Incorrect number of channels in file./n", __LINE__) ;		exit (1) ;		} ;	check_log_buffer_or_die (file, __LINE__) ;	sf_close (file) ;	printf ("ok/n") ;	unlink (filename) ;} /* headerless_test */
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:59,


示例6: large_free_test

static voidlarge_free_test (const char *filename, int format, size_t chunk_size){	SNDFILE 		* file ;	SF_INFO			sfinfo ;	SF_CHUNK_INFO	chunk_info ;	char chunk_data [20002] ;	short audio [16] ;	int	err ;	print_test_name (__func__, filename) ;	exit_if_true (sizeof (chunk_data) <= chunk_size, "/n/nLine %d : sizeof (data) < chunk_size/n/n", __LINE__) ;	memset (chunk_data, 53, sizeof (chunk_data)) ;	chunk_data [chunk_size] = 0 ;	sfinfo.samplerate	= 44100 ;	sfinfo.channels		= 1 ;	sfinfo.frames		= 0 ;	sfinfo.format		= format ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	/* Set up the chunk to write. */	memset (&chunk_info, 0, sizeof (chunk_info)) ;	snprintf (chunk_info.id, sizeof (chunk_info.id), "free") ;	chunk_info.id_size = 4 ;	chunk_info.data = chunk_data ;	chunk_info.datalen = chunk_size ;	err = sf_set_chunk (file, &chunk_info) ;	exit_if_true (		err != SF_ERR_NO_ERROR,		"/n/nLine %d : sf_set_chunk returned for testdata : %s/n/n", __LINE__, sf_error_number (err)		) ;	memset (chunk_info.data, 0, chunk_info.datalen) ;	/* Add some audio data. */	memset (audio, 0, sizeof (audio)) ;	sf_write_short (file, audio, ARRAY_LEN (audio)) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (		sfinfo.frames != ARRAY_LEN (audio),		"/n/nLine %d : Incorrect sample count (%d should be %d)/n", __LINE__, (int) sfinfo.frames, (int) ARRAY_LEN (audio)		) ;	if (chunk_size < 512)		check_log_buffer_or_die (file, __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* large_free_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:59,


示例7: read_write_peak_test

static	voidread_write_peak_test (const char *filename, int filetype){	SNDFILE	*file ;    SF_INFO	sfinfo ;    double   small_data [10] ;    double   max_peak = 0.0 ;    unsigned k ;	print_test_name (__func__, filename) ;    for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)        small_data [k] = 0.1 ;    sfinfo.samplerate	= 44100 ;    sfinfo.channels		= 2 ;    sfinfo.format		= filetype ;    sfinfo.frames		= 0 ;	/* Open the file, add peak chunk and write samples with value 0.1. */    file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;    sf_command (file, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;	test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;    sf_close (file) ;    /* Open the fiel RDWR, write sample valied 1.25. */    file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;    for (k = 0 ; k < ARRAY_LEN (small_data) ; k ++)        small_data [k] = 1.0 ;	test_write_double_or_die (file, 0, small_data, ARRAY_LEN (small_data), __LINE__) ;    sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;    sf_close (file) ;    exit_if_true (max_peak < 0.1, "/n/nLine %d : max peak (%5.3f) should not be 0.1./n/n", __LINE__, max_peak) ;    /* Open the file and test the values written to the PEAK chunk. */    file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	exit_if_true (sfinfo.channels * sfinfo.frames != 2 * ARRAY_LEN (small_data),			"Line %d : frame count is %ld, should be %d/n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * ARRAY_LEN (small_data)) ;    sf_command (file, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (double)) ;    sf_close (file) ;    exit_if_true (max_peak < 1.0, "/n/nLine %d : max peak (%5.3f) should be 1.0./n/n", __LINE__, max_peak) ;	unlink (filename) ;	puts ("ok") ;} /* read_write_peak_test */
开发者ID:5in4,项目名称:libsox.dll,代码行数:57,


示例8: string_short_rdwr_test

static voidstring_short_rdwr_test (const char *filename, int typemajor){	SNDFILE *file ;	SF_INFO sfinfo ;	sf_count_t frames = BUFFER_LEN ;	const char * str ;	print_test_name (__func__, filename) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	sfinfo.format		= typemajor | SF_FORMAT_PCM_16 ;	sfinfo.samplerate	= 44100 ;	sfinfo.channels		= 1 ;	sfinfo.frames		= 0 ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	/* Write data to file. */	test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;	sf_set_string (file, SF_STR_TITLE, long_title) ;	sf_set_string (file, SF_STR_ARTIST, long_artist) ;	sf_close (file) ;	/* Open the file RDWR. */	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;	exit_if_true (frames != sfinfo.frames, "/n/nLine %d : Frame count %" PRId64 " should be %" PRId64 "./n", __LINE__, sfinfo.frames, frames) ;	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, long_title) != 0, "/n/nLine %d : SF_STR_TITLE doesn't match what was written./n", __LINE__) ;	str = sf_get_string (file, SF_STR_ARTIST) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, long_artist) != 0, "/n/nLine %d : SF_STR_ARTIST doesn't match what was written./n", __LINE__) ;	/* Change title and artist. */	sf_set_string (file, SF_STR_TITLE, title) ;	sf_set_string (file, SF_STR_ARTIST, artist) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	check_log_buffer_or_die (file, __LINE__) ;	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, title) != 0, "/n/nLine %d : SF_STR_TITLE doesn't match what was written./n", __LINE__) ;	str = sf_get_string (file, SF_STR_ARTIST) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_ARTIST string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, artist) != 0, "/n/nLine %d : SF_STR_ARTIST doesn't match what was written./n", __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* string_short_rdwr_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:57,


示例9: double_scaled_test

static voiddouble_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr){	SNDFILE		*file ;	SF_INFO		sfinfo ;	double		snr ;	print_test_name ("double_scaled_test", filename) ;	gen_windowed_sine (orig_data, DFT_DATA_LENGTH, 0.95) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= DFT_DATA_LENGTH ;	sfinfo.channels		= 1 ;	sfinfo.format		= filetype ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, __LINE__) ;	sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;	test_write_double_or_die (file, 0, orig_data, DFT_DATA_LENGTH, __LINE__) ;	sf_close (file) ;	memset (test_data, 0, sizeof (test_data)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, __LINE__) ;	sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;	if (sfinfo.format != filetype)	{	printf ("/n/nLine %d: Returned format incorrect (0x%08X => 0x%08X)./n", __LINE__, filetype, sfinfo.format) ;		exit (1) ;		} ;	if (sfinfo.frames < DFT_DATA_LENGTH)	{	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) ;		} ;	check_log_buffer_or_die (file, __LINE__) ;	test_read_double_or_die (file, 0, test_data, DFT_DATA_LENGTH, __LINE__) ;	sf_close (file) ;	snr = dft_cmp (__LINE__, orig_data, test_data, DFT_DATA_LENGTH, target_snr, allow_exit) ;	if (snr < target_snr)		printf ("% 6.1fdB SNR ... ok/n", snr) ;	unlink (filename) ;	return ;} /* double_scaled_test */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:57,


示例10: channel_map_test

static	voidchannel_map_test (const char *filename, int filetype){	SNDFILE	 *file ;	SF_INFO	 sfinfo ;	int channel_map_read [4], channel_map_write [4] =	{	SF_CHANNEL_MAP_FRONT_LEFT, SF_CHANNEL_MAP_FRONT_CENTER,		SF_CHANNEL_MAP_REAR_LEFT, SF_CHANNEL_MAP_REAR_RIGHT		} ;	print_test_name ("channel_map_test", filename) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	sfinfo.samplerate	= 11025 ;	sfinfo.format		= filetype ;	sfinfo.channels		= ARRAY_LEN (channel_map_read) ;	/* Write file without channel map. */	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;	sf_close (file) ;	/* Read file making sure no channel map exists. */	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (		sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) != SF_FALSE,		"/n/nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) should have failed./n/n", __LINE__		) ;	check_log_buffer_or_die (file, __LINE__) ;	sf_close (file) ;	/* Write file with a channel map. */	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;	exit_if_true (		sf_command (file, SFC_SET_CHANNEL_MAP_INFO, channel_map_write, sizeof (channel_map_write)) == SF_FALSE,		"/n/nLine %d : sf_command (SFC_SET_CHANNEL_MAP_INFO) failed./n/n", __LINE__		) ;	sf_close (file) ;	/* Read file making sure no channel map exists. */	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (		sf_command (file, SFC_GET_CHANNEL_MAP_INFO, channel_map_read, sizeof (channel_map_read)) != SF_TRUE,		"/n/nLine %d : sf_command (SFC_GET_CHANNEL_MAP_INFO) failed./n/n", __LINE__		) ;	check_log_buffer_or_die (file, __LINE__) ;	sf_close (file) ;	exit_if_true (		memcmp (channel_map_read, channel_map_write, sizeof (channel_map_read)) != 0,		"/n/nLine %d : Channel map read does not match channel map written./n/n", __LINE__		) ;	unlink (filename) ;	puts ("ok") ;} /* channel_map_test */
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:56,


示例11: string_rdwr_grow_test

static voidstring_rdwr_grow_test (const char *filename, int typemajor){	SNDFILE *file ;	SF_INFO sfinfo ;	sf_count_t frames ;	const char * str ;	print_test_name (__func__, filename) ;	/* Create a file that contains some strings. Then open the file in RDWR mode and		 grow the file by writing more audio data to it. Check that the audio data has		 been added to the file, and that the strings are still there. */	/* Create a short file that contains a string. */	memset (&sfinfo, 0, sizeof (sfinfo)) ;	sfinfo.samplerate	= 44100 ;	sfinfo.channels		= 2 ;	sfinfo.frames		= 0 ;	sfinfo.format		= typemajor | SF_FORMAT_PCM_16 ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	/* Write data to file. */	test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;	/* Write some strings at end of file. */	sf_set_string (file, SF_STR_TITLE , title) ;	sf_set_string (file, SF_STR_COMMENT, comment) ;	sf_close (file) ;	/* Now open file again in SFM_RDWR mode and write more audio data to it. */	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;	/* Write more data to file.  */	test_write_short_or_die (file, 0, data_out, BUFFER_LEN, __LINE__) ;	sf_close (file) ;	/* Now open file again. It should now contain two BUFFER_LEN's worth of frames and the strings. */	frames = 2 * BUFFER_LEN / sfinfo.channels ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (frames != sfinfo.frames, "/n/nLine %d : Frame count %" PRId64 " should be %" PRId64 "./n", __LINE__, sfinfo.frames, frames) ;	/* Check the strings */	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, title) != 0, "/n/nLine %d : SF_STR_TITLE doesn't match what was written./n", __LINE__) ;	str = sf_get_string (file, SF_STR_COMMENT) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_COMMENT string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, comment) != 0, "/n/nLine %d : SF_STR_COMMENT doesn't match what was written./n", __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* string_rdwr_grow_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:56,


示例12: ogg_int_test

static voidogg_int_test (void){	const char * filename = "vorbis_int.oga" ;	SNDFILE * file ;	SF_INFO sfinfo ;	int seek_data [10] ;	unsigned k ;	print_test_name ("ogg_int_test", filename) ;	/* Generate float data. */	gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ;	/* Convert to integer. */	for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++)		data_out.i [k] = lrintf (data_out.f [k]) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	/* Set up output file type. */	sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;	sfinfo.channels = 1 ;	sfinfo.samplerate = SAMPLE_RATE ;	/* Write the output file. */	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ;	sf_close (file) ;	/* Read the file in again. */	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ;	sf_close (file) ;	puts ("ok") ;	/* Test seeking. */	print_test_name ("ogg_seek_test", filename) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;	test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;	compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ;	sf_close (file) ;	puts ("ok") ;	unlink (filename) ;} /* ogg_int_test */
开发者ID:DannyDaemonic,项目名称:libsndfile,代码行数:54,


示例13: rf64_downgrade_test

static voidrf64_downgrade_test (const char *filename){	static short	output	[BUFFER_LEN] ;	static short	input	[BUFFER_LEN] ;	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k ;	print_test_name (__func__, filename) ;	sf_info_clear (&sfinfo) ;	sfinfo.samplerate	= 44100 ;	sfinfo.frames		= ARRAY_LEN (output) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_FORMAT_RF64 | SF_FORMAT_PCM_16 ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_FALSE) != SF_FALSE, "/n/nLine %d: sf_command failed./n", __LINE__) ;	exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "/n/nLine %d: sf_command failed./n", __LINE__) ;	test_write_short_or_die (file, 0, output, ARRAY_LEN (output), __LINE__) ;	exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_FALSE) != SF_TRUE, "/n/nLine %d: sf_command failed./n", __LINE__) ;	exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "/n/nLine %d: sf_command failed./n", __LINE__) ;	sf_close (file) ;	memset (input, 0, sizeof (input)) ;	sf_info_clear (&sfinfo) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (sfinfo.format != (SF_FORMAT_WAVEX | SF_FORMAT_PCM_16), "/n/nLine %d: RF64 to WAV downgrade failed./n", __LINE__) ;	exit_if_true (sfinfo.frames != ARRAY_LEN (output), "/n/nLine %d: Incorrect number of frames in file (too short). (%d should be %d)/n", __LINE__, (int) sfinfo.frames, (int) ARRAY_LEN (output)) ;	exit_if_true (sfinfo.channels != 1, "/n/nLine %d: Incorrect number of channels in file./n", __LINE__) ;	check_log_buffer_or_die (file, __LINE__) ;	test_read_short_or_die (file, 0, input, ARRAY_LEN (input), __LINE__) ;	sf_close (file) ;	for (k = 0 ; k < ARRAY_LEN (input) ; k++)		exit_if_true (input [k] != output [k],			"/n/nLine: %d: Error on input %d, expected %d, got %d/n", __LINE__, k, output [k], input [k]) ;	puts ("ok") ;	unlink (filename) ;	return ;} /* rf64_downgrade_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:54,


示例14: vorbis_quality_test

static voidvorbis_quality_test (void){	/*	**	Encode two files, one at quality 0.3 and one at quality 0.5 and then	**	make sure that the quality 0.3 files is the smaller of the two.	*/	const char * q3_fname = "q3_vorbis.oga" ;	const char * q5_fname = "q5_vorbis.oga" ;	SNDFILE *q3_file, *q5_file ;	SF_INFO sfinfo ;	int q3_size, q5_size ;	double quality ;	int k ;	print_test_name (__func__, "q[35]_vorbis.oga") ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	/* Set up output file type. */	sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;	sfinfo.channels = 1 ;	sfinfo.samplerate = SAMPLE_RATE ;	/* Write the output file. */	q3_file = test_open_file_or_die (q3_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	q5_file = test_open_file_or_die (q5_fname, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	quality = 0.3 ;	sf_command (q3_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ;	quality = 0.5 ;	sf_command (q5_file, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof (quality)) ;	for (k = 0 ; k < 5 ; k++)	{	gen_lowpass_noise_float (data_out, ARRAY_LEN (data_out)) ;		test_write_float_or_die (q3_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ;		test_write_float_or_die (q5_file, 0, data_out, ARRAY_LEN (data_out), __LINE__) ;		} ;	sf_close (q3_file) ;	sf_close (q5_file) ;	q3_size = file_length (q3_fname) ;	q5_size = file_length (q5_fname) ;	if (q3_size >= q5_size)	{	printf ("/n/nLine %d : q3 size (%d) >= q5 size (%d)/n/n", __LINE__, q3_size, q5_size) ;		exit (1) ;		} ;	puts ("ok") ;	unlink (q3_fname) ;	unlink (q5_fname) ;} /* vorbis_quality_test */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:54,


示例15: rf64_long_file_downgrade_test

static voidrf64_long_file_downgrade_test (const char *filename){	static int	output	[BUFFER_LEN] ;	static int	input	[1] = { 0 } ;	SNDFILE		*file ;	SF_INFO		sfinfo ;	sf_count_t	output_frames = 0 ;	print_test_name (__func__, filename) ;	sf_info_clear (&sfinfo) ;	memset (output, 0, sizeof (output)) ;	output [0] = 0x1020304 ;	sfinfo.samplerate	= 44100 ;	sfinfo.frames		= ARRAY_LEN (output) ;	sfinfo.channels		= 1 ;	sfinfo.format		= SF_FORMAT_RF64 | SF_FORMAT_PCM_32 ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (sf_command (file, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) != SF_TRUE, "/n/nLine %d: sf_command failed./n", __LINE__) ;	while (output_frames * sizeof (output [0]) < 0x100000000)	{	test_write_int_or_die (file, 0, output, ARRAY_LEN (output), __LINE__) ;		output_frames += ARRAY_LEN (output) ;		} ;	sf_close (file) ;	sf_info_clear (&sfinfo) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	exit_if_true (sfinfo.format != (SF_FORMAT_RF64 | SF_FORMAT_PCM_32), "/n/nLine %d: RF64 to WAV downgrade should have failed./n", __LINE__) ;	exit_if_true (sfinfo.channels != 1, "/n/nLine %d: Incorrect number of channels in file./n", __LINE__) ;	exit_if_true (sfinfo.frames != output_frames, "/n/nLine %d: Incorrect number of frames in file (%d should be %d)./n", __LINE__, (int) sfinfo.frames, (int) output_frames) ;	/* Check that the first sample read is the same as the first written. */	test_read_int_or_die (file, 0, input, ARRAY_LEN (input), __LINE__) ;	exit_if_true (input [0] != output [0], "/n/nLine %d: Bad first sample (0x%08x)./n", __LINE__, input [0]) ;	check_log_buffer_or_die (file, __LINE__) ;	sf_close (file) ;	puts ("ok") ;	unlink (filename) ;	return ;} /* rf64_long_file_downgrade_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:53,


示例16: double_scaled_test

static voiddouble_scaled_test (const char *filename, int allow_exit, int replace_float, int filetype, double target_snr){	SNDFILE		*file ;	SF_INFO		sfinfo ;	double		snr ;	int			byterate ;	print_test_name ("double_scaled_test", filename) ;	gen_windowed_sine_double (double_data, DFT_DATA_LENGTH, 0.9999) ;	sfinfo.samplerate	= SAMPLE_RATE ;	sfinfo.frames		= DFT_DATA_LENGTH ;	sfinfo.channels		= 1 ;	sfinfo.format		= filetype ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;	test_write_double_or_die (file, 0, double_data, DFT_DATA_LENGTH, __LINE__) ;	sf_close (file) ;	memset (double_test, 0, sizeof (double_test)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	sf_command (file, SFC_TEST_IEEE_FLOAT_REPLACE, NULL, replace_float) ;	exit_if_true (sfinfo.format != filetype, "/n/nLine %d: Returned format incorrect (0x%08X => 0x%08X)./n", __LINE__, filetype, sfinfo.format) ;	exit_if_true (sfinfo.frames < DFT_DATA_LENGTH, "/n/nLine %d: Incorrect number of frames in file (too short). (%" PRId64 " should be %d)/n", __LINE__, sfinfo.frames, DFT_DATA_LENGTH) ;	exit_if_true (sfinfo.channels != 1, "/n/nLine %d: Incorrect number of channels in file./n", __LINE__) ;	check_log_buffer_or_die (file, __LINE__) ;	test_read_double_or_die (file, 0, double_test, DFT_DATA_LENGTH, __LINE__) ;	byterate = sf_current_byterate (file) ;	exit_if_true (byterate <= 0, "/n/nLine %d: byterate is zero./n", __LINE__) ;	sf_close (file) ;	snr = dft_cmp_double (__LINE__, double_data, double_test, DFT_DATA_LENGTH, target_snr, allow_exit) ;	exit_if_true (snr > target_snr, "% 6.1fdB SNR/n/n    Error : should be better than % 6.1fdB/n/n", snr, target_snr) ;	printf ("% 6.1fdB SNR ... ok/n", snr) ;	unlink (filename) ;	return ;} /* double_scaled_test */
开发者ID:CarlosXViera,项目名称:SoundShake,代码行数:51,


示例17: string_rdwr_test

static voidstring_rdwr_test (const char *filename, int typemajor){	SNDFILE *file ;	SF_INFO sfinfo ;	sf_count_t frames ;	const char * str ;	print_test_name (__func__, filename) ;	create_short_sndfile (filename, typemajor | SF_FORMAT_PCM_16, 2) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;	frames = sfinfo.frames ;	sf_set_string (file, SF_STR_TITLE, title) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	exit_if_true (frames != sfinfo.frames, "/n/nLine %d : Frame count %" PRId64 " should be %" PRId64 "./n", __LINE__, sfinfo.frames, frames) ;	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, title) != 0, "/n/nLine %d : SF_STR_TITLE doesn't match what was written./n", __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;	frames = sfinfo.frames ;	sf_set_string (file, SF_STR_TITLE, title) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	sf_set_string (file, SF_STR_ARTIST, artist) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	str = sf_get_string (file, SF_STR_ARTIST) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_ARTIST string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, artist) != 0, "/n/nLine %d : SF_STR_ARTIST doesn't match what was written./n", __LINE__) ;	str = sf_get_string (file, SF_STR_TITLE) ;	exit_if_true (str == NULL, "/n/nLine %d : SF_STR_TITLE string is NULL./n", __LINE__) ;	exit_if_true (strcmp (str, title) != 0, "/n/nLine %d : SF_STR_TITLE doesn't match what was written./n", __LINE__) ;	exit_if_true (frames != sfinfo.frames, "/n/nLine %d : Frame count %" PRId64 " should be %" PRId64 "./n", __LINE__, sfinfo.frames, frames) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* string_rdwr_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:51,


示例18: print_test_name

static	voidcurrent_sf_info_test	(const char *filename){	SNDFILE *outfile, *infile ;	SF_INFO outinfo, ininfo ;	sf_count_t last_count ;	print_test_name ("current_sf_info_test", filename) ;	outinfo.samplerate	= 44100 ;	outinfo.format		= (SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;	outinfo.channels	= 1 ;	outinfo.frames		= 0 ;	outfile = test_open_file_or_die (filename, SFM_WRITE, &outinfo, SF_TRUE, __LINE__) ;	sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, 0) ;	exit_if_true (outinfo.frames != 0,		"/n/nLine %d : Initial sfinfo.frames is not zero./n/n", __LINE__		) ;	test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;	sf_command (outfile, SFC_GET_CURRENT_SF_INFO, &outinfo, sizeof (outinfo)) ;	exit_if_true (outinfo.frames != BUFFER_LEN,		"/n/nLine %d : Initial sfinfo.frames (%ld) should be %d./n/n", __LINE__,		SF_COUNT_TO_LONG (outinfo.frames), BUFFER_LEN		) ;	/* Read file making sure no channel map exists. */	memset (&ininfo, 0, sizeof (ininfo)) ;	infile = test_open_file_or_die (filename, SFM_READ, &ininfo, SF_TRUE, __LINE__) ;	last_count = ininfo.frames ;	test_write_double_or_die (outfile, 0, double_data, BUFFER_LEN, __LINE__) ;	sf_command (infile, SFC_GET_CURRENT_SF_INFO, &ininfo, sizeof (ininfo)) ;	exit_if_true (ininfo.frames != BUFFER_LEN,		"/n/nLine %d : Initial sfinfo.frames (%ld) should be %d./n/n", __LINE__,		SF_COUNT_TO_LONG (ininfo.frames), BUFFER_LEN		) ;	sf_close (outfile) ;	sf_close (infile) ;	unlink (filename) ;	puts ("ok") ;} /* current_sf_info_test */
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:49,


示例19: double_int_big_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.9999) ;	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). (%" PRId64 " should be %d)/n", __LINE__, 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 */
开发者ID:CarlosXViera,项目名称:SoundShake,代码行数:49,


示例20: checksum_test

static voidchecksum_test (const CHECKSUM * cksum){	SNDFILE * file ;	SF_INFO info ;	print_test_name (__func__, cksum->enc_name) ;	memset (&info, 0, sizeof (SF_INFO)) ;	info.format = cksum->enc_fmt ;	info.channels = 1 ;	info.samplerate	= SAMPLE_RATE ;	file = test_open_file_or_die (cksum->enc_name, SFM_WRITE, &info, 0, __LINE__) ;	test_write_float_or_die (file, 0, orig, ARRAY_LEN (orig), __LINE__) ;	sf_close (file) ;	check_file_hash_or_die (cksum->enc_name, cksum->enc_cksum, __LINE__) ;	puts ("ok") ;	/*------------------------------------------------------------------------*/	print_test_name (__func__, cksum->dec_name) ;	memset (&info, 0, sizeof (SF_INFO)) ;	info.format = cksum->enc_fmt ;	info.channels = 1 ;	info.samplerate	= SAMPLE_RATE ;	file = test_open_file_or_die (cksum->enc_name, SFM_READ, &info, 0, __LINE__) ;	test_read_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ;	sf_close (file) ;	memset (&info, 0, sizeof (SF_INFO)) ;	info.format = SF_ENDIAN_LITTLE | SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;	info.channels = 1 ;	info.samplerate	= SAMPLE_RATE ;	file = test_open_file_or_die (cksum->dec_name, SFM_WRITE, &info, 0, __LINE__) ;	test_write_short_or_die (file, 0, data, ARRAY_LEN (data), __LINE__) ;	sf_close (file) ;	check_file_hash_or_die (cksum->dec_name, cksum->dec_cksum, __LINE__) ;	remove (cksum->enc_name) ;	remove (cksum->dec_name) ;	puts ("ok") ;} /* checksum_test */
开发者ID:stohrendorf,项目名称:libsndfile,代码行数:49,


示例21: float_short_little_test

static voidfloat_short_little_test (const char * filename){	SNDFILE		*file ;	SF_INFO		sfinfo ;	unsigned	k, max ;	print_test_name ("float_short_little_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_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_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 ((unsigned) 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_little_test */
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:49,


示例22: ogg_double_test

static voidogg_double_test (void){	const char * filename = "vorbis_double.oga" ;	SNDFILE * file ;	SF_INFO sfinfo ;	double seek_data [10] ;	print_test_name ("ogg_double_test", filename) ;	gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	/* Set up output file type. */	sfinfo.format = SF_FORMAT_OGG | SF_FORMAT_VORBIS ;	sfinfo.channels = 1 ;	sfinfo.samplerate = SAMPLE_RATE ;	/* Write the output file. */	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ;	sf_close (file) ;	/* Read the file in again. */	memset (&sfinfo, 0, sizeof (sfinfo)) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ;	sf_close (file) ;	puts ("ok") ;	/* Test seeking. */	print_test_name ("ogg_seek_test", filename) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ;	test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ;	compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ;	sf_close (file) ;	puts ("ok") ;	unlink (filename) ;} /* ogg_double_test */
开发者ID:DannyDaemonic,项目名称:libsndfile,代码行数:48,


示例23: instrumet_rw_test

static voidinstrumet_rw_test (const char *filename){	SNDFILE *sndfile ;	SF_INFO sfinfo ;	SF_INSTRUMENT inst ;	memset (&sfinfo, 0, sizeof (SF_INFO)) ;	sndfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;	if (sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)	{	inst.basenote = 22 ;		if (sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)			printf ("Sucess: [%s] updated/n", filename) ;		else			printf ("Error: SFC_SET_INSTRUMENT on [%s] [%s]/n", filename, sf_strerror (sndfile)) ;		}	else		printf ("Error: SFC_GET_INSTRUMENT on [%s] [%s]/n", filename, sf_strerror (sndfile)) ;	if (sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) != 0)		printf ("Error: SFC_UPDATE_HEADER_NOW on [%s] [%s]/n", filename, sf_strerror (sndfile)) ;	sf_write_sync (sndfile) ;	sf_close (sndfile) ;	return ;} /* instrumet_rw_test */
开发者ID:5in4,项目名称:libsox.dll,代码行数:29,


示例24: truncate_test

static voidtruncate_test (const char *filename, int filetype){	SNDFILE 	*file ;	SF_INFO		sfinfo ;	sf_count_t	len ;	print_test_name ("truncate_test", filename) ;	sfinfo.samplerate	= 11025 ;	sfinfo.format		= filetype ;	sfinfo.channels		= 2 ;	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;	test_write_int_or_die (file, 0, int_data, BUFFER_LEN, __LINE__) ;	len = 100 ;	if (sf_command (file, SFC_FILE_TRUNCATE, &len, sizeof (len)))	{	printf ("Line %d: sf_command (SFC_FILE_TRUNCATE) returned error./n", __LINE__) ;		exit (1) ;		} ;	test_seek_or_die (file, 0, SEEK_CUR, len, 2, __LINE__) ;	test_seek_or_die (file, 0, SEEK_END, len, 2, __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;} /* truncate_test */
开发者ID:5in4,项目名称:libsox.dll,代码行数:30,


示例25: print_test_name

static voidrdwr_short_test	(const char *filename){	SNDFILE *file ;	SF_INFO sfinfo ;    sf_count_t frames ;    short buffer [160] ;	print_test_name ("rdwr_short_test", filename) ;	memset (buffer, 0, sizeof (buffer)) ;	/* Create sound file with no data. */	sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16 ;	sfinfo.samplerate = 16000 ;	sfinfo.channels = 1 ;	unlink (filename) ;	frames = ARRAY_LEN (buffer) ;	/* Open again for read/write. */	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;	test_write_short_or_die (file, 0, buffer, frames, __LINE__) ;	test_read_short_or_die (file, 0, buffer, frames, __LINE__) ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;	return ;} /* rdwr_short_test */
开发者ID:Cnotinfor,项目名称:TopQX_Sound,代码行数:33,


示例26: locale_test

static voidlocale_test (const LOCALE_DATA * ldata){#if !HAVE_LOCALE_H || !HAVE_SETLOCALE	locname = filename = NULL ;	width = 0 ;	return ;#else	const short wdata [] = { 1, 2, 3, 4, 5, 6, 7, 8 } ;	short rdata [ARRAY_LEN (wdata)] ;	const char *old_locale ;	char utf8_locname [32] ;	SNDFILE *file ;	SF_INFO sfinfo ;	snprintf (utf8_locname, sizeof (utf8_locname), "%s%s", ldata->locale, ldata->utf8 ? ".UTF-8" : "") ;	/* Change the locale saving the old one. */	if ((old_locale = setlocale (LC_CTYPE, utf8_locname)) == NULL)		return ;	printf ("    locale_test           %-8s : %s %*c ", ldata->locale, ldata->filename, 24 - ldata->width, ' ') ;	fflush (stdout) ;	sfinfo.format = SF_FORMAT_AU | SF_FORMAT_PCM_16 ;	sfinfo.channels = 1 ;	sfinfo.samplerate = 44100 ;	file = test_open_file_or_die (ldata->filename, SFM_WRITE, &sfinfo, 0, __LINE__) ;	test_write_short_or_die (file, 0, wdata, ARRAY_LEN (wdata), __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (ldata->filename, SFM_READ, &sfinfo, 0, __LINE__) ;	test_read_short_or_die (file, 0, rdata, ARRAY_LEN (rdata), __LINE__) ;	sf_close (file) ;	unlink (ldata->filename) ;	/* Restore old locale. */	setlocale (LC_CTYPE, old_locale) ;	puts ("ok") ;#endif} /* locale_test */
开发者ID:stohrendorf,项目名称:libsndfile,代码行数:44,


示例27: header_shrink_test

static voidheader_shrink_test (const char *filename, int filetype){	SNDFILE *outfile, *infile ;	SF_INFO sfinfo ;	sf_count_t frames ;	float buffer [8], bufferin [8] ;	print_test_name ("header_shrink_test", filename) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	sfinfo.samplerate = 44100 ;	sfinfo.format = filetype | SF_FORMAT_FLOAT ;	sfinfo.channels = 1 ;	memset (buffer, 0xA0, sizeof (buffer)) ;	/* Now write some frames. */	frames = ARRAY_LEN (buffer) / sfinfo.channels ;	/* Test the file with extra header data. */	outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ;	sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;	sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, SF_FALSE) ;	sf_command (outfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;	test_writef_float_or_die (outfile, 0, buffer, frames, __LINE__) ;	sf_close (outfile) ;	/* Open again for read. */	infile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;	test_readf_float_or_die (infile, 0, bufferin, frames, __LINE__) ;	sf_close (infile) ;	compare_float_or_die (buffer, bufferin, frames, __LINE__) ;	unlink (filename) ;	puts ("ok") ;	return ;} /* header_shrink_test */
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:41,


示例28: broadcast_rdwr_test

static	voidbroadcast_rdwr_test (const char *filename, int filetype){	SF_BROADCAST_INFO binfo ;	SNDFILE *file ;	SF_INFO sfinfo ;	sf_count_t frames ;	print_test_name (__func__, filename) ;	create_short_sndfile (filename, filetype, 2) ;	memset (&sfinfo, 0, sizeof (sfinfo)) ;	memset (&binfo, 0, sizeof (binfo)) ;	snprintf (binfo.description, sizeof (binfo.description), "Test description") ;	snprintf (binfo.originator, sizeof (binfo.originator), "Test originator") ;	snprintf (binfo.originator_reference, sizeof (binfo.originator_reference), "%08x-%08x", (unsigned int) time (NULL), (unsigned int) (~ time (NULL))) ;	snprintf (binfo.origination_date, sizeof (binfo.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;	snprintf (binfo.origination_time, sizeof (binfo.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;	snprintf (binfo.umid, sizeof (binfo.umid), "Some umid") ;	binfo.coding_history_size = 0 ;	file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;	frames = sfinfo.frames ;	if (sf_command (file, SFC_SET_BROADCAST_INFO, &binfo, sizeof (binfo)) != SF_FALSE)	{	printf ("/n/nLine %d : sf_command (SFC_SET_BROADCAST_INFO) should have failed but didn't./n/n", __LINE__) ;		exit (1) ;		} ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	sf_close (file) ;	exit_if_true (frames != sfinfo.frames, "/n/nLine %d : Frame count %lld should be %lld./n", __LINE__, sfinfo.frames, frames) ;	unlink (filename) ;	puts ("ok") ;} /* broadcast_rdwr_test */
开发者ID:5in4,项目名称:libsox.dll,代码行数:37,


示例29: largefile_test

static voidlargefile_test (int filetype, const char * filename){	static float data [BUFFER_LEN] ;	SNDFILE		*file ;	SF_INFO		sfinfo ;	int k ;	print_test_name ("largefile_test", filename) ;	sfinfo.samplerate	= 44100 ;	sfinfo.channels		= 2 ;	sfinfo.frames		= 0 ;	sfinfo.format = (filetype | SF_FORMAT_PCM_32) ;	file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;	for (k = 0 ; k < BUFFER_COUNT ; k++)		test_write_float_or_die (file, k, data, BUFFER_LEN, __LINE__) ;	sf_close (file) ;	file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;	if ((sfinfo.frames * sfinfo.channels) / BUFFER_LEN != BUFFER_COUNT)	{	printf ("/n/nLine %d : bad frame count./n", __LINE__) ;		exit (1) ;		} ;	sf_close (file) ;	unlink (filename) ;	puts ("ok") ;	return ;} /* largefile_test */
开发者ID:AaronFae,项目名称:VimProject,代码行数:36,


示例30: pipe_read_test

static voidpipe_read_test (int filetype, const char *ext){	static short data [PIPE_TEST_LEN] ;	static char buffer [256] ;	static char filename [256] ;	SNDFILE	*outfile ;	SF_INFO sfinfo ;	int k, retval ;	snprintf (filename, sizeof (filename), "pipe_in.%s", ext) ;	print_test_name ("pipe_read_test", filename) ;	sfinfo.format = filetype | SF_FORMAT_PCM_16 ;	sfinfo.channels = 1 ;	sfinfo.samplerate = 44100 ;	for (k = 0 ; k < PIPE_TEST_LEN ; k++)		data [k] = PIPE_INDEX (k) ;	outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, __LINE__) ;	test_writef_short_or_die (outfile, 0, data, PIPE_TEST_LEN, __LINE__) ;	sf_close (outfile) ;	snprintf (buffer, sizeof (buffer), "cat %s | ./stdin_test %s ", filename, ext) ;	if ((retval = system (buffer)) != 0)	{	retval = WEXITSTATUS (retval) ;		printf ("/n/n    Line %d : pipe test returned error for file type /"%s/"./n/n", __LINE__, ext) ;		exit (retval) ;		} ;	unlink (filename) ;	puts ("ok") ;	return ;} /* pipe_read_test */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:36,



注:本文中的test_open_file_or_die函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ test_opt函数代码示例
C++ test_one函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。