Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 8 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
Jan 13, 2012
gui/audio add Bass Mid Treb indication bar
Signed-off-by: Xiangfu Liu <xiangfu@sharism.cc>
e9ad307
gui/audio: connect the indicate bar to bass,mid,treb
  set the bass from 0 to 200
  set the mid  from 0 to 600
  set the treb from 0 to 600

blow is the output of bass mid treb:
bass        mid      treb
0.875562, 2.837142, 3.324385
1.810086, 1.343698, 3.975147
0.588209, 1.993805, 5.159028
2.064919, 2.064337, 1.319500
1.914740, 1.852213, 1.077198
0.120748, 2.099725, 9.086357
0.038853, 0.507175, 4.591012
0.083254, 2.366420, 7.137532
2.098818, 1.917822, 1.701536
2.109711, 1.425635, 0.479246
0.063677, 2.136738, 11.364171
0.034193, 1.012987, 15.184698
0.080345, 1.995278, 14.193623
1.757692, 1.649233, 4.319139
1.246085, 0.817685, 5.233008
0139aeb
gui/audio: make the bar from bottom to top 614d449
gui/audio: using XXX_att which is better for GUI 5783649
gui/audio: move the indicate to right 80e6b13
gui/audio: do resmgr_acquire before open 766f86d
gui/monitor: output the windows title in resmgr_acquire 22e2890
gui/audio: using float value directly 6bc121b
85  src/gui/audio.c
@@ -33,6 +33,9 @@
33 33
 #include "flash.h"
34 34
 #include "about.h"
35 35
 #include "audio.h"
  36
+#include "resmgr.h"
  37
+#include "../input.h"
  38
+#include "../renderer/sampler.h"
36 39
 
37 40
 static int appid;
38 41
 
@@ -43,6 +46,34 @@ static int line_mute;
43 46
 static int mic_vol;
44 47
 static int mic_mute;
45 48
 
  49
+static float bass, mid, treb;
  50
+
  51
+static void sampler_callback(struct frame_descriptor *frd)
  52
+{
  53
+	bass = frd->bass_att;
  54
+	mid = frd->mid_att;
  55
+	treb = frd->treb_att;
  56
+
  57
+	sampler_return(frd);
  58
+}
  59
+
  60
+#define UPDATE_PERIOD 10
  61
+static rtems_interval next_update;
  62
+
  63
+static void monitor_update(mtk_event *e, int count)
  64
+{
  65
+	rtems_interval t;
  66
+
  67
+	t = rtems_clock_get_ticks_since_boot();
  68
+	if(t >= next_update) {
  69
+		mtk_cmdf(appid, "ld_bass.barconfig(load, -value %f)", bass);
  70
+		mtk_cmdf(appid, "ld_mid.barconfig(load, -value %f)", mid);
  71
+		mtk_cmdf(appid, "ld_treb.barconfig(load, -value %f)", treb);
  72
+
  73
+		next_update = t + UPDATE_PERIOD;
  74
+	}
  75
+}
  76
+
46 77
 static void set_level(int channel, unsigned int val)
47 78
 {
48 79
 	int request;
@@ -125,6 +156,11 @@ static void ok_callback(mtk_event *e, void *arg)
125 156
 	w_open = 0;
126 157
 	mtk_cmd(appid, "w.close()");
127 158
 	set_config();
  159
+	sampler_stop();
  160
+	input_delete_callback(monitor_update);
  161
+	resmgr_release(RESOURCE_AUDIO);
  162
+	resmgr_release(RESOURCE_DMX_IN);
  163
+	resmgr_release(RESOURCE_SAMPLER);
128 164
 }
129 165
 
130 166
 static void close_callback(mtk_event *e, void *arg)
@@ -132,6 +168,11 @@ static void close_callback(mtk_event *e, void *arg)
132 168
 	w_open = 0;
133 169
 	mtk_cmd(appid, "w.close()");
134 170
 	load_audio_config();
  171
+	sampler_stop();
  172
+	input_delete_callback(monitor_update);
  173
+	resmgr_release(RESOURCE_AUDIO);
  174
+	resmgr_release(RESOURCE_DMX_IN);
  175
+	resmgr_release(RESOURCE_SAMPLER);
135 176
 }
136 177
 
137 178
 void init_audio(void)
@@ -142,6 +183,14 @@ void init_audio(void)
142 183
 		"g = new Grid()",
143 184
 
144 185
 		"gv = new Grid()",
  186
+
  187
+		"l_bass = new Label(-text \"Bass\")",
  188
+		"l_mid  = new Label(-text \"Mid\")",
  189
+		"l_treb = new Label(-text \"Treb\")",
  190
+		"ld_bass = new LoadDisplay(-from 3 -to 0 -orient vertical)",
  191
+		"ld_mid  = new LoadDisplay(-from 6 -to 0 -orient vertical)",
  192
+		"ld_treb = new LoadDisplay(-from 6 -to 0 -orient vertical)",
  193
+
145 194
 		"l_linevol = new Label(-text \"Line volume\")",
146 195
 		"s_linevol = new Scale(-from 0 -to 100 -value 0 -orient vertical)",
147 196
 		"l_micvol = new Label(-text \"Mic volume\")",
@@ -153,24 +202,39 @@ void init_audio(void)
153 202
 		"gv.place(l_linevol, -column 1 -row 1)",
154 203
 		"gv.place(s_linevol, -column 1 -row 2)",
155 204
 		"gv.place(b_mutline, -column 1 -row 3)",
  205
+
156 206
 		"gv.place(l_micvol, -column 2 -row 1)",
157 207
 		"gv.place(s_micvol, -column 2 -row 2)",
158 208
 		"gv.place(b_mutmic, -column 2 -row 3)",
159 209
 
160  
-		"gv.rowconfig(2, -size 150)",
  210
+		"gv.rowconfig(2, -size 180)",
161 211
 
162 212
 		"g.place(gv, -column 1 -row 1)",
163 213
 
  214
+		"sep = new Separator(-vertical yes)",
  215
+		"g.place(sep, -column 2 -row 1)",
  216
+
  217
+		"gb = new Grid()",
  218
+
  219
+		"gb.place(l_bass,  -column 1 -row 1)",
  220
+		"gb.place(ld_bass, -column 1 -row 2)",
  221
+		"gb.place(l_mid,   -column 2 -row 1)",
  222
+		"gb.place(ld_mid,  -column 2 -row 2)",
  223
+		"gb.place(l_treb,  -column 3 -row 1)",
  224
+		"gb.place(ld_treb, -column 3 -row 2)",
  225
+
  226
+		"g.place(gb, -column 3 -row 1)",
  227
+
164 228
 		"g_btn = new Grid()",
165 229
 
166 230
 		"b_ok = new Button(-text \"OK\")",
167 231
 		"b_cancel = new Button(-text \"Cancel\")",
168 232
 
169  
-		"g_btn.columnconfig(1, -size 90)",
170  
-		"g_btn.place(b_ok, -column 2 -row 1)",
171  
-		"g_btn.place(b_cancel, -column 3 -row 1)",
  233
+		"g_btn.place(b_ok, -column 1 -row 1)",
  234
+		"g_btn.place(b_cancel, -column 2 -row 1)",
172 235
 
173  
-		"g.place(g_btn, -column 1 -row 2)",
  236
+		"g.rowconfig(2, -size 10)",
  237
+		"g.place(g_btn, -column 3 -row 3)",
174 238
 
175 239
 		"w = new Window(-content g -title \"Audio settings\")",
176 240
 		0);
@@ -196,6 +260,17 @@ void init_audio(void)
196 260
 void open_audio_window(void)
197 261
 {
198 262
 	if(w_open) return;
  263
+
  264
+	if(!resmgr_acquire_multiple("Audio settings",
  265
+	  RESOURCE_AUDIO,
  266
+	  RESOURCE_DMX_IN,
  267
+	  RESOURCE_SAMPLER,
  268
+	  INVALID_RESOURCE))
  269
+		return;
  270
+
199 271
 	w_open = 1;
200 272
 	mtk_cmd(appid, "w.open()");
  273
+	next_update = rtems_clock_get_ticks_since_boot() + UPDATE_PERIOD;
  274
+	input_add_callback(monitor_update);
  275
+	sampler_start(sampler_callback);
201 276
 }
2  src/gui/monitor.c
@@ -171,7 +171,7 @@ void open_monitor_window(void)
171 171
 {
172 172
 	if(w_open) return;
173 173
 
174  
-	if(!resmgr_acquire_multiple("monitor",
  174
+	if(!resmgr_acquire_multiple("Variable monitor",
175 175
 	  RESOURCE_AUDIO,
176 176
 	  RESOURCE_DMX_IN,
177 177
 	  RESOURCE_SAMPLER,

No commit comments for this range

Something went wrong with that request. Please try again.