16static boolean storedfdsset =
FALSE;
19static void audio_reset_stored_fnames(
void) {
21 storedfnames[i] = NULL;
29 if (totchans == 1)
return (
_(
"Mono"));
31 if (idx == 0)
return (
_(
"Left channel"));
32 if (idx == 1)
return (
_(
"Right channel"));
57 if (
mainw->
files[fnum]->
opening && !lives_file_test(fname, LIVES_FILE_TEST_EXISTS)) {
73 if (!storedfdsset)
return;
106 for (i = abuf->
out_achans; i < channum; i++) {
140 for (i = abuf->
out_achans; i < channum; i++) {
149 g_print(
"append16 to afb\n");
159 for (i = 0; i < 2; i++) {
169#ifdef HAVE_PULSE_AUDIO
202 g_print(
"init afb\n");
243 g_print(
"clear afb %p\n", abuf);
251 double atime = start;
259 while (atime <= end) {
260 for (c = 0; c < afile->
achans; c++) {
266 if (xf > xx) xx = xf;
267 if (thresh >= 0. && xx > thresh) {
272 atime += 1. / afile->
arps;
284 if (xx <= 0.)
return FALSE;
287 double atime = start;
288 float fact = thresh / xx, val;
291 boolean swap_endian =
FALSE;
321 while (atime <= end) {
323 if (count == afile->
arps) count = 0;
325 for (c = 0; c < afile->
achans; c++) {
331 val = xx * 127.4999 + 127.4999;
332 ucval = (uint8_t)(127.4999 * xx) + 127.4999;
337 scval = (char)(255.499 * xx - 128.);
344 usval = (val > 65535 ? 65535 : val < 0 ? 0 : val);
345 if (swap_endian)
swab2(&usval, &usval, 1);
351 if (swap_endian)
swab2(&ssval, &ssval, 1);
361 atime += 1. / afile->
arps;
383 size_t bytes = (size_t)(secs * (
double)afile->
arate) * quant;
385 if (!bytes)
return 0.;
387 apos = ((size_t)(bytes / quant) * quant);
396 else val = val8 - 127;
397 if (val > 0.) val /= 127.;
403 else val16 = (uint16_t)(val8b << 8) + val8;
405 else val = val16 - 32767;
406 if (val > 0.) val /= 32767.;
422 float **fbuff = (
float **)
lives_calloc(nchans,
sizeof(
float *));
423 boolean memok =
TRUE;
426 for (i = 0; i < nchans; i++) {
427 fbuff[i] = (
float *)
lives_calloc(nframes,
sizeof(
float));
428 if (!fbuff[i]) memok =
FALSE;
437 for (i = 0; i < nchans; i++) {
460 uint64_t nsamples,
size_t tbytes,
double scale,
461 int nDstChannels,
int nSrcChannels,
int swap_sign) {
465 static double rem = 0.f;
466 double src_offset_d = rem;
468 unsigned char *src_end;
469 off_t src_offset_i = 0;
471 int nSrcCount, nDstCount;
474 src_end = src + tbytes - nSrcChannels;
476 if (!nSrcChannels)
return;
479 src_offset_d = ((double)nsamples * (-scale) - 1.f - rem);
480 src_offset_i = (off_t)src_offset_d * nSrcChannels;
484 nSrcCount = nSrcChannels;
485 nDstCount = nDstChannels;
493 ptr = src + ccount + src_offset_i;
494 ptr = ptr > src ? (ptr < (src_end + ccount) ? ptr : (src_end + ccount)) : src;
496 if (!swap_sign) *(dst++) = *(ptr) << 8;
497 else if (swap_sign ==
SWAP_U_TO_S) *(dst++) = ((
short)(*(ptr)) - 128) << 8;
498 else *((
unsigned short *)(dst++)) = ((
short)(*(ptr)) + 128) << 8;
503 if (!nSrcCount && nDstCount) {
505 nSrcCount = nSrcChannels;
510 src_offset_i = (off_t)((src_offset_d += scale) + .4999) * nSrcChannels;
514 if (src_offset_d > src_offset_i) rem = src_offset_d - (double)src_offset_i;
516 if (src_offset_d < src_offset_i) rem = (double)src_offset_i - src_offset_d;
525 uint64_t nsamples,
size_t tbytes,
double scale,
int nDstChannels,
526 int nSrcChannels,
int swap_endian,
int swap_sign) {
528 static double rem = 0.f;
529 double src_offset_d = rem;
532 int nSrcCount, nDstCount;
533 off_t src_offset_i = 0;
536 if (!nSrcChannels)
return;
539 src_offset_d = ((double)nsamples * (-scale) - 1.f - rem);
540 src_offset_i = (off_t)src_offset_d * nSrcChannels;
544 src_end = src + tbytes / 2 - nSrcChannels;
546 if ((off_t)((fabs(scale) * (double)nsamples) + rem) * nSrcChannels * 2 > tbytes)
547 scale = scale > 0. ? ((double)(tbytes / nSrcChannels / 2) - rem) / (
double)nsamples
548 : -(((double)(tbytes / nSrcChannels / 2) - rem) / (
double)nsamples);
551 if ((nSrcCount = nSrcChannels) == (nDstCount = nDstChannels) && !swap_endian && !swap_sign) {
555 lives_memcpy((
void *)dst, (
void *)src, nsamples * 2 * nSrcChannels);
559 ptr = src + src_offset_i;
560 ptr = ptr > src ? (ptr < src_end ? ptr : src_end) : src;
571 ptr = src + ccount + src_offset_i;
572 ptr = ptr > src ? (ptr < (src_end + ccount) ? ptr : (src_end + ccount)) : src;
576 if (!swap_sign) *(dst++) = *ptr;
580 if (!swap_sign) *(dst++) = (((*ptr) & 0x00FF) << 8) + ((*ptr) >> 8);
581 else if (swap_sign ==
SWAP_S_TO_U) *((uint16_t *)dst++) = (uint16_t)(((*ptr & 0x00FF) << 8) + (*ptr >> 8)
585 if (!swap_sign) *(dst++) = (((*ptr) & 0x00FF) << 8) + ((*ptr) >> 8);
586 else if (swap_sign ==
SWAP_S_TO_U) *((uint16_t *)dst++) =
596 if (!nSrcCount && nDstCount) {
598 nSrcCount = nSrcChannels;
603 src_offset_i = (off_t)((src_offset_d += scale) + .4999) * nSrcChannels;
607 if (src_offset_d > src_offset_i) rem = src_offset_d - (double)src_offset_i;
609 if (src_offset_d < src_offset_i) rem = (double)src_offset_i - src_offset_d;
618 uint64_t nsamples,
size_t tbytes,
double scale,
int nDstChannels,
int nSrcChannels,
int swap_sign) {
621 double src_offset_d = rem;
624 off_t src_offset_i = 0;
626 int nSrcCount, nDstCount;
628 if (!nSrcChannels)
return;
631 src_offset_d = ((double)nsamples * (-scale) - 1.f - rem);
632 src_offset_i = (off_t)src_offset_d * nSrcChannels;
635 src_end = src + tbytes /
sizeof(short) - nSrcChannels;
638 nSrcCount = nSrcChannels;
639 nDstCount = nDstChannels;
648 ptr = src + ccount + src_offset_i;
649 ptr = ptr > src ? (ptr < (src_end + ccount) ? ptr : src_end + ccount) : src;
652 if (!swap_sign) *(dst++) = (*ptr >> 8);
653 else if (swap_sign ==
SWAP_S_TO_U) *(dst++) = (uint8_t)((int8_t)(*ptr >> 8) + 128);
654 else *((int8_t *)dst++) = (int8_t)((uint8_t)(*ptr >> 8) - 128);
659 if (!nSrcCount && nDstCount) {
661 nSrcCount = nSrcChannels;
666 src_offset_i = (off_t)((src_offset_d += scale) + .4999) * nSrcChannels;
670 if (src_offset_d > src_offset_i) rem = src_offset_d - (double)src_offset_i;
672 if (src_offset_d < src_offset_i) rem = (double)src_offset_i - src_offset_d;
677float sample_move_d16_float(
float *dst,
short *src, uint64_t nsamples, uint64_t src_skip,
int is_unsigned,
boolean rev_endian,
700 if (vol == 0.) vol = 0.0000001f;
713 srcxs = ((srcx[1] & 0xFF) << 8) + (srcx[0] & 0xFF);
719 oil_scaleconv_f32_s16(&val, srcp, 1, &y, val > 0 ? &xp : &xn);
721 if ((val = (
float)((
float)(*srcp) / (*srcp > 0 ? svolp : svoln))) > 1.0f) val = 1.0f;
722 else if (val < -1.0f) val = -1.0f;
726 oil_scaleconv_f32_u16(&val, (
unsigned short *)srcp, 1, &y, &xa);
730 if ((val = (
float)((
float)(valss) / (valss > 0 ? svolp : svoln))) > 1.0f) val = 1.0f;
731 else if (val < -1.0f) val = -1.0f;
735 if (val > maxval) maxval = val;
736 else if (-val > maxval) maxval = -val;
747 static double rem = 0.f;
753 offs_d = ((double)nsamples * (-scale) - 1.f - rem);
754 offs = (off_t)offs_d;
757 if (scale == 1.f && dst_skip == 1) {
758 lives_memcpy((
void *)dst, (
void *)src, nsamples *
sizeof(
float));
762 for (i = 0; i < nsamples; i++) {
765 offs = (off_t)((offs_d += scale) + .4999);
769 if (offs_d > offs) rem = offs_d - (double)offs;
771 if (offs_d < offs) rem = (double)offs - offs_d;
776#define CLIP_DECAY ((double)16535. / (double)16536.)
793int64_t
sample_move_float_int(
void *holding_buff,
float **float_buffer,
int nsamps,
double scale,
int chans,
int asamps,
794 int usigned,
boolean rev_endian,
boolean interleaved,
float vol) {
795 int64_t frames_out = 0l;
797 off_t offs = 0, coffs = 0, lcoffs = -1;
799 static double coffs_d = 0.f;
802 short *hbuffs = (
short *)holding_buff;
803 unsigned short *hbuffu = (
unsigned short *)holding_buff;
804 unsigned char *hbuffc = (
unsigned char *)holding_buff;
806 unsigned short valu[chans];
807 static float clip = 1.0;
808 float ovalf[chans], valf[chans], fval;
809 float volx = vol, ovolx = -1.;
810 boolean checklim =
FALSE;
814 if (clip > 1.0) checklim =
TRUE;
816 while ((nsamps - frames_out) > 0) {
829 for (i = 0; i < chans; i++) {
830 if (coffs != lcoffs) {
831 if ((fval = fabsf((ovalf[i] = *(float_buffer[i] + (interleaved ? (coffs * chans) : coffs))))) > clip) {
839 if (volx != ovolx || coffs != lcoffs) {
840 valf[i] = ovalf[i] * volx;
841 if (valf[i] > vol) valf[i] = vol;
842 else if (valf[i] < -vol) valf[i] = -vol;
850 if (usigned) *(hbuffu + offs) = valu[i];
851 else *(hbuffs + offs) = val[i];
854 *(hbuffc + offs) = valu[i] & 0x00FF;
855 *(hbuffc + (++offs)) = (valu[i] & 0xFF00) >> 8;
857 *(hbuffc + offs) = val[i] & 0x00FF;
858 *(hbuffc + (++offs)) = (val[i] & 0xFF00) >> 8;
862 *(hbuffc + offs) = (
unsigned char)(valu[i] >> 8);
867 coffs = (off_t)((coffs_d += scale) + .4999);
869 coffs_d -= (double)coffs;
871 if (frames_out != nsamps) {
872 char *msg =
lives_strdup_printf(
"audio float -> int: buffer mismatch of %ld samples\n", frames_out - nsamps);
897 off_t offs = 0, ioffs, xchan;
899 double src_offset_d = 0.f;
900 off_t src_offset_i = 0;
914 in_arate = abuf->
arate;
916 scale = (double)in_arate / (
double)out_arate;
932 for (i = 0; i < nsamps; i++) {
940 for (j = 0; j < nchans; j++) {
948 obuf[j][offs + i] = abuf->
bufferf[xchan][curval] * vol;
953 src_offset_i = (off_t)((src_offset_d += scale) + .4999);
996#ifdef HAVE_PULSE_AUDIO
1001 int in_arate, nsampsx;
1002 ssize_t offs = 0, ioffs, xchan;
1004 double src_offset_d = 0.f;
1005 ssize_t src_offset_i = 0;
1019 in_arate = abuf->
arate;
1021 scale = (double)in_arate / (
double)out_arate;
1023 while (nsamps > 0) {
1036 nsampsx = nsamps * nchans;
1038 for (i = 0; i < nsampsx; i += nchans) {
1047 for (j = 0; j < nchans; j++) {
1054 obuf[(offs++)] = abuf->
buffer16[0][curval + xchan];
1058 src_offset_i = (ssize_t)((src_offset_d += scale) + .4999);
1064 samples_out += samps;
1095static size_t chunk_to_float_abuf(
lives_audio_buf_t *abuf,
float **float_buffer,
int nsamps) {
1100 for (i = 0; i < chans; i++) {
1103 return (
size_t)nsamps;
1112 if (!tmpfbuffer)
return FALSE;
1114 for (i = 0; i < nsamps; i++) {
1115 for (j = 0; j < nchans; j++) {
1116 tmpfbuffer[nsamps * j + i] = fbuffer[i * nchans + j];
1119 lives_memcpy(fbuffer, tmpfbuffer, nsamps * nchans *
sizeof(
float));
1130 if (!tmpfbuffer)
return FALSE;
1132 for (i = 0; i < nsamps; i++) {
1133 for (j = 0; j < nchans; j++) {
1134 tmpfbuffer[i * nchans + j] = fbuffer[j * nsamps + i];
1137 lives_memcpy(fbuffer, tmpfbuffer, nsamps * nchans *
sizeof(
float));
1145static size_t chunk_to_int16_abuf(
lives_audio_buf_t *abuf,
float **float_buffer,
int nsamps) {
1153 return (
size_t)frames_out;
1159boolean pad_with_silence(
int out_fd,
void *buff, off64_t oins_size, int64_t ins_size,
int asamps,
int aunsigned,
1160 boolean big_endian) {
1167 static uint64_t *zero_buff = NULL;
1168 static int oasamps = 0;
1169 static int ounsigned = 0;
1170 static int orevendian = 0;
1175 boolean retval =
TRUE;
1176 boolean revendian =
FALSE;
1180 if (ins_size <= oins_size) {
1182 g_print(
"sbytes is l.t zero\n");
1186 sbytes = ins_size - oins_size;
1189 g_print(
"sbytes is %ld\n", sbytes);
1196 if (!buff)
return FALSE;
1200 if (ounsigned != aunsigned || oasamps != asamps || orevendian != revendian) {
1210 uint64_t theval = (revendian ? 0x0080008000800080ul : 0x8000800080008000ul);
1211 for (i = 0; i < sblocksize; i ++) {
1212 zero_buff[i] = theval;
1217 ounsigned = aunsigned;
1219 orevendian = revendian;
1225 if (
THREADVAR(write_failed) == out_fd + 1) {
1234 }
else if (out_fd >= 0) {
1277 weed_timecode_t tc_start, weed_timecode_t tc_end,
double *chvol,
double opvol_start,
1284 weed_plant_t *shortcut = NULL;
1287 void *finish_buff = NULL;
1289 short *holding_buff;
1291 char *infilename, *outfilename;
1292 off64_t seekstart[nfiles];
1296 int in_asamps[nfiles];
1297 int in_achans[nfiles];
1298 int in_arate[nfiles];
1299 int in_arps[nfiles];
1300 int in_unsigned[nfiles];
1302 boolean in_reverse_endian[nfiles];
1303 boolean is_silent[nfiles];
1305 size_t max_aud_mem, bytes_to_read, aud_buffer;
1312 weed_timecode_t tc = tc_start;
1316 double opvol = opvol_start;
1317 double zavel, zzavel, zavel_max = 0.;
1319 boolean out_reverse_endian =
FALSE;
1320 boolean is_fade =
FALSE;
1321 boolean use_live_chvols =
FALSE;
1325 int out_arate = to_file > -1 ? outfile->
arate : obuf->
arate;
1331 int first_nonsilent = -1;
1339 int64_t frames_out = 0;
1340 int64_t ins_size = 0l, cur_size;
1341 int64_t tsamples = ((double)(tc_end - tc_start) /
TICKS_PER_SECOND_DBL * (double)out_arate + .5);
1342 int64_t blocksize, zsamples, xsamples;
1343 int64_t tot_frames = 0l;
1345 float *float_buffer[out_achans * nfiles];
1346 float *chunk_float_buffer[out_achans * nfiles];
1349 if (out_achans * nfiles * tsamples == 0)
return 0l;
1353 if (!storedfdsset) audio_reset_stored_fnames();
1357 render_block_size *= 100;
1363 g_print(
"writing to %s\n", outfilename);
1370 THREADVAR(write_failed_file) = lives_strdup(outfilename);
1378 ins_pt *= out_achans * out_arate * out_asamps;
1379 ins_size = ((int64_t)(ins_pt / out_achans / out_asamps + .5)) * out_achans * out_asamps;
1383 out_reverse_endian =
TRUE;
1384 else out_reverse_endian =
FALSE;
1386 if (ins_size > cur_size) {
1388 pad_with_silence(out_fd, NULL, cur_size, ins_size, out_asamps, out_unsigned, out_bendian);
1391 if (opvol_start == opvol_end && opvol_start == 0.) {
1405 g_print(
"here %d %ld %ld %d\n", nfiles, tc_start, tc_end, to_file);
1408 for (track = 0; track < nfiles; track++) {
1413 g_print(
" track %d %d %.4f %.4f\n", track, from_files[track], fromtime[track], avels[track]);
1416 if (avels[track] == 0.) {
1417 is_silent[track] =
TRUE;
1421 is_silent[track] =
FALSE;
1424 in_asamps[track] = infile->
asampsize / 8;
1425 in_achans[track] = infile->
achans;
1426 in_arate[track] = infile->
arate;
1427 in_arps[track] = infile->
arps;
1431 if (LIVES_UNLIKELY(in_achans[track] == 0)) is_silent[track] =
TRUE;
1435 in_reverse_endian[track] =
TRUE;
1436 else in_reverse_endian[track] =
FALSE;
1440 zavel = avels[track] * (double)in_arate[track] / (
double)out_arate * in_asamps[track] * in_achans[track];
1442 if (fabs(zavel) > zavel_max) zavel_max = fabs(zavel);
1447 if (track <
NSTOREDFDS && storedfnames[track] && !strcmp(infilename, storedfnames[track])) {
1448 in_fd[track] = storedfds[track];
1452 if (in_fd[track] < 0) {
1454 THREADVAR(read_failed_file) = lives_strdup(infilename);
1458 storedfds[track] = in_fd[track];
1459 storedfnames[track] = lives_strdup(infilename);
1464 seekstart[track] =
quant_abytes(fromtime[track], in_arps[track], in_achans[track], in_asamps[track]);
1472 for (track = 0; track < nfiles; track++) {
1473 if (!is_silent[track]) {
1474 first_nonsilent = track;
1479 if (first_nonsilent == -1) {
1483 int64_t oins_size = ins_size;
1485 ins_pt *= out_achans * out_arate * out_asamps;
1486 ins_size = ((int64_t)(ins_pt / out_achans / out_asamps) + .5) * out_achans * out_asamps;
1487 pad_with_silence(out_fd, NULL, oins_size, ins_size, out_asamps, out_unsigned, out_bendian);
1491 for (i = 0; i < out_achans; i++) {
1509 max_aud_mem = (max_aud_mem >> 7) << 7;
1510 max_aud_mem = max_aud_mem / out_achans / nfiles;
1514 bytes_to_read = tsamples * (
sizeof(float));
1517 max_segments = (int)((
double)bytes_to_read / (double)max_aud_mem + 1.);
1520 aud_buffer = bytes_to_read / max_segments;
1522 zsamples = (int)(aud_buffer /
sizeof(
float) + .5);
1524 xsamples = zsamples + (tsamples - (max_segments * zsamples));
1528 for (i = 0; i < out_achans * nfiles; i++) {
1536 g_print(
" rendering %ld samples %f\n", tsamples, opvol);
1545 while (tsamples > 0) {
1546 tsamples -= xsamples;
1548 for (track = 0; track < nfiles; track++) {
1549 if (is_silent[track]) {
1551 for (c = 0; c < out_achans; c++) {
1552 lives_memset(float_buffer[track * out_achans + c], 0, xsamples *
sizeof(
float));
1557 zavel = avels[track] * (double)in_arate[track] / (
double)out_arate;
1563 tbytes = (int)((
double)xsamples * fabs(zavel) + ((double)
fastrand() / (double)LIVES_MAXUINT64)) *
1564 in_asamps[track] * in_achans[track];
1567 for (c = 0; c < out_achans; c++) {
1568 lives_memset(float_buffer[track * out_achans + c], 0, xsamples *
sizeof(
float));
1575 if (in_fd[track] > -1) {
1589 if (bytes_read < 0) bytes_read = 0;
1591 if (in_fd[track] > -1) {
1598 / (double)(in_asamps[track] * in_achans[track] * in_arate[track]);
1602 if (
THREADVAR(read_failed) == in_fd[track] + 1) {
1607 if (bytes_read < tbytes && bytes_read >= 0) {
1613 nframes = (tbytes / (in_asamps[track]) / in_achans[track] / fabs(zavel) + .001);
1620 if (in_asamps[track] == 1) {
1625 sample_move_d8_d16(holding_buff, (uint8_t *)in_buff, nframes, tbytes, zavel, out_achans, in_achans[track], 0);
1632 in_achans[track], in_reverse_endian[track] ?
SWAP_X_TO_L : 0, 0);
1640 for (c = 0; c < out_achans; c++) {
1643 out_achans, in_unsigned[track],
FALSE, clip_vol * (use_live_chvols ? 1. : chvol[track]));
1649 blocksize = render_block_size;
1651 for (i = 0; i < xsamples; i += render_block_size) {
1652 if (i + render_block_size > xsamples) blocksize = xsamples - i;
1654 for (track = 0; track < nfiles; track++) {
1658 for (c = 0; c < out_achans; c++) {
1660 chunk_float_buffer[track * out_achans + c] = float_buffer[track * out_achans + c] + i;
1701 for (x = 0; x < nfiles; x++) {
1702 float **adata = (
float **)
lives_calloc(out_achans,
sizeof(
float *));
1704 for (y = 0; y < out_achans; y++) {
1705 adata[y] = chunk_float_buffer[x * out_achans + y];
1719 for (x = 0; x < nfiles; x++) {
1721 for (y = 0; y < out_achans; y++) {
1722 if (chunk_float_buffer[x * out_achans + y] != adata[y]) {
1739 time += (double)frames_out / (
double)out_arate;
1740 opvol = opvol_start + (opvol_end - opvol_start) * (time / (
double)((tc_end - tc_start) /
TICKS_PER_SECOND_DBL));
1747 frames_out =
sample_move_float_int((
void *)finish_buff, chunk_float_buffer, blocksize, 1., out_achans,
1748 out_asamps * 8, out_unsigned, out_reverse_endian,
FALSE, opvol);
1751 tot_frames += frames_out;
1765 out_asamps * 8, out_unsigned, out_reverse_endian,
FALSE, opvol);
1771 tot_frames += frames_out;
1775 frames_out = chunk_to_float_abuf(obuf, float_buffer, xsamples);
1777 frames_out = chunk_to_int16_abuf(obuf, float_buffer, xsamples);
1780 tot_frames += frames_out;
1783 xsamples = zsamples;
1787 for (i = 0; i < out_achans * nfiles; i++) {
1788 if (float_buffer[i])
lives_free(float_buffer[i]);
1796 for (track = 0; track < nfiles; track++) {
1797 if (!is_silent[track]) {
1813void aud_fade(
int fileno,
double startt,
double endt,
double startv,
double endv) {
1814 double vel = 1., vol = 1.;
1841 if (
cfile->achans > 0) {
1845 (
cfile->asampsize / 8);
1846 if (apos >
cfile->aseek_pos)
cfile->aseek_pos = apos;
1857#ifdef HAVE_PULSE_AUDIO
1887#ifdef HAVE_PULSE_AUDIO
1915#ifdef HAVE_PULSE_AUDIO
1945 jack_message.data = NULL;
1946 jack_message.next = NULL;
1952#ifdef HAVE_PULSE_AUDIO
1968 pulse_message.data = NULL;
1969 pulse_message.next = NULL;
1992 float ovol =
cfile->vol;
2002 double dvol = (double)newvol;
2053 if (retval == LIVES_RESPONSE_CANCEL) {
2058 }
while (retval == LIVES_RESPONSE_RETRY);
2066 if (!jackd_read_started) {
2155void jack_rec_audio_end(
boolean close_device,
boolean close_fd) {
2160 jack_flush_read_data(0, NULL);
2181#ifdef HAVE_PULSE_AUDIO
2209 if (retval == LIVES_RESPONSE_CANCEL) {
2214 }
while (retval == LIVES_RESPONSE_RETRY);
2317void pulse_rec_audio_end(
boolean close_device,
boolean close_fd) {
2357 int n = MIN(nostate, nstate);
2367 int num_aclips = 0, atrack;
2369 double *aseeks = NULL;
2377 for (i = 0; i < num_aclips; i += 2) {
2378 if (aclips[i + 1] > 0) {
2380 if (atrack + btoffs >= naudstate - 1) {
2381 atstate = resize_audstate(atstate, naudstate, atrack + btoffs + 2);
2382 naudstate = atrack + btoffs + 1;
2383 atstate[naudstate].
afile = -1;
2385 atstate[atrack + btoffs].
afile = aclips[i + 1];
2386 atstate[atrack + btoffs].
seek = aseeks[i];
2387 atstate[atrack + btoffs].
vel = aseeks[i + 1];
2394 if (ntracks) *ntracks = num_aclips;
2401 return aframe_to_atstate_inner(event, NULL);
2406 return aframe_to_atstate_inner(event, ntracks);
2420 weed_timecode_t fill_tc,
int what_to_get,
boolean exact) {
2424 weed_timecode_t last_tc = 0;
2427 int nfiles, nnfiles, etype;
2446 while ((st_event && event != st_event) || (!st_event &&
get_event_timecode(event) < fill_tc)) {
2450 case WEED_EVENT_TYPE_FILTER_MAP:
2457 case WEED_EVENT_TYPE_FILTER_INIT:
2468 case WEED_EVENT_TYPE_FILTER_DEINIT:
2475 case WEED_EVENT_TYPE_PARAM_CHANGE:
2482 char *key_string = weed_get_string_value((weed_plant_t *)init_event,
WEED_LEAF_HOST_TAG, NULL);
2483 int key = atoi(key_string);
2484 char *filter_name = weed_get_string_value((weed_plant_t *)init_event,
WEED_LEAF_FILTER, NULL);
2500 weed_leaf_dup(param, event, WEED_LEAF_VALUE);
2505 case WEED_EVENT_TYPE_FRAME:
2517 for (nfiles = 0; audstate[nfiles].afile != -1; nfiles++) {
2524 for (nnfiles = 0; atstate[nnfiles].
afile != -1; nnfiles++);
2525 if (nnfiles > nfiles) {
2526 audstate = resize_audstate(audstate, nfiles, nnfiles + 1);
2527 audstate[nnfiles].afile = -1;
2530 for (
int i = 0; i < nnfiles; i++) {
2531 if (atstate[i].afile > 0) {
2532 audstate[i].afile = atstate[i].
afile;
2533 audstate[i].seek = atstate[i].
seek;
2534 audstate[i].vel = atstate[i].
vel;
2554 for (nfiles = 0; audstate[nfiles].afile != -1; nfiles++) {
2580 static weed_timecode_t last_tc, tc;
2581 static weed_timecode_t fill_tc;
2582 static weed_plant_t *event;
2585 static int *from_files = NULL;
2586 static double *aseeks = NULL, *avels = NULL;
2614 for (i = 0; i < nfiles; i++) {
2616 avels[i] = aseeks[i] = 0.;
2623 for (i = 0; atstate[i].
afile != -1; i++) {
2624 if (atstate[i].afile > 0) {
2625 from_files[i] = atstate[i].
afile;
2626 avels[i] = atstate[i].
vel;
2627 aseeks[i] = atstate[i].
seek;
2636 for (i = 0; i < nfiles; i++) {
2641 }
else chvols[0] = 1.;
2651 render_audio_segment(nfiles, from_files, -1, avels, aseeks, last_tc, tc, chvols, 1., 1., abuf);
2664 for (nnfiles = 0; atstate[nnfiles].
afile != -1; nnfiles++);
2665 for (i = 0; i < nnfiles; i++) {
2666 if (atstate[i].afile > 0) {
2667 from_files[i] = atstate[i].
afile;
2668 avels[i] = atstate[i].
vel;
2669 aseeks[i] = atstate[i].
seek;
2678 if (last_tc < fill_tc) {
2683 render_audio_segment(nfiles, from_files, -1, avels, aseeks, last_tc, fill_tc, chvols, 1., 1., abuf);
2721 for (chan = 0; chan < achans; chan++) {
2730#ifdef HAVE_PULSE_AUDIO
2742 achans *
sizeof(
short));
2756 for (chan = 0; chan <
mainw->
jackd->abufs[i]->out_achans; chan++) {
2769#ifdef HAVE_PULSE_AUDIO
2832 if (
cfile->achans == 0
2834#ifdef HAVE_PULSE_AUDIO
2848 if (!jack_audio_seek_frame(
mainw->
jackd, frameno)) {
2849 if (jack_try_reconnect()) jack_audio_seek_frame(
mainw->
jackd, frameno);
2861#ifdef HAVE_PULSE_AUDIO
2866 if (!pulse_audio_seek_frame(
mainw->
pulsed, frameno)) {
2867 if (pulse_try_reconnect()) pulse_audio_seek_frame(
mainw->
pulsed, frameno);
2884static pthread_t athread;
2886static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
2887static pthread_mutex_t cond_mutex = PTHREAD_MUTEX_INITIALIZER;
2904static void *cache_my_audio(
void *arg) {
2909 while (!cbuffer->
die) {
2912 pthread_mutex_lock(&cond_mutex);
2913 pthread_cond_wait(&cond, &cond_mutex);
2914 pthread_mutex_unlock(&cond_mutex);
2920 if (cbuffer->
_fd != -1)
2938#ifdef HAVE_PULSE_AUDIO
3136 if (cbuffer->
_fd == -1) {
3137 lives_printerr(
"audio cache thread: error opening %s\n", filename);
3232 pthread_mutex_lock(&cond_mutex);
3233 pthread_cond_signal(&cond);
3234 pthread_mutex_unlock(&cond_mutex);
3264 cache_buffer->
_cseek = -1;
3265 cache_buffer->
_fd = -1;
3270 pthread_create(&athread, NULL, cache_my_audio, cache_buffer);
3272 return cache_buffer;
3281 if (!cache_buffer) {
3287 pthread_join(athread, NULL);
3313 xcache_buffer = cache_buffer;
3314 cache_buffer = NULL;
3325 return cache_buffer;
3335 weed_plant_t *orig_inst = inst;
3336 weed_plant_t *filter;
3337 weed_plant_t *channel;
3338 weed_plant_t *ctmpl;
3340 weed_error_t retval;
3342 int xnchans = 0, xxnchans, xrate = 0;
3353 if (flags & WEED_FILTER_AUDIO_RATES_MAY_VARY) rvary =
TRUE;
3354 if (flags & WEED_FILTER_CHANNEL_LAYOUTS_MAY_VARY) lvary =
TRUE;
3364 if (lvary && weed_plant_has_leaf(ctmpl, WEED_LEAF_AUDIO_CHANNELS))
3365 xnchans = weed_get_int_value(ctmpl, WEED_LEAF_AUDIO_CHANNELS, NULL);
3366 else if (weed_plant_has_leaf(filter, WEED_LEAF_MAX_AUDIO_CHANNELS)) {
3367 xxnchans = weed_get_int_value(filter, WEED_LEAF_MAX_AUDIO_CHANNELS, NULL);
3368 if (xxnchans > 0 && xxnchans < nchans) xnchans = xxnchans;
3370 if (xnchans > nchans) {
3374 if (weed_get_int_value(channel, WEED_LEAF_AUDIO_CHANNELS, NULL) != nchans
3375 && (cflags & WEED_CHANNEL_REINIT_ON_LAYOUT_CHANGE))
3377 else weed_set_int_value(channel, WEED_LEAF_AUDIO_CHANNELS, nchans);
3380 if (rvary && weed_plant_has_leaf(ctmpl, WEED_LEAF_AUDIO_RATE))
3381 xrate = weed_get_int_value(ctmpl, WEED_LEAF_AUDIO_RATE, NULL);
3382 else if (weed_plant_has_leaf(filter, WEED_LEAF_AUDIO_RATE))
3383 xrate = weed_get_int_value(filter, WEED_LEAF_AUDIO_RATE, NULL);
3384 if (arate != xrate) {
3389 if (weed_get_int_value(channel, WEED_LEAF_AUDIO_RATE, NULL) != arate) {
3390 if (cflags & WEED_CHANNEL_REINIT_ON_RATE_CHANGE) {
3395 weed_set_int_value(channel, WEED_LEAF_AUDIO_RATE, arate);
3403 weed_set_int64_value(channel, WEED_LEAF_TIMECODE, tc);
3406 weed_set_double_value(inst, WEED_LEAF_FPS,
cfile->pb_fps);
3425 if (retval != WEED_SUCCESS) {
3431 if (channel && xnchans == 1 && nchans == 2) {
3433 lives_memcpy(fbuffer[1], fbuffer[0], nsamps *
sizeof(
float));
3468static char *audio_file;
3493 if (audio_fd == -1)
return FALSE;
3496 off64_t audio_end_pos = (double)((
cfile->start - 1) *
cfile->arate *
cfile->achans *
cfile->asampsize / 8) /
cfile->fps;
3525 float **fltbuf, *fltbufni = NULL;
3526 short *shortbuf = NULL;
3527 boolean rev_endian =
FALSE;
3536 if ((abigendian &&
capable->
byte_order == LIVES_LITTLE_ENDIAN) || (!abigendian &&
3539 tbytes = nframes *
cfile->achans *
cfile->asampsize / 8;
3543 if (tbytes <= 0)
return TRUE;
3544 nframes = tbytes /
cfile->achans / (
cfile->asampsize / 8);
3550 if (!in_buff)
return FALSE;
3552 if (
cfile->asampsize == 8) {
3567 if (
THREADVAR(read_failed) == audio_fd + 1) {
3577 if (
cfile->asampsize == 8) {
3580 }
else shortbuf = (
short *)in_buff;
3582 nframes = tbytes /
cfile->achans / (
cfile->asampsize / 8);
3586 for (i = 0; i <
cfile->achans; i++) {
3588 fltbuf[i] = (
float *)
lives_calloc(nframes,
sizeof(
float));
3590 for (--i; i >= 0; i--) {
3594 if (shortbuf != (
short *)in_buff)
lives_free(shortbuf);
3628 for (i = 0; i <
cfile->achans; i++) {
3635 if (shortbuf != (
short *)in_buff)
lives_free(shortbuf);
3646 for (i = 0; i <
cfile->achans; i++) {
3653 if (audio_fd >= 0) {
3656 tbytes = onframes *
cfile->achans *
cfile->asampsize / 8;
3661 if (shortbuf != (
short *)in_buff)
lives_free(shortbuf);
3664 if (
THREADVAR(write_failed) == audio_fd + 1) {
3691 weed_plant_t *ctmpl;
3695 size_t samps, offs = 0;
3697 int trate, tchans, xnchans, flags;
3710 ctmpl = weed_get_plantptr_value(achan, WEED_LEAF_TEMPLATE, NULL);
3712 flags = weed_get_int_value(filter, WEED_LEAF_FLAGS, NULL);
3713 if (flags & WEED_FILTER_AUDIO_RATES_MAY_VARY) rvary =
TRUE;
3714 if (flags & WEED_FILTER_CHANNEL_LAYOUTS_MAY_VARY) lvary =
TRUE;
3720 if (maxlen < samps) {
3721 offs = samps - maxlen;
3728 if (rvary && weed_plant_has_leaf(ctmpl, WEED_LEAF_AUDIO_RATE))
3729 trate = weed_get_int_value(ctmpl, WEED_LEAF_AUDIO_RATE, NULL);
3730 else if (weed_plant_has_leaf(filter, WEED_LEAF_AUDIO_RATE))
3731 trate = weed_get_int_value(filter, WEED_LEAF_AUDIO_RATE, NULL);
3735 if (lvary && weed_plant_has_leaf(ctmpl, WEED_LEAF_AUDIO_CHANNELS))
3736 tchans = weed_get_int_value(ctmpl, WEED_LEAF_AUDIO_CHANNELS, NULL);
3737 else if (weed_plant_has_leaf(filter, WEED_LEAF_MAX_AUDIO_CHANNELS)) {
3738 xnchans = weed_get_int_value(filter, WEED_LEAF_MAX_AUDIO_CHANNELS, NULL);
3739 if (xnchans > 0 && xnchans < tchans) tchans = xnchans;
3793 scale = (double)trate / (
double)abuf->
arate;
3794 alen = (size_t)(fabs(((
double)alen * scale)));
3800 for (i = 0; i < tchans; i++) {
3805 if (abuf->
arate == trate) {
3811 }
else dst[i] = NULL;
3828 const char *playername =
"audiostreamer.pl";
3829 char *astream_name = NULL;
3830 char *astream_name_out = NULL;
3836 char *astreamer, *com;
3844 astream_name = lives_build_filename(
prefs->
workdir, astname, NULL);
3847 mkfifo(astream_name, S_IRUSR | S_IWUSR);
3850 astream_name_out = lives_build_filename(
prefs->
workdir, astname_out, NULL);
3856#ifdef HAVE_PULSE_AUDIO
3881 afd =
lives_open2(astream_name, O_WRONLY | O_SYNC);
3882 if (afd != -1)
break;
3888#ifdef HAVE_PULSE_AUDIO
3909 const char *playername =
"audiostreamer.pl";
3914 char *astream_name = lives_build_filename(
prefs->
workdir, astname, NULL);
3915 char *astream_name_out = lives_build_filename(
prefs->
workdir, astname_out, NULL);
3922#ifdef HAVE_PULSE_AUDIO
3952 char *astream_name = lives_build_filename(
prefs->
workdir, astname, NULL);
3954 char *astream_name_out = lives_build_filename(
prefs->
workdir, astname_out, NULL);
3973 _(
"\nClick Retry to attempt to restart the audio server.\n")) :
3977 _(
"LiVES was unable to connect to %s.\nPlease check your audio settings and restart %s\n"
3978 "and LiVES if necessary.\n%s"),
3982#ifdef HAVE_PULSE_AUDIO
3984 if (retval == LIVES_RESPONSE_RETRY) pulse_try_reconnect();
4004void nullaudio_time_reset(int64_t offset) {
4006 mainw->nullaudio_seek_posn = 0;
4007 mainw->nullaudio_arate = DEF_AUDIO_RATE;
4008 mainw->nullaudio_playing_file = -1;
4013void nullaudio_arate_set(
int arate) {
4014 mainw->nullaudio_arate = arate;
4018void nullaudio_seek_set(offs64_t seek_posn) {
4020 mainw->nullaudio_seek_posn = seek_posn;
4024void nullaudio_clip_set(
int clipno) {
4025 mainw->nullaudio_playing_file = clipno;
4029int64_t nullaudio_update_seek_posn() {
4035 mainw->nullaudo_startticks = current_ticks;
4036 if (
mainw->nullaudio_seek_posn < 0) {
4043 mainw->nullaudio_arate = -
mainw->nullaudio->arate;
4044 mainw->nullaudio_seek_posn = 0;
4045 }
else mainw->nullaudio_seek_posn +=
mainw->nullaudio_seek_end;
4048 if (
mainw->nullaudio_seek_posn >
mainw->nullaudio_seek_end) {
4056 mainw->nullaudio_arate = -
mainw->nullaudio_arate;
4057 mainw->nullaudio_seek_posn =
mainw->nullaudio_seek_end - (
mainw->nullaudio_seek_pos -
mainw->nullaudio_seek_end);
4059 mainw->nullaudio_seek_posn -=
mainw->nullaudio_seek_end;
4061 nullaudio_set_rec_avals();
4068void nullaudio_get_rec_avals(
void) {
4079static void nullaudio_set_rec_avals(
boolean is_forward) {
4083 nullaudio_get_rec_avals();
void audio_free_fnames(void)
void append_to_audio_bufferf(float *src, uint64_t nsamples, int channum)
boolean apply_rte_audio(int64_t nframes)
LIVES_LOCAL_INLINE lives_audio_track_state_t * aframe_to_atstate(weed_plant_t *event)
void init_audio_frame_buffers(short aplayer)
boolean get_audio_from_plugin(float **fbuffer, int nchans, int arate, int nsamps, boolean is_audio_thread)
int64_t sample_move_abuf_float(float **obuf, int nchans, int nsamps, int out_arate, float vol)
copy audio data from cache into audio sound buffer
void append_to_audio_buffer16(void *src, uint64_t nsamples, int channum)
void sample_move_float_float(float *dst, float *src, uint64_t nsamples, double scale, int dst_skip)
void wake_audio_thread(void)
void audio_cache_end(void)
int64_t render_audio_segment(int nfiles, int *from_files, int to_file, double *avels, double *fromtime, weed_timecode_t tc_start, weed_timecode_t tc_end, double *chvol, double opvol_start, double opvol_end, lives_audio_buf_t *obuf)
render a chunk of audio, apply effects and mixing it
LIVES_GLOBAL_INLINE char * get_achannel_name(int totchans, int idx)
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
LIVES_LOCAL_INLINE void audio_process_events_to(weed_timecode_t tc)
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_GLOBAL_INLINE lives_audio_track_state_t * audio_frame_to_atstate(weed_event_t *event, int *ntracks)
LIVES_GLOBAL_INLINE void audio_stream(void *buff, size_t nbytes, int fd)
LIVES_GLOBAL_INLINE void avsync_force(void)
boolean start_audio_stream(void)
void init_jack_audio_buffers(int achans, int arate, boolean exact)
lives_pgid_t astream_pgid
void aud_fade(int fileno, double startt, double endt, double startv, double endv)
fade in/fade out
void reinit_audio_gen(void)
LIVES_GLOBAL_INLINE const char * audio_player_get_display_name(const char *aplayer)
float get_float_audio_val_at_time(int fnum, int afd, double secs, int chnum, int chans)
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_GLOBAL_INLINE char * get_audio_file_name(int fnum, boolean opening)
void free_audio_frame_buffer(lives_audio_buf_t *abuf)
lives_audio_buf_t * audio_cache_init(void)
int64_t sample_move_float_int(void *holding_buff, float **float_buffer, int nsamps, double scale, int chans, int asamps, int usigned, boolean rev_endian, boolean interleaved, float vol)
convert float samples back to int interleaved is for the float buffer; output int is always interleav...
LIVES_GLOBAL_INLINE lives_audio_buf_t * audio_cache_get_buffer(void)
void free_pulse_audio_buffers(void)
boolean adjust_clip_volume(int fileno, float newvol, boolean make_backup)
void clear_audio_stream(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)
void sample_move_d16_d16(int16_t *dst, int16_t *src, uint64_t nsamples, size_t tbytes, double scale, int nDstChannels, int nSrcChannels, int swap_endian, int swap_sign)
convert from any number of source channels to any number of destination channels - both interleaved
LIVES_GLOBAL_INLINE char * lives_get_audio_file_name(int fnum)
void free_jack_audio_buffers(void)
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)
convert from any number of source channels to any number of destination channels - 8 bit output
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_GLOBAL_INLINE lives_cancel_t handle_audio_timeout(void)
boolean float_deinterleave(float *fbuffer, int nsamps, int nchans)
LIVES_GLOBAL_INLINE void sample_silence_dS(float *dst, uint64_t nsamples)
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)
void apply_rte_audio_end(boolean del)
boolean float_interleave(float *fbuffer, int nsamps, int nchans)
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
int64_t sample_move_abuf_int16(short *obuf, int nchans, int nsamps, int out_arate)
copy audio data from cache into audio sound buffer
#define MAX_AUDIO_MEM
TODO ** - make configurable - audio buffer size for rendering.
#define SILENCE_BLOCK_SIZE
size of silent block in bytes
#define SAMPLE_MAX_16BIT_P
#define RENDER_BLOCK_SIZE
chunk size for interpolate/effect cycle
#define XSAMPLES
buffer size (output samples) for (semi) realtime audio (bytes == XSAMPLES * achans * samp....
#define SAMPLE_MAX_16BITI
#define SWAP_L_TO_X
local to other
#define WEED_LEAF_HOST_KEEP_ADATA
#define ASERVER_CMD_FILE_CLOSE
#define is_realtime_aplayer(ptype)
#define SAMPLE_MAX_16BIT_N
#define DEFAULT_AUDIO_CHANS
#define lives_vol_from_linear(vol)
#define DEFAULT_AUDIO_RATE
defaults for when not specifed
#define SWAP_X_TO_L
endian swapping
#define SWAP_U_TO_S
sign swapping
#define SWAP_S_TO_U
signed to unsigned
void on_playsel_activate(LiVESMenuItem *menuitem, livespointer user_data)
LIVES_GLOBAL_INLINE weed_layer_t * weed_layer_free(weed_layer_t *layer)
frees pixel_data for a layer, then the layer itself
LIVES_GLOBAL_INLINE weed_layer_t * weed_layer_new(int layer_type)
LIVES_GLOBAL_INLINE float ** weed_layer_get_audio_data(weed_layer_t *layer, int *naudchans)
LIVES_GLOBAL_INLINE int weed_layer_get_audio_length(weed_layer_t *layer)
LIVES_GLOBAL_INLINE weed_layer_t * weed_layer_set_audio_data(weed_layer_t *layer, float **data, int arate, int naudchans, weed_size_t nsamps)
#define WEED_LAYER_TYPE_AUDIO
weed_plant_t weed_layer_t
void do_write_failed_error_s(const char *s, const char *addinfo)
LIVES_GLOBAL_INLINE LiVESResponseType do_abort_cancel_retry_dialog(const char *text)
boolean do_auto_dialog(const char *text, int type)
LiVESResponseType do_write_failed_error_s_with_retry(const char *fname, const char *errtext)
void do_read_failed_error_s(const char *s, const char *addinfo)
LIVES_GLOBAL_INLINE LiVESResponseType do_error_dialog(const char *text)
void threaded_dialog_spin(double fraction)
boolean pconx_chain_data(int key, int mode, boolean is_audio_thread)
LIVES_GLOBAL_INLINE int filter_mutex_unlock(int key)
int rte_key_getmode(int key)
returns current active mode for a key (or -1)
weed_plant_t * weed_instance_get_filter(weed_plant_t *inst, boolean get_compound_parent)
void weed_apply_audio_effects_rt(weed_layer_t *alayer, weed_timecode_t tc, boolean analysers_only, boolean is_audio_thread)
weed_plant_t * rte_keymode_get_instance(int key, int mode)
returns refcounted filter_instance bound to key/mode (or NULL)
int weed_get_idx_for_hashname(const char *hashname, boolean fullname)
fullname includes author and version
boolean has_audio_chans_out(weed_plant_t *filter, boolean count_opt)
lives_filter_error_t run_process_func(weed_plant_t *instance, weed_timecode_t tc, int key)
LIVES_GLOBAL_INLINE int weed_instance_unref(weed_plant_t *inst)
weed_plant_t * get_weed_filter(int idx)
weed_plant_t * weed_inst_in_param(weed_plant_t *inst, int param_num, boolean skip_hidden, boolean skip_internal)
void weed_apply_audio_effects(weed_plant_t *filter_map, weed_layer_t **layers, int nbtracks, int nchans, int64_t nsamps, double arate, weed_timecode_t tc, double *vis)
weed_plant_t * get_enabled_channel(weed_plant_t *inst, int which, boolean is_in)
for FILTER_INST
boolean has_audio_filters(lives_af_t af_type)
boolean is_pure_audio(weed_plant_t *plant, boolean count_opt)
TRUE if audio in or out and no vid in/out.
lives_filter_error_t weed_reinit_effect(weed_plant_t *inst, boolean reinit_compound)
@ FILTER_INFO_REINITED
values >= 512 are info
#define WEED_LEAF_HOST_NEXT_INSTANCE
#define WEED_LEAF_HOST_TAG
double * get_track_visibility_at_tc(weed_plant_t *event_list, int ntracks, int nbtracks, weed_timecode_t tc, weed_plant_t **shortcut, boolean bleedthru)
calculate the "visibility" of each track at timecode tc
weed_plant_t * get_next_audio_frame_event(weed_plant_t *event)
LIVES_GLOBAL_INLINE weed_timecode_t weed_event_get_timecode(weed_event_t *event)
weed_plant_t * process_events(weed_plant_t *next_event, boolean process_audio, weed_timecode_t curr_tc)
LIVES_GLOBAL_INLINE int weed_event_get_type(weed_event_t *event)
LIVES_GLOBAL_INLINE weed_plant_t * get_first_event(weed_plant_t *event_list)
LIVES_GLOBAL_INLINE weed_timecode_t get_event_timecode(weed_plant_t *plant)
LIVES_GLOBAL_INLINE weed_plant_t * get_next_event(weed_plant_t *event)
LIVES_GLOBAL_INLINE int weed_frame_event_get_audio_tracks(weed_event_t *event, int **clips, double **seeks)
#define AUD_DIFF_MIN
ignore audio seek differences < than this (seconds)
#define WEED_LEAF_DEINIT_EVENT
#define WEED_EVENT_IS_AUDIO_FRAME(event)
#define WEED_LEAF_INIT_EVENT
#define WEED_LEAF_IN_TRACKS
weed_plant_t weed_event_t
double lives_ce_update_timeline(int frame, double x)
pointer position in timeline
#define LIVES_PREVIEW_TYPE_VIDEO_ONLY
#define LIVES_PREVIEW_TYPE_VIDEO_AUDIO
#define LIVES_PREVIEW_TYPE_AUDIO_ONLY
LIVES_GLOBAL_INLINE void * lives_calloc_safety(size_t nmemb, size_t xsize)
off_t get_file_size(int fd)
LIVES_GLOBAL_INLINE ticks_t lives_get_current_ticks(void)
LIVES_GLOBAL_INLINE void swab2(const void *from, const void *to, size_t gran)
LIVES_GLOBAL_INLINE uint64_t fastrand(void)
boolean reverse_buffer(uint8_t *buff, size_t count, size_t chunk)
#define EXTRA_BYTES
TODO - split into: memory, files, sysops, threads.
#define lives_nanosleep(nanosec)
ssize_t lives_read_buffered(int fd, void *buf, ssize_t count, boolean allow_less)
int lives_close_buffered(int fd)
lives_pid_t lives_fork(const char *com)
ssize_t lives_write(int fd, livesconstpointer buf, ssize_t count, boolean allow_fail)
off_t lives_lseek_buffered_writer(int fd, off_t offset)
#define LIVES_GLOBAL_INLINE
ticks_t lives_get_current_playback_ticks(ticks_t origsecs, ticks_t origusecs, lives_time_source_t *time_source)
@ CANCEL_KILL
normal - kill background processes working on current clip
@ CANCEL_SOFT
just cancel in GUI (for keep, etc)
ssize_t lives_write_buffered(int fd, const char *buf, ssize_t count, boolean allow_fail)
#define DEF_FILE_PERMS
non-executable, is modified by the umask
#define IS_NORMAL_CLIP(clip)
#define LIVES_CLIP_HEADER_VERSION
size_t lives_buffered_orig_size(int fd)
int lives_open3(const char *pathname, int flags, mode_t mode)
#define CURRENT_CLIP_HAS_AUDIO
boolean lives_alarm_clear(lives_alarm_t alarm_handle)
#define LIVES_LOCAL_INLINE
int lives_system(const char *com, boolean allow_error)
int lives_killpg(lives_pgid_t pgrp, int sig)
void switch_aud_to_none(boolean set_pref)
#define AFORM_LITTLE_ENDIAN
int lives_open_buffered_rdonly(const char *pathname)
#define SIGNED_DIVIDE(a, b)
@ CLIP_DETAILS_HEADER_VERSION
lives_alarm_t lives_alarm_set(ticks_t ticks)
set alarm for now + delta ticks (10 nanosec) param ticks (10 nanoseconds) is the offset when we want ...
#define IS_VALID_CLIP(clip)
int lives_rm(const char *file)
void d_print_failed(void)
off_t lives_buffered_offset(int fd)
int lives_open2(const char *pathname, int flags)
void d_print(const char *fmt,...)
int lives_open_buffered_writer(const char *pathname, int mode, boolean append)
boolean lives_buffered_rdonly_set_reversed(int fd, boolean val)
#define CLIP_AUDIO_TIME(clip)
off_t lives_lseek_buffered_rdonly(int fd, off_t offset)
off_t lives_lseek_buffered_rdonly_absolute(int fd, off_t offset)
uint32_t get_signed_endian(boolean is_signed, boolean little_endian)
produce bitmapped value
boolean lives_freep(void **ptr)
boolean save_clip_value(int which, lives_clip_details_t, void *val)
ticks_t lives_alarm_check(lives_alarm_t alarm_handle)
lives_cancel_t
cancel reason
@ CANCEL_AUD_END
video playback completed
@ CANCEL_ERROR
cancelled because of error
@ CANCEL_AUDIO_ERROR
cancelled because of soundcard error
#define USEC_TO_TICKS
multiplying factor uSec -> ticks_t (def. 100)
#define CLIP_TEMP_AUDIO_FILENAME
#define TICKS_PER_SECOND_DBL
actually microseconds / 100.
#define CLIP_AUDIO_FILENAME
#define LIVES_DEFAULT_TIMEOUT
#define PLUGIN_AUDIO_STREAM
#define AUDIO_PLAYER_PULSE_AUDIO
used for display, alternate pref and alternate startup opt (-aplayer pulseaudio)
#define AUDIO_PLAYER_PULSE
used in pref and for external players (e.g -ao pulse, -aplayer pulse)
#define AUDIO_OPTS_FOLLOW_FPS
LIVES_GLOBAL_INLINE off_t quant_abytes(double seek, int arate, int achans, int asampsize)
boolean perm_audio_reader
volatile uint32_t audio_opts
boolean push_audio_to_gens
boolean force_system_clock
char workdir[PATH_MAX]
kept in locale encoding
char backend_sync[PATH_MAX *4]
boolean(* render_audio_frame_float)(float **audio, int nsamps)
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
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
corresponds to one clip in the GUI
int arps
audio physical sample rate (i.e the "normal" sample rate of the clip when played at 1,...
int asampsize
audio sample size in bits (8 or 16)
int achans
number of audio channels (0, 1 or 2)
int cb_src
source clip for clipboard; for other clips, may be used to hold some temporary linkage
uint32_t signed_endian
bitfield
int arate
current audio playback rate (varies if the clip rate is changed)
float vol
relative volume level / gain; sizeof array will be equal to achans
_vid_playback_plugin * vpp
video plugin
volatile int agen_key
which fx key is generating audio [1 based] (or 0 for none)
pthread_mutex_t abuf_frame_mutex
used to synch audio buffer for generators
volatile boolean video_seek_ready
int write_abuf
audio buffer number to write to (for multitrack)
double aframeno
and the audio 'frame' for when we are looping
pthread_mutex_t audio_filewriteend_mutex
sync for ending writing audio to file
int aud_rec_fd
fd of file we are recording audio to
volatile ticks_t currticks
wall clock time, updated whenever lives_get_*_ticks is called
void * pulsed
pulseaudio player
lives_clip_t * files[MAX_FILES+1]
+1 for the clipboard
ticks_t origsecs
playback start seconds - subtracted from all other ticks to keep numbers smaller
volatile boolean ext_audio
using external video playback plugin to stream audio
volatile lives_cancel_t cancelled
lives_cancel_type_t cancel_type
ticks_t orignsecs
usecs at start of playback - ditto
void * jackd
jack audio player / transport
uint64_t agen_samps_count
count of samples since init
lives_audio_buf_t * afb[2]
used for buffering / feeding audio to video generators
weed_plant_t * filter_map
pthread_mutex_t vpp_stream_mutex
prevent from writing audio when stream is closing
boolean suppress_dprint
tidy up, e.g. by blocking "switched to file..." and "closed file..." messages
weed_plant_t * audio_event
pthread_mutex_t abuf_mutex
mutices
volatile int rec_aclip
recording values - to be inserted at the following video frame
volatile double rec_aseek
boolean playing_sel
list of set names in current workdir, mau be NULL
volatile boolean record_paused
pause during recording
int ascrap_file
scrap file for recording audio scraps
lives_mt * multitrack
holds a pointer to the entire multitrack environment; NULL in Clip Edit mode
pthread_mutex_t avseek_mutex
boolean foreign
for external window capture
volatile boolean agen_needs_reinit
pthread_mutex_t cache_buffer_mutex
sync for jack playback termination
boolean preview_rendering
volatile int abufs_to_fill
ticks_t deltaticks
deltaticks for scratching
volatile ticks_t startticks
effective ticks when current frame was (should have been) displayed
weed_plant_t * afilter_map
volatile boolean audio_seek_ready
lives_pconnect_t * pconx
list of out -> in param connections
volatile lives_whentostop_t whentostop
int playing_file
which number file we are playing (or -1) [generally mainw->current_file]
pthread_mutex_t fx_mutex[FX_KEYS_MAX]
used to prevent fx processing when it is scheduled for deinit
volatile lives_audio_buf_t * audio_frame_buffer
used for buffering / feeding audio to video generators
weed_event_t * event_list
current event_list, for recording
#define lives_strdup_printf(fmt,...)
WEED_GLOBAL_INLINE int weed_chantmpl_get_flags(weed_plant_t *chantmpl)
WEED_GLOBAL_INLINE weed_plant_t * weed_channel_get_template(weed_plant_t *channel)
WEED_GLOBAL_INLINE weed_layer_t * weed_channel_set_audio_data(weed_plant_t *channel, float **data, int arate, int naudchans, int nsamps)
WEED_GLOBAL_INLINE int weed_filter_get_flags(weed_plant_t *filter)
WEED_GLOBAL_INLINE int weed_chantmpl_get_max_audio_length(weed_plant_t *chantmpl)