JAP puzzle


#1

Having a very confusing problem at the moment. I’ve made three classes, which sit in a nested array structure.

It’s pretty basic stuff, but for some reason, merely having an instance of this class as a member of my juce filter causes an exception in juce::SortedSet::insertInternal(…). What possible reason could there be for this?

Is there any chance anyone could include this in a plugin and add a member of SixteenChannelMaps to the filter class to check I’m not going insane?

Here’s the code for the class file…





class SingleNoteMap
{
public:

	SingleNoteMap ()
	{
	}

	void setTargetNote (int noteNumber)
	{
		jassert (noteNumber < 128);
		note = noteNumber;
	}

	int getTargetNote ()
	{
		return note;
	}

	void setTargetChannel (int chan)
	{
		jassert ((chan > 0) && (chan < 17));
		channel = chan;
	}

	int getTargetChannel ()
	{
		return channel;
	}

private:

	int channel;
	int note;
};

class NoteMap
{
public:

	NoteMap ()
	{
	}

	void resetAll (int channelNumber)
	{
		channel = channelNumber;
		for (int i=0; i<128; i++)
		{
			map [i].setTargetNote (i);
			map [i].setTargetChannel (channel);
		}
	}

	SingleNoteMap& getMap (int inputNoteNumber)
	{
		jassert (inputNoteNumber < 128);
		return map [inputNoteNumber];
	}

	int getOutputNoteFor (int inputNoteNumber)
	{
		jassert (inputNoteNumber < 128);
		return map [inputNoteNumber].getTargetNote ();
	}

	int getOutputChannelFor (int inputNoteNumber)
	{
		jassert (inputNoteNumber < 128);
		return map [inputNoteNumber].getTargetChannel ();
	}

	void setOutputNoteFor (int inputNoteNumber, int output)
	{
		jassert ((inputNoteNumber < 128) && (output < 128));
		map [inputNoteNumber].setTargetNote (output);
	}

	void setOutputChannelFor (int inputNoteNumber, int output)
	{
		jassert ((inputNoteNumber < 128) && (output > 0) && (output < 17));
		map [inputNoteNumber].setTargetChannel (output);
	}

private:

	SingleNoteMap map [128];
	int channel;
};

class SixteenChannelMaps
{
public:

	SixteenChannelMaps ()
	{
		for (int i=1; i<17; i++)
		{
			maps[i].resetAll (i);
		}
	}

	NoteMap& getMapForChannel (int channel)
	{
		jassert ((channel > 0) && (channel < 17));
		return maps [channel];
	}

private:

	NoteMap maps [16];
};


#2

actually, i think i’m being a remedial of sorts and know what the problem is… i forgot to convert the 1-16 channel index to the proper array indexes…

d’oh, time to try that.

it’s always something stupid isn’t it?


#3

yup, forget i said anything :slight_smile: the silly bugs always wait til you can look as stupid as possible before they let you find them.

i’m half tempted to edit away these posts, but i’m going to leave them as a reminder to myself to look harder (or perhaps easier) next time :oops: :oops:


#4