source: buchla-68k/orig/BUCHLA/CURTAB.C@ 4b63bf3

Last change on this file since 4b63bf3 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.0 KB
Line 
1/*
2 =============================================================================
3 curtab.c -- compute sine wave cursor table for waveshape editor
4 Written by D.N. Lynx Crowe -- see VER below for version
5 =============================================================================
6*/
7
8#define VER "Version 4 -- 1987-10-07"
9
10#define DEBUGIT 0
11
12#include "stdio.h"
13#include "limits.h"
14#include "math.h"
15#include "stddefs.h"
16
17#define TWOPI ((double)(2.0 * PI))
18
19#define TABLEN 256
20#define DTABLEN ((double)256.0)
21
22#define LO_LIM 64
23#define HI_LIM 192
24
25#define ADJUSTER ((double)32768.0)
26
27#define THE_FILE "wdcurtab.dat"
28
29char *fname1;
30
31int t[TABLEN];
32double k[TABLEN];
33double m[TABLEN];
34
35/*
36
37*/
38
39/*
40 =============================================================================
41 curtab.c: main -- compute sine wave cursor table for waveshape editor
42 =============================================================================
43*/
44
45main()
46{
47 register FILE *fp1;
48 register int i, j;
49 double q;
50
51 printf("Buchla 700 Waveshape Cursor Table Generator %s\n", VER);
52
53 fname1 = THE_FILE;
54
55 if( (fp1 = fopen(fname1, "wa")) EQ NULL) {
56
57 printf("curtab: ERROR - couldn't open [%s]\n", fname1);
58 exit();
59 }
60
61 printf("curtab: Creating %d entry waveshape cursor table\n", TABLEN);
62
63 q = TWOPI / DTABLEN;
64
65 for(i = 0; i < TABLEN; i++) {
66
67 k[i] = sin((double)i * q);
68
69 if(k[i] GE (double)1.0)
70 k[i] = (double)0.999999;
71
72 m[i] = (k[i] + (double)1.0) / (double)2.0;
73 t[i] = m[i] * ADJUSTER;
74
75#if DEBUGIT
76 if (! (i & 0x00000007))
77 printf("%4d %04x %04.4x %10.8f %11.8f\n",
78 i, i, (t[i] & 0x0000FFFF), k[i], m[i]);
79#endif
80 }
81
82 printf("curtab: Writing entries %d thru %d to file [%s]\n",
83 LO_LIM, (HI_LIM - 1), fname1);
84
85 for (i = LO_LIM , j = 0; i < HI_LIM; i++ , j++)
86 fprintf(fp1, "\t0x%04.4x,\t/* %4d %4d %11.8f %11.8f */\n",
87 (t[i] & 0x0000FFFF), j, i, k[i], m[i]);
88
89 fclose(fp1);
90
91 printf("curtab: Output complete on [%s].\n", fname1);
92}
Note: See TracBrowser for help on using the repository browser.