buffer = buffer2 ;
}
-#if 0
+
void slSample::changeToUnsigned ()
{
if ( getBps() == 16 )
(0xFF-buffer[i]) ;
}
}
-#endif
+
void slSample::changeBps ( int b )
{
Uchar *buffer2 = new Uchar [ length / 2 ] ;
- for ( int i = 0 ; i < length ; i++ )
+ for ( int i = 0 ; i < (length-1)/2 ; i++ )
buffer2 [ i ] = ((int)buffer [ i*2 ] + (int)buffer [ i*2 + 1 ] ) / 2 ;
delete buffer ;
{
Ushort *buffer2 = new Ushort [ length / 4 ] ;
- for ( int i = 0 ; i < length / 4 ; i++ )
+ for ( int i = 0 ; i < (length-3) / 4 ; i++ )
buffer2 [ i ] = ((int)((Ushort *)buffer) [ i*2 ] +
(int)((Ushort *)buffer) [ i*2 + 1 ] ) / 2 ;
delete buffer ;
buffer = (Uchar *)buffer2 ;
- length /= 2 ;
+ length /= 4 ;
setStereo ( SL_FALSE ) ;
}
}
char magic [ 8 ] ;
- if ( fread ( magic, 4, 1, fd ) == -1 ||
+ if ( fread ( magic, 4, 1, fd ) == 0 ||
magic[0] != 'R' || magic[1] != 'I' ||
magic[2] != 'F' || magic[3] != 'F' )
{
int leng1 ;
- if ( fread ( & leng1, sizeof(int), 1, fd ) == -1 )
+ if ( fread ( & leng1, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;
{
found_header = SL_TRUE ;
- if ( fread ( & leng1, sizeof(int), 1, fd ) == -1 )
+ if ( fread ( & leng1, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;
return SL_FALSE ;
}
- if ( fread ( & length, sizeof(int), 1, fd ) == -1 )
+ if ( fread ( & length, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in data\n", fname ) ;
fclose ( fd ) ;
char magic [ 4 ] ;
- if ( fread ( magic, 4, 1, fd ) == -1 ||
+ if ( fread ( magic, 4, 1, fd ) == 0 ||
magic[0] != '.' || magic[1] != 's' ||
magic[2] != 'n' || magic[3] != 'd' )
{
int irate ;
int nchans ;
- if ( fread ( & hdr_length, sizeof(int), 1, fd ) == -1 ||
- fread ( & dat_length, sizeof(int), 1, fd ) == -1 ||
- fread ( & nbytes , sizeof(int), 1, fd ) == -1 ||
- fread ( & irate , sizeof(int), 1, fd ) == -1 ||
- fread ( & nchans , sizeof(int), 1, fd ) == -1 )
+ if ( fread ( & hdr_length, sizeof(int), 1, fd ) == 0 ||
+ fread ( & dat_length, sizeof(int), 1, fd ) == 0 ||
+ fread ( & nbytes , sizeof(int), 1, fd ) == 0 ||
+ fread ( & irate , sizeof(int), 1, fd ) == 0 ||
+ fread ( & nchans , sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;