Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIDI output messages as integers #294

Open
sensestage opened this issue May 25, 2017 · 9 comments
Open

MIDI output messages as integers #294

sensestage opened this issue May 25, 2017 · 9 comments

Comments

@sensestage
Copy link
Contributor

In some cases it is useful to set the raw value of a MIDI output element, as the bytes may have some clever encoding.
This is for example the case with the Tascam US-2400 for the encoder ring display.

I will commit an IntegerClip class which can act as a spec to restrict a value to a certain integer range.

@sensestage
Copy link
Contributor Author

The only issue is then for the GUI views, how to display this properly

@LFSaw
Copy link
Member

LFSaw commented May 26, 2017

Can't this be done with a (Control)Spec?
This seems to be similar to the String specs used in the OSC implementation, or?

@sensestage
Copy link
Contributor Author

When you do byte-encoding you do not want to go through a floating point representation as is the case in a spec (which always converts to/from a 0 to 1)

I guess it could be an output collective where you combine all of the options into one byte and then send it.

I have to admit that I am not uptodate enough with the code base to know how much of the work on Collectives that I put in is still in the current version.

The ItemSpec comes close, but you'd want to pass in values as symbols/strings and then output integers.

@sensestage
Copy link
Contributor Author

For reference, here is the function to set the encoder ring in meter mode:

(
~levelSpec = [0,15,\linear,1].asSpec;
~meterVal = { |level, showPeak=false, resetOverload = false, overload=false|
	level = ~levelSpec.map( level );
	level = level.asInteger & 0x0F;
	if ( showPeak ){
		level = level | 0x10;
	};
	if ( resetOverload ){
		level = level | 0x40; // reset the overload
		if ( overload ){
			level = level | 0x20; // there is an overload
		};
	};
	level.postln;
};
);

and here in the other mode:

(
~levelSpec = [0,15,\linear,1].asSpec;
~ringVal = { |level, mode=1, center=false|
	level = ~levelSpec.map( level );
	level = level.asInteger & 0x0F;
	if ( center ){
		level = level | 0x40;
	};
	switch( mode,
		// 1, { },    // data & 0x30 = 0
		// \dot, { }, // data & 0x30 = 0
		2, { level = level | 0x10; }, // data & 0x30 = 0x10
		\cutBoost, { level = level | 0x10; }, // data & 0x30 = 0x10
		3, { level = level | 0x10; }, // data & 0x30 = 0x20
		\spread, { level = level | 0x20; }, // data & 0x30 = 0x20
		4, {
			level = level | 0x10;
			level = level | 0x20;
		}, // data & 0x30 = 0x20
		\width, {
			level = level | 0x10;
			level = level | 0x20;
		} // data & 0x30 = 0x20
	);
	level.postln;
};
);

Another common case seems to be the LED [ \off, \blink, \on] case.

@LFSaw
Copy link
Member

LFSaw commented May 26, 2017

@sensestage:

I have to admit that I am not uptodate enough with the code base to know how much of the work on Collectives that I put in is still in the current version.

@adcxyz , can you comment?

@adcxyz
Copy link
Contributor

adcxyz commented Jun 1, 2017

AFAIR, all the collective stuff is still there and works.

@LFSaw
Copy link
Member

LFSaw commented Jun 1, 2017

Speaking of MKtlElementCollective, it is missing documentation... And I have no diea whatsoever what it is intended for.

@adcxyz
Copy link
Contributor

adcxyz commented Jul 2, 2017

This seems similar to the CinematixWheel #117, hardware with indiosyncratic ways of compressing data into (MIDI) messages. Like there, I think it good to provide a specific solution for the case and document its logic; like there also, I don't understand what the general case to solve is.

For a no-spec MKtlElement, one could use MAbstractElement; for mapped/unmapped integer values, one could write a ControlSpec subclass with a flag whether to do .asInteger on the output or not.
collectives for distributing incoming values seems fine - one can also just provide a full example that does the conversion, and tell users to attach that to the MKtl concerned.
2c a

@adcxyz
Copy link
Contributor

adcxyz commented Jul 25, 2017

@sensestage ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants