2
Copyright (C) 2003-2010 Fons Adriaensen <fons@kokkinizita.net>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
// --------------------------------------------------------------------------------
27
#include <jack/jack.h>
32
static jack_client_t *jack_handle;
33
static jack_port_t *jack_out1;
34
static jack_port_t *jack_out2;
36
static float b0, b1, b2, b3, b4, b5, b6;
37
static float gain = 1.0f;
40
static void process (int n, float *op1, float *op2)
46
x = gain * rngen.grandf ();
47
*op1++ = 0.07071f * x;
49
b0 = 0.99886f * b0 + 0.0555179f * x;
50
b1 = 0.99332f * b1 + 0.0750759f * x;
51
b2 = 0.96900f * b2 + 0.1538520f * x;
52
b3 = 0.86650f * b3 + 0.3104856f * x;
53
b4 = 0.55000f * b4 + 0.5329522f * x;
54
b5 = -0.7616f * b5 - 0.0168980f * x;
55
*op2++ = b0 + b1 + b2 + b3 + b4 + b5 + b6 + x * 0.5362f;
61
static void jack_shutdown (void *arg)
67
static int jack_callback (jack_nframes_t nframes, void *arg)
71
op1 = (float *)(jack_port_get_buffer (jack_out1, nframes));
72
op2 = (float *)(jack_port_get_buffer (jack_out2, nframes));
73
process (nframes, op1, op2);
78
int main (int ac, char *av [])
89
fprintf (stderr, "Level is too high, max = -10dB\n");
92
gain = powf (10.0f, 0.05f * (g + 20));
95
opts = JackNoStartServer;
96
if ((jack_handle = jack_client_open ("jnoise", opts, &stat)) == 0)
98
fprintf (stderr, "Can't connect to JACK\n");
102
jack_set_process_callback (jack_handle, jack_callback, 0);
103
jack_on_shutdown (jack_handle, jack_shutdown, 0);
104
jack_out1 = jack_port_register (jack_handle, "white", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
105
jack_out2 = jack_port_register (jack_handle, "pink", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
109
if (jack_activate (jack_handle))
111
fprintf(stderr, "Can't activate JACK");
115
while (1) usleep (200000);
120
// --------------------------------------------------------------------------------