1 /* 2 * DSP interface 3 * 4 * This file is part of GTick 5 * 6 * 7 * Copyright (c) 1999, Alex Roberts 8 * Copyright (c) 2003, 2004, 2005, 2006 Roland Stigge <stigge@antcom.de> 9 * 10 * GTick is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 3 of the License, or 13 * (at your option) any later version. 14 * 15 * GTick is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with GTick; if not, see <http://www.gnu.org/licenses/>. 22 * 23 */ 24 25 #ifndef DSP_H 26 #define DSP_H 27 28 /* GTK headers */ 29 #include <gtk/gtk.h> 30 31 #ifndef __DragonFly__ 32 #include <pulse/simple.h> 33 #endif 34 35 /* own headers */ 36 #include "threadtalk.h" 37 38 typedef struct dsp_t { 39 char* devicename; 40 char* soundname; 41 char* soundsystem; 42 43 #ifndef __DragonFly__ 44 pa_simple *pas; /* pa simple playback stream */ 45 #endif 46 47 int dspfd; /* file descriptor */ 48 int fragmentsize; /* fragment size */ 49 int fragstotal; /* number of fragments in DSP buffer */ 50 int channels; /* number of channels */ 51 int rate; /* number of frames per second in Hz */ 52 int samplesize; /* number of bits per item (usually 8 or 16) */ 53 int format; 54 55 int rate_in; /* rate of input data in Hz */ 56 int channels_in; /* number of channels of input data in Hz */ 57 58 unsigned char* fragment; 59 60 unsigned char* tickdata0; /* raw dsp sample bytes for single tick */ 61 int td0_size; /* length in bytes */ 62 unsigned char* tickdata1; /* raw dsp sample bytes for first tick */ 63 int td1_size; 64 unsigned char* tickdata2; /* dsp sample bytes for other ticks */ 65 int td2_size; 66 67 unsigned char* silence; /* size = channels * samplesize / 8 */ 68 69 short* frames; /* the original frames yet to be scaled by volume */ 70 int number_of_frames; 71 72 int meter; /* meter mode */ 73 double frequency; /* ticking frequency in Hz */ 74 int cyclepos; /* current number of tick (0, 1, 2 for 3/4) */ 75 int tickpos; /* number of frame in tick */ 76 int* accents; 77 78 int running; /* on/off flag */ 79 80 double volume; /* 0.0 ... 1.0 */ 81 82 int sync_flag; 83 84 comm_t* inter_thread_comm; 85 } dsp_t; 86 87 dsp_t* dsp_new(comm_t* comm); 88 void dsp_delete(dsp_t* dsp); 89 90 int dsp_open(dsp_t* dsp); 91 void dsp_close(dsp_t* dsp); 92 int dsp_init(dsp_t* dsp); 93 void dsp_deinit(dsp_t* dsp); 94 gboolean dsp_feed(dsp_t* dsp); 95 96 double dsp_get_volume(dsp_t* dsp); 97 void dsp_set_volume(dsp_t* dsp, double volume); 98 99 void dsp_main_loop(dsp_t* dsp); 100 101 #endif /* DSP_H */ 102