Phasing in mono plugin

Hi all,
I have a phasing problem when i try to run my plugin in mono mode.
I tested it in Logic Pro.When it is stereo, everything is fine. But once i switch to mono, it adds 3.3dB to volume and also a phasing problem occurs. In my isBusesLayoutSupported section i try to support both mono and stereo but looks like something else happens in mono. It is possible that Daw is doing something to it ?

 #ifndef JucePlugin_PreferredChannelConfigurations

 bool AudioProcessor::isBusesLayoutSupported( const BusesLayout& layouts) 
 const

{

 #if JucePlugin_IsMidiEffect

ignoreUnused(layouts);

return  true ;

#else

// This is the place where you check if the layout is supported.

// In this template code we only support mono or stereo.

if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()

&& layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())

return false;

 // This checks if the input layout matches the output layout

 #if ! JucePlugin_IsSynth

 if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())

 return false ;

 #endif

 return true ;

 #endif

 }

 #endif

Thanks in advance

I don’t think this is where the issue lies. It’s more likely in your processBlock() code. You can see in Logic if there are one or two output meters, which would tell you if you were actually using mono-to-stereo instead of mono-to-mono.

Thank you for your answer. I checked it.
When i put in a mono track, output is also mono,
When i put in a stereo track, ouput is stereo.
When i put in a dual-mono track, output is also dual-mono,
I cannot see any problem with that. The thing is in my processBlock i don’t try to change the number of channels. I iterates through the channels but i take the number of the channels from the totalNumInputChannels variable. If it is mono it will iterate only once, if it is stereo , it will iterate twice.
Of course it is not easy to spot the problem without checking everything but i thought maybe some else had this problem before. Because it works perfectly when it is stereo.

for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
      processmydata( channel, buffer);  // this section has been editted
}

Your code within the loop doesn’t appear to be affected by the “channel” variable as you are just passing the buffer as a whole to whatever function your process my data function is - you will actually just be processing the same stuff a different amount of times. I guess you need to look within that function and remove the loop.

Is processmydata stateful in some way, e.g. does it use filters or does it contain compression algorithms? If so, you need a separate instance per channel of each stateful element

Sorry i was just trying to show that i am taking the number of the channel from the framework :slight_smile: i don’t use a hard-coded value. I just fix it in post above. Let me show you my whole code structure:

 void AudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& 
 midiMessages)
 {
ScopedNoDenormals noDenormals;
const int totalNumInputChannels = getTotalNumInputChannels();
const int totalNumOutputChannels = getTotalNumOutputChannels();

for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
	buffer.clear (i, 0, buffer.getNumSamples());

// i know instead of this method, i could have used copiedbuffer.makeCopyOf(buffer);
// i just want to show you my structure. I use this structure for all methods. 
//  first i iterate through the first channel then i process 512 samples then iterate through second (if it exists) and process the second 512 samples block 
   copyInput(buffer);


 }




void AudioProcessor::copyInput(AudioBuffer<float> &buffer)
  {

// Channel processing
for (int channel = 0; channel < buffer.getNumChannels(); ++channel)
      {

         for (int sample = 0; sample < buffer.getNumSamples(); sample++)
              {
             copiedBuffer.addSample(channel, sample, buffer.getSample(channel, sample));
              }
      }

   }

I disabled my modules one by one. I found out that it is because my output section. It can’t deal with mono properly.