annotate src/skins/ui_main_evlisteners.c @ 3193:93cf4d0a0dde

alsa-ng: Prefer "PCM" volume control over "Wave" on systems that have both, for consistency with OSS plugin and maybe other apps (closes AUD-34 and AUD-36).
author John Lindgren <john.lindgren@tds.net>
date Mon, 29 Jun 2009 23:05:56 -0400
parents 1ffcad5f406c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2006-2007 Audacious development team.
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 *
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * GNU General Public License for more details.
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 *
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 *
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 */
2967
165ccb8de035 audlegacy-plugins begins.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2679
diff changeset
20
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 #include <glib.h>
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 #include <math.h>
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
23
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2967
diff changeset
24 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2967
diff changeset
25 #include <audlegacy/input.h>
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
26
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_equalizer.h"
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "ui_main.h"
2640
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2633
diff changeset
29 #include "ui_playlist.h"
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include "ui_skinned_playstatus.h"
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include "ui_skinned_textbox.h"
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include "ui_skinned_window.h"
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include "skins_cfg.h"
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 static gint song_info_timeout_source = 0;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36
2625
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
37 typedef struct {
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
38 gint bitrate;
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
39 gint samplerate;
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
40 gint channels;
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
41 } PlaylistEventInfoChange;
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
42
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 gchar *text = (gchar *) hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 ui_skinned_textbox_set_text(mainwin_info, text);
2625
29526d9db9cc remove few more #if 0's
Tomasz Mon <desowin@gmail.com>
parents: 2619
diff changeset
49 playlistwin_update_list(aud_playlist_get_active());
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 ui_main_evlistener_hide_seekbar(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 mainwin_disable_seekbar();
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 ui_main_evlistener_volume_change(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 gint *h_vol = (gint *) hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 gint vl, vr, b, v;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 vl = CLAMP(h_vol[0], 0, 100);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 vr = CLAMP(h_vol[1], 0, 100);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 v = MAX(vl, vr);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 if (vl > vr)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 else if (vl < vr)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 else
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 b = 0;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 mainwin_set_volume_slider(v);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 equalizerwin_set_volume_slider(v);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 mainwin_set_balance_slider(b);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 equalizerwin_set_balance_slider(b);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
80 void ui_main_evlistener_playback_begin (void * hook_data, void * user_data)
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 ui_vis_clear_data(mainwin_vis);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 ui_svis_clear_data(mainwin_svis);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 mainwin_disable_seekbar();
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 mainwin_update_song_info();
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 if (config.player_shaded) {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 gtk_widget_show(mainwin_stime_min);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 gtk_widget_show(mainwin_stime_sec);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 gtk_widget_show(mainwin_sposition);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 } else {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 gtk_widget_show(mainwin_minus_num);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 gtk_widget_show(mainwin_10min_num);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 gtk_widget_show(mainwin_min_num);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 gtk_widget_show(mainwin_10sec_num);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 gtk_widget_show(mainwin_sec_num);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 gtk_widget_show(mainwin_position);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
100 song_info_timeout_source =
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
101 g_timeout_add (250, (GSourceFunc) mainwin_update_song_info, NULL);
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 ui_main_evlistener_playback_stop(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 if (song_info_timeout_source)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 g_source_remove(song_info_timeout_source);
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
111
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
115 void ui_main_evlistener_playback_pause (void * hook_data, void * user_data)
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 ui_main_evlistener_playback_unpause(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 ui_main_evlistener_playback_play_file(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 {
2679
fb5375e86a03 make setting random skin on play working
Tomasz Mon <desowin@gmail.com>
parents: 2669
diff changeset
129 if (config.random_skin_on_play)
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 skin_set_random_skin();
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 ui_main_evlistener_playlist_end_reached(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 mainwin_clear_song_info();
2640
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2633
diff changeset
137
dd255ad225f3 use more hooks
Tomasz Mon <desowin@gmail.com>
parents: 2633
diff changeset
138 if (aud_cfg->stopaftersong)
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 mainwin_set_stopaftersong(FALSE);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 ui_main_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 ui_main_evlistener_mainwin_set_always_on_top(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 gboolean *ontop = (gboolean*)hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 mainwin_set_always_on_top(*ontop);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 ui_main_evlistener_mainwin_show(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 gboolean *show = (gboolean*)hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 mainwin_show(*show);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 ui_main_evlistener_equalizerwin_show(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 gboolean *show = (gboolean*)hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 equalizerwin_show(*show);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 ui_main_evlistener_visualization_timeout(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 {
2669
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
174 if (hook_data == NULL) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
175 if (config.player_shaded && config.player_visible)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
176 ui_svis_timeout_func(mainwin_svis, NULL);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
177 else
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
178 ui_vis_timeout_func(mainwin_vis, NULL);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
179 return;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
180 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
181
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
182 VisNode *vis = (VisNode*) hook_data;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
183
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
184 guint8 intern_vis_data[512];
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
185 gint16 mono_freq[2][256];
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
186 gboolean mono_freq_calced = FALSE;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
187 gint16 mono_pcm[2][512], stereo_pcm[2][512];
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
188 gboolean mono_pcm_calced = FALSE, stereo_pcm_calced = FALSE;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
189 gint i;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
190
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
191 if (config.vis_type == VIS_OFF)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
192 return;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
193
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
194 if (config.vis_type == VIS_ANALYZER) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
195 /* Spectrum analyzer */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
196 /* 76 values */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
197 const gint long_xscale[] =
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
198 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
199 17, 18,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
200 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
201 34,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
202 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
203 50, 51,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
204 52, 53, 54, 55, 56, 57, 58, 61, 66, 71, 76, 81, 87, 93,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
205 100, 107,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
206 114, 122, 131, 140, 150, 161, 172, 184, 255
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
207 };
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
208 /* 20 values */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
209 const int short_xscale[] =
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
210 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 15, 20, 27,
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
211 36, 47, 62, 82, 107, 141, 184, 255
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
212 };
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
213 const double y_scale = 3.60673760222; /* 20.0 / log(256) */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
214 const int *xscale;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
215 gint j, y, max;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
216
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
217 if (!mono_freq_calced)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
218 aud_calc_mono_freq(mono_freq, vis->data, vis->nch);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
219
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
220 memset(intern_vis_data, 0, 75);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
221
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
222 if (config.analyzer_type == ANALYZER_BARS) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
223 if (config.player_shaded) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
224 max = 13;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
225 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
226 else {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
227 max = 19;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
228 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
229 xscale = short_xscale;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
230 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
231 else {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
232 if (config.player_shaded) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
233 max = 37;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
234 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
235 else {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
236 max = 75;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
237 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
238 xscale = long_xscale;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
239 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
240
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
241 for (i = 0; i < max; i++) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
242 for (j = xscale[i], y = 0; j < xscale[i + 1]; j++) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
243 if (mono_freq[0][j] > y)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
244 y = mono_freq[0][j];
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
245 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
246 y >>= 7;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
247 if (y != 0) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
248 intern_vis_data[i] = log(y) * y_scale;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
249 if (intern_vis_data[i] > 15)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
250 intern_vis_data[i] = 15;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
251 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
252 else
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
253 intern_vis_data[i] = 0;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
254 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
255 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
256 else if(config.vis_type == VIS_VOICEPRINT){
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
257 if (config.player_shaded && config.player_visible) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
258 /* VU */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
259 gint vu, val;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
260
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
261 if (!stereo_pcm_calced)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
262 aud_calc_stereo_pcm(stereo_pcm, vis->data, vis->nch);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
263 vu = 0;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
264 for (i = 0; i < 512; i++) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
265 val = abs(stereo_pcm[0][i]);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
266 if (val > vu)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
267 vu = val;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
268 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
269 intern_vis_data[0] = (vu * 37) >> 15;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
270 if (intern_vis_data[0] > 37)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
271 intern_vis_data[0] = 37;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
272 if (vis->nch == 2) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
273 vu = 0;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
274 for (i = 0; i < 512; i++) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
275 val = abs(stereo_pcm[1][i]);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
276 if (val > vu)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
277 vu = val;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
278 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
279 intern_vis_data[1] = (vu * 37) >> 15;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
280 if (intern_vis_data[1] > 37)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
281 intern_vis_data[1] = 37;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
282 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
283 else
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
284 intern_vis_data[1] = intern_vis_data[0];
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
285 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
286 else { /*Voiceprint*/
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
287 if (!mono_freq_calced)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
288 aud_calc_mono_freq(mono_freq, vis->data, vis->nch);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
289 memset(intern_vis_data, 0, 256);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
290
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
291 /* For the values [0-16] we use the frequency that's 3/2 as much.
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
292 If we assume the 512 values calculated by calc_mono_freq to
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
293 cover 0-22kHz linearly we get a range of
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
294 [0-16] * 3/2 * 22000/512 = [0-1,031] Hz.
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
295 Most stuff above that is harmonics and we want to utilize the
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
296 16 samples we have to the max[tm]
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
297 */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
298 for (i = 0; i < 50 ; i+=3){
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
299 intern_vis_data[i/3] += (mono_freq[0][i/2] >> 5);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
300
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
301 /*Boost frequencies above 257Hz a little*/
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
302 //if(i > 4 * 3)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
303 // intern_vis_data[i/3] += 8;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
304 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
305 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
306 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
307 else { /* (config.vis_type == VIS_SCOPE) */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
308
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
309 /* Oscilloscope */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
310 gint pos, step;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
311
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
312 if (!mono_pcm_calced)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
313 aud_calc_mono_pcm(mono_pcm, vis->data, vis->nch);
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
314
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
315 step = (vis->length << 8) / 74;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
316 for (i = 0, pos = 0; i < 75; i++, pos += step) {
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
317 intern_vis_data[i] = ((mono_pcm[0][pos >> 8]) >> 12) + 7;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
318 if (intern_vis_data[i] == 255)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
319 intern_vis_data[i] = 0;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
320 else if (intern_vis_data[i] > 12)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
321 intern_vis_data[i] = 12;
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
322 /* Do not see the point of that? (comparison always false) -larne.
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
323 if (intern_vis_data[i] < 0)
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
324 intern_vis_data[i] = 0; */
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
325 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
326 }
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
327
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 if (config.player_shaded && config.player_visible)
2669
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
329 ui_svis_timeout_func(mainwin_svis, intern_vis_data);
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 else
2669
ed0ad7b373d3 make vis working
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
331 ui_vis_timeout_func(mainwin_vis, intern_vis_data);
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 static void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 ui_main_evlistener_config_save(gpointer hook_data, gpointer user_data)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 ConfigDb *db = (ConfigDb *) hook_data;
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 if (SKINNED_WINDOW(mainwin)->x != -1 &&
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 SKINNED_WINDOW(mainwin)->y != -1 )
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 aud_cfg_db_set_int(db, "skins", "player_x", SKINNED_WINDOW(mainwin)->x);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343 aud_cfg_db_set_int(db, "skins", "player_y", SKINNED_WINDOW(mainwin)->y);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 aud_cfg_db_set_bool(db, "skins", "mainwin_use_bitmapfont",
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 config.mainwin_use_bitmapfont);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 void
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 ui_main_evlistener_init(void)
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 {
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 aud_hook_associate("title change", ui_main_evlistener_title_change, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 aud_hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 aud_hook_associate("volume set", ui_main_evlistener_volume_change, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 aud_hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 aud_hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 aud_hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 aud_hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 aud_hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 aud_hook_associate("playlist end reached", ui_main_evlistener_playlist_end_reached, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 aud_hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 aud_hook_associate("mainwin set always on top", ui_main_evlistener_mainwin_set_always_on_top, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 aud_hook_associate("mainwin show", ui_main_evlistener_mainwin_show, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 aud_hook_associate("equalizerwin show", ui_main_evlistener_equalizerwin_show, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 aud_hook_associate("visualization timeout", ui_main_evlistener_visualization_timeout, NULL);
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 aud_hook_associate("config save", ui_main_evlistener_config_save, NULL);
2633
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
368
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
369 aud_hook_associate("playback audio error", (void *) mainwin_stop_pushed, NULL);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
370 aud_hook_associate("playback audio error", (void *) run_no_output_device_dialog, NULL);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
371
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
372 aud_hook_associate("playback seek", (HookFunction) mainwin_update_song_info, NULL);
2602
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 }
7cd898f08f31 work in progress - add ui_manager and ui_main_evlisteners
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374
2633
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
375 void
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
376 ui_main_evlistener_dissociate(void)
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
377 {
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
378 aud_hook_dissociate("title change", ui_main_evlistener_title_change);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
379 aud_hook_dissociate("hide seekbar", ui_main_evlistener_hide_seekbar);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
380 aud_hook_dissociate("volume set", ui_main_evlistener_volume_change);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
381 aud_hook_dissociate("playback begin", ui_main_evlistener_playback_begin);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
382 aud_hook_dissociate("playback stop", ui_main_evlistener_playback_stop);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
383 aud_hook_dissociate("playback pause", ui_main_evlistener_playback_pause);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
384 aud_hook_dissociate("playback unpause", ui_main_evlistener_playback_unpause);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
385 aud_hook_dissociate("playback play file", ui_main_evlistener_playback_play_file);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
386 aud_hook_dissociate("playlist end reached", ui_main_evlistener_playlist_end_reached);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
387 aud_hook_dissociate("playlist info change", ui_main_evlistener_playlist_info_change);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
388 aud_hook_dissociate("mainwin set always on top", ui_main_evlistener_mainwin_set_always_on_top);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
389 aud_hook_dissociate("mainwin show", ui_main_evlistener_mainwin_show);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
390 aud_hook_dissociate("equalizerwin show", ui_main_evlistener_equalizerwin_show);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
391 aud_hook_dissociate("visualization timeout", ui_main_evlistener_visualization_timeout);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
392 aud_hook_dissociate("config save", ui_main_evlistener_config_save);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
393
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
394 aud_hook_dissociate("playback audio error", (void *) mainwin_stop_pushed);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
395 aud_hook_dissociate("playback audio error", (void *) run_no_output_device_dialog);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
396
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
397 aud_hook_dissociate("playback seek", (HookFunction) mainwin_update_song_info);
8e4af29f7e17 dissociate hooks at plugin cleanup
Tomasz Mon <desowin@gmail.com>
parents: 2625
diff changeset
398 }