Skip to content
Snippets Groups Projects
frame.c 28.9 KiB
Newer Older
  • Learn to ignore specific revisions
  •       }
        return result;
    }
    
    double double2db( double value)
    {
      if (value < 0)
        value = -value;
      return 6.0 * log( value / 32767) / log( 2);
    }
    
    void readawaysamples( FILE *in, size_t size)
    {
      short *buffer;
      int samplesread, count;
    
      buffer = malloc( sizeof( *buffer) * BUFFSIZE);
      if (buffer == NULL) fatalperror("Couldn't allocate buffer");
    
      while (size > 0)
        {
          if (size > BUFFSIZE)
    	count = BUFFSIZE;
          else
    	count = size;
    
          samplesread = fread( buffer, sizeof(*buffer), count, in);
          if (ferror( in) != 0)
    	fatalperror("Error reading input file");
          size -= samplesread;
        }
      free( buffer);
    }