1b815c7f3Sopenharmony_ci/* 2b815c7f3Sopenharmony_ci** Copyright (C) 2007-2019 Erik de Castro Lopo <erikd@mega-nerd.com> 3b815c7f3Sopenharmony_ci** Copyright (C) 2019 John ffitch <jpff@codemist.co.uk> 4b815c7f3Sopenharmony_ci** 5b815c7f3Sopenharmony_ci** This program is free software; you can redistribute it and/or modify 6b815c7f3Sopenharmony_ci** it under the terms of the GNU General Public License as published by 7b815c7f3Sopenharmony_ci** the Free Software Foundation; either version 2 of the License, or 8b815c7f3Sopenharmony_ci** (at your option) any later version. 9b815c7f3Sopenharmony_ci** 10b815c7f3Sopenharmony_ci** This program is distributed in the hope that it will be useful, 11b815c7f3Sopenharmony_ci** but WITHOUT ANY WARRANTY; without even the implied warranty of 12b815c7f3Sopenharmony_ci** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13b815c7f3Sopenharmony_ci** GNU General Public License for more details. 14b815c7f3Sopenharmony_ci** 15b815c7f3Sopenharmony_ci** You should have received a copy of the GNU General Public License 16b815c7f3Sopenharmony_ci** along with this program; if not, write to the Free Software 17b815c7f3Sopenharmony_ci** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18b815c7f3Sopenharmony_ci*/ 19b815c7f3Sopenharmony_ci 20b815c7f3Sopenharmony_ci#include "sfconfig.h" 21b815c7f3Sopenharmony_ci 22b815c7f3Sopenharmony_ci#include <stdio.h> 23b815c7f3Sopenharmony_ci#include <stdlib.h> 24b815c7f3Sopenharmony_ci#include <string.h> 25b815c7f3Sopenharmony_ci#if HAVE_UNISTD_H 26b815c7f3Sopenharmony_ci#include <unistd.h> 27b815c7f3Sopenharmony_ci#else 28b815c7f3Sopenharmony_ci#include "sf_unistd.h" 29b815c7f3Sopenharmony_ci#endif 30b815c7f3Sopenharmony_ci 31b815c7f3Sopenharmony_ci#include <math.h> 32b815c7f3Sopenharmony_ci 33b815c7f3Sopenharmony_ci#include <sndfile.h> 34b815c7f3Sopenharmony_ci 35b815c7f3Sopenharmony_ci#include "utils.h" 36b815c7f3Sopenharmony_ci 37b815c7f3Sopenharmony_ci#define SAMPLE_RATE 44100 38b815c7f3Sopenharmony_ci#define DATA_LENGTH (SAMPLE_RATE / 8) 39b815c7f3Sopenharmony_ci 40b815c7f3Sopenharmony_citypedef union 41b815c7f3Sopenharmony_ci{ double d [DATA_LENGTH] ; 42b815c7f3Sopenharmony_ci float f [DATA_LENGTH] ; 43b815c7f3Sopenharmony_ci int i [DATA_LENGTH] ; 44b815c7f3Sopenharmony_ci short s [DATA_LENGTH] ; 45b815c7f3Sopenharmony_ci} BUFFER ; 46b815c7f3Sopenharmony_ci 47b815c7f3Sopenharmony_cistatic BUFFER data_out ; 48b815c7f3Sopenharmony_cistatic BUFFER data_in ; 49b815c7f3Sopenharmony_ci 50b815c7f3Sopenharmony_cistatic void 51b815c7f3Sopenharmony_cimpeg_short_test (void) 52b815c7f3Sopenharmony_ci{ const char * filename = "mpeg_short.mp3" ; 53b815c7f3Sopenharmony_ci 54b815c7f3Sopenharmony_ci SNDFILE * file ; 55b815c7f3Sopenharmony_ci SF_INFO sfinfo ; 56b815c7f3Sopenharmony_ci short seek_data [10] ; 57b815c7f3Sopenharmony_ci unsigned k ; 58b815c7f3Sopenharmony_ci 59b815c7f3Sopenharmony_ci print_test_name ("mpeg_short_test", filename) ; 60b815c7f3Sopenharmony_ci 61b815c7f3Sopenharmony_ci /* Generate float data. */ 62b815c7f3Sopenharmony_ci gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7F00) ; 63b815c7f3Sopenharmony_ci 64b815c7f3Sopenharmony_ci /* Convert to shorteger. */ 65b815c7f3Sopenharmony_ci for (k = 0 ; k < ARRAY_LEN (data_out.s) ; k++) 66b815c7f3Sopenharmony_ci data_out.s [k] = lrintf (data_out.f [k]) ; 67b815c7f3Sopenharmony_ci 68b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 69b815c7f3Sopenharmony_ci 70b815c7f3Sopenharmony_ci /* Set up output file type. */ 71b815c7f3Sopenharmony_ci sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; 72b815c7f3Sopenharmony_ci sfinfo.channels = 1 ; 73b815c7f3Sopenharmony_ci sfinfo.samplerate = SAMPLE_RATE ; 74b815c7f3Sopenharmony_ci 75b815c7f3Sopenharmony_ci /* Write the output file. */ 76b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; 77b815c7f3Sopenharmony_ci test_write_short_or_die (file, 0, data_out.s, ARRAY_LEN (data_out.s), __LINE__) ; 78b815c7f3Sopenharmony_ci sf_close (file) ; 79b815c7f3Sopenharmony_ci 80b815c7f3Sopenharmony_ci /* Read the file in again. */ 81b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 82b815c7f3Sopenharmony_ci 83b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 84b815c7f3Sopenharmony_ci test_read_short_or_die (file, 0, data_in.s, ARRAY_LEN (data_in.s), __LINE__) ; 85b815c7f3Sopenharmony_ci sf_close (file) ; 86b815c7f3Sopenharmony_ci 87b815c7f3Sopenharmony_ci puts ("ok") ; 88b815c7f3Sopenharmony_ci 89b815c7f3Sopenharmony_ci /* Test seeking. */ 90b815c7f3Sopenharmony_ci print_test_name ("mpeg_seek_test", filename) ; 91b815c7f3Sopenharmony_ci 92b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 93b815c7f3Sopenharmony_ci 94b815c7f3Sopenharmony_ci test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; 95b815c7f3Sopenharmony_ci test_read_short_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; 96b815c7f3Sopenharmony_ci compare_short_or_die (seek_data, data_in.s + 10, ARRAY_LEN (seek_data), __LINE__) ; 97b815c7f3Sopenharmony_ci 98b815c7f3Sopenharmony_ci /* Test seek to end of file. */ 99b815c7f3Sopenharmony_ci test_seek_or_die (file, 0, SEEK_END, sfinfo.frames, sfinfo.channels, __LINE__) ; 100b815c7f3Sopenharmony_ci 101b815c7f3Sopenharmony_ci sf_close (file) ; 102b815c7f3Sopenharmony_ci 103b815c7f3Sopenharmony_ci puts ("ok") ; 104b815c7f3Sopenharmony_ci 105b815c7f3Sopenharmony_ci unlink (filename) ; 106b815c7f3Sopenharmony_ci} /* mpeg_short_test */ 107b815c7f3Sopenharmony_ci 108b815c7f3Sopenharmony_cistatic void 109b815c7f3Sopenharmony_cimpeg_int_test (void) 110b815c7f3Sopenharmony_ci{ const char * filename = "mpeg_int.mp3" ; 111b815c7f3Sopenharmony_ci 112b815c7f3Sopenharmony_ci SNDFILE * file ; 113b815c7f3Sopenharmony_ci SF_INFO sfinfo ; 114b815c7f3Sopenharmony_ci int seek_data [10] ; 115b815c7f3Sopenharmony_ci unsigned k ; 116b815c7f3Sopenharmony_ci 117b815c7f3Sopenharmony_ci print_test_name ("mpeg_int_test", filename) ; 118b815c7f3Sopenharmony_ci 119b815c7f3Sopenharmony_ci /* Generate float data. */ 120b815c7f3Sopenharmony_ci gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 1.0 * 0x7FFF0000) ; 121b815c7f3Sopenharmony_ci 122b815c7f3Sopenharmony_ci /* Convert to integer. */ 123b815c7f3Sopenharmony_ci for (k = 0 ; k < ARRAY_LEN (data_out.i) ; k++) 124b815c7f3Sopenharmony_ci data_out.i [k] = lrintf (data_out.f [k]) ; 125b815c7f3Sopenharmony_ci 126b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 127b815c7f3Sopenharmony_ci 128b815c7f3Sopenharmony_ci /* Set up output file type. */ 129b815c7f3Sopenharmony_ci sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; 130b815c7f3Sopenharmony_ci sfinfo.channels = 1 ; 131b815c7f3Sopenharmony_ci sfinfo.samplerate = SAMPLE_RATE ; 132b815c7f3Sopenharmony_ci 133b815c7f3Sopenharmony_ci /* Write the output file. */ 134b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; 135b815c7f3Sopenharmony_ci test_write_int_or_die (file, 0, data_out.i, ARRAY_LEN (data_out.i), __LINE__) ; 136b815c7f3Sopenharmony_ci sf_close (file) ; 137b815c7f3Sopenharmony_ci 138b815c7f3Sopenharmony_ci /* Read the file in again. */ 139b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 140b815c7f3Sopenharmony_ci 141b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 142b815c7f3Sopenharmony_ci test_read_int_or_die (file, 0, data_in.i, ARRAY_LEN (data_in.i), __LINE__) ; 143b815c7f3Sopenharmony_ci sf_close (file) ; 144b815c7f3Sopenharmony_ci 145b815c7f3Sopenharmony_ci puts ("ok") ; 146b815c7f3Sopenharmony_ci 147b815c7f3Sopenharmony_ci /* Test seeking. */ 148b815c7f3Sopenharmony_ci print_test_name ("mpeg_seek_test", filename) ; 149b815c7f3Sopenharmony_ci 150b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 151b815c7f3Sopenharmony_ci 152b815c7f3Sopenharmony_ci test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; 153b815c7f3Sopenharmony_ci test_read_int_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; 154b815c7f3Sopenharmony_ci compare_int_or_die (seek_data, data_in.i + 10, ARRAY_LEN (seek_data), __LINE__) ; 155b815c7f3Sopenharmony_ci 156b815c7f3Sopenharmony_ci sf_close (file) ; 157b815c7f3Sopenharmony_ci 158b815c7f3Sopenharmony_ci puts ("ok") ; 159b815c7f3Sopenharmony_ci 160b815c7f3Sopenharmony_ci unlink (filename) ; 161b815c7f3Sopenharmony_ci} /* mpeg_int_test */ 162b815c7f3Sopenharmony_ci 163b815c7f3Sopenharmony_cistatic void 164b815c7f3Sopenharmony_cimpeg_float_test (void) 165b815c7f3Sopenharmony_ci{ const char * filename = "mpeg_float.mp3" ; 166b815c7f3Sopenharmony_ci 167b815c7f3Sopenharmony_ci SNDFILE * file ; 168b815c7f3Sopenharmony_ci SF_INFO sfinfo ; 169b815c7f3Sopenharmony_ci float seek_data [10] ; 170b815c7f3Sopenharmony_ci 171b815c7f3Sopenharmony_ci print_test_name ("mpeg_float_test", filename) ; 172b815c7f3Sopenharmony_ci 173b815c7f3Sopenharmony_ci gen_windowed_sine_float (data_out.f, ARRAY_LEN (data_out.f), 0.95) ; 174b815c7f3Sopenharmony_ci 175b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 176b815c7f3Sopenharmony_ci 177b815c7f3Sopenharmony_ci /* Set up output file type. */ 178b815c7f3Sopenharmony_ci sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; 179b815c7f3Sopenharmony_ci sfinfo.channels = 1 ; 180b815c7f3Sopenharmony_ci sfinfo.samplerate = SAMPLE_RATE ; 181b815c7f3Sopenharmony_ci 182b815c7f3Sopenharmony_ci /* Write the output file. */ 183b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; 184b815c7f3Sopenharmony_ci test_write_float_or_die (file, 0, data_out.f, ARRAY_LEN (data_out.f), __LINE__) ; 185b815c7f3Sopenharmony_ci sf_close (file) ; 186b815c7f3Sopenharmony_ci 187b815c7f3Sopenharmony_ci /* Read the file in again. */ 188b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 189b815c7f3Sopenharmony_ci 190b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 191b815c7f3Sopenharmony_ci test_read_float_or_die (file, 0, data_in.f, ARRAY_LEN (data_in.f), __LINE__) ; 192b815c7f3Sopenharmony_ci sf_close (file) ; 193b815c7f3Sopenharmony_ci 194b815c7f3Sopenharmony_ci puts ("ok") ; 195b815c7f3Sopenharmony_ci 196b815c7f3Sopenharmony_ci /* Test seeking. */ 197b815c7f3Sopenharmony_ci print_test_name ("mpeg_seek_test", filename) ; 198b815c7f3Sopenharmony_ci 199b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 200b815c7f3Sopenharmony_ci 201b815c7f3Sopenharmony_ci test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; 202b815c7f3Sopenharmony_ci test_read_float_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; 203b815c7f3Sopenharmony_ci compare_float_or_die (seek_data, data_in.f + 10, ARRAY_LEN (seek_data), __LINE__) ; 204b815c7f3Sopenharmony_ci 205b815c7f3Sopenharmony_ci sf_close (file) ; 206b815c7f3Sopenharmony_ci 207b815c7f3Sopenharmony_ci puts ("ok") ; 208b815c7f3Sopenharmony_ci 209b815c7f3Sopenharmony_ci unlink (filename) ; 210b815c7f3Sopenharmony_ci} /* mpeg_float_test */ 211b815c7f3Sopenharmony_ci 212b815c7f3Sopenharmony_cistatic void 213b815c7f3Sopenharmony_cimpeg_double_test (void) 214b815c7f3Sopenharmony_ci{ const char * filename = "mpeg_double.mp3" ; 215b815c7f3Sopenharmony_ci 216b815c7f3Sopenharmony_ci SNDFILE * file ; 217b815c7f3Sopenharmony_ci SF_INFO sfinfo ; 218b815c7f3Sopenharmony_ci double seek_data [10] ; 219b815c7f3Sopenharmony_ci 220b815c7f3Sopenharmony_ci print_test_name ("mpeg_double_test", filename) ; 221b815c7f3Sopenharmony_ci 222b815c7f3Sopenharmony_ci gen_windowed_sine_double (data_out.d, ARRAY_LEN (data_out.d), 0.95) ; 223b815c7f3Sopenharmony_ci 224b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 225b815c7f3Sopenharmony_ci 226b815c7f3Sopenharmony_ci /* Set up output file type. */ 227b815c7f3Sopenharmony_ci sfinfo.format = SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III ; 228b815c7f3Sopenharmony_ci sfinfo.channels = 1 ; 229b815c7f3Sopenharmony_ci sfinfo.samplerate = SAMPLE_RATE ; 230b815c7f3Sopenharmony_ci 231b815c7f3Sopenharmony_ci /* Write the output file. */ 232b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; 233b815c7f3Sopenharmony_ci test_write_double_or_die (file, 0, data_out.d, ARRAY_LEN (data_out.d), __LINE__) ; 234b815c7f3Sopenharmony_ci sf_close (file) ; 235b815c7f3Sopenharmony_ci 236b815c7f3Sopenharmony_ci /* Read the file in again. */ 237b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 238b815c7f3Sopenharmony_ci 239b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 240b815c7f3Sopenharmony_ci test_read_double_or_die (file, 0, data_in.d, ARRAY_LEN (data_in.d), __LINE__) ; 241b815c7f3Sopenharmony_ci sf_close (file) ; 242b815c7f3Sopenharmony_ci 243b815c7f3Sopenharmony_ci puts ("ok") ; 244b815c7f3Sopenharmony_ci 245b815c7f3Sopenharmony_ci /* Test seeking. */ 246b815c7f3Sopenharmony_ci print_test_name ("mpeg_seek_test", filename) ; 247b815c7f3Sopenharmony_ci 248b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 249b815c7f3Sopenharmony_ci 250b815c7f3Sopenharmony_ci test_seek_or_die (file, 10, SEEK_SET, 10, sfinfo.channels, __LINE__) ; 251b815c7f3Sopenharmony_ci test_read_double_or_die (file, 0, seek_data, ARRAY_LEN (seek_data), __LINE__) ; 252b815c7f3Sopenharmony_ci compare_double_or_die (seek_data, data_in.d + 10, ARRAY_LEN (seek_data), __LINE__) ; 253b815c7f3Sopenharmony_ci 254b815c7f3Sopenharmony_ci sf_close (file) ; 255b815c7f3Sopenharmony_ci 256b815c7f3Sopenharmony_ci puts ("ok") ; 257b815c7f3Sopenharmony_ci 258b815c7f3Sopenharmony_ci unlink (filename) ; 259b815c7f3Sopenharmony_ci} /* mpeg_double_test */ 260b815c7f3Sopenharmony_ci 261b815c7f3Sopenharmony_ci 262b815c7f3Sopenharmony_cistatic void 263b815c7f3Sopenharmony_cimpeg_stereo_seek_test (const char * filename, int format) 264b815c7f3Sopenharmony_ci{ static float data [SAMPLE_RATE] ; 265b815c7f3Sopenharmony_ci static float stereo_out [SAMPLE_RATE * 2] ; 266b815c7f3Sopenharmony_ci 267b815c7f3Sopenharmony_ci SNDFILE * file ; 268b815c7f3Sopenharmony_ci SF_INFO sfinfo ; 269b815c7f3Sopenharmony_ci sf_count_t pos ; 270b815c7f3Sopenharmony_ci unsigned k ; 271b815c7f3Sopenharmony_ci 272b815c7f3Sopenharmony_ci print_test_name (__func__, filename) ; 273b815c7f3Sopenharmony_ci 274b815c7f3Sopenharmony_ci gen_windowed_sine_float (data, ARRAY_LEN (data), 0.95) ; 275b815c7f3Sopenharmony_ci for (k = 0 ; k < ARRAY_LEN (data) ; k++) 276b815c7f3Sopenharmony_ci { stereo_out [2 * k] = data [k] ; 277b815c7f3Sopenharmony_ci stereo_out [2 * k + 1] = data [ARRAY_LEN (data) - k - 1] ; 278b815c7f3Sopenharmony_ci } ; 279b815c7f3Sopenharmony_ci 280b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 281b815c7f3Sopenharmony_ci 282b815c7f3Sopenharmony_ci /* Set up output file type. */ 283b815c7f3Sopenharmony_ci sfinfo.format = format ; 284b815c7f3Sopenharmony_ci sfinfo.channels = 2 ; 285b815c7f3Sopenharmony_ci sfinfo.samplerate = SAMPLE_RATE ; 286b815c7f3Sopenharmony_ci 287b815c7f3Sopenharmony_ci /* Write the output file. */ 288b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_FALSE, __LINE__) ; 289b815c7f3Sopenharmony_ci test_write_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; 290b815c7f3Sopenharmony_ci sf_close (file) ; 291b815c7f3Sopenharmony_ci 292b815c7f3Sopenharmony_ci /* Open file in again for reading. */ 293b815c7f3Sopenharmony_ci memset (&sfinfo, 0, sizeof (sfinfo)) ; 294b815c7f3Sopenharmony_ci file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ; 295b815c7f3Sopenharmony_ci 296b815c7f3Sopenharmony_ci /* Read in the whole file. */ 297b815c7f3Sopenharmony_ci test_read_float_or_die (file, 0, stereo_out, ARRAY_LEN (stereo_out), __LINE__) ; 298b815c7f3Sopenharmony_ci 299b815c7f3Sopenharmony_ci /* Now hammer seeking code. */ 300b815c7f3Sopenharmony_ci test_seek_or_die (file, 234, SEEK_SET, 234, sfinfo.channels, __LINE__) ; 301b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 302b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + (234 * sfinfo.channels), 10, __LINE__) ; 303b815c7f3Sopenharmony_ci 304b815c7f3Sopenharmony_ci test_seek_or_die (file, 442, SEEK_SET, 442, sfinfo.channels, __LINE__) ; 305b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 306b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + (442 * sfinfo.channels), 10, __LINE__) ; 307b815c7f3Sopenharmony_ci 308b815c7f3Sopenharmony_ci test_seek_or_die (file, 12, SEEK_CUR, 442 + 10 + 12, sfinfo.channels, __LINE__) ; 309b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 310b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + ((442 + 10 + 12) * sfinfo.channels), 10, __LINE__) ; 311b815c7f3Sopenharmony_ci 312b815c7f3Sopenharmony_ci test_seek_or_die (file, 12, SEEK_CUR, 442 + 20 + 24, sfinfo.channels, __LINE__) ; 313b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 314b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + ((442 + 20 + 24) * sfinfo.channels), 10, __LINE__) ; 315b815c7f3Sopenharmony_ci 316b815c7f3Sopenharmony_ci pos = 500 - sfinfo.frames ; 317b815c7f3Sopenharmony_ci test_seek_or_die (file, pos, SEEK_END, 500, sfinfo.channels, __LINE__) ; 318b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 319b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + (500 * sfinfo.channels), 10, __LINE__) ; 320b815c7f3Sopenharmony_ci 321b815c7f3Sopenharmony_ci pos = 10 - sfinfo.frames ; 322b815c7f3Sopenharmony_ci test_seek_or_die (file, pos, SEEK_END, 10, sfinfo.channels, __LINE__) ; 323b815c7f3Sopenharmony_ci test_readf_float_or_die (file, 0, data, 10, __LINE__) ; 324b815c7f3Sopenharmony_ci compare_float_or_die (data, stereo_out + (10 * sfinfo.channels), 10, __LINE__) ; 325b815c7f3Sopenharmony_ci 326b815c7f3Sopenharmony_ci sf_close (file) ; 327b815c7f3Sopenharmony_ci 328b815c7f3Sopenharmony_ci puts ("ok") ; 329b815c7f3Sopenharmony_ci unlink (filename) ; 330b815c7f3Sopenharmony_ci} /* mpeg_stereo_seek_test */ 331b815c7f3Sopenharmony_ci 332b815c7f3Sopenharmony_ci 333b815c7f3Sopenharmony_ciint 334b815c7f3Sopenharmony_cimain (void) 335b815c7f3Sopenharmony_ci{ 336b815c7f3Sopenharmony_ci if (HAVE_MPEG) 337b815c7f3Sopenharmony_ci { mpeg_short_test () ; 338b815c7f3Sopenharmony_ci mpeg_int_test () ; 339b815c7f3Sopenharmony_ci mpeg_float_test () ; 340b815c7f3Sopenharmony_ci mpeg_double_test () ; 341b815c7f3Sopenharmony_ci 342b815c7f3Sopenharmony_ci mpeg_stereo_seek_test ("mpeg_seek.mp3", SF_FORMAT_MPEG | SF_FORMAT_MPEG_LAYER_III) ; 343b815c7f3Sopenharmony_ci } 344b815c7f3Sopenharmony_ci else 345b815c7f3Sopenharmony_ci puts (" No MPEG tests because mpg123/lame support was not compiled in.") ; 346b815c7f3Sopenharmony_ci return 0 ; 347b815c7f3Sopenharmony_ci} /* main */ 348b815c7f3Sopenharmony_ci 349