
#include "Matrix88Cv.hpp"

void Matrix88Cv::processAlways(const ProcessArgs& args) {
	int position = 0;
	int baseID = 0;
	if (baseConnected()) {
		Matrix88ExpanderMessage* bm = fromBase();
		baseID = bm->baseID;
		position = bm->position;
	}
	setBaseIDAndPosition(baseID, position);

	if (expanderConnected()) {
		Matrix88ExpanderMessage* te = toExpander();
		te->baseID = _baseID;
		te->position = _position > 0 ? _position + 1 : 0;
	}
}

struct Matrix88CvWidget : BGModuleWidget {
	static constexpr int hp = 20;

	Matrix88CvWidget(Matrix88Cv* module) {
		setModule(module);
		box.size = Vec(RACK_GRID_WIDTH * hp, RACK_GRID_HEIGHT);
		setPanel(box.size, "Matrix88Cv");
		createScrews();

		// generated by svg_widgets.rb
		auto cv11InputPosition = Vec(15.5, 30.0);
		auto cv21InputPosition = Vec(15.5, 67.0);
		auto cv31InputPosition = Vec(15.5, 104.0);
		auto cv41InputPosition = Vec(15.5, 141.0);
		auto cv51InputPosition = Vec(15.5, 178.0);
		auto cv61InputPosition = Vec(15.5, 215.0);
		auto cv71InputPosition = Vec(15.5, 252.0);
		auto cv81InputPosition = Vec(15.5, 289.0);
		auto cv12InputPosition = Vec(50.5, 30.0);
		auto cv22InputPosition = Vec(50.5, 67.0);
		auto cv32InputPosition = Vec(50.5, 104.0);
		auto cv42InputPosition = Vec(50.5, 141.0);
		auto cv52InputPosition = Vec(50.5, 178.0);
		auto cv62InputPosition = Vec(50.5, 215.0);
		auto cv72InputPosition = Vec(50.5, 252.0);
		auto cv82InputPosition = Vec(50.5, 289.0);
		auto cv13InputPosition = Vec(85.5, 30.0);
		auto cv23InputPosition = Vec(85.5, 67.0);
		auto cv33InputPosition = Vec(85.5, 104.0);
		auto cv43InputPosition = Vec(85.5, 141.0);
		auto cv53InputPosition = Vec(85.5, 178.0);
		auto cv63InputPosition = Vec(85.5, 215.0);
		auto cv73InputPosition = Vec(85.5, 252.0);
		auto cv83InputPosition = Vec(85.5, 289.0);
		auto cv14InputPosition = Vec(120.5, 30.0);
		auto cv24InputPosition = Vec(120.5, 67.0);
		auto cv34InputPosition = Vec(120.5, 104.0);
		auto cv44InputPosition = Vec(120.5, 141.0);
		auto cv54InputPosition = Vec(120.5, 178.0);
		auto cv64InputPosition = Vec(120.5, 215.0);
		auto cv74InputPosition = Vec(120.5, 252.0);
		auto cv84InputPosition = Vec(120.5, 289.0);
		auto cv15InputPosition = Vec(155.5, 30.0);
		auto cv25InputPosition = Vec(155.5, 67.0);
		auto cv35InputPosition = Vec(155.5, 104.0);
		auto cv45InputPosition = Vec(155.5, 141.0);
		auto cv55InputPosition = Vec(155.5, 178.0);
		auto cv65InputPosition = Vec(155.5, 215.0);
		auto cv75InputPosition = Vec(155.5, 252.0);
		auto cv85InputPosition = Vec(155.5, 289.0);
		auto cv16InputPosition = Vec(190.5, 30.0);
		auto cv26InputPosition = Vec(190.5, 67.0);
		auto cv36InputPosition = Vec(190.5, 104.0);
		auto cv46InputPosition = Vec(190.5, 141.0);
		auto cv56InputPosition = Vec(190.5, 178.0);
		auto cv66InputPosition = Vec(190.5, 215.0);
		auto cv76InputPosition = Vec(190.5, 252.0);
		auto cv86InputPosition = Vec(190.5, 289.0);
		auto cv17InputPosition = Vec(225.5, 30.0);
		auto cv27InputPosition = Vec(225.5, 67.0);
		auto cv37InputPosition = Vec(225.5, 104.0);
		auto cv47InputPosition = Vec(225.5, 141.0);
		auto cv57InputPosition = Vec(225.5, 178.0);
		auto cv67InputPosition = Vec(225.5, 215.0);
		auto cv77InputPosition = Vec(225.5, 252.0);
		auto cv87InputPosition = Vec(225.5, 289.0);
		auto cv18InputPosition = Vec(260.5, 30.0);
		auto cv28InputPosition = Vec(260.5, 67.0);
		auto cv38InputPosition = Vec(260.5, 104.0);
		auto cv48InputPosition = Vec(260.5, 141.0);
		auto cv58InputPosition = Vec(260.5, 178.0);
		auto cv68InputPosition = Vec(260.5, 215.0);
		auto cv78InputPosition = Vec(260.5, 252.0);
		auto cv88InputPosition = Vec(260.5, 289.0);
		// end generated by svg_widgets.rb

		addInput(createInput<Port24>(cv11InputPosition, module, Matrix88Cv::CV11_INPUT));
		addInput(createInput<Port24>(cv21InputPosition, module, Matrix88Cv::CV21_INPUT));
		addInput(createInput<Port24>(cv31InputPosition, module, Matrix88Cv::CV31_INPUT));
		addInput(createInput<Port24>(cv41InputPosition, module, Matrix88Cv::CV41_INPUT));
		addInput(createInput<Port24>(cv51InputPosition, module, Matrix88Cv::CV51_INPUT));
		addInput(createInput<Port24>(cv61InputPosition, module, Matrix88Cv::CV61_INPUT));
		addInput(createInput<Port24>(cv71InputPosition, module, Matrix88Cv::CV71_INPUT));
		addInput(createInput<Port24>(cv81InputPosition, module, Matrix88Cv::CV81_INPUT));
		addInput(createInput<Port24>(cv12InputPosition, module, Matrix88Cv::CV12_INPUT));
		addInput(createInput<Port24>(cv22InputPosition, module, Matrix88Cv::CV22_INPUT));
		addInput(createInput<Port24>(cv32InputPosition, module, Matrix88Cv::CV32_INPUT));
		addInput(createInput<Port24>(cv42InputPosition, module, Matrix88Cv::CV42_INPUT));
		addInput(createInput<Port24>(cv52InputPosition, module, Matrix88Cv::CV52_INPUT));
		addInput(createInput<Port24>(cv62InputPosition, module, Matrix88Cv::CV62_INPUT));
		addInput(createInput<Port24>(cv72InputPosition, module, Matrix88Cv::CV72_INPUT));
		addInput(createInput<Port24>(cv82InputPosition, module, Matrix88Cv::CV82_INPUT));
		addInput(createInput<Port24>(cv13InputPosition, module, Matrix88Cv::CV13_INPUT));
		addInput(createInput<Port24>(cv23InputPosition, module, Matrix88Cv::CV23_INPUT));
		addInput(createInput<Port24>(cv33InputPosition, module, Matrix88Cv::CV33_INPUT));
		addInput(createInput<Port24>(cv43InputPosition, module, Matrix88Cv::CV43_INPUT));
		addInput(createInput<Port24>(cv53InputPosition, module, Matrix88Cv::CV53_INPUT));
		addInput(createInput<Port24>(cv63InputPosition, module, Matrix88Cv::CV63_INPUT));
		addInput(createInput<Port24>(cv73InputPosition, module, Matrix88Cv::CV73_INPUT));
		addInput(createInput<Port24>(cv83InputPosition, module, Matrix88Cv::CV83_INPUT));
		addInput(createInput<Port24>(cv14InputPosition, module, Matrix88Cv::CV14_INPUT));
		addInput(createInput<Port24>(cv24InputPosition, module, Matrix88Cv::CV24_INPUT));
		addInput(createInput<Port24>(cv34InputPosition, module, Matrix88Cv::CV34_INPUT));
		addInput(createInput<Port24>(cv44InputPosition, module, Matrix88Cv::CV44_INPUT));
		addInput(createInput<Port24>(cv54InputPosition, module, Matrix88Cv::CV54_INPUT));
		addInput(createInput<Port24>(cv64InputPosition, module, Matrix88Cv::CV64_INPUT));
		addInput(createInput<Port24>(cv74InputPosition, module, Matrix88Cv::CV74_INPUT));
		addInput(createInput<Port24>(cv84InputPosition, module, Matrix88Cv::CV84_INPUT));
		addInput(createInput<Port24>(cv15InputPosition, module, Matrix88Cv::CV15_INPUT));
		addInput(createInput<Port24>(cv25InputPosition, module, Matrix88Cv::CV25_INPUT));
		addInput(createInput<Port24>(cv35InputPosition, module, Matrix88Cv::CV35_INPUT));
		addInput(createInput<Port24>(cv45InputPosition, module, Matrix88Cv::CV45_INPUT));
		addInput(createInput<Port24>(cv55InputPosition, module, Matrix88Cv::CV55_INPUT));
		addInput(createInput<Port24>(cv65InputPosition, module, Matrix88Cv::CV65_INPUT));
		addInput(createInput<Port24>(cv75InputPosition, module, Matrix88Cv::CV75_INPUT));
		addInput(createInput<Port24>(cv85InputPosition, module, Matrix88Cv::CV85_INPUT));
		addInput(createInput<Port24>(cv16InputPosition, module, Matrix88Cv::CV16_INPUT));
		addInput(createInput<Port24>(cv26InputPosition, module, Matrix88Cv::CV26_INPUT));
		addInput(createInput<Port24>(cv36InputPosition, module, Matrix88Cv::CV36_INPUT));
		addInput(createInput<Port24>(cv46InputPosition, module, Matrix88Cv::CV46_INPUT));
		addInput(createInput<Port24>(cv56InputPosition, module, Matrix88Cv::CV56_INPUT));
		addInput(createInput<Port24>(cv66InputPosition, module, Matrix88Cv::CV66_INPUT));
		addInput(createInput<Port24>(cv76InputPosition, module, Matrix88Cv::CV76_INPUT));
		addInput(createInput<Port24>(cv86InputPosition, module, Matrix88Cv::CV86_INPUT));
		addInput(createInput<Port24>(cv17InputPosition, module, Matrix88Cv::CV17_INPUT));
		addInput(createInput<Port24>(cv27InputPosition, module, Matrix88Cv::CV27_INPUT));
		addInput(createInput<Port24>(cv37InputPosition, module, Matrix88Cv::CV37_INPUT));
		addInput(createInput<Port24>(cv47InputPosition, module, Matrix88Cv::CV47_INPUT));
		addInput(createInput<Port24>(cv57InputPosition, module, Matrix88Cv::CV57_INPUT));
		addInput(createInput<Port24>(cv67InputPosition, module, Matrix88Cv::CV67_INPUT));
		addInput(createInput<Port24>(cv77InputPosition, module, Matrix88Cv::CV77_INPUT));
		addInput(createInput<Port24>(cv87InputPosition, module, Matrix88Cv::CV87_INPUT));
		addInput(createInput<Port24>(cv18InputPosition, module, Matrix88Cv::CV18_INPUT));
		addInput(createInput<Port24>(cv28InputPosition, module, Matrix88Cv::CV28_INPUT));
		addInput(createInput<Port24>(cv38InputPosition, module, Matrix88Cv::CV38_INPUT));
		addInput(createInput<Port24>(cv48InputPosition, module, Matrix88Cv::CV48_INPUT));
		addInput(createInput<Port24>(cv58InputPosition, module, Matrix88Cv::CV58_INPUT));
		addInput(createInput<Port24>(cv68InputPosition, module, Matrix88Cv::CV68_INPUT));
		addInput(createInput<Port24>(cv78InputPosition, module, Matrix88Cv::CV78_INPUT));
		addInput(createInput<Port24>(cv88InputPosition, module, Matrix88Cv::CV88_INPUT));
	}
};

Model* modelMatrix88Cv = createModel<Matrix88Cv, Matrix88CvWidget>("Bogaudio-Matrix88Cv", "MX88CV", "CV expander for MATRIX88", "Mixer", "Expander", "Polyphonic");
