XCode Error with dsp Syntax


#1

My code complies and runs on VS2017, but wherever I use the odd dsp class syntax “chain<0>().” Xcode gives an “Expression Expected” error. I’ve set C++14 semantics. Have I missed something?


#2

By the way, I am on OSX High Sierra 10.13.3 and Xcode 9.2, compiling for 64bit.

I use Xcode only for my OSX builds, so I am only knowledgeable on a very rudimentary level. There may be other settings I need to tweak. That is what I need to know?


#3

Could you copy-paste the complete line that is giving you the error? I searched for chain in juce_dsp, but could only find Chain, which doesn’t take an integer as template parameter.


#4

Sorry…“chain” is my dsp::ProcessorChain variable. An example line of code is;

chain.get<0>().setGainLinear(*pluginState.getRawParameterValue(Trim));

It compiles and runs fine on VS2017, but Xcode says “Expression Expected” with a red tick under the second parenthesis. And it does so for each line with similar syntax.


#5

Xcode says “Expression Expected” with a red tick under the second parenthesis

Here you are talking about what Xcode, the IDE, is reporting, it’s not a compiler error from clang, right? Do you also get a compiler error from clang? If yes, please copy-paste it here, clang usually has comprehensive error messages. If no, then it means that Xcode itself is broken.


#6

All that Xcode does is to open the source file, put the red tick under the “)”, and state “Expression Expected”. There is nothing more.


#7

That’s what I understood. Now you should build your code (CMD + B if I remember well) and see what clang, the compiler, has to say.


#8

I found the “Reveal in Log”, see below, but its not very helpful.

/Users/User/SDKs/AAXProjects/Dip/Source/PluginProcessor.cpp:107:15: error: expected expression
chain.get<0>().setGainLinear(*pluginState.getRawParameterValue(Trim));


#9

Break it into multiple lines…

float fValue = *pluginState.getRawParameterValue (Trim);

chain.get<0>().setGainLinear (fValue);

What happens?

BTW - What’s Trim…? The JUCE code style guidelines say that Class names are Capitalized.

Rail


#10

Your syntax change makes no difference—same error.

“Trim” is “const String Trim = “trim””.


#11

When you split it to 2 lines… where’s the error?

Rail


#12

The error appears in the same place, under the first “)” of the chain.get<0>().setGainLinear(*pluginState.getRawParameterValue(Trim)); statement.


#13

We’d have to see more of your code then to see where chain is defined, etc…

Rail


#14

Below is the declaration section;

	using GainProcessor = dsp::Gain<T>;
	template<typename T>
	using FilterProcessorLow = dsp::ProcessorDuplicator<dsp::IIR::Filter<T>, dsp::IIR::Coefficients<T>>;
	template<typename T>
	using FilterProcessorHigh = dsp::ProcessorDuplicator<dsp::IIR::Filter<T>, dsp::IIR::Coefficients<T>>;

	template <typename T>
	using ProcessorChain = dsp::ProcessorChain<GainProcessor<T>, FilterProcessorLow<T>, FilterProcessorHigh<T>>;

	ProcessorChain<float> floatChain;
	ProcessorChain<double> doubleChain;

	template<typename T>
	void process(dsp::ProcessContextReplacing<T>, ProcessorChain<T>&);

#15

…and, just to mention again, this code works fine in VS2017. No issues whatsoever, and I compile with Treat Warnings as Errors enabled!


#16

Below are the template specializations;

	{
		dsp::AudioBlock<float> block(buffer);
		process(dsp::ProcessContextReplacing<float>(block), floatChain);
	}

	void processBlock(AudioBuffer<double>& buffer, MidiBuffer& ) override
	{
		dsp::AudioBlock<double> block(buffer);
		process(dsp::ProcessContextReplacing<double>(block), doubleChain);
	}

    //==============================================================================

and here is the process method;

template<typename T>
void DipAudioProcessor::process(dsp::ProcessContextReplacing<T> context, ProcessorChain<T>& chain)
{
	ScopedNoDenormals noDenormals;

	const double sampleRate = getSampleRate();

	const float peakLow = (*pluginState.getRawParameterValue(PeakLow));
	const float peakHzLow = ((*pluginState.getRawParameterValue(PeakHzLow)) * 1000.0f);//convert to kilohertz
	const float peakQLow = (*pluginState.getRawParameterValue(PeakQLow));
	const float peakHigh = (*pluginState.getRawParameterValue(PeakHigh));
	const float peakHzHigh = ((*pluginState.getRawParameterValue(PeakHzHigh)) * 1000.0f);//convert to kilohertz
	const float peakQHigh = (*pluginState.getRawParameterValue(PeakQHigh));

	const bool isMixModeLow = ((*pluginState.getRawParameterValue(MixSweepLow)) < 0.5f ? false : true);
	const bool isMixModeHigh = ((*pluginState.getRawParameterValue(MixSweepHigh)) < 0.5f ? false : true);

	chain.get<0>().setGainLinear(*pluginState.getRawParameterValue(Trim));

	if (isMixModeLow)
	{
		*chain.get<1>().state = *dsp::IIR::Coefficients<T>::makePeakFilter(sampleRate, peakHzLow, peakQLow, peakLow);
	}
	else
	{
		*chain.get<1>().state = *dsp::IIR::Coefficients<T>::makePeakFilter(sampleRate, peakHzLow, 8.0f, db2Gain(15.0f));
	}

	if (isMixModeHigh)
	{
		*chain.get<2>().state = *dsp::IIR::Coefficients<T>::makePeakFilter(sampleRate, peakHzHigh, peakQHigh, peakHigh);
	}
	else
	{
		*chain.get<2>().state = *dsp::IIR::Coefficients<T>::makePeakFilter(sampleRate, peakHzHigh, 8.0f, db2Gain(15.0f));
	}

	chain.process(context);
}

#17

Just noticed the first line of the template specializations is missing, so here they are again;

	void processBlock(AudioBuffer<float>& buffer, MidiBuffer& ) override
	{
		dsp::AudioBlock<float> block(buffer);
		process(dsp::ProcessContextReplacing<float>(block), floatChain);
	}

	void processBlock(AudioBuffer<double>& buffer, MidiBuffer& ) override
	{
		dsp::AudioBlock<double> block(buffer);
		process(dsp::ProcessContextReplacing<double>(block), doubleChain);
	}

#18

Bump. Surely someone must know how to get Xcode to compile this (see original post up top). I am sure it must be an Xcode setting that I don’t know.

Any ideas?


#19

Does something like this work?

auto& p = chain.get<0>();
auto val = *pluginState.getRawParameterValue(Trim);
p.setGainLinear (val);

#20

Thank you for the attempt. But this results in an error in the same place. In other words, it is the chain.get<0>() that code chokes on. Again, with your code, Xcode says “Expression Expected” and places a red tick under the “)”.

I am baffled, because; a) it compiles and runs fine with VS2017, b) I think the dsp class probably developed on OSX, so there must be a way to do this on a Mac.
@jules, @Fabian, @Ivan…what needs to be done to get Xcode to compile this successfully?