[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] MIDI help files



You're reading an old version of that help file. I revised it about a month ago and that paragraph is gone.

There's an example in the new helpfile on using arrays, but the dictionary idea is not bad either. The lookup may be slightly faster if you do:

ccArray = Array.newClear(128);
ccArray[10] = { ... };
ccArray[11] = { ... };
// etc.

And of course, for speed of lookup, you should use IdentityDictionary instead of Dictionary.

hjh

On Tuesday, Dec 28, 2004, at 19:01 US/Eastern, nescivi wrote:

Hi,

someone posted about the MIDI help files some time ago...

I'd like to suggest after the paragraph:

"For this reason, it's generally too much trouble to work with MIDIIn
directly for regular use (note on/off, controller messages). It's
better to wrap the core functionality within higher-level classes that
handle the internals for you."

to add:

"One way of working around this problem is using a Dictionary for the
MIDIIn responders:

(
var mididict;
mididict = Dictionary.new;
mididict = (
	10: {|val|
		"midicontrol ".post; 10.post; ": ".post; val.postln;
	},
	11: {|val|
		"midicontrol ".post; 11.post; ": ".post; val.postln;
	},
	3:	{|val|
		"midicontrol ".post; 3.post; ": ".post; val.postln;
	}
);

mididict.postln;

MIDIIn.control = { arg src, chan, num, val;
	mididict.at(num).value(val/127); };

/// adding a function later:
mididict.add( 8 -> { |val|
	"midicontrol ".post; 8.post; ": ".post; val.postln;
});

mididict.postln;
)
"

in case people do not want to use other higher level libraries or want
to create their own.



sincerely,
Marije
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users


____________________________________

H. James Harkins /// dewdrop_world
http://www.dewdrop-world.net

"If attacked by a lion, thrust your arm down his throat.
This takes some practice."  -- Cyril Connolly