comparison src/jack/bio2jack.h @ 12:3da1b8942b8b trunk

[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author nenolod
date Mon, 18 Sep 2006 03:14:20 -0700
parents src/Output/jack/bio2jack.h@13389e613d67
children
comparison
equal deleted inserted replaced
11:cff1d04026ae 12:3da1b8942b8b
1 /*
2 * Copyright 2003-2004 Chris Morgan <cmorgan@alum.wpi.edu>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef _H_JACK_OUT_H
20 #define _H_JACK_OUT_H
21
22 #include <jack/jack.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #else
27 #define bool long
28 #endif
29
30 #ifndef TRUE
31 #define TRUE 1
32 #endif
33
34 #ifndef FALSE
35 #define FALSE 0
36 #endif
37
38 #define ERR_SUCCESS 0
39 #define ERR_OPENING_JACK 1
40 #define ERR_RATE_MISMATCH 2
41 #define ERR_BYTES_PER_OUTPUT_FRAME_INVALID 3
42 #define ERR_BYTES_PER_INPUT_FRAME_INVALID 4
43 #define ERR_TOO_MANY_OUTPUT_CHANNELS 5
44 #define ERR_PORT_NAME_OUTPUT_CHANNEL_MISMATCH 6
45 #define ERR_PORT_NOT_FOUND 7
46 #define ERR_TOO_MANY_INPUT_CHANNELS 8
47 #define ERR_PORT_NAME_INPUT_CHANNEL_MISMATCH 9
48
49 enum status_enum { PLAYING, PAUSED, STOPPED, CLOSED, RESET };
50 enum pos_enum { BYTES, MILLISECONDS };
51
52 #define PLAYED 1 /* played out of the speakers(estimated value but should be close */
53 #define WRITTEN_TO_JACK 2 /* amount written out to jack */
54 #define WRITTEN 3 /* amount written to the bio2jack device */
55
56 /**********************/
57 /* External functions */
58 void JACK_Init(void); /* call this before any other bio2jack calls */
59 void JACK_DoSampleRateConversion(bool value); /* whether the next device that's Open()d should do
60 sample rate conversion if necessary */
61 void JACK_SetSampleRateConversionFunction(int converter); /* which SRC converter function should be used
62 for the next Open()d device */
63 int JACK_Open(int *deviceID, unsigned int bits_per_sample, unsigned long *rate, int channels); /* Note: defaults to 0 input channels
64 if you need input (record) use OpenEx
65 instead */
66 int JACK_OpenEx(int *deviceID, unsigned int bits_per_channel,
67 unsigned long *rate,
68 unsigned int input_channels, unsigned int output_channels,
69 const char **jack_port_name, unsigned int jack_port_name_count,
70 unsigned long jack_port_flags);
71 int JACK_Close(int deviceID); /* return 0 for success */
72 void JACK_Reset(int deviceID); /* free all buffered data and reset several values in the device */
73 long JACK_Write(int deviceID, unsigned char *data, unsigned long bytes); /* returns the number of bytes written */
74 long JACK_Read(int deviceID, unsigned char *data, unsigned long bytes); /* returns the number of bytes read */
75
76 /* state setting values */
77 /* set/get the written/played/buffered value based on a byte or millisecond input value */
78 long JACK_GetPosition(int deviceID, enum pos_enum position, int type);
79 void JACK_SetPosition(int deviceID, enum pos_enum position, long value);
80
81 long JACK_GetJackLatency(int deviceID); /* deprectated, you probably want JACK_GetJackOutputLatency */
82 long JACK_GetJackOutputLatency(int deviceID); /* return the output latency in frames */
83 long JACK_GetJackInputLatency(int deviceID); /* return the input latency in frames */
84
85 int JACK_SetState(int deviceID, enum status_enum state); /* playing, paused, stopped */
86 enum status_enum JACK_GetState(int deviceID);
87
88 long JACK_GetMaxOutputBufferedBytes(int deviceID);
89 long JACK_GetMaxInputBufferedBytes(int deviceID);
90
91 /* bytes that jack requests during each callback */
92 unsigned long JACK_GetJackBufferedBytes(int deviceID);
93
94 /* Properties of the jack driver */
95
96 /* linear means 0 volume is silence, 100 is full volume */
97 /* dbAttenuation means 0 volume is 0dB attenuation */
98 /* Bio2jack defaults to linear */
99 /* Note: volume controls only effect output channels for now */
100 enum JACK_VOLUME_TYPE { linear, dbAttenuation };
101 enum JACK_VOLUME_TYPE JACK_SetVolumeEffectType(int deviceID,
102 enum JACK_VOLUME_TYPE type);
103
104 int JACK_SetAllVolume(int deviceID, unsigned int volume); /* returns 0 on success */
105 int JACK_SetVolumeForChannel(int deviceID, unsigned int channel, unsigned int volume);
106 void JACK_GetVolumeForChannel(int deviceID, unsigned int channel, unsigned int *volume);
107
108
109 unsigned long JACK_GetOutputBytesPerSecond(int deviceID); /* bytes_per_output_frame * sample_rate */
110 unsigned long JACK_GetInputBytesPerSecond(int deviceID); /* bytes_per_input_frame * sample_rate */
111 unsigned long JACK_GetBytesStored(int deviceID); /* bytes currently buffered in the output buffer */
112 unsigned long JACK_GetBytesFreeSpace(int deviceID); /* bytes of free space in the output buffer */
113 unsigned long JACK_GetBytesUsedSpace(int deviceID); /* bytes of space used in the input buffer */
114 unsigned long JACK_GetBytesPerOutputFrame(int deviceID);
115 unsigned long JACK_GetBytesPerInputFrame(int deviceID);
116
117 /* Note: these will probably be removed in a future release */
118 int JACK_GetNumInputChannels(int deviceID);
119 int JACK_GetNumOutputChannels(int deviceID);
120
121 long JACK_GetSampleRate(int deviceID); /* samples per second */
122
123 void JACK_SetClientName(char *name); /* sets the name that bio2jack will use when
124 creating a new jack client. name_%pid%_%deviceID%%counter%
125 will be used
126 NOTE: this defaults to name = bio2jack
127 NOTE: we limit the size of the client name to
128 jack_client_name_size() */
129
130 enum JACK_PORT_CONNECTION_MODE
131 {
132 CONNECT_ALL, /* connect to all avaliable ports */
133 CONNECT_OUTPUT, /* connect only to the ports we need for output */
134 CONNECT_NONE /* don't connect to any ports */
135 };
136
137 /* set the mode for port connections */
138 /* defaults to CONNECT_ALL */
139 void JACK_SetPortConnectionMode(enum JACK_PORT_CONNECTION_MODE mode);
140
141 #ifdef __cplusplus
142 }
143 #endif
144
145 #endif /* #ifndef JACK_OUT_H */