Skip to content
Snippets Groups Projects
frame.c 29.1 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 *input, 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, input);
          if (ferror( input) != 0)
    
    	fatalperror("Error reading input file");
          size -= samplesread;
        }
      free( buffer);
    }