From: Steven S. <ste...@co...> - 2005-03-29 01:27:00
|
Methinks this went to the wrong list _____ From: Steven Schmidt [mailto:ste...@co...] Sent: Monday, March 28, 2005 10:36 AM To: 'jsy...@li...' Subject: Re: What is the JSL way to deal with negative param values? I've been casting it as a byte and while it seems to work up to a point - I'm not getting the negative values to display. I thought it should work the way I'm doing it, but it stops at zero. Please have a look at this snippet and make recommendations if you can: The purpose of this method is to subtract the max value for the widget if the param value is greater than the max value. public static SpinnerWidget dynaSpinner(String label, IPatch patch, int min, int max, int base, IParamModel pmodel, ISender sender) { String pt = patch.getByteArray().toString(); int rawval = pmodel.get(); int prelimval = (byte)pmodel.get()+ max & 0x7F; System.out.println("rawval:"+ rawval+" prelimval:"+prelimval); if (rawval > max) { base = -max; System.out.println(" BASE:"+base + " The math:"+(prelimval + base)); SpinnerWidget spinner = new SpinnerWidget (label, patch, min, max, base, pmodel, sender); } SpinnerWidget spinner = new SpinnerWidget (label, patch, min, max, base, pmodel, sender); return spinner; } } This outputs: rawval:126 prelimval:10 BASE:-12 The math:-2 -2 is the correct value, but the spinner widget actually displays a '0' - apparently getting stuck at 0. Help!!! Bill Zwicky wrote: > Note that this goofiness is on top of the fact that your synth has > probably scrambled the bytes a little to get around the restrictions of > the sysex message. So you need to deal with that, on top of dealing > with signed bytes. |