From 08916c00272cb6597a0f971e9a3a99b6380aaf52 Mon Sep 17 00:00:00 2001 From: Giuliano Pochini Date: Wed, 19 Jan 2005 10:48:45 +0000 Subject: [PATCH] echomixer update 1/4 - Matrix mixer drawing code cleanup. - New feature: echomixer can load and restore the status of nominal level switches. Signed-off-by: Giuliano Pochini --- echomixer/echomixer.c | 268 ++++++++++++++++++++---------------------- 1 file changed, 125 insertions(+), 143 deletions(-) diff --git a/echomixer/echomixer.c b/echomixer/echomixer.c index d84e8db..ada36be 100644 --- a/echomixer/echomixer.c +++ b/echomixer/echomixer.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define EM_VERSION "%s Echomixer v1.0.2" +#define EM_VERSION "%s Echomixer v" VERSION /******* @@ -75,8 +75,8 @@ // REAL is for debugging only. #define REAL -#define CTLID_DEBUG(x) printf x -//#define CTLID_DEBUG(x) +//#define CTLID_DEBUG(x) printf x +#define CTLID_DEBUG(x) #define UI_DEBUG(x) //#define UI_DEBUG(x) printf x @@ -92,6 +92,7 @@ char card[64], cardId[16]; char dmodeName[DIGITAL_MODES][64], clocksrcName[DIGITAL_MODES][64], spdifmodeName[DIGITAL_MODES][64]; +char NominalIn[ECHO_MAXAUDIOINPUTS], NominalOut[ECHO_MAXAUDIOOUTPUTS]; int nLOut, nIn, fdIn, fdOut, nPOut, ClockMask; int ndmodes, nclocksrc, nspdifmodes; int GMixerRow, GMixerColumn, Gang; @@ -102,6 +103,7 @@ int mouseY, mouseButton; int dmodeVal, clocksrcVal, spdifmodeVal; int VUwidth, VUheight, Mixwidth, Mixheight; +#define DONT_DRAW (ECHOGAIN_MUTED-1) #define NOPOS 999999 struct geometry { int st; // window status: 0 = hidden ; 1 = visible ; NOPOS = no stored setting @@ -358,8 +360,8 @@ void GetVUmeters(int *InLevel, int *InPeak, int *OutLevel, int *OutPeak, int *Vi } #else for (i=0; iECHOGAIN_MUTED) { + // Draw the "integer" part of the bar + db=level>>2; + gdk_gc_set_foreground(gc, &Bars); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x, y-db, GM_BARWIDTH, YCELLDIM+db); + + // Draw the antialiased part + Bars1.pixel=(level&3) << (6 + 8); // 4 levels (256/4==64==2^6) of green (2^8) + if (Bars1.pixel) { + gdk_gc_set_foreground(gc, &Bars1); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x, y-db-1, GM_BARWIDTH, 1); + } + } + + // Draw the peak + if (peak>ECHOGAIN_MUTED) { + db=peak>>2; + gdk_gc_set_foreground(gc, &Peak); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x, y-db, GM_BARWIDTH, 1); + } + + // Draw the mixer gain + if (gain>=ECHOGAIN_MUTED) { + db=gain>>2; + gdk_gc_set_foreground(gc, &Level); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x-XMETER+XVOLUME, y, 1, YCELLDIM); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x-XMETER+XVOLUME-2, y-db, 5, 1); + } +} + + + // Draw the matrix mixer gint DrawMixer(gpointer unused) { GdkRectangle update_rect; @@ -597,18 +633,14 @@ gint DrawMixer(gpointer unused) { int InPeak[ECHO_MAXAUDIOINPUTS]; int OutLevel[ECHO_MAXAUDIOOUTPUTS]; int OutPeak[ECHO_MAXAUDIOOUTPUTS]; - int VirLevel[ECHO_MAXAUDIOOUTPUTS];//maxpipes + int VirLevel[ECHO_MAXAUDIOOUTPUTS]; int VirPeak[ECHO_MAXAUDIOOUTPUTS]; static int InClip[ECHO_MAXAUDIOINPUTS]; static int OutClip[ECHO_MAXAUDIOOUTPUTS]; char str[8]; - int i, o, y, dB, db, inchannels, outchannels; + int i, o, dB, inchannels, outchannels; GdkColor Grid={0x787878, 0, 0, 0}; GdkColor Labels={0x9694C4, 0, 0, 0}; - GdkColor Bars={0x00FF00, 0, 0, 0}; - GdkColor Bars1={0x000000, 0, 0, 0}; - GdkColor Peak={0x1BABFF, 0, 0, 0}; - GdkColor Level={0xC0B000, 0, 0, 0}; GdkColor Hilight={0x000078, 0, 0, 0}; GdkColor Hilight2={0x600000, 0, 0, 0}; @@ -650,6 +682,7 @@ gint DrawMixer(gpointer unused) { } // Draw the grid + gdk_gc_set_font(gc, fnt); // Horizontal lines and input channel labels for (i=0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db, GM_BARWIDTH, YCELLDIM+db); - if ((Bars1.pixel=(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db-1, GM_BARWIDTH, 1); - } - } - gdk_gc_set_foreground(gc, &Peak); - for (i=0; i>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, YCELLTOT*i+YCELLBORDER-db, GM_BARWIDTH, 1); - } + for (i=0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db, GM_BARWIDTH, YCELLDIM+db); - if ((Bars1.pixel=(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db-1, GM_BARWIDTH, 1); - } - } - gdk_gc_set_foreground(gc, &Peak); - for (i=0; i>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, YCELLTOT*(i+GMixerSection.VmixerFirst)+YCELLBORDER-db, GM_BARWIDTH, 1); - } + for (i=0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, GM_BARWIDTH, YCELLDIM+db); - if ((Bars1.pixel=(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db-1, GM_BARWIDTH, 1); - } - db=OutPeak[o]>>2; - gdk_gc_set_foreground(gc, &Peak); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, GM_BARWIDTH, 1); - gdk_gc_set_foreground(gc, &Level); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME+XCELLTOT*(o+1), y, 1, YCELLDIM); - db=lineoutControl.Gain[o]>>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME-2+XCELLTOT*(o+1), y-db, 5, 1); - } + for (o=0; o>2; - if (db<-YCELLDIM) - db=-YCELLDIM; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, GM_BARWIDTH, YCELLDIM+db); - if (dB>-(YCELLDIM<<2)) - if ((Bars1.pixel=(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db-1, GM_BARWIDTH, 1); - } - gdk_gc_set_foreground(gc, &Level); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME+XCELLTOT*(o+1), y, 1, YCELLDIM); - db=mixerControl.mixer[o][i].Gain>>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME-2+XCELLTOT*(o+1), y-db, 5, 1); + DrawBar(o+1, i, dB, DONT_DRAW, mixerControl.mixer[o][i].Gain); } } - // Draw vmixer elements + // Draw vmixer elements (Vmixer cards only) if (vmixerId) { - for (o=0; o>2; - if (db<-YCELLDIM) - db=-YCELLDIM; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, GM_BARWIDTH, YCELLDIM+db); - if (dB>-(YCELLDIM<<2)) - if ((Bars1.pixel=(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db-1, GM_BARWIDTH, 1); - } - gdk_gc_set_foreground(gc, &Level); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME+XCELLTOT*(o+1), y, 1, YCELLDIM); - db=vmixerControl.mixer[o][i].Gain>>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME-2+XCELLTOT*(o+1), y-db, 5, 1); - } - } + for (o=0; owindow, widget->allocation.width, widget->allocation.height, -1); @@ -1971,6 +1932,9 @@ printf("components = %s\n", snd_ctl_card_info_get_components(hw_info));*/ GMixerSection.VmixerFirst=nIn; GMixerSection.VmixerLast=nIn+vmixerControl.vchannels-1; GMixerSection.LineOut=GMixerSection.VmixerLast+1; + memset(NominalIn, 0, sizeof(NominalIn)); + memset(NominalOut, 0, sizeof(NominalOut)); + // Read current mixer setting. if (mixerId) ReadMixer(&mixerControl); @@ -1982,6 +1946,10 @@ printf("components = %s\n", snd_ctl_card_info_get_components(hw_info));*/ ReadControl(lineinControl.Gain, nIn, lineinControl.id); if (lineoutId) ReadControl(lineoutControl.Gain, nLOut, lineoutId); + if (p4InId) + ReadNominalLevels(NominalIn, p4InId); + if (p4OutId) + ReadNominalLevels(NominalOut, p4OutId); //@@ check the values if (load) { @@ -2003,6 +1971,14 @@ printf("components = %s\n", snd_ctl_card_info_get_components(hw_info));*/ sscanf(str+7, "%d %d", &o, &n); if (o>=0 && o=0 && o=0 && i=0 && o=0 && i \n"); for (i=0; i \n"); - for (o=0; o \n"); - if (vmixerId) + if (p4InId) { + fprintf(f, "-- NominalIn \n"); + for (i=0; i \n"); + for (o=0; o \n"); + for (o=0; o \n"); for (o=0; o \n"); fprintf(f, "MainWindow %d %d %d %d\n", Mainw_geom.x, Mainw_geom.y, Mainw_geom.w, Mainw_geom.h); if (VUwindow) @@ -2826,10 +2815,3 @@ printf("components = %s\n", snd_ctl_card_info_get_components(hw_info));*/ return(0); } -/* -TODO: -non controlla se c'รจ mixerId e forse altri -controllare tutorial su GdkColor e tracciamento -*/ - - -- 2.47.1