1 /* header file for jack-pv.c -- 2 * real-time phase vocoder with curses interface and JACK 3 * Copyright (C) 2007 Kengo Ichiki <kichiki@users.sourceforge.net> 4 * $Id: jack-pv.h,v 1.1 2007/10/29 02:49:09 kichiki Exp $ 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program 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 this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 #ifndef _JACK_PV_H_ 21 #define _JACK_PV_H_ 22 23 24 #include "pv-complex.h" // struct pv_complex 25 #include <jack/jack.h> // jack_client_t, jack_port_t 26 27 /* a simple state machine for this client */ 28 enum jack_state { 29 Init, 30 Run, 31 Exit 32 }; 33 34 struct pv_jack { 35 struct pv_complex *pv; 36 jack_client_t *client; 37 jack_port_t *out; 38 enum jack_state state; 39 }; 40 41 42 /* play one hop_in by the phase vocoder: 43 * phase vocoder by complex arithmetics with fixed hops. 44 * t_i - s_i = u_i - u_{i-1} = hop 45 * where s_i and t_i are the times for two analysis FFT 46 * and u_i is the time for the synthesis FFT at step i 47 * Reference: M.Puckette (1995) 48 * INPUT 49 * pv : struct pv_complex 50 * cur : current frame to play. 51 * you have to increment this by yourself. 52 * pv->flag_lock : 0 == no phase lock 53 * 1 == loose phase lock 54 * OUTPUT 55 * left[pv->hop_res], right[pv->hop_res] : 56 * returned value : hop_res (not hop_syn). 57 */ 58 int 59 jack_pv_complex_play_step (struct pv_complex *pv, 60 long cur, 61 double *left, double *right); 62 63 /** 64 * The process callback for this JACK application is called in a 65 * special realtime thread once for each audio cycle. 66 * 67 * This client follows a simple rule: when the JACK transport is 68 * running, copy the input port to the output. When it stops, exit. 69 */ 70 int 71 my_jack_process (jack_nframes_t nframes, void *arg); 72 73 /** 74 * JACK calls this shutdown_callback if the server ever shuts down or 75 * decides to disconnect the client. 76 */ 77 void 78 jack_shutdown (void *arg); 79 80 /** 81 * start jack process for output (playback) 82 * INPUT 83 * OUTPUT 84 * returned value : struct pv_jack *pv_jack. 85 */ 86 struct pv_jack * 87 pv_jack_init (struct pv_complex *pv); 88 89 void 90 pv_jack_free (struct pv_jack *pv_jack); 91 92 /** 93 * phase vocoder by complex arithmetics with fixed hops. 94 */ 95 void pv_complex_curses_jack (const char *file, 96 long len, long hop_syn); 97 98 99 #endif /* !_JACK_PV_ */ 100