Blame hdspmixer/src/HDSPMixerSetup.cxx

Packit 427e91
/*
Packit 427e91
 *   HDSPMixer
Packit 427e91
 *    
Packit 427e91
 *   Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
Packit 427e91
 *    
Packit 427e91
 *   This program is free software; you can redistribute it and/or modify
Packit 427e91
 *   it under the terms of the GNU General Public License as published by
Packit 427e91
 *   the Free Software Foundation; either version 2 of the License, or
Packit 427e91
 *   (at your option) any later version.
Packit 427e91
 *
Packit 427e91
 *   This program is distributed in the hope that it will be useful,
Packit 427e91
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 427e91
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 427e91
 *   GNU General Public License for more details.
Packit 427e91
 *
Packit 427e91
 *   You should have received a copy of the GNU General Public License
Packit 427e91
 *   along with this program; if not, write to the Free Software
Packit 427e91
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit 427e91
 */
Packit 427e91
Packit 427e91
#pragma implementation
Packit 427e91
#include "HDSPMixerSetup.h"
Packit 427e91
Packit 427e91
static void rate_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    const Fl_Menu_Item *i = ((Fl_Menu_ *)widget)->mvalue();
Packit 427e91
    if (!strncmp("s", i->label(), 1)) {
Packit 427e91
	w->setup->rate_val = 0;
Packit 427e91
    } else if (!strncmp("m", i->label(), 1)) {
Packit 427e91
	w->setup->rate_val = 1;
Packit 427e91
    } else {
Packit 427e91
	w->setup->rate_val = 2;
Packit 427e91
    }
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
static void ok_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerSetup *s = (HDSPMixerSetup *)arg;
Packit 427e91
    s->hide();
Packit 427e91
}
Packit 427e91
Packit 427e91
Packit 427e91
static void peak_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    w->setup->numbers_val = 1;
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
static void rms_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    w->setup->numbers_val = 0;
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
Packit 427e91
static void fourty_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    w->setup->level_val = 0;
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
static void sixty_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    w->setup->level_val = 1;
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
static void over_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    w->setup->over_val = (int)w->setup->over->value();
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
Packit 427e91
static void rmsplus3_cb(Fl_Widget *widget, void *arg)
Packit 427e91
{
Packit 427e91
    HDSPMixerWindow *w = (HDSPMixerWindow *)arg;
Packit 427e91
    if (w->setup->rmsplus3->value()) {
Packit 427e91
	w->setup->rmsplus3_val = 1;
Packit 427e91
    } else {
Packit 427e91
	w->setup->rmsplus3_val = 0;
Packit 427e91
    }
Packit 427e91
    w->checkState();
Packit 427e91
}
Packit 427e91
Packit 427e91
Packit 427e91
HDSPMixerSetup::HDSPMixerSetup(int w, int h, char const *label, HDSPMixerWindow *win):Fl_Double_Window(w, h, label)
Packit 427e91
{
Packit 427e91
    basew = win;
Packit 427e91
    plm = new Fl_Group(10, 25, 380, 60, "Peak Level Meters");    
Packit 427e91
    plm->labelfont(FL_HELVETICA);
Packit 427e91
    plm->labelsize(12);
Packit 427e91
    plm->align(FL_ALIGN_TOP_LEFT);
Packit 427e91
    plm->box(FL_ENGRAVED_FRAME);
Packit 427e91
    over = new Fl_Counter(30, 50, 50, 20, "FS samples for OVR  ");
Packit 427e91
    over->callback((Fl_Callback *)over_cb, (void *)basew);
Packit 427e91
    over->type(FL_SIMPLE_COUNTER);
Packit 427e91
    over->bounds(1, 15);
Packit 427e91
    over->step(1);
Packit 427e91
    over->value(3);
Packit 427e91
    over_val = 3;
Packit 427e91
    over->labelfont(FL_HELVETICA);
Packit 427e91
    over->labelsize(12);
Packit 427e91
    over->align(FL_ALIGN_TOP_LEFT);
Packit 427e91
    rate = new Fl_Choice(230, 50, 80, 20, "Release Rate  ");
Packit 427e91
    rate->align(FL_ALIGN_TOP_LEFT);
Packit 427e91
    rate->labelfont(FL_HELVETICA);
Packit 427e91
    rate->labelsize(12);
Packit 427e91
    rate->add("slow", 0, (Fl_Callback *)rate_cb, (void *)basew);
Packit 427e91
    rate->add("medium", 0, (Fl_Callback *)rate_cb, (void *)basew);
Packit 427e91
    rate->add("high", 0, (Fl_Callback *)rate_cb, (void *)basew);
Packit 427e91
    rate->value(1);
Packit 427e91
    rate_val = 1;
Packit 427e91
    plm->end();
Packit 427e91
    numbers = new Fl_Group(10, 110, 180, 60, "Numbers");
Packit 427e91
    numbers->box(FL_ENGRAVED_FRAME);
Packit 427e91
    numbers->labelfont(FL_HELVETICA);
Packit 427e91
    numbers->labelsize(12);
Packit 427e91
    numbers->align(FL_ALIGN_TOP_LEFT);    
Packit 427e91
    rms = new Fl_Round_Button(30, 120, 60, 20, "RMS");
Packit 427e91
    rms->labelfont(FL_HELVETICA);
Packit 427e91
    rms->labelsize(12);
Packit 427e91
    rms->callback((Fl_Callback *)rms_cb, (void *)basew);
Packit 427e91
    rms->set();
Packit 427e91
    numbers_val = 0;
Packit 427e91
    rms->type(FL_RADIO_BUTTON);
Packit 427e91
    peak = new Fl_Round_Button(30, 140, 60, 20, "Peak");
Packit 427e91
    peak->labelfont(FL_HELVETICA);
Packit 427e91
    peak->labelsize(12);
Packit 427e91
    peak->type(FL_RADIO_BUTTON);
Packit 427e91
    peak->callback((Fl_Callback *)peak_cb, (void *)basew);
Packit 427e91
    numbers->end();
Packit 427e91
    level = new Fl_Group(210, 110, 180, 60, "Minimum Level");
Packit 427e91
    level->box(FL_ENGRAVED_FRAME);
Packit 427e91
    level->labelfont(FL_HELVETICA);
Packit 427e91
    level->labelsize(12);
Packit 427e91
    level->align(FL_ALIGN_TOP_LEFT);
Packit 427e91
    fourty = new Fl_Round_Button(230, 120, 60, 20, "-40 dB");
Packit 427e91
    fourty->labelfont(FL_HELVETICA);
Packit 427e91
    fourty->labelsize(12);
Packit 427e91
    fourty->type(FL_RADIO_BUTTON);
Packit 427e91
    fourty->set();
Packit 427e91
    level_val = 0;
Packit 427e91
    fourty->callback((Fl_Callback *)fourty_cb, (void *)basew);
Packit 427e91
    sixty = new Fl_Round_Button(230, 140, 60, 20, "-60 dB");
Packit 427e91
    sixty->labelfont(FL_HELVETICA);
Packit 427e91
    sixty->labelsize(12);
Packit 427e91
    sixty->type(FL_RADIO_BUTTON);
Packit 427e91
    sixty->callback((Fl_Callback *)sixty_cb, (void *)basew);
Packit 427e91
    level->end();
Packit 427e91
    rmsplus3grp = new Fl_Group(10, 190, 180, 60);
Packit 427e91
    rmsplus3grp->box(FL_ENGRAVED_FRAME);
Packit 427e91
    rmsplus3 = new Fl_Check_Button(30, 210, 100, 20, "RMS +3dB");
Packit 427e91
    rmsplus3->labelfont(FL_HELVETICA);
Packit 427e91
    rmsplus3->labelsize(12);
Packit 427e91
    rmsplus3->callback((Fl_Callback *)rmsplus3_cb, (void *)basew);
Packit 427e91
    rmsplus3_val = 0;
Packit 427e91
    rmsplus3grp->end();
Packit 427e91
    ok = new Fl_Return_Button(270, 210, 60, 20, "OK");
Packit 427e91
    ok->callback((Fl_Callback *)ok_cb, (void *)this);
Packit 427e91
    end();
Packit 427e91
#ifndef NON_MODAL_SETUP
Packit 427e91
    set_modal();
Packit 427e91
#endif
Packit 427e91
}
Packit 427e91
Packit 427e91
void HDSPMixerSetup::updateValues()
Packit 427e91
{
Packit 427e91
    rmsplus3->value(rmsplus3_val);
Packit 427e91
    if (level_val) {
Packit 427e91
	sixty->setonly();
Packit 427e91
    } else {
Packit 427e91
	fourty->setonly();
Packit 427e91
    }
Packit 427e91
    if (numbers_val) {
Packit 427e91
	peak->setonly();
Packit 427e91
    } else {
Packit 427e91
	rms->setonly();
Packit 427e91
    }
Packit 427e91
    over->value(over_val);
Packit 427e91
    rate->value(rate_val);    
Packit 427e91
#ifdef NON_MODAL_SETUP
Packit 427e91
    if (shown()) {
Packit 427e91
	redraw();
Packit 427e91
    }
Packit 427e91
#endif
Packit 427e91
}
Packit 427e91