# Having some trouble setting BinaryData wav file to stereo

**URL:** https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614
**Category:** General JUCE discussion
**Created:** [November 5, 2021, 4:21pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614 "2021-11-05T16:21:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Donovan](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Donovan](https://forum.juce.com/u/Donovan)
#### Post date: [November 5, 2021, 4:21pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/1 "2021-11-05T16:21:51Z")

</div>

Hi everyone,  
I’m having some issues there… I’m playing fixed Binary stereo files

constructor

```auto
auto reader = formatManager.createReaderFor(std::make_unique<juce::MemoryInputStream>(BinaryData::Test7_wav, BinaryData::Test7_wavSize, true));

	if (reader != nullptr)
	{
		newSource = new juce::AudioFormatReaderSource(reader, true);
		newSource->setLooping(true);
	}
auto reader2 = formatManager.createReaderFor(std::make_unique<juce::MemoryInputStream>(BinaryData::Test8_wav, BinaryData::Test8_wavSize, true));

	if (reader != nullptr)
	{
		newSource2 = new juce::AudioFormatReaderSource(reader, true);
		newSource2->setLooping(true);
	}

```

```auto
void FXAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
	
	juce::ScopedNoDenormals noDenormals;
	auto totalNumInputChannels = getTotalNumInputChannels();
	auto totalNumOutputChannels = getTotalNumOutputChannels();

	for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
		buffer.clear(i, 0, buffer.getNumSamples());
	
	juce::AudioSourceChannelInfo info(&mixBuffer, 0, buffer.getNumSamples());
	
	newSource->getNextAudioBlock(info);
	for (int c = 0; c < std::min(mixBuffer.getNumChannels(), buffer.getNumChannels()); ++c)
		buffer.addFrom(0, c, mixBuffer.getReadPointer(c), buffer.getNumSamples());

	}

```

```auto
void FXAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
{
	mixBuffer.setSize(2, samplesPerBlock);
}

```

now everything plays fine but only to the left channel… would anybody notice what i do wrong ? been struggling for days with no clue thanks a lot!

---

<div class="post-metadata">

### Author: ![timart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timart/32/1119_2.png) [@timart](https://forum.juce.com/u/timart)
#### Post date: [November 5, 2021, 5:34pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/2 "2021-11-05T17:34:37Z")

</div>

Maybe try using the debugger.  
Look at the value of `totalNumInputChannels` and `totalNumOutputChannels` in `processBlock()` and make sure they are both 2 for stereo.  
Maybe you did not set your audio processor to have 2 channels for stereo?

---

<div class="post-metadata">

### Author: ![Donovan](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Donovan](https://forum.juce.com/u/Donovan)
#### Post date: [November 5, 2021, 5:49pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/3 "2021-11-05T17:49:51Z")

</div>

Thanks replying timart,  
wouldn’t that already make the fit?

```auto
void FXAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
	
	juce::ScopedNoDenormals noDenormals;
	auto totalNumInputChannels = getTotalNumInputChannels();
	auto totalNumOutputChannels = getTotalNumOutputChannels();

```

```auto
FXAudioProcessor::FXAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
	: AudioProcessor(BusesProperties()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
		.withInput("Input", juce::AudioChannelSet::stereo(), true)
#endif
		.withOutput("Output", juce::AudioChannelSet::stereo(), true)

```

---

<div class="post-metadata">

### Author: ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)
#### Post date: [November 5, 2021, 8:52pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/4 "2021-11-05T20:52:30Z")

</div>

The constructor arguments are merely a default. Which BusesLayout is chosen is the result of a negotiation where the host is calling isBusesLayoutSupported() to find out what your plugin supports.

---

<div class="post-metadata">

### Author: ![Donovan](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Donovan](https://forum.juce.com/u/Donovan)
#### Post date: [November 5, 2021, 9:08pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/5 "2021-11-05T21:08:45Z")

</div>

Thanks Daniel,  
If i understand well because of

```auto
bool FXAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
	juce::ignoreUnused(layouts);
	return true;
#else

	if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
		&& layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
		return false;

#if ! JucePlugin_IsSynth
	if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
		return false;
#endif

	return true;
#endif
}

```

the plugin should be working both mono and stereo?

---

<div class="post-metadata">

### Author: ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)
#### Post date: [November 5, 2021, 9:19pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/6 "2021-11-05T21:19:22Z")

</div>

It accepts everything except if output channelset is different from input channelset and if main output is neither mono nor stereo.

I don’t see it at the moment. Good luck

---

<div class="post-metadata">

### Author: ![Donovan](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Donovan](https://forum.juce.com/u/Donovan)
#### Post date: [November 5, 2021, 9:20pm UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/7 "2021-11-05T21:20:13Z")

</div>

> [@daniel](#):
>
> t accepts everything except if output cha

thanks a lot 😉

---

<div class="post-metadata">

### Author: ![Donovan](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Donovan](https://forum.juce.com/u/Donovan)
#### Post date: [November 7, 2021, 4:49am UTC](https://forum.juce.com/t/having-some-trouble-setting-binarydata-wav-file-to-stereo/48614/8 "2021-11-07T04:49:11Z")

</div>

```
buffer.addFrom(c, 0, mixBuffer.getReadPointer(c), buffer.getNumSamples(), calcul);
buffer.addFrom(0, c, mixBuffer.getReadPointer(c), buffer.getNumSamples(), calcul);

```

just got thoose to arguments mixed up my bad
