Some advice needed in regards to namespaces and class library


#1

Hi JUCE folk.

I’m wondering if any other senior C++ warriors around can help me out with choosing the best way to put together some header files and namespaces.

I’m currently writing a plugin which acts as an evaluation tool for different methods applied to real-time audio classification/machine listening.

Part of this plugin could be useful for future use and for others using JUCE interesting in machine listening/computer audition.

So, my issue.

I have a class - AudioClassifier which uses another class internally - OnsetDetector.

Each of these classes exist in separate headers within their own sub-folders of the AudioClassify library. However both of these classes also use a set of enum classes for configuration options which reside in a struct AudioClassifyOptions. The folder structure is below.

AudioClassify/
AudioClassifyOptions/
AudioClassifyOptions.h
AudioClassifier/
AudioClassifier.cpp
AudioClassifier.h
OnsetDetector/
OnsetDetector.cpp
OnsetDetector.h
AudioClassify.h

I want myself and end users of the code to be able to simply include AudioClassify.h, instantiate an object of type AudioClassfier and go off on their merry way calling things like:

int audioClassLabel = myAudioClassifier->classifyAudioFrame(T frame);*

The user also needs to be able to reference the enum class options like so:

myAudioClassifier->setClassifierType(AudioClassifyOptions::ClassifierType::naiveBayes);

At the moment this is working OK but it seems a little naive. Can anyone offer advice as to what might be the best way to lay things out ? I’m wondering whether creating a namespace to wrap everything under is the best option however it introduces further complexity as these classes are all template classes and I require some brushing up on my knowledge of namespaces and modular library layouts.

Any help would be most appreciated. Hoping to carve out the AudioClassify library when done and make it a public repo for people to mess around with.

Cheers

Josh


#2

Errr…

Clearly not fluent with the new forum…how do you keep indentation/tabs ? I did try to tab out that folder structure.