mirror of
https://github.com/alsa-project/alsa-tools.git
synced 2026-02-22 01:40:18 -05:00
echomixer update 3/4
- Code cleanup: remove some redundant variables. - Enhancement: The matrix mixer ignores mouse clicks that don't fall inside enabled mixer cells. Signed-off-by: Giuliano Pochini <pochini@shiny.it>
This commit is contained in:
parent
6d36219735
commit
c57ea192bb
1 changed files with 63 additions and 75 deletions
|
|
@ -114,9 +114,10 @@ struct geometry {
|
||||||
|
|
||||||
// This structure contains the first and the last row of each section of the graphic mixer window
|
// This structure contains the first and the last row of each section of the graphic mixer window
|
||||||
struct {
|
struct {
|
||||||
int Monitor; // The first is always 0
|
int VmixerFirst, VmixerLast; // Rows
|
||||||
int VmixerFirst, VmixerLast;
|
int LineOut; // There is only one row
|
||||||
int LineOut; // There is only one row
|
int Inputs; // Rows
|
||||||
|
int Outputs; // Columns
|
||||||
} GMixerSection;
|
} GMixerSection;
|
||||||
|
|
||||||
struct mixel {
|
struct mixel {
|
||||||
|
|
@ -255,12 +256,6 @@ char *strOutGain(char *s, int g) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int ADATmode() {
|
|
||||||
return(!memcmp(dmodeName[dmodeVal], "ADAT", 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Write an enumerated ALSA control
|
// Write an enumerated ALSA control
|
||||||
int SetEnum(int numid, int val) {
|
int SetEnum(int numid, int val) {
|
||||||
int err;
|
int err;
|
||||||
|
|
@ -638,20 +633,12 @@ gint DrawMixer(gpointer unused) {
|
||||||
static int InClip[ECHO_MAXAUDIOINPUTS];
|
static int InClip[ECHO_MAXAUDIOINPUTS];
|
||||||
static int OutClip[ECHO_MAXAUDIOOUTPUTS];
|
static int OutClip[ECHO_MAXAUDIOOUTPUTS];
|
||||||
char str[8];
|
char str[8];
|
||||||
int i, o, dB, inchannels, outchannels;
|
int i, o, dB;
|
||||||
GdkColor Grid={0x787878, 0, 0, 0};
|
GdkColor Grid={0x787878, 0, 0, 0};
|
||||||
GdkColor Labels={0x9694C4, 0, 0, 0};
|
GdkColor Labels={0x9694C4, 0, 0, 0};
|
||||||
GdkColor Hilight={0x000078, 0, 0, 0};
|
GdkColor Hilight={0x000078, 0, 0, 0};
|
||||||
GdkColor Hilight2={0x600000, 0, 0, 0};
|
GdkColor Hilight2={0x600000, 0, 0, 0};
|
||||||
|
|
||||||
if (ADATmode()) {
|
|
||||||
inchannels=nIn;
|
|
||||||
outchannels=nLOut;
|
|
||||||
} else {
|
|
||||||
inchannels=fdIn+2;
|
|
||||||
outchannels=fdOut+2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Mixpixmap)
|
if (!Mixpixmap)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
||||||
|
|
@ -715,7 +702,7 @@ gint DrawMixer(gpointer unused) {
|
||||||
gdk_draw_rectangle(Mixpixmap, gc, TRUE, 0, YCELLTOT*(GMixerSection.LineOut+1)-1, Mixwidth, 1);
|
gdk_draw_rectangle(Mixpixmap, gc, TRUE, 0, YCELLTOT*(GMixerSection.LineOut+1)-1, Mixwidth, 1);
|
||||||
|
|
||||||
// Draw input levels and peaks
|
// Draw input levels and peaks
|
||||||
for (i=0; i<inchannels; i++)
|
for (i=0; i<GMixerSection.Inputs; i++)
|
||||||
DrawBar(0, i, InLevel[i], InPeak[i], DONT_DRAW);
|
DrawBar(0, i, InLevel[i], InPeak[i], DONT_DRAW);
|
||||||
|
|
||||||
// Draw vchannels levels and peaks (Vmixer cards only)
|
// Draw vchannels levels and peaks (Vmixer cards only)
|
||||||
|
|
@ -725,12 +712,12 @@ gint DrawMixer(gpointer unused) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw output levels, peaks and volumes
|
// Draw output levels, peaks and volumes
|
||||||
for (o=0; o<outchannels; o++)
|
for (o=0; o<GMixerSection.Outputs; o++)
|
||||||
DrawBar(o+1, GMixerSection.LineOut, OutLevel[o], OutPeak[o], lineoutControl.Gain[o]);
|
DrawBar(o+1, GMixerSection.LineOut, OutLevel[o], OutPeak[o], lineoutControl.Gain[o]);
|
||||||
|
|
||||||
// Draw monitor mixer elements
|
// Draw monitor mixer elements
|
||||||
for (o=0; o<outchannels; o++) {
|
for (o=0; o<GMixerSection.Outputs; o++) {
|
||||||
for (i=0; i<inchannels; i++) {
|
for (i=0; i<GMixerSection.Inputs; i++) {
|
||||||
dB=Add_dB(mixerControl.mixer[o][i].Gain, InLevel[i]);
|
dB=Add_dB(mixerControl.mixer[o][i].Gain, InLevel[i]);
|
||||||
DrawBar(o+1, i, dB, DONT_DRAW, mixerControl.mixer[o][i].Gain);
|
DrawBar(o+1, i, dB, DONT_DRAW, mixerControl.mixer[o][i].Gain);
|
||||||
}
|
}
|
||||||
|
|
@ -738,7 +725,7 @@ gint DrawMixer(gpointer unused) {
|
||||||
|
|
||||||
// Draw vmixer elements (Vmixer cards only)
|
// Draw vmixer elements (Vmixer cards only)
|
||||||
if (vmixerId) {
|
if (vmixerId) {
|
||||||
for (o=0; o<outchannels; o++)
|
for (o=0; o<GMixerSection.Outputs; o++)
|
||||||
for (i=0; i<vmixerControl.vchannels; i++)
|
for (i=0; i<vmixerControl.vchannels; i++)
|
||||||
DrawBar(o+1, i+GMixerSection.VmixerFirst, VirLevel[i], DONT_DRAW, vmixerControl.mixer[o][i].Gain);
|
DrawBar(o+1, i+GMixerSection.VmixerFirst, VirLevel[i], DONT_DRAW, vmixerControl.mixer[o][i].Gain);
|
||||||
}
|
}
|
||||||
|
|
@ -926,24 +913,23 @@ static gint Gmixer_button_press(GtkWidget *widget, GdkEventButton *event) {
|
||||||
GMixerRow=(int)event->y/YCELLTOT;
|
GMixerRow=(int)event->y/YCELLTOT;
|
||||||
GMixerColumn=(int)event->x/XCELLTOT-1;
|
GMixerColumn=(int)event->x/XCELLTOT-1;
|
||||||
|
|
||||||
|
if (GMixerColumn<0 || GMixerColumn>=GMixerSection.Outputs)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* grab_focus must follow set_active because the latter causes
|
/* grab_focus must follow set_active because the latter causes
|
||||||
Vmixer_*_selector_clicked() to be called and, in turn,
|
Vmixer_*_selector_clicked() to be called and, in turn,
|
||||||
Vmixer_volume_changed() which changes mixerControl.input
|
Vmixer_volume_changed() which changes mixerControl.input
|
||||||
(or .output in non-reverse mode). grab_focus then causes
|
(or .output in non-reverse mode). grab_focus then causes
|
||||||
Vmixer_volume_clicked() to be called and that event handler
|
Vmixer_volume_clicked() to be called and that event handler
|
||||||
finally sets the correct value of mixerControl.input */
|
finally sets the correct value of mixerControl.input */
|
||||||
if (GMixerRow<=GMixerSection.Monitor) {
|
if (GMixerRow<GMixerSection.Inputs) {
|
||||||
if (GMixerColumn!=mixerControl.output && GMixerColumn>=0) {
|
if (GMixerColumn!=mixerControl.output)
|
||||||
if (GMixerColumn<fdOut+2 || (ADATmode() && GMixerColumn<nLOut))
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixerControl.outsel[GMixerColumn]), TRUE);
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixerControl.outsel[GMixerColumn]), TRUE);
|
|
||||||
}
|
|
||||||
if (GMixerRow!=mixerControl.input)
|
if (GMixerRow!=mixerControl.input)
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(mixerControl.volume[GMixerRow]));
|
gtk_widget_grab_focus(GTK_WIDGET(mixerControl.volume[GMixerRow]));
|
||||||
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
||||||
if (GMixerColumn!=vmixerControl.output && GMixerColumn>=0) {
|
if (GMixerColumn!=vmixerControl.output)
|
||||||
if (GMixerColumn<fdOut+2 || (ADATmode() && GMixerColumn<vmixerControl.outputs))
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vmixerControl.outsel[GMixerColumn]), TRUE);
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vmixerControl.outsel[GMixerColumn]), TRUE);
|
|
||||||
}
|
|
||||||
if (GMixerRow!=vmixerControl.vchannel)
|
if (GMixerRow!=vmixerControl.vchannel)
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(vmixerControl.volume[GMixerRow-GMixerSection.VmixerFirst]));
|
gtk_widget_grab_focus(GTK_WIDGET(vmixerControl.volume[GMixerRow-GMixerSection.VmixerFirst]));
|
||||||
}
|
}
|
||||||
|
|
@ -962,21 +948,20 @@ static gint Gmixer_button_press(GtkWidget *widget, GdkEventButton *event) {
|
||||||
GMixerRow=(int)event->y/YCELLTOT;
|
GMixerRow=(int)event->y/YCELLTOT;
|
||||||
GMixerColumn=(int)event->x/XCELLTOT-1;
|
GMixerColumn=(int)event->x/XCELLTOT-1;
|
||||||
|
|
||||||
|
if (GMixerColumn<0 || GMixerColumn>=GMixerSection.Outputs)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
// See the note above
|
// See the note above
|
||||||
if (GMixerRow<=GMixerSection.Monitor) {
|
if (GMixerRow<GMixerSection.Inputs) {
|
||||||
if (GMixerRow!=mixerControl.input)
|
if (GMixerRow!=mixerControl.input)
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixerControl.inpsel[GMixerRow]), TRUE);
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixerControl.inpsel[GMixerRow]), TRUE);
|
||||||
if (GMixerColumn!=mixerControl.output && GMixerColumn>=0) {
|
if (GMixerColumn!=mixerControl.output)
|
||||||
if (GMixerColumn<fdOut+2 || (ADATmode() && GMixerColumn<nLOut))
|
gtk_widget_grab_focus(GTK_WIDGET(mixerControl.volume[GMixerColumn]));
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(mixerControl.volume[GMixerColumn]));
|
|
||||||
}
|
|
||||||
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
||||||
if (GMixerRow!=vmixerControl.vchannel)
|
if (GMixerRow!=vmixerControl.vchannel)
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vmixerControl.vchsel[GMixerRow-GMixerSection.VmixerFirst]), TRUE);
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vmixerControl.vchsel[GMixerRow-GMixerSection.VmixerFirst]), TRUE);
|
||||||
if (GMixerColumn!=vmixerControl.output && GMixerColumn>=0) {
|
if (GMixerColumn!=vmixerControl.output)
|
||||||
if (GMixerColumn<fdOut+2 || (ADATmode() && GMixerColumn<vmixerControl.outputs))
|
gtk_widget_grab_focus(GTK_WIDGET(vmixerControl.volume[GMixerColumn]));
|
||||||
gtk_widget_grab_focus(GTK_WIDGET(vmixerControl.volume[GMixerColumn]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->button==1) {
|
if (event->button==1) {
|
||||||
|
|
@ -999,6 +984,8 @@ static gint Gmixer_button_release(GtkWidget *widget, GdkEventButton *event) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Gets how many pixels the mouse pointer was moved of and updates
|
||||||
|
// the currently active mixer/vmixer/line_out control.
|
||||||
static gint Gmixer_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
|
static gint Gmixer_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
|
||||||
int x, y;
|
int x, y;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
|
|
@ -1012,42 +999,40 @@ static gint Gmixer_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
|
||||||
state=event->state;
|
state=event->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the button is still pressed because the release event can fall in another window, so we may miss it.
|
// Check if the button is still pressed because the release event can
|
||||||
if (!(state & GDK_BUTTON1_MASK))
|
// fall in another window, so we may miss it. Ignore the event if there
|
||||||
|
// isn't a backing pixmap or the user clicked an invalid cell. We also
|
||||||
|
// have to check mouseButton because the button_press event may arrive
|
||||||
|
// after the respective motion_notify event.
|
||||||
|
if (!(state & GDK_BUTTON1_MASK) || !mouseButton || !Mixpixmap || GMixerColumn<0 || GMixerColumn>=GMixerSection.Outputs) {
|
||||||
mouseButton=0;
|
mouseButton=0;
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
if (GMixerRow<=GMixerSection.Monitor) {
|
if (GMixerRow<GMixerSection.Inputs) {
|
||||||
if (mouseButton && Mixpixmap != NULL) {
|
val=INVERT(mixerControl.mixer[mixerControl.output][mixerControl.input].Gain);
|
||||||
val=INVERT(mixerControl.mixer[mixerControl.output][mixerControl.input].Gain);
|
val+=y-mouseY;
|
||||||
val+=y-mouseY;
|
mouseY=y;
|
||||||
mouseY=y;
|
// Gtk already limits the range of "val"
|
||||||
// Gtk already limits the range of "val"
|
|
||||||
#ifdef REVERSE
|
#ifdef REVERSE
|
||||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixerControl.adj[mixerControl.input]), (gfloat)val);
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixerControl.adj[mixerControl.input]), (gfloat)val);
|
||||||
#else
|
#else
|
||||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixerControl.adj[mixerControl.output]), (gfloat)val);
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixerControl.adj[mixerControl.output]), (gfloat)val);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
} else if (GMixerRow>=GMixerSection.VmixerFirst && GMixerRow<=GMixerSection.VmixerLast) {
|
||||||
if (mouseButton && Mixpixmap != NULL) {
|
val=INVERT(vmixerControl.mixer[vmixerControl.output][vmixerControl.vchannel].Gain);
|
||||||
val=INVERT(vmixerControl.mixer[vmixerControl.output][vmixerControl.vchannel].Gain);
|
val+=y-mouseY;
|
||||||
val+=y-mouseY;
|
mouseY=y;
|
||||||
mouseY=y;
|
|
||||||
// Gtk already limits the range of "val"
|
|
||||||
#ifdef REVERSE
|
#ifdef REVERSE
|
||||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(vmixerControl.adj[vmixerControl.vchannel]), (gfloat)val);
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(vmixerControl.adj[vmixerControl.vchannel]), (gfloat)val);
|
||||||
#else
|
#else
|
||||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(vmixerControl.adj[vmixerControl.output]), (gfloat)val);
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(vmixerControl.adj[vmixerControl.output]), (gfloat)val);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
} else if (GMixerRow==GMixerSection.LineOut) {
|
} else if (GMixerRow==GMixerSection.LineOut) {
|
||||||
if (mouseButton && Mixpixmap != NULL) {
|
val=INVERT(lineoutControl.Gain[GMixerColumn]);
|
||||||
val=INVERT(lineoutControl.Gain[GMixerColumn]);
|
val+=y-mouseY;
|
||||||
val+=y-mouseY;
|
mouseY=y;
|
||||||
mouseY=y;
|
gtk_adjustment_set_value(GTK_ADJUSTMENT(lineoutControl.adj[GMixerColumn]), (gfloat)val);
|
||||||
// Gtk already limits the range of "val"
|
|
||||||
gtk_adjustment_set_value(GTK_ADJUSTMENT(lineoutControl.adj[GMixerColumn]), (gfloat)val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
@ -1403,12 +1388,15 @@ void Digital_mode_activate(GtkWidget *widget, gpointer mode) {
|
||||||
// When I change the digital mode, the clock source can change too
|
// When I change the digital mode, the clock source can change too
|
||||||
gtk_option_menu_set_history(GTK_OPTION_MENU(clocksrcOpt), clocksrcVal=GetEnum(clocksrcId));
|
gtk_option_menu_set_history(GTK_OPTION_MENU(clocksrcOpt), clocksrcVal=GetEnum(clocksrcId));
|
||||||
}
|
}
|
||||||
adat=ADATmode();
|
adat=!memcmp(dmodeName[dmodeVal], "ADAT", 4);
|
||||||
SetSensitivity(adat);
|
SetSensitivity(adat);
|
||||||
if (adat)
|
if (adat) {
|
||||||
GMixerSection.Monitor=nIn-1;
|
GMixerSection.Inputs=nIn;
|
||||||
else
|
GMixerSection.Outputs=nLOut;
|
||||||
GMixerSection.Monitor=fdIn+2-1; // S/PDIF has only 2 channels
|
} else {
|
||||||
|
GMixerSection.Inputs=fdIn+2; // S/PDIF has only 2 channels
|
||||||
|
GMixerSection.Outputs=fdOut+2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1811,12 +1799,11 @@ int OpenControls(const char *card, const char *cardname) {
|
||||||
#ifndef REAL
|
#ifndef REAL
|
||||||
vmixerId=1000;
|
vmixerId=1000;
|
||||||
vmixerControl.vchannels=12;
|
vmixerControl.vchannels=12;
|
||||||
vmixerControl.outputs=mixerControl.outputs=10;
|
vmixerControl.outputs=mixerControl.outputs=nLOut=10;
|
||||||
metersStreams=3;
|
metersStreams=3;
|
||||||
metersNumber=16;
|
metersNumber=16;
|
||||||
metersTypes=2;
|
metersTypes=2;
|
||||||
nPOut=12;
|
nPOut=12;
|
||||||
nLOut=10;
|
|
||||||
fdOut=2;
|
fdOut=2;
|
||||||
nIn=10;
|
nIn=10;
|
||||||
fdIn=2;
|
fdIn=2;
|
||||||
|
|
@ -1928,7 +1915,8 @@ printf("components = %s\n", snd_ctl_card_info_get_components(hw_info));*/
|
||||||
Mixerw_geom.st=NOPOS;
|
Mixerw_geom.st=NOPOS;
|
||||||
Vmixerw_geom.st=NOPOS;
|
Vmixerw_geom.st=NOPOS;
|
||||||
VUwindow=GMwindow=0;
|
VUwindow=GMwindow=0;
|
||||||
GMixerSection.Monitor=fdIn+2-1; // The correct value is set by Digital_mode_activate()
|
GMixerSection.Inputs=fdIn+2; // The correct value is set by Digital_mode_activate()
|
||||||
|
GMixerSection.Outputs=fdOut+2;
|
||||||
GMixerSection.VmixerFirst=nIn;
|
GMixerSection.VmixerFirst=nIn;
|
||||||
GMixerSection.VmixerLast=nIn+vmixerControl.vchannels-1;
|
GMixerSection.VmixerLast=nIn+vmixerControl.vchannels-1;
|
||||||
GMixerSection.LineOut=GMixerSection.VmixerLast+1;
|
GMixerSection.LineOut=GMixerSection.VmixerLast+1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue