Iteration counter .sortedKeysValuesDo

hey, i have an IdentityDictionary self.params with keys and specs and use the method .sortedKeysValuesDo to set the value and action of the knobs of a midiController (Modality Toolkit).

The knobs are numbered GR01_kn_1, GR01_kn_2 etc.
Can i have an iteration counter while using .sortedKeysValuesDo to set numKnob to acces each knob?
Or is there another workaround? many thanks :slight_smile:

self.params.sortedKeysValuesDo{ |key, spec|

	var paramVal;
	
	paramVal = self.nodeProxy.get(key);
	
	self.midiController.elAt(\GR01, \kn, numKnob)
	//self.midiController.dictAt("GR01_kn_%".format(numKnob).asSymbol)
	.value_(spec.unmap(paramVal))
	.action_{ |el|
		self.nodeProxy.set(key, spec.map(el.value));
	};
	
};

Like this?

(x: 3, y: 2, z: 1).sortedKeysValuesDo { |k v i| [k, v, i].postln }
2 Likes

awesome, easier then i thought. thats it :slight_smile: