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:
parent
83f7aa87f0
commit
7895b5ec7e
|
@ -66,8 +66,22 @@ Mono_Pan_Module::handle_sample_rate_change ( nframes_t n )
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -81,9 +95,12 @@ void
|
|||
Mono_Pan_Module::process ( nframes_t nframes )
|
||||
{
|
||||
if ( unlikely( bypass() ) )
|
||||
{
|
||||
if ( audio_input.size() == 1 )
|
||||
{
|
||||
buffer_copy( (sample_t*)audio_output[1].buffer(), (sample_t*)audio_input[0].buffer(), nframes );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const float gt = (control_input[0].control_value() + 1.0f) * 0.5f;
|
||||
|
@ -91,10 +108,17 @@ Mono_Pan_Module::process ( nframes_t nframes )
|
|||
sample_t gainbuf[nframes];
|
||||
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 ) )
|
||||
{
|
||||
/* right channel */
|
||||
|
||||
buffer_copy_and_apply_gain_buffer( (sample_t*)audio_output[1].buffer(),
|
||||
(sample_t*)audio_input[0].buffer(),
|
||||
gainbuf,
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
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 );
|
||||
|
||||
LOG_CREATE_FUNC( Mono_Pan_Module );
|
||||
|
|
Loading…
Reference in New Issue