1 // ----------------------------------------------------------------------------
2 //
3 //  Copyright (C) 2010-2017 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 3 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 <jack/jack.h>
26 #include <clthreads.h>
27 #include "retuner.h"
28 
29 
30 class Jclient : public A_thread
31 {
32 public:
33 
34     Jclient (const char *jname, const char *jserv);
35     ~Jclient (void);
36 
jname(void)37     const char *jname (void) { return _jname; }
fsize(void)38     unsigned int fsize (void) const { return _fsize; }
fsamp(void)39     unsigned int fsamp (void) const { return _fsamp; }
retuner(void)40     Retuner *retuner (void) { return _retuner; }
set_notemask(int m)41     void set_notemask (int m) { _notemask = m; }
set_midichan(int c)42     void set_midichan (int c) { _midichan = c; }
43     void clr_midimask (void);
get_noteset(void)44     int  get_noteset (void) { return _retuner->get_noteset (); }
get_midiset(void)45     int  get_midiset (void) { return _midimask; }
46 
47 private:
48 
thr_main(void)49     virtual void thr_main (void) {}
50 
51     void init_jack (const char *jname, const char *jserv);
52     void close_jack (void);
53     void jack_shutdown (void);
54     int  jack_process (int nframes);
55     void midi_process (int nframes);
56 
57     jack_client_t  *_jack_client;
58     jack_port_t    *_ainp_port;
59     jack_port_t    *_aout_port;
60     jack_port_t    *_midi_port;
61     bool            _active;
62     const char     *_jname;
63     unsigned int    _fsamp;
64     unsigned int    _fsize;
65     Retuner        *_retuner;
66     int             _notes [12];
67     int             _notemask;
68     int             _midimask;
69     int             _midichan;
70 
71     static void jack_static_shutdown (void *arg);
72     static int  jack_static_process (jack_nframes_t nframes, void *arg);
73 };
74 
75 
76 #endif
77