barkmel.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
  4. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  5. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  6. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  7. * *
  8. * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: bark scale utility
  13. last mod: $Id: barkmel.c 19454 2015-03-02 22:39:28Z xiphmont $
  14. ********************************************************************/
  15. #include <stdio.h>
  16. #include "scales.h"
  17. int main(){
  18. int i;
  19. double rate;
  20. for(i=64;i<32000;i*=2){
  21. rate=48000.f;
  22. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  23. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  24. rate=44100.f;
  25. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  26. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  27. rate=32000.f;
  28. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  29. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  30. rate=22050.f;
  31. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  32. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  33. rate=16000.f;
  34. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  35. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  36. rate=11025.f;
  37. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  38. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  39. rate=8000.f;
  40. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n\n",
  41. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  42. }
  43. {
  44. float i;
  45. int j;
  46. for(i=0.,j=0;i<28;i+=1,j++){
  47. fprintf(stderr,"(%d) bark=%f %gHz (%d of 128)\n",
  48. j,i,fromBARK(i),(int)(fromBARK(i)/22050.*128.));
  49. }
  50. }
  51. return(0);
  52. }