summaryrefslogtreecommitdiffstats
path: root/gst/goom/lines.c
blob: cadf9203331067145a0bd43289d976b75259c5bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 *  lines.c
 *  iTunesXPlugIn
 *
 *  Created by guillaum on Tue Aug 14 2001.
 *  Copyright (c) 2001 __CompanyName__. All rights reserved.
 *
 */

#include "lines.h"
#include <math.h>

extern unsigned int resolx,resoly;

inline unsigned char  lighten(unsigned char value,unsigned char power)
{
    unsigned char i;
    for (i=0;i < power; i++) value += (255-value)/5;
    return value;
}

void goom_lines(gint16 data [2][512], unsigned int ID,unsigned int* p, guint32 power)
{
    guint32 color1;
    guint32 color2;
    unsigned char * color = 1 + (unsigned char *) &color1;

    switch (ID)
    {
        case 0: /* Horizontal stereo lines */
        {
            color1 = 0x0000AA00;
            color2 = 0x00AA0000;
            break;
        }

        case 1: /* Stereo circles */
        {
            color1 = 0x00AA33DD;
            color2 = 0x00AA33DD;
            break;
        }
    }
    *color = lighten(*color,power);
    color++;  
    * color = lighten(*color,power);
    color++;  
    * color = lighten(*color,power);
    color = 1 + (unsigned char *) &color2;
    * color = lighten(*color,power);
    color++;  
    * color = lighten(*color,power);
    color++;  
    * color = lighten(*color,power);
    
    switch (ID)
    {
        case 0: /* Horizontal stereo lines */
        {
            unsigned int i;
            for (i=0;i<512;i++)
            {
                guint32 plot ;
                plot = i * resolx / 512 + (resoly / 4 + data[0][i] / 1600) * resolx;
                p[plot] = color1;
                p[plot+1] = color1;
                plot = i * resolx / 512 + (resoly * 3 / 4 - data[1][i] / 1600) * resolx;
                p[plot] = color2;
                p[plot+1] = color2;
            }
            break;
        }

        case 1: /* Stereo circles */
        {
            float z;
            unsigned int monX = resolx/2;
            float monY = resoly/4;
            float monY2 = resoly/2;
            for (z=0;z<6.2832f; z+=1.0f/monY)
            {
               /* float offset1 = 128+data[1][(unsigned int)(z*81.33f)])/200000; */
                p[ monX + (unsigned int)( (monY + ((float)resoly) * (128+data[1][(unsigned int)(z*81.33f)])/200000) * cos (z) + resolx * (unsigned int)( monY2 + (monY + ((float)resoly)*(128+data[1][(unsigned int)(z*81.33f)])/400000) * sin (z)))] = color1;
                p[ monX + (unsigned int)((monY - ((float)resoly) * (128+data[0][(unsigned int)(z*81.33f)])/200000) * cos (z) + resolx * (unsigned int)( monY2 + (monY - ((float)resoly)*(128+data[0][(unsigned int)(z*81.33f)])/400000) * sin (z)))] = color2;
            }
        break;
        }
    }
}