# Cannot open source file BinaryData.h

**URL:** <https://forum.juce.com/t/cannot-open-source-file-binarydata-h/64818>\
**Category:** Development\
**Created:** [January 7, 2025, 2:12pm UTC](https://forum.juce.com/t/cannot-open-source-file-binarydata-h/64818 "2025-01-07T14:12:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguelreid](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@miguelreid](https://forum.juce.com/u/miguelreid)\
**Post date:** [January 7, 2025, 2:12pm UTC](https://forum.juce.com/t/cannot-open-source-file-binarydata-h/64818/1 "2025-01-07T14:12:16Z")

</div>

Hi there, sorry if this is a basic question but just starting with JUCE. I’m developing a synth and have included the different samples as BinaryData in Projucer. I have enabled the BinaryData namespace and included it in the JuceHeader all in the Projucer. I’m trying different ways to load all of my samples in a neat and clean way instead of individually one by one. My idea was to do something like the following however I can’t include BinaryData.h or nor is it recognised if I don’t include it. The error when using BinaryData is “name followed by :: must be a class or a namespace name” which supposedly should be a namespace as set in the projucer. This is my code if anyone can help me, thank you very much in advance.

```auto
SampleLoader::SampleLoader(juce::AudioFormatManager& fm) : formatManager(fm) {}

void SampleLoader::loadSamples(juce::Synthesiser& synthesiser)
{
    for (int midiNote = 21; midiNote <= 108; ++midiNote)
    {
        juce::String fileName = "note" + juce::String(midiNote) + ".wav";

        if (auto* data = BinaryData::getNamedResource(fileName.toRawUTF8(), fileName.length()))
        {
            auto size = BinaryData::getNamedResourceSize(fileName.toRawUTF8());
            auto inputStream = std::make_unique<juce::MemoryInputStream>(data, size, false);
            std::unique_ptr<juce::AudioFormatReader> formatReader(formatManager.createReaderFor(std::move(inputStream)));

            if (formatReader != nullptr)
            {
                juce::BigInteger allNotes;
                allNotes.setBit(midiNote);
                synthesiser.addSound(new juce::SamplerSound("Sample",
                    *formatReader,
                    allNotes,
                    midiNote,
                    0.1,
                    0.1,
                    10.0));
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![ibisum](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ibisum/32/21288_2.png) [@ibisum](https://forum.juce.com/u/ibisum)\
**Post date:** [January 7, 2025, 2:21pm UTC](https://forum.juce.com/t/cannot-open-source-file-binarydata-h/64818/2 "2025-01-07T14:21:20Z")

</div>

Answered, recently, here:

> [@How to embed .wav files in a executable](https://forum.juce.com/t/how-to-embed-wav-files-in-a-executable/64810):
>
> Hey guys i am trying to build a MIDI sampler. I am quite new to JUCE and to understand it i am trying to run the examples (examples/Audio/AudioSynthesizerDemo.h), i see this project has a functionality to either play from a sampled sound or a pure sine wave. The sampled sound is located in examples/Assets/cello.wav. Now i have a few wav samples i want to “relate/assign” to different keys. How could it so when built the samples are already included? Any tips or guidance is more than welcome! Than…

However, this aspect leaves me with a question:

> I have enabled the BinaryData namespace and included it in the JuceHeader all in the Projucer.

Did you save and re-generate your project in the Projucer? This is where BinaryData.h/.cpp gets updated with the new contents. You don’t have to do anything manual (besides **#include “BinaryData.h”** ) … but you should be sure to renerate after adding a resource in Projucer (and marking it as 'included in Binary Resources") …

---

<div class="post-metadata">

**Author:** ![miguelreid](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@miguelreid](https://forum.juce.com/u/miguelreid)\
**Post date:** [January 7, 2025, 4:42pm UTC](https://forum.juce.com/t/cannot-open-source-file-binarydata-h/64818/3 "2025-01-07T16:42:36Z")

</div>

It looks like the sample I had was deleted by trying out different things and I forgot to include it again, then the BinaryData is not recognised if there aren’t any binary resources within the folder. Thank you very much for the quick reply! I’m working on my dissertation right now so you’ll probably see me a lot around here 🙂
