Debian Codegraph @

myjack-dsp.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1
2 #ifndef __jack_dsp__
3 #define __jack_dsp__cxx . . $ `myjack-dsp.h:3:9`!
4
5 #include <cstdlib>
6 #include <stdio.h>
•7 #include <stdlib.h>
8 #include <jack/jack.h>
9 #include "faust/audio/audio.h"cxx . . $ `<file>/faudiostream/architecture/faust/audio/audio.h`/
10 #include "faust/audio/dsp.h"cxx . . $ `<file>/faudiostream/architecture/faust/audio/dsp.h`/
11
12 static int _sratecxx . . $ _srate(3a1320329ebf51c9).(jack_nframes_t nframes, void *);
13 static void _jack_shutdowncxx . . $ _jack_shutdown(5d22bdacc48458e8).(void *);
14 static int _processcxx . . $ _process(3a1320329ebf51c9). (jack_nframes_t nframes, void *client);
15 #ifdef _OPENMP
16 static void* _jackthread(void* arg);
17 #endif
18
19 /******************************************************************************
20 *******************************************************************************
21
22 JACK AUDIO INTERFACE
23
24 *******************************************************************************
25 *******************************************************************************/
26
27 class jackaudiocxx . . $ jackaudio# : public audiocxx . . $ audio# {
28 dspcxx . . $ dsp#* fDspcxx . . $ jackaudio#fDsp.;
29 jack_client_t* fClientcxx . . $ jackaudio#fClient.;
30 int fNumInChanscxx . . $ jackaudio#fNumInChans.; // number of input channels
31 int fNumOutChanscxx . . $ jackaudio#fNumOutChans.; // number of output channels
32 jack_port_t * fInput_portscxx . . $ jackaudio#fInput_ports.[256]; // Jack input ports
33 jack_port_t * fOutput_portscxx . . $ jackaudio#fOutput_ports.[256]; // Jack output ports
34 float* fInChannelcxx . . $ jackaudio#fInChannel.[256]; // tables of noninterleaved input channels for FAUST
35 float* fOutChannelcxx . . $ jackaudio#fOutChannel.[256]; // tables of noninterleaved output channels for FAUST
36
37 public:
38 jackaudiocxx . . $ jackaudio#jackaudio(49f6e7a06ebc5aa8).() : fClientcxx . . $ jackaudio#fClient.(0), fNumInChanscxx . . $ jackaudio#fNumInChans.(0), fNumOutChanscxx . . $ jackaudio#fNumOutChans.(0) {}
39 virtual ~cxx . . $ jackaudio#`~jackaudio`(ced63f7c635d850d).jackaudiocxx . . $ jackaudio#() { stopcxx . . $ jackaudio#stop(49f6e7a06ebc5aa8).(); }
40
41 virtual bool initcxx . . $ jackaudio#init(6d24b0d766d974e1).(const char*name, dspcxx . . $ dsp#* DSP) {
42 fDspcxx . . $ jackaudio#fDsp. = DSP;
43 if ((fClientcxx . . $ jackaudio#fClient. = jack_client_open(name, JackNullOption, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) == 0) {
44 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "jack server not running?\n");
45 return false;
46 }
47 #ifdef _OPENMP
48 jack_set_process_thread(fClient, _jackthread, this);
49 #else
50 jack_set_process_callback(fClientcxx . . $ jackaudio#fClient., _processcxx . . $ _process(3a1320329ebf51c9)., this);
51 #endif
52
53 jack_set_sample_rate_callback(fClientcxx . . $ jackaudio#fClient., _sratecxx . . $ _srate(3a1320329ebf51c9)., 0);
54 jack_on_shutdown(fClientcxx . . $ jackaudio#fClient., _jack_shutdowncxx . . $ _jack_shutdown(5d22bdacc48458e8)., 0);
55
56 fNumInChanscxx . . $ jackaudio#fNumInChans. = fDspcxx . . $ jackaudio#fDsp.->getNumInputscxx . . $ dsp#getNumInputs(b126dc7c1de90089).();
57 fNumOutChanscxx . . $ jackaudio#fNumOutChans. = fDspcxx . . $ jackaudio#fDsp.->getNumOutputscxx . . $ dsp#getNumOutputs(b126dc7c1de90089).();
58
59 for (int i = 0; i < fNumInChanscxx . . $ jackaudio#fNumInChans.; i++) {
60 char buf[256];
61 snprintf(buf, 256, "in_%d", i);
62 fInput_portscxx . . $ jackaudio#fInput_ports.[i] = jack_port_register(fClientcxx . . $ jackaudio#fClient., buf, JACK_DEFAULT_AUDIO_TYPEcxx . . $ `<external>/2838810560580927090/types.h:461:9`!, JackPortIsInput, 0);
63 }
64 for (int i = 0; i < fNumOutChanscxx . . $ jackaudio#fNumOutChans.; i++) {
65 char buf[256];
66 snprintf(buf, 256, "out_%d", i);
67 fOutput_portscxx . . $ jackaudio#fOutput_ports.[i] = jack_port_register(fClientcxx . . $ jackaudio#fClient., buf, JACK_DEFAULT_AUDIO_TYPEcxx . . $ `<external>/2838810560580927090/types.h:461:9`!, JackPortIsOutput, 0);
68 }
69 fDspcxx . . $ jackaudio#fDsp.->initcxx . . $ dsp#init(d4f767463ce0a6b3).(jack_get_sample_rate(fClientcxx . . $ jackaudio#fClient.));
70 return true;
71 }
72
73 virtual bool startcxx . . $ jackaudio#start(efaadfb7dc14930a).(bool autoconnect) {
74 if (jack_activate(fClientcxx . . $ jackaudio#fClient.)) {
75 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "cannot activate client");
76 return false;
77 }
78
79 if(autoconnect){
80 char** physicalInPorts = (char **)jack_get_ports(fClientcxx . . $ jackaudio#fClient., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, JackPortIsPhysical|JackPortIsInput);
81 char** physicalOutPorts = (char **)jack_get_ports(fClientcxx . . $ jackaudio#fClient., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, JackPortIsPhysical|JackPortIsOutput);
82 if (physicalOutPorts != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
83 for (int i = 0; i < fNumInChanscxx . . $ jackaudio#fNumInChans. && physicalOutPorts[i]; i++)
84 jack_connect(fClientcxx . . $ jackaudio#fClient., physicalOutPorts[i], jack_port_name(fInput_portscxx . . $ jackaudio#fInput_ports.[i]));
85 }
86 if (physicalInPorts != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
87 for (int i = 0; i < fNumOutChanscxx . . $ jackaudio#fNumOutChans. && physicalInPorts[i]; i++)
88 jack_connect(fClientcxx . . $ jackaudio#fClient., jack_port_name(fOutput_portscxx . . $ jackaudio#fOutput_ports.[i]), physicalInPorts[i]);
89 }
90 }
91
92 return true;
93 }
94
95 virtual bool startcxx . . $ jackaudio#start(c9857a73d68e59ba).(){
96 return startcxx . . $ jackaudio#start(efaadfb7dc14930a).(true);
97 }
98
99 virtual void stopcxx . . $ jackaudio#stop(49f6e7a06ebc5aa8).() {
100 if (fClientcxx . . $ jackaudio#fClient.) {
101 jack_deactivate(fClientcxx . . $ jackaudio#fClient.);
102 for (int i = 0; i < fNumInChanscxx . . $ jackaudio#fNumInChans.; i++)
103 jack_port_unregister(fClientcxx . . $ jackaudio#fClient., fInput_portscxx . . $ jackaudio#fInput_ports.[i]);
104 for (int i = 0; i < fNumOutChanscxx . . $ jackaudio#fNumOutChans.; i++)
105 jack_port_unregister(fClientcxx . . $ jackaudio#fClient., fOutput_portscxx . . $ jackaudio#fOutput_ports.[i]);
106 jack_client_close(fClientcxx . . $ jackaudio#fClient.);
107 fClientcxx . . $ jackaudio#fClient. = 0;
108 }
109 }
110
111 // jack callbacks
112 int processcxx . . $ jackaudio#process(4c679297bf94b9eb). (jack_nframes_t nframes) {
113 AVOIDDENORMALScxx . . $ `audio/faudiostream/architecture/faust/audio/dsp.h:43:17`!;
114 for (int i = 0; i < fNumInChanscxx . . $ jackaudio#fNumInChans.; i++)
115 fInChannelcxx . . $ jackaudio#fInChannel.[i] = (float *)jack_port_get_buffer(fInput_portscxx . . $ jackaudio#fInput_ports.[i], nframes);
116 for (int i = 0; i < fNumOutChanscxx . . $ jackaudio#fNumOutChans.; i++)
117 fOutChannelcxx . . $ jackaudio#fOutChannel.[i] = (float *)jack_port_get_buffer(fOutput_portscxx . . $ jackaudio#fOutput_ports.[i], nframes);
118 fDspcxx . . $ jackaudio#fDsp.->computecxx . . $ dsp#compute(4254ec6c518224ca).(nframes, fInChannelcxx . . $ jackaudio#fInChannel., fOutChannelcxx . . $ jackaudio#fOutChannel.);
119 return 0;
120 }
121
122 #ifdef _OPENMP
123 void process_thread () {
124 jack_nframes_t nframes;
125 while (1) {
126 nframes = jack_cycle_wait(fClient);
127 process (nframes);
128 jack_cycle_signal(fClient, 0);
129 }
130 }
131 #endif
132 };
133
134 //----------------------------------------------------------------------------
135 // Jack Callbacks
136 //----------------------------------------------------------------------------
137 static int _sratecxx . . $ _srate(3a1320329ebf51c9).(jack_nframes_t nframes, void *)
138 {
139 printf("the sample rate is now %u/sec\n", nframes);
140 return 0;
141 }
142
143 static void _jack_shutdowncxx . . $ _jack_shutdown(5d22bdacc48458e8).(void *)
144 {
145 exit(1);
146 }
147
148 static int _processcxx . . $ _process(3a1320329ebf51c9).(jack_nframes_t nframes, void *client)
149 {
150 jackaudiocxx . . $ jackaudio#* jackclient = (jackaudiocxx . . $ jackaudio#*)client;
151 return jackclient->processcxx . . $ jackaudio#process(4c679297bf94b9eb). (nframes);
152 }
153
154 #ifdef _OPENMP
155 static void* _jackthread(void* arg)
156 {
157 jackaudio* jackclient = (jackaudio*)arg;
158 jackclient->process_thread();
159 return 0;
160 }
161 #endif
162
163
164
165 #endif