LiVES  1.6.4-svn
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
audio.h
Go to the documentation of this file.
1 // audio.h
2 // LiVES (lives-exe)
3 // (c) G. Finch 2005 - 2009
4 // Released under the GPL 3 or later
5 // see file ../COPYING for licensing details
6 
7 #ifndef HAS_LIVES_AUDIO_H
8 #define HAS_LIVES_AUDIO_H
9 
10 #define SAMPLE_MAX_16BIT_P 32767.0f
11 #define SAMPLE_MAX_16BIT_N 32768.0f
12 #define SAMPLE_MAX_16BITI 32768
13 
15 #define SWAP_U_TO_S 1
16 #define SWAP_S_TO_U 2
17 
18 
19 #define SWAP_X_TO_L 1
20 #define SWAP_L_TO_X 2
21 
22 
24 # define DEFAULT_AUDIO_RATE 44100
25 # define DEFAULT_AUDIO_CHANS 2
26 # define DEFAULT_AUDIO_SAMPS 16
27 # define DEFAULT_AUDIO_SIGNED8 (AFORM_UNSIGNED)
28 # define DEFAULT_AUDIO_SIGNED16 (!AFORM_UNSIGNED)
29 
31 #define LIVES_ACONNECT_TIMEOUT (10 * U_SEC)
32 
34 #define MAX_AUDIO_MEM 8*1024*1024
35 
37 #define RENDER_BLOCK_SIZE 1024
38 
40 #define SILENCE_BLOCK_SIZE 65536
41 
43 #define READ_BLOCK_SIZE 4096
44 
46 #define XSAMPLES 128000
47 
48 
51 
52 
53 #define ASERVER_CMD_PROCESSED 0
54 #define ASERVER_CMD_FILE_OPEN 1
55 #define ASERVER_CMD_FILE_CLOSE 2
56 #define ASERVER_CMD_FILE_SEEK 3
57 
58 /* message passing structure */
59 typedef struct _aserver_message_t {
60  volatile gint command;
61  volatile gchar *data;
62  volatile struct _aserver_message_t *next;
64 
65 
66 
67 typedef enum {
73 
74 
75 
76 
77 typedef struct {
78  lives_operation_t operation; // read, write, or convert [readonly by server]
79  volatile gboolean is_ready; // [readwrite all]
80  gboolean eof;
81  int fileno; // [readonly by server]
82 
83  // readonly by server:
84 
85  // use one or other
86  off_t seek;
87  weed_timecode_t start_tc;
88 
89  double arate;
90 
91  ssize_t bytesize; // file in/out length in bytes [write by server in case of eof]
92 
93  gboolean in_interleaf;
94  gboolean out_interleaf;
95 
96  int in_achans;
97  int out_achans;
98  int in_asamps; // set to -val for float
99  int out_asamps; // set to -val for float
102  double shrink_factor;
103 
104  size_t samp_space;
105 
106 
107  // in or out buffers
108  uint8_t **buffer8;
109  short **buffer16;
110  int32_t **buffer24;
111  int32_t **buffer32;
112  float **bufferf;
113 
114 
115  // ring buffer
116  size_t samples_filled;
117  size_t start_sample;
118 
119 
120  // private fields (used by server)
121  uint8_t *_filebuffer;
122  ssize_t _cbytesize;
123  size_t _csamp_space;
124  int _fd;
125  int _cfileno;
126  int _cseek;
127  int _cachans;
130  int _casamps;
131 
132  volatile gboolean die;
133 
135 
136 
138 
139 typedef enum lives_audio_loop {
144 
145 
146 
147 void sample_silence_dS (float *dst, uint64_t nsamples);
148 
149 void sample_move_d8_d16(short *dst, guchar *src,
150  uint64_t nsamples, size_t tbytes, float scale, int nDstChannels, int nSrcChannels, int swap_sign);
151 
152 void sample_move_d16_d16(short *dst, short *src,
153  uint64_t nsamples, size_t tbytes, float scale, int nDstChannels, int nSrcChannels, int swap_endian, int swap_sign);
154 
155 void sample_move_d16_d8(uint8_t *dst, short *src,
156  uint64_t nsamples, size_t tbytes, float scale, int nDstChannels, int nSrcChannels, int swap_sign);
157 
158 void sample_move_d16_float (float *dst, short *src, uint64_t nsamples, uint64_t src_skip, int is_unsigned, float vol);
159 
160 int64_t sample_move_float_int(void *holding_buff, float **float_buffer, int nsamps, float scale, int chans, int asamps, int usigned, gboolean swap_endian, gboolean float_interleaved, float vol);
161 
162 int64_t sample_move_abuf_float (float **obuf, int nchans, int nsamps, int out_arate, float vol);
163 
164 int64_t sample_move_abuf_int16 (short *obuf, int nchans, int nsamps, int out_arate);
165 
166 void sample_move_float_float (float *dst, float *src, uint64_t nsamples, uint64_t src_skip, float vol);
167 
168 boolean float_deinterleave(float *fbuffer, int nsamps, int nchans);
169 boolean float_interleave(float *fbuffer, int nsamps, int nchans);
170 
171 int64_t render_audio_segment(gint nfiles, gint *from_files, gint to_file, gdouble *avels, gdouble *fromtime, weed_timecode_t tc_start, weed_timecode_t tc_end, gdouble *chvol, gdouble opvol_start, gdouble opvol_end, lives_audio_buf_t *obuf);
172 
173 void aud_fade(gint fileno, gdouble startt, gdouble endt, gdouble startv, gdouble endv);
174 
175 typedef enum {
182 
183 #ifdef ENABLE_JACK
184 void jack_rec_audio_to_clip(gint fileno, gint oldfileno, lives_rec_audio_type_t rec_type);
185 void jack_rec_audio_end(void);
186 #endif
187 
188 #ifdef HAVE_PULSE_AUDIO
189 void pulse_rec_audio_to_clip(gint fileno, gint oldfileno, lives_rec_audio_type_t rec_type);
190 void pulse_rec_audio_end(void);
191 #endif
192 
193 void fill_abuffer_from(lives_audio_buf_t *abuf, weed_plant_t *event_list, weed_plant_t *st_event, gboolean exact);
194 
195 
196 gboolean resync_audio(gint frameno);
197 
198 
199 lives_audio_track_state_t *get_audio_and_effects_state_at(weed_plant_t *event_list, weed_plant_t *st_event, gboolean get_audstate, gboolean exact);
200 
201 gboolean get_audio_from_plugin(float *fbuffer, int nchans, int arate, int nsamps);
202 void reinit_audio_gen(void);
203 
204 void init_jack_audio_buffers (gint achans, gint arate, gboolean exact);
205 void free_jack_audio_buffers(void);
206 
207 void init_pulse_audio_buffers (gint achans, gint arate, gboolean exact);
208 void free_pulse_audio_buffers(void);
209 
210 void audio_free_fnames(void);
211 
213 void audio_cache_end (void);
215 
216 gboolean start_audio_stream(void);
217 void stop_audio_stream(void);
218 void clear_audio_stream(void);
219 void audio_stream(void *buff, size_t nbytes, int fd);
220 
221 #endif