barkmel.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 https://xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: bark scale utility
  13. ********************************************************************/
  14. #include <stdio.h>
  15. #include "scales.h"
  16. int main(){
  17. int i;
  18. double rate;
  19. for(i=64;i<32000;i*=2){
  20. rate=48000.f;
  21. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  22. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  23. rate=44100.f;
  24. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  25. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  26. rate=32000.f;
  27. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  28. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  29. rate=22050.f;
  30. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  31. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  32. rate=16000.f;
  33. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  34. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  35. rate=11025.f;
  36. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n",
  37. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  38. rate=8000.f;
  39. fprintf(stderr,"rate=%gHz, block=%d, f(1)=%.2gHz bark(1)=%.2g (of %.2g)\n\n",
  40. rate,i,rate/2 / (i/2),toBARK(rate/2 /(i/2)),toBARK(rate/2));
  41. }
  42. {
  43. float i;
  44. int j;
  45. for(i=0.,j=0;i<28;i+=1,j++){
  46. fprintf(stderr,"(%d) bark=%f %gHz (%d of 128)\n",
  47. j,i,fromBARK(i),(int)(fromBARK(i)/22050.*128.));
  48. }
  49. }
  50. return(0);
  51. }