Changeset 1274e9f


Ignore:
Timestamp:
Sep 25, 2009, 5:17:19 AM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
58779e3
Parents:
e4d0f8f
Message:

ext/jackio.{c,h}: update copyright and license, run though indent

Location:
ext
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ext/jackio.c

    re4d0f8f r1274e9f  
    11/*
    2    Copyright (C) 2003 Paul Brossier
    3 
    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.
    8 
    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.
    13 
    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.
     2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
     3
     4  This file is part of aubio.
     5
     6  aubio is free software: you can redistribute it and/or modify
     7  it under the terms of the GNU General Public License as published by
     8  the Free Software Foundation, either version 3 of the License, or
     9  (at your option) any later version.
     10
     11  aubio is distributed in the hope that it will be useful,
     12  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  GNU General Public License for more details.
     15
     16  You should have received a copy of the GNU General Public License
     17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
    1718
    1819*/
     
    3536 * jack device structure
    3637 */
    37 struct _aubio_jack_t {
     38struct _aubio_jack_t
     39{
    3840  /** jack client */
    3941  jack_client_t *client;
     
    4648  /** jack output buffer */
    4749  jack_sample_t **obufs;
    48 #ifdef AUBIO_JACK_NEEDS_CONVERSION 
     50#ifdef AUBIO_JACK_NEEDS_CONVERSION
    4951  /** converted jack input buffer */
    5052  smpl_t **sibufs;
     
    5961  uint_t samplerate;
    6062  /** jack processing function */
    61   aubio_process_func_t callback; 
     63  aubio_process_func_t callback;
    6264};
    6365
    6466/* static memory management */
    65 static aubio_jack_t * aubio_jack_alloc(uint_t ichan, uint_t ochan);
    66 static uint_t aubio_jack_free(aubio_jack_t * jack_setup);
     67static aubio_jack_t *aubio_jack_alloc (uint_t ichan, uint_t ochan);
     68static uint_t aubio_jack_free (aubio_jack_t * jack_setup);
    6769/* jack callback functions */
    68 static int aubio_jack_process(jack_nframes_t nframes, void *arg);
     70static int aubio_jack_process (jack_nframes_t nframes, void *arg);
    6971static void aubio_jack_shutdown (void *arg);
    7072
    71 aubio_jack_t * new_aubio_jack(uint_t ichan, uint_t ochan,
    72     aubio_process_func_t callback) {
    73   aubio_jack_t * jack_setup = aubio_jack_alloc (ichan, ochan);
     73aubio_jack_t *
     74new_aubio_jack (uint_t ichan, uint_t ochan, aubio_process_func_t callback)
     75{
     76  aubio_jack_t *jack_setup = aubio_jack_alloc (ichan, ochan);
    7477  uint_t i;
    75   char * client_name = "aubio";
     78  char *client_name = "aubio";
    7679  char name[64];
    7780  /* initial jack client setup */
    7881  if ((jack_setup->client = jack_client_new (client_name)) == 0) {
    7982    AUBIO_ERR ("jack server not running?\n");
    80     AUBIO_QUIT(AUBIO_FAIL);
     83    AUBIO_QUIT (AUBIO_FAIL);
    8184  }
    8285
    8386  /* set callbacks */
    84   jack_set_process_callback (jack_setup->client, aubio_jack_process, 
    85       (void*) jack_setup);
    86   jack_on_shutdown (jack_setup->client, aubio_jack_shutdown, 
    87       (void*) jack_setup);
     87  jack_set_process_callback (jack_setup->client, aubio_jack_process,
     88      (void *) jack_setup);
     89  jack_on_shutdown (jack_setup->client, aubio_jack_shutdown,
     90      (void *) jack_setup);
    8891
    8992  /* register jack output ports */
    90   for (i = 0; i < ochan; i++)
    91   {
    92     AUBIO_SPRINTF(name, "out_%d", i+1);
    93     AUBIO_MSG("%s\n", name);
    94     if ((jack_setup->oports[i] =
    95           jack_port_register (jack_setup->client, name,
    96             JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == 0)
    97     {
    98       AUBIO_ERR("failed registering output port \"%s\"!\n", name);
     93  for (i = 0; i < ochan; i++) {
     94    AUBIO_SPRINTF (name, "out_%d", i + 1);
     95    AUBIO_MSG ("%s\n", name);
     96    if ((jack_setup->oports[i] =
     97            jack_port_register (jack_setup->client, name,
     98                JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)) == 0) {
     99      AUBIO_ERR ("failed registering output port \"%s\"!\n", name);
    99100      jack_client_close (jack_setup->client);
    100       AUBIO_QUIT(AUBIO_FAIL);
     101      AUBIO_QUIT (AUBIO_FAIL);
    101102    }
    102103  }
    103104
    104105  /* register jack input ports */
    105   for (i = 0; i < ichan; i++)
    106   {
    107     AUBIO_SPRINTF(name, "in_%d", i+1);
    108     AUBIO_MSG("%s\n", name);
    109     if ((jack_setup->iports[i] =
    110           jack_port_register (jack_setup->client, name,
    111             JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)) == 0)
    112     {
    113       AUBIO_ERR("failed registering input port \"%s\"!\n", name);
     106  for (i = 0; i < ichan; i++) {
     107    AUBIO_SPRINTF (name, "in_%d", i + 1);
     108    AUBIO_MSG ("%s\n", name);
     109    if ((jack_setup->iports[i] =
     110            jack_port_register (jack_setup->client, name,
     111                JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)) == 0) {
     112      AUBIO_ERR ("failed registering input port \"%s\"!\n", name);
    114113      jack_client_close (jack_setup->client);
    115       AUBIO_QUIT(AUBIO_FAIL);
     114      AUBIO_QUIT (AUBIO_FAIL);
    116115    }
    117116  }
     
    122121}
    123122
    124 uint_t aubio_jack_activate(aubio_jack_t *jack_setup) {
     123uint_t
     124aubio_jack_activate (aubio_jack_t * jack_setup)
     125{
    125126  /* get sample rate */
    126127  jack_setup->samplerate = jack_get_sample_rate (jack_setup->client);
    127128  /* actual jack process activation */
    128   if (jack_activate (jack_setup->client))
    129   {
    130     AUBIO_ERR("jack client activation failed");
     129  if (jack_activate (jack_setup->client)) {
     130    AUBIO_ERR ("jack client activation failed");
    131131    return 1;
    132132  }
     
    134134}
    135135
    136 void aubio_jack_close(aubio_jack_t *jack_setup) {
     136void
     137aubio_jack_close (aubio_jack_t * jack_setup)
     138{
    137139  /* bug : should disconnect all ports first */
    138   jack_client_close(jack_setup->client);
    139   aubio_jack_free(jack_setup);
     140  jack_client_close (jack_setup->client);
     141  aubio_jack_free (jack_setup);
    140142}
    141143
    142144/* memory management */
    143 static aubio_jack_t * aubio_jack_alloc(uint_t ichan, uint_t ochan) {
    144   aubio_jack_t *jack_setup = AUBIO_NEW(aubio_jack_t);
     145static aubio_jack_t *
     146aubio_jack_alloc (uint_t ichan, uint_t ochan)
     147{
     148  aubio_jack_t *jack_setup = AUBIO_NEW (aubio_jack_t);
    145149  jack_setup->ichan = ichan;
    146150  jack_setup->ochan = ochan;
    147   jack_setup->oports = AUBIO_ARRAY(jack_port_t*, ichan);
    148   jack_setup->iports = AUBIO_ARRAY(jack_port_t*, ochan);
    149   jack_setup->ibufs  = AUBIO_ARRAY(jack_sample_t*, ichan);
    150   jack_setup->obufs  = AUBIO_ARRAY(jack_sample_t*, ochan);
    151 #ifdef AUBIO_JACK_NEEDS_CONVERSION 
    152   jack_setup->sibufs = AUBIO_ARRAY(smpl_t*, ichan);
     151  jack_setup->oports = AUBIO_ARRAY (jack_port_t *, ichan);
     152  jack_setup->iports = AUBIO_ARRAY (jack_port_t *, ochan);
     153  jack_setup->ibufs = AUBIO_ARRAY (jack_sample_t *, ichan);
     154  jack_setup->obufs = AUBIO_ARRAY (jack_sample_t *, ochan);
     155#ifdef AUBIO_JACK_NEEDS_CONVERSION
     156  jack_setup->sibufs = AUBIO_ARRAY (smpl_t *, ichan);
    153157  uint_t i;
    154158  for (i = 0; i < ichan; i++) {
    155     jack_setup->sibufs[i] = AUBIO_ARRAY(smpl_t, AUBIO_JACK_MAX_FRAMES);
    156   }
    157   jack_setup->sobufs = AUBIO_ARRAY(smpl_t*, ochan);
     159    jack_setup->sibufs[i] = AUBIO_ARRAY (smpl_t, AUBIO_JACK_MAX_FRAMES);
     160  }
     161  jack_setup->sobufs = AUBIO_ARRAY (smpl_t *, ochan);
    158162  for (i = 0; i < ochan; i++) {
    159     jack_setup->sobufs[i] = AUBIO_ARRAY(smpl_t, AUBIO_JACK_MAX_FRAMES);
     163    jack_setup->sobufs[i] = AUBIO_ARRAY (smpl_t, AUBIO_JACK_MAX_FRAMES);
    160164  }
    161165#endif
     
    163167}
    164168
    165 static uint_t aubio_jack_free(aubio_jack_t * jack_setup) {
    166   AUBIO_FREE(jack_setup->oports);
    167   AUBIO_FREE(jack_setup->iports);
    168   AUBIO_FREE(jack_setup->ibufs );
    169   AUBIO_FREE(jack_setup->obufs );
    170   AUBIO_FREE(jack_setup);
     169static uint_t
     170aubio_jack_free (aubio_jack_t * jack_setup)
     171{
     172  AUBIO_FREE (jack_setup->oports);
     173  AUBIO_FREE (jack_setup->iports);
     174  AUBIO_FREE (jack_setup->ibufs);
     175  AUBIO_FREE (jack_setup->obufs);
     176  AUBIO_FREE (jack_setup);
    171177  return AUBIO_OK;
    172178}
    173179
    174180/* jack callback functions */
    175 static void aubio_jack_shutdown (void *arg UNUSED){
    176   AUBIO_ERR("jack shutdown\n");
    177   AUBIO_QUIT(AUBIO_OK);
    178 }
    179 
    180 static int aubio_jack_process(jack_nframes_t nframes, void *arg) {
    181   aubio_jack_t* dev = (aubio_jack_t *)arg;
     181static void
     182aubio_jack_shutdown (void *arg UNUSED)
     183{
     184  AUBIO_ERR ("jack shutdown\n");
     185  AUBIO_QUIT (AUBIO_OK);
     186}
     187
     188static int
     189aubio_jack_process (jack_nframes_t nframes, void *arg)
     190{
     191  aubio_jack_t *dev = (aubio_jack_t *) arg;
    182192  uint_t i;
    183   for (i=0;i<dev->ichan;i++) {
     193  for (i = 0; i < dev->ichan; i++) {
    184194    /* get readable input */
    185     dev->ibufs[i] = 
    186       (jack_sample_t *) jack_port_get_buffer (dev->iports[i], nframes);
     195    dev->ibufs[i] =
     196        (jack_sample_t *) jack_port_get_buffer (dev->iports[i], nframes);
    187197    /* get writable output */
    188     dev->obufs[i] = 
    189       (jack_sample_t *) jack_port_get_buffer (dev->oports[i], nframes);
     198    dev->obufs[i] =
     199        (jack_sample_t *) jack_port_get_buffer (dev->oports[i], nframes);
    190200  }
    191201#ifndef AUBIO_JACK_NEEDS_CONVERSION
    192   dev->callback(dev->ibufs,dev->obufs,nframes);
     202  dev->callback (dev->ibufs, dev->obufs, nframes);
    193203#else
    194204  uint_t j;
    195   for (j = 0; j < MIN(nframes, AUBIO_JACK_MAX_FRAMES); j++) {
    196     for (i = 0; i < dev->ichan; i++) { 
    197       dev->sibufs[i][j] = (smpl_t)dev->ibufs[i][j];
    198     }
    199   }
    200   dev->callback(dev->sibufs, dev->sobufs, nframes);
    201   for (j = 0; j < MIN(nframes, AUBIO_JACK_MAX_FRAMES); j++) {
    202     for (i = 0; i < dev->ichan; i++) { 
    203       dev->obufs[i][j] = (jack_sample_t)dev->sobufs[i][j];
     205  for (j = 0; j < MIN (nframes, AUBIO_JACK_MAX_FRAMES); j++) {
     206    for (i = 0; i < dev->ichan; i++) {
     207      dev->sibufs[i][j] = (smpl_t) dev->ibufs[i][j];
     208    }
     209  }
     210  dev->callback (dev->sibufs, dev->sobufs, nframes);
     211  for (j = 0; j < MIN (nframes, AUBIO_JACK_MAX_FRAMES); j++) {
     212    for (i = 0; i < dev->ichan; i++) {
     213      dev->obufs[i][j] = (jack_sample_t) dev->sobufs[i][j];
    204214    }
    205215  }
  • ext/jackio.h

    re4d0f8f r1274e9f  
    11/*
    2    Copyright (C) 2003 Paul Brossier
     2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
    33
    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.
     4  This file is part of aubio.
    85
    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.
     6  aubio is free software: you can redistribute it and/or modify
     7  it under the terms of the GNU General Public License as published by
     8  the Free Software Foundation, either version 3 of the License, or
     9  (at your option) any later version.
    1310
    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.
     11  aubio is distributed in the hope that it will be useful,
     12  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  GNU General Public License for more details.
     15
     16  You should have received a copy of the GNU General Public License
     17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
    1718
    1819*/
     
    2930
    3031#ifdef __cplusplus
    31 extern "C" {
     32extern "C"
     33{
    3234#endif
    3335
     
    3537typedef struct _aubio_jack_t aubio_jack_t;
    3638/** jack process function */
    37 typedef int (*aubio_process_func_t)(smpl_t **input,
    38     smpl_t **output, int nframes);
     39typedef int (*aubio_process_func_t) (smpl_t ** input,
     40    smpl_t ** output, int nframes);
    3941
    4042/** jack device creation function */
    41 aubio_jack_t * new_aubio_jack (uint_t inchannels, uint_t outchannels,
     43aubio_jack_t *new_aubio_jack (uint_t inchannels, uint_t outchannels,
    4244    aubio_process_func_t callback);
    4345/** activate jack client (run jackprocess function) */
    44 uint_t aubio_jack_activate(aubio_jack_t *jack_setup);
     46uint_t aubio_jack_activate (aubio_jack_t * jack_setup);
    4547/** close and delete jack client */
    46 void aubio_jack_close(aubio_jack_t *jack_setup);
     48void aubio_jack_close (aubio_jack_t * jack_setup);
    4749
    4850#ifdef __cplusplus
     
    5052#endif
    5153
    52 #endif /* JACKIO_H */
     54#endif                          /* JACKIO_H */
Note: See TracChangeset for help on using the changeset viewer.