Hi, august wrote:
> The effect I want (for now at least until arbitrary mixing can be > done) is as follows: > > If I have 5 channel output, but an 8 channel input, I want the first 5 > channels to be passed to the first 5 channels of output and disregard > the last 3. > > If I have a 5 channel output, but a 3 channel input, I want > the 3 input channels to be passed to the first 3 output channels and > then disregard the final 2 out channels. > If you don't need mixing for now, you can try to trick gavl into thinking that the channel setups are equal: e.g. your 8->5 case could look like: gavl_audio_format_t tmp; gavl_audio_format_copy(&tmp, in_format); tmp.num_channels = 5; gavl_audio_converter_init(&tmp, &out_format); The 3 -> 5 channel case can become: gavl_audio_format_t tmp; gavl_audio_format_copy(&tmp, out_format); tmp.num_channels = 3; gavl_audio_converter_init(&in_format, &tmp); Of couse this works *only* for GAVL_INTERLEAVE_NONE and the frames are always allocated with the real formats. > do I set it up like this: > > channel_locations[0] =0; > channel_locations[1] =1; > . > . > channel_locations[x]=x; Wrong. > > or, do I set it up like this: > > for (int i=0;i<GAVL_MAX_CHANNELS;i++) > channel_locations[i]= GAVL_CHID_AUX; Right. > ahh, ok. funny that I didn't come up to this previously. Eventually, I > may be throwing GAVL_MAX_CHANNELS at it - maybe even more. GAVL_MAX_CHANNELS can be increased, but not arbitrarily. I don't want the gavl_audio_format_t to contain dynamically allocated memory for the channel IDs. >> Not yet, but it would be a nice feature. A clean way would be a public >> function: >> >> gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt, double ** >> matrix); >> >> where matrix[i][j] contains the factor for mixing input channel j to output >> channel i. > > ok. Factor is from 0.0 -> 1.0 I assume? Yes. In theory it can also become -1.0 for phase-inversed mixing. >> Internally, in gavl/mix.c there is a function init_matrix(), which could >> check >> if there is a predefined matrix. If you want you can play around with that. > > ok, I will look into that when I get a chance. > >> Also note, that the matrix is normalized by default such that the signal >> *never* clips (maximum coefficient sum of each matrix row must be one). >> Maybe you also want an option for disabling this. > > how about: > > gavl_audio_options_set_mix_matrix( > gavl_audio_options_t * opt, > double ** matrix, > bool normalize); If bool becomes an int, then yes (bool is not that portable). > I still get a segfault if I set channel_locations[] to GAVL_CHID_NONE. No wonder. > If I set them to GAVL_CHID_AUX, I get no audio. Trick the converter into assuming equal channel numbers like explained above. If that also doesn't work I'll look into that. Burkhard ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ Gmerlin-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gmerlin-general
