7#ifndef HAS_LIVES_AUDIO_H
8#define HAS_LIVES_AUDIO_H
10#define SAMPLE_MAX_16BIT_P 32767.4999999f
11#define SAMPLE_MAX_16BIT_N 32768.0f
12#define SAMPLE_MAX_16BITI 32768
23# define DEFAULT_AUDIO_RATE 44100
24# define DEFAULT_AUDIO_CHANS 2
25# define DEFAULT_AUDIO_SAMPS 16
26# define DEFAULT_AUDIO_SIGNED8 (AFORM_UNSIGNED)
27# define DEFAULT_AUDIO_SIGNED16 (!AFORM_UNSIGNED)
36#define MAX_AUDIO_MEM 32 * 1024 * 1024
39#define RENDER_BLOCK_SIZE 1024
42#define SILENCE_BLOCK_SIZE BUFFER_FILL_BYTES_LARGE
47#define XSAMPLES 393216
49#define AUD_WRITE_CHECK 0xFFFFFFFFF4000000
51#define WEED_LEAF_HOST_KEEP_ADATA "keep_adata"
56#define ASERVER_CMD_PROCESSED 0
57#define ASERVER_CMD_FILE_OPEN 1
58#define ASERVER_CMD_FILE_CLOSE 2
59#define ASERVER_CMD_FILE_SEEK 3
62typedef struct _aserver_message_t {
66 volatile struct _aserver_message_t *
next;
145typedef enum lives_audio_loop {
154boolean normalise_audio(
int fnum,
double start,
double end,
float thresh);
160boolean pad_with_silence(
int out_fd,
void *buff, off64_t oins_size, int64_t ins_size,
int asamps,
int aunsigned,
164 uint64_t nsamples,
size_t tbytes,
double scale,
int nDstChannels,
int nSrcChannels,
int swap_sign)
GNU_HOT;
167 uint64_t nsamples,
size_t tbytes,
double scale,
int nDstChannels,
int nSrcChannels,
int swap_endian,
171 uint64_t nsamples,
size_t tbytes,
double scale,
int nDstChannels,
int nSrcChannels,
int swap_sign)
GNU_HOT;
173float sample_move_d16_float(
float *dst,
short *src, uint64_t nsamples, uint64_t src_skip,
int is_unsigned,
boolean rev_endian,
176int64_t
sample_move_float_int(
void *holding_buff,
float **float_buffer,
int nsamps,
double scale,
int chans,
int asamps,
178 boolean swap_endian,
boolean float_interleaved,
float vol)
GNU_HOT;
192void aud_fade(
int fileno,
double startt,
double endt,
double startv,
double endv);
205void jack_rec_audio_to_clip(
int fileno,
int oldfileno,
207void jack_rec_audio_end(
boolean close_dev,
boolean close_fd);
210#ifdef HAVE_PULSE_AUDIO
211void pulse_rec_audio_to_clip(
int fileno,
int oldfileno,
213void pulse_rec_audio_end(
boolean close_dev,
boolean close_fd);
223 weed_timecode_t fill_tc,
int what_to_get,
boolean exact);
225boolean get_audio_from_plugin(
float **fbuffer,
int nchans,
int arate,
int nsamps,
boolean is_audio_thread);
236#define is_realtime_aplayer(ptype) ((ptype == AUD_PLAYER_JACK || ptype == AUD_PLAYER_PULSE || ptype == AUD_PLAYER_NONE))
269#define lives_vol_from_linear(vol) ((float)squared(squared((vol))))
270#define lives_vol_to_linear(vol) (sqrtf(sqrtf((vol))))
void sample_move_d16_d8(uint8_t *dst, short *src, uint64_t nsamples, size_t tbytes, double scale, int nDstChannels, int nSrcChannels, int swap_sign) GNU_HOT
convert from any number of source channels to any number of destination channels - 8 bit output
int64_t sample_move_abuf_float(float **obuf, int nchans, int nsamps, int out_arate, float vol) GNU_HOT
copy audio data from cache into audio sound buffer
int64_t sample_move_float_int(void *holding_buff, float **float_buffer, int nsamps, double scale, int chans, int asamps, int usigned, boolean swap_endian, boolean float_interleaved, float vol) GNU_HOT
returns frames output
void audio_free_fnames(void)
float get_float_audio_val_at_time(int fnum, int afd, double secs, int chnum, int chans) GNU_HOT
void append_to_audio_bufferf(float *src, uint64_t nsamples, int channum)
boolean apply_rte_audio(int64_t nframes)
void init_audio_frame_buffers(short aplayer)
boolean get_audio_from_plugin(float **fbuffer, int nchans, int arate, int nsamps, boolean is_audio_thread)
char * get_audio_file_name(int fnum, boolean opening)
void append_to_audio_buffer16(void *src, uint64_t nsamples, int channum)
void wake_audio_thread(void)
float sample_move_d16_float(float *dst, short *src, uint64_t nsamples, uint64_t src_skip, int is_unsigned, boolean rev_endian, float vol) GNU_HOT
void audio_cache_end(void)
char * lives_get_audio_file_name(int fnum)
char * get_achannel_name(int totchans, int idx) WARN_UNUSED
boolean resync_audio(double frameno)
resync audio playback to the current video frame
float audiofile_get_maxvol(int fnum, double start, double end, float thresh)
boolean push_audio_to_channel(weed_plant_t *filter, weed_plant_t *achan, lives_audio_buf_t *abuf)
fill the audio channel(s) for effects with mixed audio / video
void sample_move_d16_d16(short *dst, short *src, uint64_t nsamples, size_t tbytes, double scale, int nDstChannels, int nSrcChannels, int swap_endian, int swap_sign) GNU_HOT
boolean float_deinterleave(float *fbuffer, int nsamps, int nchans) GNU_HOT
void fill_abuffer_from(lives_audio_buf_t *abuf, weed_plant_t *event_list, weed_plant_t *st_event, boolean exact)
void preview_aud_vol(void)
lives_cancel_t handle_audio_timeout(void)
boolean start_audio_stream(void)
void init_jack_audio_buffers(int achans, int arate, boolean exact)
int64_t render_audio_segment(int nfiles, int *from_files, int to_file, double *avels, double *fromtime, ticks_t tc_start, ticks_t tc_end, double *chvol, double opvol_start, double opvol_end, lives_audio_buf_t *obuf)
void aud_fade(int fileno, double startt, double endt, double startv, double endv)
fade in/fade out
const char * audio_player_get_display_name(const char *aplayer)
int64_t sample_move_abuf_int16(short *obuf, int nchans, int nsamps, int out_arate) GNU_HOT
copy audio data from cache into audio sound buffer
void reinit_audio_gen(void)
void sample_silence_stream(int nchans, int64_t nframes)
void stop_audio_stream(void)
void init_pulse_audio_buffers(int achans, int arate, boolean exact)
lives_audio_buf_t * audio_cache_get_buffer(void)
boolean float_interleave(float *fbuffer, int nsamps, int nchans) GNU_HOT
void free_audio_frame_buffer(lives_audio_buf_t *abuf)
lives_audio_buf_t * audio_cache_init(void)
void sample_move_float_float(float *dst, float *src, uint64_t nsamples, double scale, int dst_skip) GNU_HOT
void free_pulse_audio_buffers(void)
boolean adjust_clip_volume(int fileno, float newvol, boolean make_backup)
void clear_audio_stream(void)
@ LIVES_CONVERT_OPERATION
void sample_silence_dS(float *dst, uint64_t nsamples)
void free_jack_audio_buffers(void)
boolean normalise_audio(int fnum, double start, double end, float thresh)
boolean pad_with_silence(int out_fd, void *buff, off64_t oins_size, int64_t ins_size, int asamps, int aunsigned, boolean big_endian)
lives_audio_track_state_t * audio_frame_to_atstate(weed_plant_t *event, int *ntracks)
void sample_move_d8_d16(short *dst, uint8_t *src, uint64_t nsamples, size_t tbytes, double scale, int nDstChannels, int nSrcChannels, int swap_sign) GNU_HOT
void apply_rte_audio_end(boolean del)
void audio_stream(void *buff, size_t nbytes, int fd)
boolean apply_rte_audio_init(void)
lives_audio_track_state_t * get_audio_and_effects_state_at(weed_plant_t *event_list, weed_plant_t *st_event, weed_timecode_t fill_tc, int what_to_get, boolean exact)
get audio (and optionally video) state at timecode tc OR before event st_event
lives_cancel_t
cancel reason
volatile struct _aserver_message_t * next
double _shrink_factor
resampling ratio
int32_t ** buffer32
sample data in 32 bit format (or NULL)
int _casamps
current out_asamps
short ** buffer16
sample data in 16 bit format (or NULL)
lives_operation_t operation
float ** bufferf
sample data in float format (or NULL)
boolean eof
did we read EOF ? [readonly by client]
size_t _csamp_space
current sample buffer size in single channel samples
uint8_t ** buffer16_8
sample data in 8 bit format (or NULL)
volatile boolean is_ready
ssize_t _cbytesize
current _filebuffer bytesize; if this changes we need to realloc _filebuffer
int in_achans
channels for _filebuffer side
int32_t ** buffer24
sample data in 24 bit format (or NULL)
volatile size_t samples_filled
number of samples filled (readonly client)
int out_achans
channels for buffer* side
volatile boolean die
set to TRUE to shut down thread
int _cachans
current output channels
boolean sequential
hint that we will read sequentially starting from seek
size_t start_sample
used for reading (readonly server)
size_t samp_space
buffer space in samples (* by sizeof(type) to get bytesize) [if interleaf, also * by chans]
int _cseek
current seek pos
uint8_t * _filebuffer
raw data to/from file - can be cast to int16_t
uint8_t ** buffer8
sample data in 8 bit format (or NULL)
double shrink_factor
resampling ratio
int _cfileno
current fileno