| @@ -130,9 +130,10 @@ static size_t output_count = 0; · 129 unmodified lines |
| 130 | * a resampling effect, a channel mixing effect, the input, and the output. | 130 | * a resampling effect, a channel mixing effect, the input, and the output. |
| 131 | */ | 131 | */ |
| 132 | #define MAX_USER_EFF (SOX_MAX_EFFECTS - 4) | 132 | #define MAX_USER_EFF (SOX_MAX_EFFECTS - 4) |
| 133 | static sox_effect_t * user_efftab[MAX_USER_EFF], efftab_options[MAX_USER_EFF]; | 133 | static struct { char *name; int argc; char *argv[256]; } user_effargs[MAX_USER_EFF]; |
| | 134 | static sox_effect_t *user_efftab[MAX_USER_EFF]; |
| 134 | static unsigned nuser_effects; | 135 | static unsigned nuser_effects; |
| 135 | static sox_effects_chain_t ofile_effects_chain; | 136 | static sox_effects_chain_t *effects_chain = NULL; |
| 136 | | 137 | |
| 137 | | 138 | |
| 138 | /* Flowing */ | 139 | /* Flowing */ |
| @@ -542,26 +543,78 @@ static sox_effect_handler_t const * output_effect_fn(void) · 403 unmodified lines |
| 542 | return &handler; | 543 | return &handler; |
| 543 | } | 544 | } |
| 544 | | 545 | |
| 545 | static void add_auto_effect(sox_effects_chain_t * chain, char const * name, char * arg, sox_signalinfo_t * signal) | 546 | static void add_effect(sox_effects_chain_t *chain, char const *name, |
| | 547 | int argc, char *argv[], sox_signalinfo_t *signal) |
| 546 | { | 548 | { |
| 547 | sox_effect_t * effp; | 549 | sox_effect_t * effp; |
| 548 | char * * argv = & arg; | | |
| 549 | | 550 | |
| 550 | effp = sox_create_effect(sox_find_effect(name)); /* Should always succeed. */ | 551 | effp = sox_create_effect(sox_find_effect(name)); /* Should always succeed. */ |
| 551 | | 552 | |
| 552 | if (effp->handler.getopts(effp, arg != NULL, argv) == SOX_EOF) | 553 | if (!effp) |
| | 554 | sox_fail("Failed creating effect. Out of Memory?\n"); |
| | 555 | |
| | 556 | if (effp->handler.flags & SOX_EFF_DEPRECATED) |
| | 557 | sox_warn("effect `%s' is deprecated; see soxeffect(7) for an alternative", |
| | 558 | effp->handler.name); |
| | 559 | |
| | 560 | if (sox_effect_options(effp, argc, argv) == SOX_EOF) |
| 553 | exit(1); /* The failing effect should have displayed an error message */ | 561 | exit(1); /* The failing effect should have displayed an error message */ |
| 554 | | 562 | |
| 555 | if (sox_add_effect(chain, effp, signal, &ofile->ft->signal) != SOX_SUCCESS) | 563 | if (sox_add_effect(chain, effp, signal, &ofile->ft->signal) != SOX_SUCCESS) |
| 556 | exit(2); /* The effects chain should have displayed an error message */ | 564 | exit(2); /* The effects chain should have displayed an error message */ |
| 557 | } | 565 | } |
| 558 | | 566 | |
| 559 | /* If needed effects are not given, auto-add at (performance) optimal point. */ | 567 | /* Creates users effects and passes in user specified options. |
| 560 | static void add_effects(sox_effects_chain_t * chain) | 568 | * This is done without putting anything into the effects chain |
| | 569 | * because an effect may set the effp->in_format and we may want |
| | 570 | * to copy that back into the input/combiner before opening and |
| | 571 | * inserting it. |
| | 572 | * Similarly, we may want to use effp->out_format to override the |
| | 573 | * default values of output file before we open it. |
| | 574 | * To keep things simple, we create all user effects. Later, when |
| | 575 | * we add them, some may already be in the chain and we will need to free |
| | 576 | * them. |
| | 577 | */ |
| | 578 | static void create_user_effects(void) |
| | 579 | { |
| | 580 | unsigned i; |
| | 581 | sox_effect_t *effp; |
| | 582 | |
| | 583 | for (i = 0; i < nuser_effects; i++) |
| | 584 | { |
| | 585 | effp = sox_create_effect(sox_find_effect(user_effargs[i].name)); |
| | 586 | |
| | 587 | if (!effp) |
| | 588 | sox_fail("Failed creating effect. Out of Memory?\n"); |
| | 589 | |
| | 590 | if (effp->handler.flags & SOX_EFF_DEPRECATED) |
| | 591 | sox_warn("effect `%s' is deprecated; see soxeffect(7) for an alternative", |
| | 592 | effp->handler.name); |
| | 593 | |
| | 594 | /* The failing effect should have displayed an error message */ |
| | 595 | if (sox_effect_options(effp, user_effargs[i].argc, |
| | 596 | user_effargs[i].argv) == SOX_EOF) |
| | 597 | exit(1); |
| | 598 | |
| | 599 | user_efftab[i] = effp; |
| | 600 | } |
| | 601 | } |
| | 602 | |
| | 603 | /* Add all user effects to the chain. If the output effect's rate or |
| | 604 | * channel count do not match the end of the effects chain then |
| | 605 | * insert effects to correct this. |
| | 606 | * |
| | 607 | * This can also be called on pre-existing effect chains so that it |
| | 608 | * will only add effects that are missing off the END of the chain. |
| | 609 | * This is useful if an effect went into drain mode and you |
| | 610 | * wish to restart it and any effects after it. |
| | 611 | */ |
| | 612 | static void add_effects(sox_effects_chain_t *chain) |
| 561 | { | 613 | { |
| 562 | sox_signalinfo_t signal = combiner_signal; | 614 | sox_signalinfo_t signal = combiner_signal; |
| 563 | unsigned i, min_chan = 0, min_rate = 0; | 615 | unsigned i, min_chan = 0, min_rate = 0; |
| 564 | sox_effect_t * effp; | 616 | sox_effect_t * effp; |
| | 617 | unsigned effects_added = 0; |
| 565 | char * rate_arg = sox_mode != sox_play? NULL : | 618 | char * rate_arg = sox_mode != sox_play? NULL : |
| 566 | (rate_arg = getenv("PLAY_RATE_ARG"))? rate_arg : "-l"; | 619 | (rate_arg = getenv("PLAY_RATE_ARG"))? rate_arg : "-l"; |
| 567 | | 620 | |
| @@ -572,35 +625,54 @@ static void add_effects(sox_effects_chain_t * chain) · 4 unmodified lines |
| 572 | if (user_efftab[i]->handler.flags & SOX_EFF_RATE) | 625 | if (user_efftab[i]->handler.flags & SOX_EFF_RATE) |
| 573 | min_rate = i + 1; | 626 | min_rate = i + 1; |
| 574 | } | 627 | } |
| 575 | /* 1st `effect' in the chain is the input combiner_signal */ | 628 | |
| 576 | effp = sox_create_effect(input_combiner_effect_fn()); | 629 | effects_added++; |
| 577 | sox_add_effect(chain, effp, &signal, &ofile->ft->signal); | 630 | if (effects_added > chain->length) |
| | 631 | { |
| | 632 | /* 1st `effect' in the chain is the input combiner_signal */ |
| | 633 | effp = sox_create_effect(input_combiner_effect_fn()); |
| | 634 | sox_add_effect(chain, effp, &signal, &ofile->ft->signal); |
| | 635 | } |
| 578 | | 636 | |
| 579 | /* Add auto effects if appropriate; add user specified effects */ | 637 | /* Add auto effects if appropriate; add user specified effects */ |
| 580 | for (i = 0; i <= nuser_effects; i++) { | 638 | for (i = 0; i < nuser_effects; i++) { |
| 581 | /* If reducing channels, it's faster to do so before all other effects: */ | 639 | effects_added++; |
| 582 | if (signal.channels > ofile->ft->signal.channels && i >= min_chan) | 640 | if (effects_added > chain->length) |
| 583 | add_auto_effect(chain, "mixer", NULL, &signal); | 641 | { |
| 584 | | 642 | /* Effects chain should have displayed an error message */ |
| 585 | /* If reducing rate, it's faster to do so before all other effects | 643 | if (sox_add_effect(chain, user_efftab[i], |
| 586 | * (except reducing channels): */ | 644 | &signal, &ofile->ft->signal) != SOX_SUCCESS) |
| 587 | if (signal.rate > ofile->ft->signal.rate && i >= min_rate) | | |
| 588 | add_auto_effect(chain, "rate", rate_arg, &signal); | | |
| 589 | | | |
| 590 | if (i < nuser_effects) | | |
| 591 | if (sox_add_effect(chain, user_efftab[i], &signal, &ofile->ft->signal) != SOX_SUCCESS) | | |
| 592 | exit(2); | 645 | exit(2); |
| | 646 | } |
| | 647 | else |
| | 648 | /* Since already added from previous pass, free the extra copy |
| | 649 | * created this pass. |
| | 650 | */ |
| | 651 | sox_delete_effect(user_efftab[i]); |
| 593 | } | 652 | } |
| | 653 | |
| 594 | /* Add auto effects if still needed at this point */ | 654 | /* Add auto effects if still needed at this point */ |
| 595 | if (signal.rate != ofile->ft->signal.rate) | 655 | if (signal.rate != ofile->ft->signal.rate) |
| 596 | add_auto_effect(chain, "rate", rate_arg, &signal); /* Must be up-sampling */ | 656 | { |
| | 657 | effects_added++; |
| | 658 | if (effects_added > chain->length) |
| | 659 | add_effect(chain, "rate", rate_arg != NULL, &rate_arg, &signal); /* Must be up-sampling */ |
| | 660 | } |
| 597 | if (signal.channels != ofile->ft->signal.channels) | 661 | if (signal.channels != ofile->ft->signal.channels) |
| 598 | add_auto_effect(chain, "mixer", NULL, &signal); /* Must be increasing channels */ | 662 | { |
| 599 | | 663 | effects_added++; |
| 600 | /* Last `effect' in the chain is the output file */ | 664 | if (effects_added > chain->length) |
| 601 | effp = sox_create_effect(output_effect_fn()); | 665 | add_effect(chain, "mixer", 0, NULL, &signal); /* Must be increasing channels */ |
| 602 | if (sox_add_effect(chain, effp, &signal, &ofile->ft->signal) != SOX_SUCCESS) | 666 | } |
| 603 | exit(2); | 667 | |
| | 668 | effects_added++; |
| | 669 | if (effects_added > chain->length) |
| | 670 | { |
| | 671 | /* Last `effect' in the chain is the output file */ |
| | 672 | effp = sox_create_effect(output_effect_fn()); |
| | 673 | if (sox_add_effect(chain, effp, &signal, &ofile->ft->signal) != SOX_SUCCESS) |
| | 674 | exit(2); |
| | 675 | } |
| 604 | | 676 | |
| 605 | for (i = 0; i < chain->length; ++i) { | 677 | for (i = 0; i < chain->length; ++i) { |
| 606 | sox_effect_t const * effp = &chain->effects[i][0]; | 678 | sox_effect_t const * effp = &chain->effects[i][0]; |
| @@ -616,7 +688,7 @@ static size_t total_clips(void) · 9 unmodified lines |
| 616 | size_t clips = 0; | 688 | size_t clips = 0; |
| 617 | for (i = 0; i < file_count; ++i) | 689 | for (i = 0; i < file_count; ++i) |
| 618 | clips += files[i]->ft->clips + files[i]->volume_clips; | 690 | clips += files[i]->ft->clips + files[i]->volume_clips; |
| 619 | return clips + mixing_clips + sox_effects_clips(&ofile_effects_chain); | 691 | return clips + mixing_clips + sox_effects_clips(effects_chain); |
| 620 | } | 692 | } |
| 621 | | 693 | |
| 622 | static sox_bool since(struct timeval * then, double secs, sox_bool always_reset) | 694 | static sox_bool since(struct timeval * then, double secs, sox_bool always_reset) |
| @@ -711,15 +783,15 @@ static void optimize_trim(void) · 88 unmodified lines |
| 711 | * to do it for multiple files is complex and problably never used. This | 783 | * to do it for multiple files is complex and problably never used. This |
| 712 | * hack is a huge time savings when trimming gigs of audio data into | 784 | * hack is a huge time savings when trimming gigs of audio data into |
| 713 | * managable chunks. */ | 785 | * managable chunks. */ |
| 714 | if (input_count == 1 && ofile_effects_chain.length > 1 && strcmp(ofile_effects_chain.effects[1][0].handler.name, "trim") == 0) { | 786 | if (input_count == 1 && effects_chain->length > 1 && strcmp(effects_chain->effects[1][0].handler.name, "trim") == 0) { |
| 715 | if (files[0]->ft->handler.seek && files[0]->ft->seekable){ | 787 | if (files[0]->ft->handler.seek && files[0]->ft->seekable){ |
| 716 | size_t offset = sox_trim_get_start(&ofile_effects_chain.effects[1][0]); | 788 | size_t offset = sox_trim_get_start(&effects_chain->effects[1][0]); |
| 717 | if (offset && sox_seek(files[0]->ft, offset, SOX_SEEK_SET) == SOX_SUCCESS) { | 789 | if (offset && sox_seek(files[0]->ft, offset, SOX_SEEK_SET) == SOX_SUCCESS) { |
| 718 | read_wide_samples = offset / files[0]->ft->signal.channels; | 790 | read_wide_samples = offset / files[0]->ft->signal.channels; |
| 719 | /* Assuming a failed seek stayed where it was. If the seek worked then | 791 | /* Assuming a failed seek stayed where it was. If the seek worked then |
| 720 | * reset the start location of trim so that it thinks user didn't | 792 | * reset the start location of trim so that it thinks user didn't |
| 721 | * request a skip. */ | 793 | * request a skip. */ |
| 722 | sox_trim_clear_start(&ofile_effects_chain.effects[1][0]); | 794 | sox_trim_clear_start(&effects_chain->effects[1][0]); |
| 723 | sox_debug("optimize_trim successful"); | 795 | sox_debug("optimize_trim successful"); |
| 724 | } | 796 | } |
| 725 | } | 797 | } |
| @@ -851,10 +923,24 @@ static void sigint(int s) · 125 unmodified lines |
| 851 | else user_abort = sox_true; | 923 | else user_abort = sox_true; |
| 852 | } | 924 | } |
| 853 | | 925 | |
| 854 | static void calculate_combiner_and_output_signal_parameters(void) | 926 | static void calculate_combiner_signal_parameters(void) |
| 855 | { | 927 | { |
| 856 | sox_bool known_length = combine_method != sox_sequence; | 928 | size_t i; |
| 857 | size_t i, olen = 0; | 929 | |
| | 930 | /* If user didn't specify # of channels then see if an effect |
| | 931 | * is specifying them. This is of most use currently with the |
| | 932 | * synth effect were user can use null input handler and specify |
| | 933 | * channel counts directly in effect. Forcing to use -c with |
| | 934 | * -n isn't as convenient. |
| | 935 | */ |
| | 936 | for (i = 0; i < input_count; i++) { |
| | 937 | unsigned j; |
| | 938 | for (j =0; j < nuser_effects && !files[i]->ft->signal.channels; ++j) |
| | 939 | files[i]->ft->signal.channels = user_efftab[j]->in_signal.channels; |
| | 940 | /* For historical reasons, default to one channel if not specified. */ |
| | 941 | if (!files[i]->ft->signal.channels) |
| | 942 | files[i]->ft->signal.channels = 1; |
| | 943 | } |
| 858 | | 944 | |
| 859 | /* Set the combiner output signal attributes to those of the 1st/next input | 945 | /* Set the combiner output signal attributes to those of the 1st/next input |
| 860 | * file. If we are in sox_sequence mode then we don't need to check the | 946 | * file. If we are in sox_sequence mode then we don't need to check the |
| @@ -884,11 +970,6 @@ static void calculate_combiner_and_output_signal_parameters(void) · 23 unmodified lines |
| 884 | max_channels = max(max_channels, files[i]->ft->signal.channels); | 970 | max_channels = max(max_channels, files[i]->ft->signal.channels); |
| 885 | min_rate = min(min_rate , files[i]->ft->signal.rate); | 971 | min_rate = min(min_rate , files[i]->ft->signal.rate); |
| 886 | max_rate = max(max_rate , files[i]->ft->signal.rate); | 972 | max_rate = max(max_rate , files[i]->ft->signal.rate); |
| 887 | known_length = known_length && files[i]->ft->signal.length != 0; | | |
| 888 | if (combine_method == sox_concatenate) | | |
| 889 | olen += files[i]->ft->signal.length / files[i]->ft->signal.channels; | | |
| 890 | else | | |
| 891 | olen = max(olen, files[i]->ft->signal.length / files[i]->ft->signal.channels); | | |
| 892 | } | 973 | } |
| 893 | | 974 | |
| 894 | /* Check for invalid/unusual rate or channel combinations: */ | 975 | /* Check for invalid/unusual rate or channel combinations: */ |
| @@ -910,6 +991,27 @@ static void calculate_combiner_and_output_signal_parameters(void) · 15 unmodified lines |
| 910 | combine_method == sox_merge? total_channels : max_channels; | 991 | combine_method == sox_merge? total_channels : max_channels; |
| 911 | } | 992 | } |
| 912 | | 993 | |
| | 994 | /* Now take account of any net speed change specified by user effects by |
| | 995 | * adjusting the nominal sample rate at the output of the combiner: */ |
| | 996 | combiner_signal.rate *= sox_effects_globals.speed; |
| | 997 | |
| | 998 | } /* calculate_combiner_signal_parameters */ |
| | 999 | |
| | 1000 | static void calculate_output_signal_parameters(void) |
| | 1001 | { |
| | 1002 | sox_bool known_length = combine_method != sox_sequence; |
| | 1003 | size_t i, olen = 0; |
| | 1004 | |
| | 1005 | /* Report all input files and gather info on differing rates & numbers of |
| | 1006 | * channels, and on the resulting output audio length: */ |
| | 1007 | for (i = 0; i < input_count; i++) { |
| | 1008 | known_length = known_length && files[i]->ft->signal.length != 0; |
| | 1009 | if (combine_method == sox_concatenate) |
| | 1010 | olen += files[i]->ft->signal.length / files[i]->ft->signal.channels; |
| | 1011 | else |
| | 1012 | olen = max(olen, files[i]->ft->signal.length / files[i]->ft->signal.channels); |
| | 1013 | } |
| | 1014 | |
| 913 | /* Determine the output file signal attributes; set from user options | 1015 | /* Determine the output file signal attributes; set from user options |
| 914 | * if given: */ | 1016 | * if given: */ |
| 915 | ofile->signal = ofile_signal_options; | 1017 | ofile->signal = ofile_signal_options; |
| @@ -928,10 +1030,6 @@ static void calculate_combiner_and_output_signal_parameters(void) · 12 unmodified lines |
| 928 | /* FIXME: comment this: */ | 1030 | /* FIXME: comment this: */ |
| 929 | ofile->signal.precision = combiner_signal.precision; | 1031 | ofile->signal.precision = combiner_signal.precision; |
| 930 | | 1032 | |
| 931 | /* Now take account of any net speed change specified by user effects by | | |
| 932 | * adjusting the nominal sample rate at the output of the combiner: */ | | |
| 933 | combiner_signal.rate *= sox_effects_globals.speed; | | |
| 934 | | | |
| 935 | /* If any given user effect modifies the audio length, then we assume that | 1033 | /* If any given user effect modifies the audio length, then we assume that |
| 936 | * we don't know what the output length will be. FIXME: in most cases, | 1034 | * we don't know what the output length will be. FIXME: in most cases, |
| 937 | * an effect that modifies length will be able to determine by how much from | 1035 | * an effect that modifies length will be able to determine by how much from |
| @@ -971,28 +1069,26 @@ static void set_combiner_and_output_encoding_parameters(void) · 33 unmodified lines |
| 971 | | 1069 | |
| 972 | static int process(void) | 1070 | static int process(void) |
| 973 | { /* Input(s) -> Balancing -> Combiner -> Effects -> Output */ | 1071 | { /* Input(s) -> Balancing -> Combiner -> Effects -> Output */ |
| 974 | unsigned i; | | |
| 975 | int flow_status; | 1072 | int flow_status; |
| 976 | | 1073 | |
| 977 | for (i = 0; i < nuser_effects; ++i) | 1074 | create_user_effects(); |
| 978 | *user_efftab[i] = efftab_options[i]; | | |
| 979 | | 1075 | |
| 980 | calculate_combiner_and_output_signal_parameters(); | 1076 | calculate_combiner_signal_parameters(); |
| 981 | set_combiner_and_output_encoding_parameters(); | 1077 | set_combiner_and_output_encoding_parameters(); |
| 982 | open_output_file(); | | |
| 983 | | 1078 | |
| 984 | ofile_effects_chain.length = 0; | 1079 | calculate_output_signal_parameters(); |
| | 1080 | open_output_file(); |
| 985 | | 1081 | |
| 986 | ofile_effects_chain.global_info = sox_effects_globals; | 1082 | if (!effects_chain) |
| 987 | ofile_effects_chain.in_enc = &combiner_encoding; | 1083 | effects_chain = sox_create_effects_chain(&combiner_encoding, |
| 988 | ofile_effects_chain.out_enc = &ofile->ft->encoding; | 1084 | &ofile->ft->encoding); |
| 989 | add_effects(&ofile_effects_chain); | 1085 | add_effects(effects_chain); |
| 990 | | 1086 | |
| 991 | optimize_trim(); | 1087 | optimize_trim(); |
| 992 | | 1088 | |
| 993 | signal(SIGTERM, sigint); /* Stop gracefully, as soon as we possibly can. */ | 1089 | signal(SIGTERM, sigint); /* Stop gracefully, as soon as we possibly can. */ |
| 994 | signal(SIGINT , sigint); /* Either skip current input or behave as SIGTERM. */ | 1090 | signal(SIGINT , sigint); /* Either skip current input or behave as SIGTERM. */ |
| 995 | flow_status = sox_flow_effects(&ofile_effects_chain, update_status); | 1091 | flow_status = sox_flow_effects(effects_chain, update_status); |
| 996 | | 1092 | |
| 997 | /* When in sox_multiple mode, changing to a new output file is | 1093 | /* When in sox_multiple mode, changing to a new output file is |
| 998 | * based on effects return ST_EOF. In that case, don't return | 1094 | * based on effects return ST_EOF. In that case, don't return |
| @@ -1674,7 +1770,6 @@ static void parse_options_and_filenames(int argc, char **argv) · 675 unmodified lines |
| 1674 | static void parse_effects(int argc, char **argv) | 1770 | static void parse_effects(int argc, char **argv) |
| 1675 | { | 1771 | { |
| 1676 | for (nuser_effects = 0; optind < argc; ++nuser_effects) { | 1772 | for (nuser_effects = 0; optind < argc; ++nuser_effects) { |
| 1677 | sox_effect_t * e; | | |
| 1678 | int i; | 1773 | int i; |
| 1679 | | 1774 | |
| 1680 | if (nuser_effects >= MAX_USER_EFF) { | 1775 | if (nuser_effects >= MAX_USER_EFF) { |
| @@ -1683,17 +1778,12 @@ static void parse_effects(int argc, char **argv) · 2 unmodified lines |
| 1683 | } | 1778 | } |
| 1684 | | 1779 | |
| 1685 | /* Name should always be correct! */ | 1780 | /* Name should always be correct! */ |
| 1686 | e = sox_create_effect(sox_find_effect(argv[optind++])); | 1781 | user_effargs[nuser_effects].name = strdup(argv[optind++]); |
| 1687 | | 1782 | for (i = 0; i < argc - optind && !sox_find_effect(argv[optind + i]); ++i) |
| 1688 | for (i = 0; i < argc - optind && !sox_find_effect(argv[optind + i]); ++i); | 1783 | user_effargs[nuser_effects].argv[i] = strdup(argv[optind + i]); |
| 1689 | if (e->handler.getopts(e, i, &argv[optind]) == SOX_EOF) | 1784 | user_effargs[nuser_effects].argc = i; |
| 1690 | exit(1); /* The failing effect should have displayed an error message */ | | |
| 1691 | | 1785 | |
| 1692 | optind += i; /* Skip past the effect arguments */ | 1786 | optind += i; /* Skip past the effect arguments */ |
| 1693 | | | |
| 1694 | if (e->handler.flags & SOX_EFF_DEPRECATED) | | |
| 1695 | sox_warn("effect `%s' is deprecated; see soxeffect(7) for an alternative", e->handler.name); | | |
| 1696 | user_efftab[nuser_effects] = e; | | |
| 1697 | } | 1787 | } |
| 1698 | } | 1788 | } |
| 1699 | | 1789 | |
| @@ -1898,15 +1988,6 @@ int main(int argc, char **argv) · 198 unmodified lines |
| 1898 | exit(0); | 1988 | exit(0); |
| 1899 | } | 1989 | } |
| 1900 | | 1990 | |
| 1901 | /* Bit of a hack: input files can get # of chans from an effect */ | | |
| 1902 | for (i = 0; i < input_count; i++) { | | |
| 1903 | unsigned j; | | |
| 1904 | for (j =0; j < nuser_effects && !files[i]->ft->signal.channels; ++j) | | |
| 1905 | files[i]->ft->signal.channels = user_efftab[j]->in_signal.channels; | | |
| 1906 | if (!files[i]->ft->signal.channels) | | |
| 1907 | ++files[i]->ft->signal.channels; | | |
| 1908 | } | | |
| 1909 | | | |
| 1910 | if (sox_globals.repeatable) | 1991 | if (sox_globals.repeatable) |
| 1911 | sox_debug("Not reseeding PRNG; randomness is repeatable"); | 1992 | sox_debug("Not reseeding PRNG; randomness is repeatable"); |
| 1912 | else { | 1993 | else { |
| @@ -1920,8 +2001,6 @@ int main(int argc, char **argv) · 7 unmodified lines |
| 1920 | * block of input files. Also used by sox_multiple output mode. */ | 2001 | * block of input files. Also used by sox_multiple output mode. */ |
| 1921 | ofile_signal_options = ofile->signal; | 2002 | ofile_signal_options = ofile->signal; |
| 1922 | ofile_encoding_options = ofile->encoding; | 2003 | ofile_encoding_options = ofile->encoding; |
| 1923 | for (i = 0; i < nuser_effects; ++i) | | |
| 1924 | efftab_options[i] = *user_efftab[i]; | | |
| 1925 | | 2004 | |
| 1926 | if (combine_method == sox_sequence || output_method == sox_multiple) do { | 2005 | if (combine_method == sox_sequence || output_method == sox_multiple) do { |
| 1927 | /* If ofile->ft is set then we've called this at least once. | 2006 | /* If ofile->ft is set then we've called this at least once. |
| @@ -1935,16 +2014,29 @@ int main(int argc, char **argv) · 7 unmodified lines |
| 1935 | * If input reached EOF then restart all effects. | 2014 | * If input reached EOF then restart all effects. |
| 1936 | */ | 2015 | */ |
| 1937 | if (output_method == sox_multiple && !input_eof) | 2016 | if (output_method == sox_multiple && !input_eof) |
| 1938 | /* FIXME: Make a function that does that */ | 2017 | { |
| 1939 | ; | 2018 | size_t e; |
| 1940 | else if (output_method == sox_multiple) | 2019 | |
| 1941 | sox_delete_effects(&ofile_effects_chain); | 2020 | /* Scan backwards until data is found and do not free input effect */ |
| | 2021 | for (e = effects_chain->length-1; e > 0; --e) |
| | 2022 | { |
| | 2023 | if (effects_chain->effects[e]->obeg != |
| | 2024 | effects_chain->effects[e]->oend) |
| | 2025 | break; |
| | 2026 | sox_delete_effect(effects_chain->effects[e]); |
| | 2027 | effects_chain->effects[e] = NULL; |
| | 2028 | effects_chain->length--; |
| | 2029 | } |
| | 2030 | } |
| | 2031 | else |
| | 2032 | sox_delete_effects(effects_chain); |
| 1942 | sox_close(ofile->ft); | 2033 | sox_close(ofile->ft); |
| 1943 | ofile->ft = NULL; | 2034 | ofile->ft = NULL; |
| 1944 | } | 2035 | } |
| 1945 | } while (process() != SOX_EOF && !user_abort && current_input < input_count); | 2036 | } while (process() != SOX_EOF && !user_abort && current_input < input_count); |
| 1946 | else process(); | 2037 | else process(); |
| 1947 | sox_delete_effects(&ofile_effects_chain); | 2038 | |
| | 2039 | sox_delete_effects_chain(effects_chain); |
| 1948 | | 2040 | |
| 1949 | for (i = 0; i < file_count; ++i) | 2041 | for (i = 0; i < file_count; ++i) |
| 1950 | if (files[i]->ft->clips != 0) | 2042 | if (files[i]->ft->clips != 0) |