1 // -----------------------------------------------------------------------------
2 //
3 //  Copyright (C) 2006-2018 Fons Adriaensen <fons@linuxaudio.org>
4 //
5 //  This program is free software; you can redistribute it and/or modify
6 //  it under the terms of the GNU General Public License as published by
7 //  the Free Software Foundation; either version 2 of the License, or
8 //  (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 //
18 // -----------------------------------------------------------------------------
19 
20 
21 #ifndef __JCLIENT_H
22 #define __JCLIENT_H
23 
24 
25 #include <clthreads.h>
26 #include <jack/jack.h>
27 #include "abprocess.h"
28 #include "kmeterdsp.h"
29 #include "virtmic.h"
30 #include "global.h"
31 
32 
33 class Jclient : public A_thread
34 {
35 public:
36 
37     Jclient (const char *jname);
38     ~Jclient (void);
39 
40     enum { METER_INP, METER_MON };
41     enum { MONIT_REC, MONIT_EXT };
42 
jname(void)43     const char *jname (void) const { return _jname; }
44 
set_hpfil(float v)45     void set_hpfil (float v) { _abproc.set_hpfil (v); }
set_mute(int m)46     void set_mute (int m) { _abproc.set_mute (m); }
set_invb(int m)47     void set_invb (int m) { _abproc.set_invb (m); }
set_endf(int m)48     void set_endf (int m) { _abproc.set_endf (m); }
set_form(int k)49     void set_form (int k)
50     {
51         _abproc.set_norm (k);
52 	_virtmic.set_norm (k);
53     }
set_lffilt(ABconfig * C)54     int  set_lffilt (ABconfig *C) { return _abproc.set_lffilt (C); }
set_matrix(ABconfig * C)55     int  set_matrix (ABconfig *C) { return _abproc.set_matrix (C); }
set_convol(ABconfig * C)56     int  set_convol (ABconfig *C) { return _abproc.set_convol (C); }
set_hffilt(ABconfig * C)57     int  set_hffilt (ABconfig *C) { return _abproc.set_hffilt (C); }
58 
set_meter(int k)59     void set_meter (int k) { _meter = k; }
set_monit(int k)60     void set_monit (int k) { _monit = k; }
set_azim(float v)61     void set_azim  (float v) { _virtmic.set_azim (v); }
set_elev(float v)62     void set_elev  (float v) { _virtmic.set_elev (v); }
set_angle(float v)63     void set_angle (float v) { _virtmic.set_angle (v); }
set_direc(float v)64     void set_direc (float v) { _virtmic.set_direc (v); }
set_xtalk(bool b)65     void set_xtalk (bool b)  { _virtmic.set_xtalk (b); }
set_mono(bool b)66     void set_mono  (bool b)  { _virtmic.set_mono (b); }
set_volum(float v)67     void set_volum (float v) { _voldb1 = v; }
68 
get_level(int i,float * rms,float * dpk)69     void get_level (int i, float *rms, float *dpk) { _kmdsp [i].read (rms, dpk); }
70 
71 private:
72 
73     enum { S_IDLE, S_PROC };
74 
thr_main(void)75     virtual void thr_main (void) {}
76 
77     void init_jack (void);
78     void init_proc (void);
79     void close_jack (void);
80     void jack_shutdown (void);
81     int  jack_process (jack_nframes_t nframes);
82     void monitor (unsigned int n, float *p [4]);
83     void measure (unsigned int n, float *p [4]);
84 
85     jack_client_t  *_jack_client;
86     jack_port_t    *_jack_ipports [8];
87     jack_port_t    *_jack_opports [10];
88     const char     *_jname;
89     unsigned int    _state;
90     unsigned int    _fsamp;
91     unsigned int    _fsize;
92     unsigned int    _psize;
93 
94     float           _vgain;
95     float           _voldb0;
96     float           _voldb1;
97     float           _dvoldb;
98     ABprocess       _abproc;
99     Virtmic         _virtmic;
100 
101     int             _meter;
102     int             _monit;
103     Kmeterdsp       _kmdsp [4];
104 
105     static void jack_static_shutdown (void *arg);
106     static int  jack_static_process (jack_nframes_t nframes, void *arg);
107     static const char *ipp_names [8];
108     static const char *opp_names [10];
109 };
110 
111 
112 #endif
113