Changeset bccac6b


Ignore:
Timestamp:
Sep 25, 2009, 6:56:58 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:
c3f4173
Parents:
52ecf09
Message:

ext/jackio.{c,h}: add support for jack midi

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    r52ecf09 rbccac6b  
    364364    debug("Jack init ...\n");
    365365    jack_setup = new_aubio_jack(channels, channels,
     366          1, 1,
    366367          (aubio_process_func_t)process_func);
    367368    if (usepitch) {
  • ext/jackio.c

    r52ecf09 rbccac6b  
    5454  smpl_t **sobufs;
    5555#endif
    56   /** jack input channels */
     56  /** jack input audio channels */
    5757  uint_t ichan;
    58   /** jack output channels */
     58  /** jack output audio channels */
    5959  uint_t ochan;
     60  /** jack input midi channels */
     61  uint_t imidichan;
     62  /** jack output midi channels */
     63  uint_t omidichan;
    6064  /** jack samplerate (Hz) */
    6165  uint_t samplerate;
     
    6569
    6670/* static memory management */
    67 static aubio_jack_t *aubio_jack_alloc (uint_t ichan, uint_t ochan);
     71static aubio_jack_t *aubio_jack_alloc (uint_t ichan, uint_t ochan,
     72    uint_t imidichan, uint_t omidichan);
    6873static uint_t aubio_jack_free (aubio_jack_t * jack_setup);
    6974/* jack callback functions */
     
    7277
    7378aubio_jack_t *
    74 new_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);
     79new_aubio_jack (uint_t ichan, uint_t ochan,
     80    uint_t imidichan, uint_t omidichan,
     81    aubio_process_func_t callback)
     82{
     83  aubio_jack_t *jack_setup = aubio_jack_alloc (ichan, ochan,
     84      imidichan, omidichan);
    7785  uint_t i;
    7886  char *client_name = "aubio";
     87  char *jack_port_type;
    7988  char name[64];
    8089  /* initial jack client setup */
     
    9099      (void *) jack_setup);
    91100
    92   /* register jack output ports */
    93   for (i = 0; i < ochan; i++) {
    94     AUBIO_SPRINTF (name, "out_%d", i + 1);
    95     AUBIO_MSG ("%s\n", name);
     101  /* register jack output audio and midi ports */
     102  for (i = 0; i < ochan + omidichan; i++) {
     103    if (i < ochan) {
     104      jack_port_type = JACK_DEFAULT_AUDIO_TYPE;
     105      AUBIO_SPRINTF (name, "out_%d", i + 1);
     106    } else {
     107      jack_port_type = JACK_DEFAULT_MIDI_TYPE;
     108      AUBIO_SPRINTF (name, "midi_out_%d", i - ochan + 1);
     109    }
    96110    if ((jack_setup->oports[i] =
    97111            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);
    100       jack_client_close (jack_setup->client);
    101       AUBIO_QUIT (AUBIO_FAIL);
    102     }
    103   }
    104 
    105   /* register jack input ports */
    106   for (i = 0; i < ichan; i++) {
    107     AUBIO_SPRINTF (name, "in_%d", i + 1);
    108     AUBIO_MSG ("%s\n", name);
     112                jack_port_type, JackPortIsOutput, 0)) == 0) {
     113      goto beach;
     114    }
     115    AUBIO_DBG ("%s:%s\n", client_name, name);
     116  }
     117
     118  /* register jack input audio ports */
     119  for (i = 0; i < ichan + imidichan; i++) {
     120    if (i < ichan) {
     121      jack_port_type = JACK_DEFAULT_AUDIO_TYPE;
     122      AUBIO_SPRINTF (name, "in_%d", i + 1);
     123    } else {
     124      jack_port_type = JACK_DEFAULT_MIDI_TYPE;
     125      AUBIO_SPRINTF (name, "midi_in_%d", i - ichan + 1);
     126    }
    109127    if ((jack_setup->iports[i] =
    110128            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);
    113       jack_client_close (jack_setup->client);
    114       AUBIO_QUIT (AUBIO_FAIL);
    115     }
     129                jack_port_type, JackPortIsInput, 0)) == 0) {
     130      goto beach;
     131    }
     132    AUBIO_DBG ("%s:%s\n", client_name, name);
    116133  }
    117134
     
    119136  jack_setup->callback = callback;
    120137  return jack_setup;
     138
     139beach:
     140  AUBIO_ERR ("failed registering port \"%s:%s\"!\n",
     141      client_name, name);
     142  jack_client_close (jack_setup->client);
     143  AUBIO_QUIT (AUBIO_FAIL);
    121144}
    122145
     
    144167/* memory management */
    145168static aubio_jack_t *
    146 aubio_jack_alloc (uint_t ichan, uint_t ochan)
     169aubio_jack_alloc (uint_t ichan, uint_t ochan,
     170    uint_t imidichan, uint_t omidichan)
    147171{
    148172  aubio_jack_t *jack_setup = AUBIO_NEW (aubio_jack_t);
    149173  jack_setup->ichan = ichan;
    150174  jack_setup->ochan = ochan;
    151   jack_setup->oports = AUBIO_ARRAY (jack_port_t *, ichan);
    152   jack_setup->iports = AUBIO_ARRAY (jack_port_t *, ochan);
     175  jack_setup->oports = AUBIO_ARRAY (jack_port_t *, ichan + imidichan);
     176  jack_setup->iports = AUBIO_ARRAY (jack_port_t *, ochan + omidichan);
    153177  jack_setup->ibufs = AUBIO_ARRAY (jack_sample_t *, ichan);
    154178  jack_setup->obufs = AUBIO_ARRAY (jack_sample_t *, ochan);
    155179#ifdef AUBIO_JACK_NEEDS_CONVERSION
     180  /* allocate arrays for data conversion */
    156181  jack_setup->sibufs = AUBIO_ARRAY (smpl_t *, ichan);
    157182  uint_t i;
  • ext/jackio.h

    r52ecf09 rbccac6b  
    4242/** jack device creation function */
    4343aubio_jack_t *new_aubio_jack (uint_t inchannels, uint_t outchannels,
     44    uint_t imidichan, uint_t omidichan,
    4445    aubio_process_func_t callback);
    4546/** activate jack client (run jackprocess function) */
Note: See TracChangeset for help on using the changeset viewer.