Advertisement
glokyfull

hypnodot tables

Jul 12th, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1.  
  2. ;
  3. ; source for do the file for the hypnodot demo source
  4. ; code by me
  5. ;
  6. ;
  7. ;
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. #include <math.h>
  13.  
  14.  
  15. void putWord(char* table,int pos,int value);
  16.  
  17.  
  18. int main(argc,argv)
  19. int argc;
  20. char **argv;
  21. {
  22.    
  23.     char mytable[1540*2];
  24.     FILE* fichier;
  25.     int ofs=0;
  26.     int i;
  27.     for (i=0;i<512;i++)
  28.     {   double sinus=sin(i*3.14159265358979/256.0);
  29.         putWord(mytable,ofs,(int) (sinus*32767+32767));
  30.         ofs+=1;
  31.     }
  32.     fichier=fopen("SIN512.ATA","w");
  33.     for (i=0;i<1024;i++)
  34.     {
  35.         fputc(mytable[i],fichier);
  36.     }
  37.     fclose(fichier);
  38.    
  39.    
  40.     ofs=0;
  41.     for (i=0;i<1540;i++)
  42.     {
  43.         double sinus=sin(i*3.14159265358979*2/1540.0);
  44.         putWord(mytable,ofs,(int) (sinus*32767+32767));
  45.         ofs+=1;
  46.     }
  47.     fichier=fopen("SIN1540.ATA","w");
  48.     for (i=0;i<1540;i++)
  49.     {
  50.         fputc(mytable[i],fichier);
  51.     }
  52.     fclose(fichier);
  53.  
  54. }
  55.    
  56. void putWord(char* table,int pos,int value)
  57. {
  58.     table[pos*2]=(char)(((value+65536)/256) & 255);
  59.     table[pos*2+1]=(char)(value & 255);
  60. }
  61. int min(int a,int b)
  62. {
  63.     int c=a;
  64.     if (a>b)
  65.     {
  66.         c=b;
  67.     }
  68.     return c;
  69. }
  70. int max(int a,int b)
  71. {
  72.     int c=a;
  73.     if (a<b)
  74.     {
  75.         c=b;
  76.     }
  77.     return c;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement