annotate src/audacious/ui_vis.c @ 3043:59452118044d

MacOS (and others): Relocate libintl to a location where audacious can link to it automatically.
author William Pitcock <nenolod@atheme-project.org>
date Thu, 12 Jul 2007 06:01:51 -0500
parents e9e925c3adb5
children b1b48ea20c16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3020
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; under version 2 of the License.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 */
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 #include "widgets/widgetcore.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26 #include "ui_vis.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "main.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "util.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "strings.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include "playback.h"
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <string.h>
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <ctype.h>
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <gtk/gtkmain.h>
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 #include <gtk/gtkmarshal.h>
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #include <gtk/gtkimage.h>
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 #define UI_TYPE_VIS (ui_vis_get_type())
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 static const guint8 vis_scope_colors[] =
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 static guchar voiceprint_data[76*16];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 enum {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 DOUBLED,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 LAST_SIGNAL
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static void ui_vis_class_init (UiVisClass *klass);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_vis_init (UiVis *vis);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static void ui_vis_destroy (GtkObject *object);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static void ui_vis_realize (GtkWidget *widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static void ui_vis_unrealize (GtkWidget *widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 static void ui_vis_size_request (GtkWidget *widget, GtkRequisition *requisition);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static void ui_vis_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static gboolean ui_vis_expose (GtkWidget *widget, GdkEventExpose *event);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 static void ui_vis_toggle_doublesize (UiVis *vis);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static GtkWidgetClass *parent_class = NULL;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 static guint vis_signals[LAST_SIGNAL] = { 0 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 GType ui_vis_get_type() {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 static GType vis_type = 0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 if (!vis_type) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 static const GTypeInfo vis_info = {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 sizeof (UiVisClass),
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 NULL,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 NULL,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 (GClassInitFunc) ui_vis_class_init,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 NULL,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 NULL,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 sizeof (UiVis),
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 0,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 (GInstanceInitFunc) ui_vis_init,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 };
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 vis_type = g_type_register_static (GTK_TYPE_WIDGET, "UiVis", &vis_info, 0);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 return vis_type;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 static void ui_vis_class_init(UiVisClass *klass) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 GtkObjectClass *object_class;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 GtkWidgetClass *widget_class;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 object_class = (GtkObjectClass*) klass;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 widget_class = (GtkWidgetClass*) klass;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 parent_class = gtk_type_class (gtk_widget_get_type ());
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 object_class->destroy = ui_vis_destroy;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 widget_class->realize = ui_vis_realize;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 widget_class->unrealize = ui_vis_unrealize;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 widget_class->expose_event = ui_vis_expose;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 widget_class->size_request = ui_vis_size_request;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 widget_class->size_allocate = ui_vis_size_allocate;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 klass->doubled = ui_vis_toggle_doublesize;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 vis_signals[DOUBLED] =
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 G_STRUCT_OFFSET (UiVisClass, doubled), NULL, NULL,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 static void ui_vis_init(UiVis *vis) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 memset(voiceprint_data, 0, 16*76);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 GtkWidget* ui_vis_new(GtkWidget *fixed, gint x, gint y, gint width) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 UiVis *vis = g_object_new (ui_vis_get_type (), NULL);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 vis->x = x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 vis->y = y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 vis->width = width;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 vis->height = 16;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 vis->fixed = fixed;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 vis->double_size = FALSE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 vis->visible_window = TRUE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 gtk_fixed_put(GTK_FIXED(vis->fixed), GTK_WIDGET(vis), vis->x, vis->y);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 return GTK_WIDGET(vis);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 static void ui_vis_destroy(GtkObject *object) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 UiVis *vis;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 g_return_if_fail (object != NULL);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 g_return_if_fail (UI_IS_VIS (object));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 vis = UI_VIS (object);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 if (GTK_OBJECT_CLASS (parent_class)->destroy)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 static void ui_vis_realize(GtkWidget *widget) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 UiVis *vis;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 GdkWindowAttr attributes;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 gint attributes_mask;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 g_return_if_fail (widget != NULL);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 g_return_if_fail (UI_IS_VIS(widget));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 vis = UI_VIS(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 attributes.x = widget->allocation.x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 attributes.y = widget->allocation.y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 attributes.width = widget->allocation.width;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 attributes.height = widget->allocation.height;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 attributes.window_type = GDK_WINDOW_CHILD;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 attributes.event_mask = gtk_widget_get_events(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 if (vis->visible_window)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 attributes.visual = gtk_widget_get_visual(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 attributes.colormap = gtk_widget_get_colormap(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 attributes.wclass = GDK_INPUT_OUTPUT;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 else
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 attributes.wclass = GDK_INPUT_ONLY;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 attributes_mask = GDK_WA_X | GDK_WA_Y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 widget->style = gtk_style_attach(widget->style, widget->window);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 gdk_window_set_user_data(widget->window, widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182 static void ui_vis_unrealize(GtkWidget *widget) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 UiVis *vis;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 vis = UI_VIS(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 static void ui_vis_size_request(GtkWidget *widget, GtkRequisition *requisition) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 UiVis *vis = UI_VIS(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 requisition->width = vis->width*(1+vis->double_size);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 requisition->height = vis->height*(1+vis->double_size);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 static void ui_vis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 UiVis *vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200 widget->allocation = *allocation;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 widget->allocation.x *= (1+vis->double_size);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 widget->allocation.y *= (1+vis->double_size);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 if (GTK_WIDGET_REALIZED (widget))
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 vis->x = widget->allocation.x/(vis->double_size ? 2 : 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 vis->y = widget->allocation.y/(vis->double_size ? 2 : 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 static gboolean ui_vis_expose(GtkWidget *widget, GdkEventExpose *event) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 g_return_val_if_fail (widget != NULL, FALSE);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 g_return_val_if_fail (UI_IS_VIS (widget), FALSE);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 g_return_val_if_fail (event != NULL, FALSE);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 UiVis *vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 gint x, y, n, h = 0, h2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 gfloat delta;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 guchar skin_col[2][3];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 guchar vis_color[24][3];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 guchar vis_voice_color[256][3], voice_c[3];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 guchar rgb_data[76 * 16 * 3 * 2 * 2], *ptr, c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 guint32 colors[24];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 GdkColor *fgc, *bgc;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 GdkRgbCmap *cmap;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 if (!GTK_WIDGET_VISIBLE(widget))
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 return FALSE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 if (!vis->visible_window)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 return FALSE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 skin_get_viscolor(bmp_active_skin, vis_color);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 for (y = 0; y < 24; y++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 colors[y] =
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 cmap = gdk_rgb_cmap_new(colors, 24);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 if(cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 memset(rgb_data, 0, 76 * 16 * 3);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 memset(rgb_data, 0, 76 * 16);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246 for (y = 1; y < 16; y += 2) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 ptr = rgb_data + (y * 76);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 for (x = 0; x < 76; x += 2, ptr += 2)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 *ptr = 1;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 if(cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 memset(rgb_data, 0, 3 * 4 * 16 * 76);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 memset(rgb_data, 0, 152 * 32);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 for (y = 1; y < 16; y += 2) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 ptr = rgb_data + (y * 304);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 for (x = 0; x < 76; x += 2, ptr += 4) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 *ptr = 1;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 *(ptr + 1) = 1;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 *(ptr + 152) = 1;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 *(ptr + 153) = 1;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 if (cfg.vis_type == VIS_ANALYZER) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 for (x = 0; x < 75; x++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 h = vis->data[x >> 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 else if (cfg.analyzer_type == ANALYZER_LINES)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 h = vis->data[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 if (h && (cfg.analyzer_type == ANALYZER_LINES ||
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 (x % 4) != 3)) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 ptr = rgb_data + ((16 - h) * 76) + x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 switch (cfg.analyzer_mode) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 case ANALYZER_NORMAL:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 for (y = 0; y < h; y++, ptr += 76)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 *ptr = 18 - h + y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 case ANALYZER_FIRE:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 for (y = 0; y < h; y++, ptr += 76)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 *ptr = y + 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 case ANALYZER_VLINES:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 for (y = 0; y < h; y++, ptr += 76)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 *ptr = 18 - h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 ptr = rgb_data + ((16 - h) * 304) + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 switch (cfg.analyzer_mode) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 case ANALYZER_NORMAL:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 for (y = 0; y < h; y++, ptr += 304) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 *ptr = 18 - h + y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 *(ptr + 1) = 18 - h + y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 *(ptr + 152) = 18 - h + y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 *(ptr + 153) = 18 - h + y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 case ANALYZER_FIRE:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 for (y = 0; y < h; y++, ptr += 304) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 *ptr = y + 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 *(ptr + 1) = y + 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 *(ptr + 152) = y + 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311 *(ptr + 153) = y + 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314 case ANALYZER_VLINES:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 for (y = 0; y < h; y++, ptr += 304) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 *ptr = 18 - h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 *(ptr + 1) = 18 - h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 *(ptr + 152) = 18 - h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 *(ptr + 153) = 18 - h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 if (cfg.analyzer_peaks) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 for (x = 0; x < 75; x++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 h = vis->peak[x >> 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 else if (cfg.analyzer_type == ANALYZER_LINES)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 h = vis->peak[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 if (h && (cfg.analyzer_type == ANALYZER_LINES || (x % 4) != 3)){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 rgb_data[(16 - h) * 76 + x] = 23;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 ptr = rgb_data + (16 - h) * 304 + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 *ptr = 23;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 *(ptr + 1) = 23;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 *(ptr + 152) = 23;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343 *(ptr + 153) = 23;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 else if (cfg.vis_type == VIS_VOICEPRINT) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 if(!playback_get_paused() && playback_get_playing()){/*Don't scroll when it's paused or stopped*/
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 for (y = 0; y < 16; y ++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 for (x = 75; x > 0; x--)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 voiceprint_data[x + y * 76] = voiceprint_data[x-1+y*76];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 for(y=0;y<16;y++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 voiceprint_data[y * 76] = vis->data[y];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 if(playback_get_playing()){ /*Only draw the data if we're playing*/
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 if(cfg.voiceprint_mode == VOICEPRINT_NORMAL){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 /* Create color gradient from the skin's background- and foreground color*/
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 fgc = skin_get_color(bmp_active_skin, SKIN_TEXTFG);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 bgc = skin_get_color(bmp_active_skin, SKIN_TEXTBG);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 skin_col[0][0] = fgc->red >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 skin_col[0][1] = fgc->green >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 skin_col[0][2] = fgc->blue >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 skin_col[1][0] = bgc->red >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 skin_col[1][1] = bgc->green >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 skin_col[1][2] = bgc->blue >> 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 for(n=0;n<3;n++){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 for(x=0;x<256;x++){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 if(skin_col[0][n] > skin_col[1][n]){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 delta = (gfloat)(skin_col[0][n] - skin_col[1][n]) / 256.0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 vis_voice_color[x][n] = skin_col[1][n] + (gfloat)(delta * x);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 else if(skin_col[0][n] == skin_col[1][n]){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 vis_voice_color[x][n] = skin_col[0][n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 delta = (gfloat)(skin_col[1][n] - skin_col[0][n]) / 256.0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379 vis_voice_color[x][n] = skin_col[1][n] - (gfloat)(delta * x);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 for (y = 0; y < 16; y ++){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 for (x = 0; x < 76; x++){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 guint8 d = voiceprint_data[x + y*76];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 if(cfg.voiceprint_mode == VOICEPRINT_NORMAL){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389 voice_c[0] = vis_voice_color[d][0];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 voice_c[1] = vis_voice_color[d][1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391 voice_c[2] = vis_voice_color[d][2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 else if(cfg.voiceprint_mode == VOICEPRINT_FIRE){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 voice_c[0] = d < 64 ? (d * 2) : 255;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 voice_c[1] = d < 64 ? 0 : (d < 128 ? (d-64) * 2 : 255);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 voice_c[2] = d < 128 ? 0 : (d-128) * 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 /* Test for black->blue->green->red. Isn't pretty, though...
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
398 voice_c[0] = d > 192 ? (d - 192) << 2 : 0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399 voice_c[1] = d > 64 ? (d < 128 ? (d - 64) << 2 : (d < 192 ? (192 - d) << 2 : 0)) : 0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 voice_c[2] = d < 64 ? d << 2 : (d < 128 ? (128 - d) << 2 : 0);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 */
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 else if(cfg.voiceprint_mode == VOICEPRINT_ICE){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 voice_c[0] = d;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405 voice_c[1] = d < 128 ? d * 2 : 255;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406 voice_c[2] = d < 64 ? d * 4 : 255;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
407 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 if(!vis->double_size){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409 for(n=0;n<3;n++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 rgb_data[x * 3 + y * 76*3+n] = voice_c[n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 ptr = rgb_data + x * 3 * 2 + y * 2 * 76 * 3 * 2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 for(n=0;n<3;n++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416 *(ptr + n) = voice_c[n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417 *(ptr + n + 3) = voice_c[n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
418 *(ptr + n + 76 * 2 * 3) = voice_c[n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
419 *(ptr + n + 3 + 76 * 2 * 3) = voice_c[n];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
422 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
425 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426 if (cfg.vis_type == VIS_SCOPE) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 for (x = 0; x < 75; x++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428 switch (cfg.scope_mode) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429 case SCOPE_DOT:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 h = vis->data[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 ptr = rgb_data + ((14 - h) * 76) + x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433 *ptr = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434 }else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 ptr = rgb_data + ((14 - h) * 304) + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436 *ptr = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 *(ptr + 1) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438 *(ptr + 152) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 *(ptr + 153) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 case SCOPE_LINE:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443 if (x != 74) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 h = 14 - vis->data[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 h2 = 14 - vis->data[x + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446 if (h > h2) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
447 y = h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 h = h2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 h2 = y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452 ptr = rgb_data + (h * 76) + x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
453 for (y = h; y <= h2; y++, ptr += 76)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 *ptr = vis_scope_colors[y - 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
455 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456 else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 ptr = rgb_data + (h * 304) + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
458 for (y = h; y <= h2; y++, ptr += 304) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
459 *ptr = vis_scope_colors[y - 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 *(ptr + 1) = vis_scope_colors[y - 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 *(ptr + 152) = vis_scope_colors[y - 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 *(ptr + 153) = vis_scope_colors[y - 2];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
463 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466 else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 h = 14 - vis->data[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
468 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469 ptr = rgb_data + (h * 76) + x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 *ptr = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 }else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 ptr = rgb_data + (h * 304) + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473 *ptr = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474 *(ptr + 1) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 *(ptr + 152) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476 *(ptr + 153) = vis_scope_colors[h + 1];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 case SCOPE_SOLID:
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 h = 14 - vis->data[x];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482 h2 = 8;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 c = vis_scope_colors[(gint) vis->data[x]];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484 if (h > h2) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
485 y = h;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 h = h2;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487 h2 = y;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
490 ptr = rgb_data + (h * 76) + x;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 for (y = h; y <= h2; y++, ptr += 76)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 *ptr = c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 }else{
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494 ptr = rgb_data + (h * 304) + (x << 1);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
495 for (y = h; y <= h2; y++, ptr += 304) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496 *ptr = c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
497 *(ptr + 1) = c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
498 *(ptr + 152) = c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499 *(ptr + 153) = c;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
501 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
502 break;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 GdkPixmap *obj = NULL;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 GdkGC *gc;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509 obj = gdk_pixmap_new(NULL, vis->width*(1+vis->double_size), vis->height*(1+vis->double_size), gdk_rgb_get_visual()->depth);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510 gc = gdk_gc_new(obj);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
512 if (!vis->double_size) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
513 if (cfg.vis_type == VIS_VOICEPRINT) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 gdk_draw_rgb_image(obj, gc, 0, 0, vis->width, vis->height,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
515 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
516 76 * 3);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
517 } else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518 gdk_draw_indexed_image(obj, gc, 0, 0, vis->width, vis->height,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
519 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
520 76 , cmap);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522 } else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
523 if (cfg.vis_type == VIS_VOICEPRINT) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524 gdk_draw_rgb_image(obj, gc, 0 << 1, 0 << 1,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
525 vis->width << 1, vis->height << 1,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
526 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527 76 * 2 * 3);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
528 } else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
529 gdk_draw_indexed_image(obj, gc, 0 << 1, 0 << 1,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
530 vis->width << 1, vis->height << 1,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
531 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 76 * 2 , cmap);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
533 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
534 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
535
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
536 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537 vis->width*(1+vis->double_size), vis->height*(1+vis->double_size));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 g_object_unref(obj);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 g_object_unref(gc);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540 gdk_rgb_cmap_free(cmap);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
541 return FALSE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544 static void ui_vis_toggle_doublesize(UiVis *vis) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 GtkWidget *widget = GTK_WIDGET (vis);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546 vis->double_size = !vis->double_size;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
548 gtk_widget_set_size_request(widget, vis->width*(1+vis->double_size), vis->height*(1+vis->double_size));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
549
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
550 gtk_widget_queue_draw(GTK_WIDGET(vis));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
553 void ui_vis_draw_pixel(GtkWidget *widget, guchar* texture, gint x, gint y, guint8 colour) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554 UiVis *vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 if (vis->double_size){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 texture[y * 76 + x] = colour;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557 texture[y * 76 + x + 1] = colour;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558 texture[y * 76 * 4 + x] = colour;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
559 texture[y * 76 * 4 + x + 1] = colour;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
560 } else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
561 texture[y * 76 + x] = colour;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
562 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
563 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565 void ui_vis_set_visible(GtkWidget *widget, gboolean window_is_visible)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
566 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 UiVis *vis;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
568 gboolean widget_is_visible;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
569
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
570 g_return_if_fail(UI_IS_VIS(widget));
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
571
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
572 vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
573 widget_is_visible = GTK_WIDGET_VISIBLE(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
574
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
575 vis->visible_window = window_is_visible;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
576
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
577 if (GTK_WIDGET_REALIZED (widget))
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
578 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579 if ( widget_is_visible )
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
580 gtk_widget_hide(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
581
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
582 gtk_widget_unrealize(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
583 gtk_widget_realize(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
584
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
585 if ( widget_is_visible )
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
586 gtk_widget_show(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
587 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
588
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
589 if (widget_is_visible)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
590 gtk_widget_queue_resize(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
591 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
592
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
593 void ui_vis_clear_data(GtkWidget *widget) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
594 gint i;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
595 UiVis *vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
596
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
597 memset(voiceprint_data, 0, 16*76);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 for (i = 0; i < 75; i++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
599 vis->data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
600 vis->peak[i] = 0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
602 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
603
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
604 void ui_vis_timeout_func(GtkWidget *widget, guchar * data) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
605 UiVis *vis = UI_VIS (widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606 static GTimer *timer = NULL;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
607 gulong micros = 9999999;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608 gboolean falloff = FALSE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
609 gint i;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
610
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
611 if (!timer) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 timer = g_timer_new();
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613 g_timer_start(timer);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 else {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616 g_timer_elapsed(timer, &micros);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 if (micros > 14000)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 g_timer_reset(timer);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
619 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
620 if (cfg.vis_type == VIS_ANALYZER) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621 if (micros > 14000)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
622 falloff = TRUE;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623 if (data || falloff) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
624 for (i = 0; i < 75; i++) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
625 if (data && data[i] > vis->data[i]) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
626 vis->data[i] = data[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
627 if (vis->data[i] > vis->peak[i]) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628 vis->peak[i] = vis->data[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629 vis->peak_speed[i] = 0.01;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
631 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
632 else if (vis->peak[i] > 0.0) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
633 vis->peak[i] -= vis->peak_speed[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
634 vis->peak_speed[i] *=
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 vis_pfalloff_speeds[cfg.peaks_falloff];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
636 if (vis->peak[i] < vis->data[i])
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
637 vis->peak[i] = vis->data[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638 if (vis->peak[i] < 0.0)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
639 vis->peak[i] = 0.0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
640 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
641 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
642 else if (falloff) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
643 if (vis->data[i] > 0.0) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
644 vis->data[i] -=
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
645 vis_afalloff_speeds[cfg.analyzer_falloff];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
646 if (vis->data[i] < 0.0)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
647 vis->data[i] = 0.0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
648 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
649 if (vis->peak[i] > 0.0) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
650 vis->peak[i] -= vis->peak_speed[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
651 vis->peak_speed[i] *=
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
652 vis_pfalloff_speeds[cfg.peaks_falloff];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
653 if (vis->peak[i] < vis->data[i])
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
654 vis->peak[i] = vis->data[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
655 if (vis->peak[i] < 0.0)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
656 vis->peak[i] = 0.0;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
658 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
659 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
660 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
661 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
662 else if (cfg.vis_type == VIS_VOICEPRINT && data){
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 for(i = 0; i < 16; i++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
665 vis->data[i] = data[15 - i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
666 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
667 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
668 else if (data) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
669 for (i = 0; i < 75; i++)
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
670 vis->data[i] = data[i];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
671 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
672
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
673 if (micros > 14000) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674 if (!vis->refresh_delay) {
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
675 gtk_widget_queue_draw(widget);
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
676 vis->refresh_delay = vis_redraw_delays[cfg.vis_refresh];
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
677 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
678 vis->refresh_delay--;
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
679 }
6065d70cb790 replace old Vis with UiVis
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
680 }