Mixer: Allow Mono Pan module to be added a stereo chain. This converts the signal to mono and then pans the result. Useful for auditioning a mix in mono.

This commit is contained in:
Jonathan Moore Liles 2020-10-11 23:16:26 -07:00
parent 83f7aa87f0
commit 7895b5ec7e
2 changed files with 30 additions and 6 deletions

View File

@ -66,8 +66,22 @@ Mono_Pan_Module::handle_sample_rate_change ( nframes_t n )
} }
bool bool
Mono_Pan_Module::configure_inputs ( int ) Mono_Pan_Module::configure_inputs ( int n )
{ {
THREAD_ASSERT( UI );
int on = audio_input.size();
if ( n > on )
{
add_port( Port( this, Port::INPUT, Port::AUDIO ) );
}
else if ( n < on )
{
audio_input.back().disconnect();
audio_input.pop_back();
}
return true; return true;
} }
@ -82,7 +96,10 @@ Mono_Pan_Module::process ( nframes_t nframes )
{ {
if ( unlikely( bypass() ) ) if ( unlikely( bypass() ) )
{ {
buffer_copy( (sample_t*)audio_output[1].buffer(), (sample_t*)audio_input[0].buffer(), nframes ); if ( audio_input.size() == 1 )
{
buffer_copy( (sample_t*)audio_output[1].buffer(), (sample_t*)audio_input[0].buffer(), nframes );
}
} }
else else
{ {
@ -90,11 +107,18 @@ Mono_Pan_Module::process ( nframes_t nframes )
sample_t gainbuf[nframes]; sample_t gainbuf[nframes];
bool use_gainbuf = smoothing.apply( gainbuf, nframes, gt ); bool use_gainbuf = smoothing.apply( gainbuf, nframes, gt );
if ( audio_input.size() == 2 )
{
/* convert stereo to mono */
buffer_mix( (sample_t*)audio_input[0].buffer(),
(sample_t*)audio_input[1].buffer(),
nframes );
}
if ( unlikely( use_gainbuf ) ) if ( unlikely( use_gainbuf ) )
{ {
/* right channel */ /* right channel */
buffer_copy_and_apply_gain_buffer( (sample_t*)audio_output[1].buffer(), buffer_copy_and_apply_gain_buffer( (sample_t*)audio_output[1].buffer(),
(sample_t*)audio_input[0].buffer(), (sample_t*)audio_input[0].buffer(),
gainbuf, gainbuf,

View File

@ -33,7 +33,7 @@ public:
const char *name ( void ) const { return "Mono Pan"; } const char *name ( void ) const { return "Mono Pan"; }
int can_support_inputs ( int n ) { return ( n == 1 ) ? 2 : -1; } int can_support_inputs ( int n ) { return ( n == 1 || n == 2 ) ? 2 : -1; }
bool configure_inputs ( int n ); bool configure_inputs ( int n );
LOG_CREATE_FUNC( Mono_Pan_Module ); LOG_CREATE_FUNC( Mono_Pan_Module );