Skip to content

Commit

Permalink
try mono support
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdenButterfield committed Sep 3, 2023
1 parent 963608e commit 70aadbf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
3 changes: 0 additions & 3 deletions Source/MP3ControllerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ void MP3ControllerManager::processBlock(juce::AudioBuffer<float>& buffer)
// }
updateParameters();

if (buffer.getNumChannels() != 2) {
return;
}
auto samplesL = buffer.getWritePointer(0);
auto samplesR = buffer.getWritePointer(1);

Expand Down
46 changes: 29 additions & 17 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,8 @@ void MaimAudioProcessor::updateParameters()
setLatencySamples(currentLatencySamples());
}

void MaimAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
juce::MidiBuffer& midiMessages)
void MaimAudioProcessor::processBlockStereo (juce::AudioBuffer<float>& buffer)
{

if (parametersNeedUpdating) {
updateParameters();
}
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

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

dryWetMixer.pushDrySamples(buffer);

if (oldPreGain != preGain) {
Expand All @@ -327,7 +315,7 @@ void MaimAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
mp3ControllerManager.processBlock(buffer);
}

for (int i = 0; i < std::min(2, buffer.getNumSamples()); ++i) {
for (int i = 0; i < 2; ++i) {
auto samples = buffer.getWritePointer(i);
postFilterHi[i].processSamples(samples, buffer.getNumSamples());
postFilterLo[i].processSamples(samples, buffer.getNumSamples());
Expand All @@ -342,6 +330,31 @@ void MaimAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
dryWetMixer.mixWetSamples(buffer);
}

void MaimAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
juce::MidiBuffer& midiMessages)
{

if (parametersNeedUpdating) {
updateParameters();
}
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

for (auto i = std::min(totalNumInputChannels,2); i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
std::cout << totalNumInputChannels << " " << buffer.getNumChannels() << "\n";
if (totalNumInputChannels >= 2 && buffer.getNumChannels() >= 2) {
processBlockStereo(buffer);
} else if (totalNumInputChannels >= 1 && buffer.getNumChannels() >= 1) {
juce::AudioBuffer<float> stereoBuffer(2, buffer.getNumSamples());
stereoBuffer.copyFrom(0,0,buffer,0,0,buffer.getNumSamples());
stereoBuffer.copyFrom(1,0,buffer,0,0,buffer.getNumSamples());
processBlockStereo(stereoBuffer);
buffer.copyFrom(0,0,stereoBuffer,0,0,buffer.getNumSamples());
}
}

//==============================================================================
bool MaimAudioProcessor::hasEditor() const
{
Expand All @@ -356,7 +369,7 @@ juce::AudioProcessorEditor* MaimAudioProcessor::createEditor()
//==============================================================================
void MaimAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
{

auto state = parameters.copyState();
for (const juce::String parameterName : {"psychoanal", "mdct"}) {
auto s = state.getChildWithName(parameterName);
Expand All @@ -368,9 +381,8 @@ void MaimAudioProcessor::getStateInformation (juce::MemoryBlock& destData)
copyXmlToBinary (*xml, destData);
addPsychoanalStateToParameters();
addMdctSamplesToParameters();

}

}
void MaimAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
{

Expand Down
1 change: 1 addition & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class MaimAudioProcessor : public juce::AudioProcessor,
void parameterChanged (const juce::String &parameterID, float newValue) override;

private:
void processBlockStereo(juce::AudioBuffer<float>& buffer);
void addPsychoanalStateToParameters();
void addMdctSamplesToParameters();
int currentLatencySamples();
Expand Down

0 comments on commit 70aadbf

Please sign in to comment.