SilverSlide
SilverSlide

Reputation: 11

Juce implementing ResamplingAudioSource

I'm looking to oversample a signal which is inside a buffer in JUCE, running on visual basic. http://www.juce.com/about-juce

To be precise: by oversample, I mean increase the number of samples over the same amount of time. If the original file is at 44100 khz, for example, I would like the sample rate to increase to 88200khz. This is useful for attenuating any digital artefacts which may present in the signal.

From what I understand, Juce has a class for this: ResamplingAudioSource http://www.juce.com/api/classResamplingAudioSource.html#details My problem is that I do not know how to implement the class. I have tried creating a new instance of the class like so:

class PluginOversampler : public ResamplingAudioSource { public: PluginOversampler(); ~PluginOversampler();

void    setResamplingRatio (double samplesInPerOutputSample)

}

with the idea being that I can then call PluginOversampler::setResamplingRatio(specified ratio here) to change the resampling rate.

But the project will not compile in visual basic. The errors are numerous, numbering into the hundred. Some of them relate to a global variable string22 which I use throughout different .cpp and .h files

std::string string22 = "";

And when the resulting error is:

extern std::string string22;
1>c:\users\friendly2\downloads\final\ctrl\source\plugineditor.h(28): error     C2377:    'std::string' : redefinition; typedef cannot be overloaded with any other symbol

The project compiles fine when I omit the declaration of

  PluginOversampler : public ResamplingAudioSource

Other error messages suggest that the Juce header files do not define types correctly, but I think the errors have come from my own programming, not the Juce files, given that the program was working perfectly (the vst file works fine in a DAW) before I implemented this.

I have already instantiated another class:

class PluginAudioProcessor  : public PluginProcessor
{
public:
    //==============================================================================
    PluginWidthCtrlAudioProcessor();
    ~PluginWidthCtrlAudioProcessor();

...
...

}

Do I need to make the class 'PluginAudioProcessor' inherit the functions inside 'ResamplingAudioSource'? I am pretty lost.

Upvotes: 1

Views: 1574

Answers (2)

Marcus Müller
Marcus Müller

Reputation: 36337

To be precise: by oversample, I mean increase the number of samples over the same amount of time. If the original file is at 44100 khz, for example, I would like the sample rate to increase to 88200khz. This is useful for attenuating any digital artefacts which may present in the signal.

No, it's not.

This is basic signal theory: Nyquist holds. You can't do anything about it. Your signal has been digitized at 44.1kS/s once, and there's no way to get back the information that was lost during that process (protip: there's no information that was lost; humans can't physically perceive things with frequencies higher than 22.05kHz).

Now, it's completely reasonable to assume the sound card that produced that signal was not completely linear over the whole 0Hz - 22.05kHz spectrum. You can account for that by equalizing, but that's a whole different story. Usually, during that process, you use specially crafted digital filters on subbands, which themselves have lower bandwidth than your original signal, not higher. However, equalizing signals is a hard problem, and you'll need to estimate the characteristics of the digitizing system first -- which, I guess, is near impossible when you don't have the possibility to get a known reference signal into it.

EDIT: by the way, your error looks like you accidentially tried to re-typedef std::string (e.g. you did something like typedef mytype std::string instead of typedef std::string mytype).

Upvotes: 0

CGD
CGD

Reputation: 269

you can use #define DONT_SET_USING_JUCE_NAMESPACE

And you have to JUCE::ResamplingAudioSource or any other juice classes.

Most of the JUCE classes have already been defined in other libraries or in system libraries. This should help you in resolving most of the bugs.

Upvotes: 0

Related Questions