OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [sim/] [iverilog/] [sound/] [waveform_gen.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
#include <stdio.h>
3
#include <math.h>
4
 
5
static double decrelconst[4] = {
6
    (double)(1/39.28064),
7
    (double)(1/31.41608),
8
    (double)(1/26.17344),
9
    (double)(1/22.44608)
10
};
11
 
12
static double attackconst[4] = {
13
    (double)(1/2.82624),
14
    (double)(1/2.25280),
15
    (double)(1/1.88416),
16
    (double)(1/1.59744)
17
};
18
 
19
int main() {
20
 
21
    /*
22
    printf("DEPTH = 256;\n");
23
    printf("WIDTH = 17;\n");
24
    printf("ADDRESS_RADIX = DEC;\n");
25
    printf("DATA_RADIX = DEC;\n");
26
    printf("CONTENT\n");
27
    printf("BEGIN\n");
28
 
29
    int i=0;
30
    for(i=0; i<256; i++) printf("%d:    %d;\n", i, (int)(sin((double)i*2.0*M_PI/4.0/256.0) * 16384.0));
31
    printf("END;\n");
32
    */
33
 
34
    /*
35
    printf("DEPTH = 256;\n");
36
    printf("WIDTH = 17;\n");
37
    printf("ADDRESS_RADIX = DEC;\n");
38
    printf("DATA_RADIX = DEC;\n");
39
    printf("CONTENT\n");
40
    printf("BEGIN\n");
41
 
42
    int i=0;
43
    for(i=0; i<256; i++) {
44
        int toff      = (i >> 4) & 0xF;
45
        int decayrate = i & 0xF;
46
 
47
        double f = (double)(-7.4493*decrelconst[toff&3]/96000.0);
48
 
49
        printf("%d:    %d;\n", i+256, (int)(((double)(pow(2.0,f*pow(2.0,(double)(decayrate+(toff>>2))))))* 65536.0));
50
    }
51
    printf("END;\n");
52
    */
53
 
54
    /*
55
    printf("DEPTH = 256;\n");
56
    printf("WIDTH = 20;\n");
57
    printf("ADDRESS_RADIX = DEC;\n");
58
    printf("DATA_RADIX = DEC;\n");
59
    printf("CONTENT\n");
60
    printf("BEGIN\n");
61
 
62
    int i=0;
63
    for(i=0; i<256; i++) {
64
        int toff      = (i >> 4) & 0xF;
65
        int attackrate = i & 0xF;
66
 
67
        int val = (int)(pow(2.0,(double)attackrate+(toff>>2)-1)*attackconst[toff&3]/96000.0*65536.0*16.0);
68
        //if(val == 0) val = 1;
69
 
70
        printf("%d:    %d;\n", i, val);
71
 
72
    }
73
    printf("END;\n");
74
    */
75
 
76
    double cycle_in_ns = 33.333333;
77
    int i;
78
    for(i=0; i<256; i++) {
79
        double f = 1000000.0 / (256.0-i);
80
 
81
        double cycles_in_period = 1000000000.0 / (f * cycle_in_ns);
82
        printf("%d:     %d;\n", i, (int)cycles_in_period);
83
    }
84
 
85
    return 0;
86
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.