From: Giuliano Pochini Subject: echomixer patch Date: Sun, 9 Jan 2005 19:54:16 +0100 Message-ID: <20050109195416.29d8cd78.pochini@shiny.it> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Alsa-devel List-Id: alsa-devel@alsa-project.org - Big cleanup in the matrix mixer drawing code. It make is way smaller and readable. - New feature: echomixer can load and restore the status of nominal level switches. - Version number bumped to 1.0.3. Signed-off-by: Giuliano Pochini --- x/ad/alsa-tools/echomixer/configure.in Wed Dec 29 14:02:53 2004 +++ alsa-tools/echomixer/configure.in Sun Jan 9 19:27:23 2005 @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(echomixer.c) -AM_INIT_AUTOMAKE(echomixer, 1.0.2) +AM_INIT_AUTOMAKE(echomixer, 1.0.3) AC_PROG_CC AC_PROG_INSTALL AC_HEADER_STDC --- x/alsa-tools/echomixer/configure.in-gtk2 Wed Dec 29 14:02:53 2004 +++ alsa-tools/echomixer/configure.in-gtk2 Sun Jan 9 19:28:55 2005 @@ -1,5 +1,5 @@ AC_INIT(echomixer.c) -AM_INIT_AUTOMAKE(echomixer, 0.5.0) +AM_INIT_AUTOMAKE(echomixer, 1.0.3) AC_PROG_CC AC_PROG_INSTALL AC_HEADER_STDC --- x/alsa-tools/echomixer/echomixer.c Wed Dec 29 14:02:53 2004 +++ alsa-tools/echomixer/echomixer.c Sun Jan 9 19:25:13 2005 @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, = USA. */ =20 -#define EM_VERSION "%s Echomixer v1.0.2" +#define EM_VERSION "%s Echomixer v" VERSION =20 =20 /******* @@ -75,8 +75,8 @@ // REAL is for debugging only. #define REAL =20 -#define CTLID_DEBUG(x) printf x -//#define CTLID_DEBUG(x) +//#define CTLID_DEBUG(x) printf x +#define CTLID_DEBUG(x) =20 #define UI_DEBUG(x) //#define UI_DEBUG(x) printf x @@ -92,6 +92,7 @@ =20 char card[64], cardId[16]; char dmodeName[DIGITAL_MODES][64], clocksrcName[DIGITAL_MODES][64], spdifm= odeName[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 dmodeVal, clocksrcVal, spdifmodeVal; int VUwidth, VUheight, Mixwidth, Mixheight; =20 +#define DONT_DRAW (ECHOGAIN_MUTED-1) #define NOPOS 999999 struct geometry { int st; // window status: 0 =3D hidden ; 1 =3D visible ; NOPOS =3D no s= tored setting @@ -358,8 +360,8 @@ } #else for (i=3D0; iECHOGAIN_MUTED) { + // Draw the "integer" part of the bar + db=3Dlevel>>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=3D(level&3) << (6 + 8); // 4 levels (256/4=3D=3D64=3D=3D2^= 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=3Dpeak>>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>=3DECHOGAIN_MUTED) { + db=3Dgain>>2; + gdk_gc_set_foreground(gc, &Level); + gdk_draw_rectangle(Mixpixmap, gc, TRUE, x-XMETER+XVOLUME, y, 1, YCELLD= IM); + 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 @@ 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=3D{0x787878, 0, 0, 0}; GdkColor Labels=3D{0x9694C4, 0, 0, 0}; - GdkColor Bars=3D{0x00FF00, 0, 0, 0}; - GdkColor Bars1=3D{0x000000, 0, 0, 0}; - GdkColor Peak=3D{0x1BABFF, 0, 0, 0}; - GdkColor Level=3D{0xC0B000, 0, 0, 0}; GdkColor Hilight=3D{0x000078, 0, 0, 0}; GdkColor Hilight2=3D{0x600000, 0, 0, 0}; =20 @@ -650,6 +682,7 @@ } =20 // Draw the grid + gdk_gc_set_font(gc, fnt); // Horizontal lines and input channel labels for (i=3D0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db, GM_BARWIDTH, YCE= LLDIM+db); - if ((Bars1.pixel=3D(((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=3D0; i>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, YCELLTOT*i+YCELLBORDER= -db, GM_BARWIDTH, 1); - } + for (i=3D0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db, GM_BARWIDTH, Y= CELLDIM+db); - if ((Bars1.pixel=3D(((dB&3)*0x40)<<8))) { - gdk_gc_set_foreground(gc, &Bars1); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, y-db-1, GM_BARWIDT= H, 1); - } - } - gdk_gc_set_foreground(gc, &Peak); - for (i=3D0; i>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER, YCELLTOT*(i+GMixerSe= ction.VmixerFirst)+YCELLBORDER-db, GM_BARWIDTH, 1); - } + for (i=3D0; i>2; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, G= M_BARWIDTH, YCELLDIM+db); - if ((Bars1.pixel=3D(((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=3DOutPeak[o]>>2; - gdk_gc_set_foreground(gc, &Peak); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-db, G= M_BARWIDTH, 1); - gdk_gc_set_foreground(gc, &Level); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME+XCELLTOT*(o+1), y, 1, = YCELLDIM); - db=3DlineoutControl.Gain[o]>>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME-2+XCELLTOT*(o+1), y-db= , 5, 1); - } + for (o=3D0; o>2; - if (db<-YCELLDIM) - db=3D-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=3D(((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=3DmixerControl.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); } } =20 - // Draw vmixer elements + // Draw vmixer elements (Vmixer cards only) if (vmixerId) { - for (o=3D0; o>2; - if (db<-YCELLDIM) - db=3D-YCELLDIM; - gdk_gc_set_foreground(gc, &Bars); - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XMETER+XCELLTOT*(o+1), y-d= b, GM_BARWIDTH, YCELLDIM+db); - if (dB>-(YCELLDIM<<2)) - if ((Bars1.pixel=3D(((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=3DvmixerControl.mixer[o][i].Gain>>2; - gdk_draw_rectangle(Mixpixmap, gc, TRUE, XVOLUME-2+XCELLTOT*(o+1), = y-db, 5, 1); - } - } + for (o=3D0; owindow, widget->allocation.width, wid= get->allocation.height, -1); @@ -1971,6 +1932,9 @@ GMixerSection.VmixerFirst=3DnIn; GMixerSection.VmixerLast=3DnIn+vmixerControl.vchannels-1; GMixerSection.LineOut=3DGMixerSection.VmixerLast+1; + memset(NominalIn, 0, sizeof(NominalIn)); + memset(NominalOut, 0, sizeof(NominalOut)); + // Read current mixer setting. if (mixerId) ReadMixer(&mixerControl); @@ -1982,6 +1946,10 @@ ReadControl(lineinControl.Gain, nIn, lineinControl.id); if (lineoutId) ReadControl(lineoutControl.Gain, nLOut, lineoutId); + if (p4InId) + ReadNominalLevels(NominalIn, p4InId); + if (p4OutId) + ReadNominalLevels(NominalOut, p4OutId); =20 //@@ check the values if (load) { @@ -2003,6 +1971,14 @@ sscanf(str+7, "%d %d", &o, &n); if (o>=3D0 && o=3D0 && o=3D0 && i=3D0 && o=3D0 && i \n"); for (i=3D0; i \n"); - for (o=3D0; o \n"); - if (vmixerId) + if (p4InId) { + fprintf(f, "-- NominalIn \n"); + for (i=3D0; i \n"); + for (o=3D0; o \n"); + for (o=3D0; o \n"); for (o=3D0; 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 @@ return(0); } =20 -/* -TODO: -non controlla se c'=E8 mixerId e forse altri -controllare tutorial su GdkColor e tracciamento -*/ - - -- Giuliano. ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt