|
Post by uncledave on Jun 28, 2022 15:06:39 GMT
OK. I have the correct manual now: Disting EX 1.14. Since you got it working with maximum value of $100, I suspect that negative values are sent as 2's complement. The manual description of the "16-bit value" is totally unhelpful on this. That will need some reworking of the script, since SB is not graceful with negative values (all its variables are "unsigned"). It's not hard, just different. I can make it so you can configure a different mode (and maximum value) for each Pitch Bend channel. But, looking at that manual, I don't understand how you need parameters $65-$68 and $74-$77 to be positive and negative. The parameters for the Quad Envelope seem to be grouped in blocks for each of 4 shapes, then each of 4 envelopes. Those parameter numbers seem to cut across the data randomly. Here are the pages I'm looking at. disting_EX_user_manual_1.14 - fragment.pdf (114.43 KB)
|
|
|
Post by mo13 on Jun 28, 2022 17:08:42 GMT
 For that reason so far I've been using the Touch Osc as there you can clearly see where the controls switch to SysEx instead of CC. If I use say a CC for Scale #1, it gos to min value -100 to +100, which you can change in the hardware as mentioned. Yes you can share Shapes between them but you are also able to set individual - to + Scales and Offsets on the last 2 Envelopes, that influences their own shapes which you can distribute to the other Envelopes, so the ones from Scale #3 and on can only be reached by SysEx, if I understood your question correctly? That would do it of course!
|
|
|
Post by uncledave on Jun 28, 2022 17:48:21 GMT
I see, you're looking at the blocks from Scale to Vel–>Attack for Envelopes 3 and 4. But aren't the numbers $66..$69 and $75..$78, as printed in the manual. Or are they one less, so the numbers sent actually start at zero for "Parameter 1".
Anyway, that needn't affect me, since you'll be configuring the script. I'll have a look at revising it to be more general.
Cheers, Dave
|
|
|
Post by uncledave on Jun 28, 2022 18:04:12 GMT
Incidentally, you don't have to configure the parameters sequentially, with no gaps. As you've done it, you include the first 5 parameters of Envelope 4, which you may not want to adjust. The table of parameter numbers is indexed by the PB message channel, so you can map each PB slider to a different parameter. I expect you may just want to map the same 4 parameters for Envelope 3 and 4. If that is correct, I'll change the script to do that.
|
|
|
Post by mo13 on Jun 28, 2022 18:31:28 GMT
Yeah that is exactly the case, if you might recall with the previous Drum Hits script version which started at parameter 8 but addressed them starting from $7.
The ones besides those are actually very important to adjust / to catch the right values which I already successfully tested with the N-1 switches going to your script, so we do need all of them being covered as you also mentioned having different modes per PB channel. Good to learn about the sequential notation.
|
|
|
Post by uncledave on Jun 28, 2022 21:52:43 GMT
OK, here it is. I've configured the other parameters with their nominal maxima, but I suspect you've fudged your controls to work with the maximum of 100, so you may need to adjust them. Please consider reserving PB for the parameters that need it: Scale through attack. You could just send simple CCs to the script for the others, and it could forward them to Disting as SysEx. You could just use CC#s matching the parameter number you want to send, and the script could catch the CC and convert it to a SysEx. No need for clever scaling,etc. Just send the value you want. Then we can configure the PB channels for the special parameters. Remember, the mapping entries do not need to be consecutive.
I tried to align the columns in the mapping table, but everybody has their own idea of spacing; sorry.
As I said, I've assumed 2's complement for negative values. This is the system where -1 is FFFF and -$100 is FF9C. If Disting doesn't like that, we'll need to think again. If you look at Sub ProcessValue, you can see how we need to dance around "negative" numbers. SB will compute them because the hardware just does it, but SB thinks they're just really large unsigned values. #DistingPBSigned
# Receives a Pitch Bend value and sends it to # Disting EX as a set parameter SysEx message. # Route script output to a MIDI connection to disting. # Remember, all numbers are hex, unless $xx. # We assume the Pitch Bend channels follow in sequence. # Disting parameter numbers are given by a table. You can adjust # them as desired. # Note the separation of variable names: Ki for constants, # Ji for saved values, Ii for temp values. Aliases make the # program more readable, since we don't have to remember # the array indices.
If load # Note: the channel number is the actual message value (range 0..F), # not the MIDI channel number (range 0..$16). Alias 0 baseChan # Channel number for the first parameter # Two blocks of 8 parameters. Each parameter is tied to the # PB fader channel from 0 to 15. Three lines of data for each # parameter. First line is the Disting parameter number. # Second line is the (positive) range. Third line is a flag, where # 1 indicates that the parameter is signed and symmetric. # Edit as desired, don't forget the $. Alias $14 numParams # number of parameters, ≤ $16. Ass K10 = $64 $65 $66 $67 $68 $69 $70 $71 Ass K20 = $3 $100 $100 $100 $100 $48 $4 $5 Ass K30 = 0 1 1 0 1 0 0 0
Ass K18 = $72 $73 $74 $75 $76 $77 Ass K28 = $22 $3 $100 $100 $100 $100 $100 $100 Ass K38 = 0 0 1 1 0 1 0 0 # No adjustable values below this line # As configured, these numbers are one less than the documented # parameter numbers. $64 is actually parameter 65, the clock mode # for envelope 3. #——————————————————— Set Name DistPB Alias 10 paramBase Alias 20 scaleBase Alias 30 flagBase Alias I00 reg0 Alias I01 reg1 Alias I02 reg2
Define distingPref F0 00 21 27 5D 00 Alias 46 setValue Alias 4A setFocus # this value cannot happen # these registers store the last value sent for each parameter Ass J00 = 8000 8000 8000 8000 8000 8000 8000 8000 Ass J08 = 8000 8000 8000 8000 8000 8000 8000 8000 # combines two 7-bit bytes into a 14-bit value. Result must be 16-bit. Sub CombineBytes result LSB MSB Mat result = 80 * MSB Mat result = result + LSB End # splits the give 14-bit value into low and high bytes, and 2 extra bytes # The extra bytes will only be set for "negative" values, which start at # FFFF for -1. Sub SplitBytes pLSB pMSB pRest value Mat pLSB = value & 7F Mat I11 = value / 80 Mat pMSB = I11 & 7F Mat pRest = value / 4000 End # display the parameter and value and add to monitor stream # value is displayed in hex to show negatives Sub ShowData pParam pValue Set LB0 pParam +D Set LB1 pValue Log Param pParam +D Log Value pValue End # scales the given 14-bit value to the given maximum, returning # the updated value. This method creates Max+1 value bands, # numbered 0..Max, with the first and last being half size. # pSpan is the range of the input, 4000 for unsigned, 2000 signed. # This is suitable for a discrete (integer) parameter. Sub ReScale pValue pMax pSpan Mat P0 = pMax * pValue Mat P1 = pSpan / 2 Mat P0 = P0 + P1 # ensure rounding (like adding 0.5) Mat pValue = P0 / pSpan # scale down End
# uses the tabulated scale and flag values to convert the given pValue # into the correct value for Disting. Sub ProcessValue pValue pSlot Mat I10 = pSlot + scaleBase # index scale factor Mat I11 = pSlot + flagBase # index signed flag Ass I12 = 0 # remembers negative result Ass I13 = 4000 # span for this item If KI11 == 1 # here for signed value Ass I13 = 2000 # span for signed If pValue >= 2000 Mat pValue = pValue - 2000 Else # here for negative value Ass I12 = 1 Mat pValue = 2000 - pValue End End ReScale pValue KI10 I13 # scale the positive value If I12 == 1 Mat pValue = 0 - pValue # negate if needed End End End # Initialization ———————————————————————————
If MT == E0 # handle PB message If MC >= baseChan # require channel in expected range Mat reg0 = MC - baseChan # slot index from channel If reg0 < numParams # Order of values in PB is LSB, MSB. CombineBytes reg1 M1 M2 # combined 14-bit value ProcessValue reg1 reg0 # scale to given maximum # only process if scaled value changed If reg1 != JI00 # save the new value Ass JI00 = reg1 # get the parameter number from the table Mat I0F = reg0 + paramBase Ass reg0 = KI0F # diagnostic display ShowData reg0 reg1 # send SysEx msg to set parameter. SplitBytes M1 M2 reg2 reg1 Snd distingPref setFocus reg0 F7 Snd distingPref setValue reg0 reg2 M2 M1 F7 End End End End Block
|
|
|
Post by uncledave on Jun 29, 2022 9:58:18 GMT
I just want to add/emphasize that you don't have to be restricted to 16 Pitch Bends to send SysEx to Disting EX. Remember, we wrote this specifically to select one of 999 clips or tracks, so PB was the only way to send a value with high enough resolution. But there are simpler ways of sending "ordinary" values (≤ 127) to a script. And it's easy for a script to convert those messages into the correct SysEx format. As I suggested earlier, we could make this script a more general SysEx converter, while preserving the PB capability for data requiring it.
Actually, in this case, do you actually need to use Pitch Bend? If lower resolution would be acceptable, we could scale a normal CC (0..127) to -100..+100. Or if you don't need the full range, we could make it -64..+63
|
|
|
Post by mo13 on Jun 29, 2022 10:37:51 GMT
Sending Pitch Bend is working flawless on all parameters! Haven't had much luck yet with CC's but maybe I misunderstood something there, for instance I tried sending $77 on Ch.1 or any and nothing comes out of SB on the monitor.
I guess not necessarily, at least in this case I think, as with the drum hits script it had to be super precise and at the time the only solution for that seemed to be going through PB, so we we can surely try that here. Btw I didn't adjust my controller so it stops at a certain value, the CC's that are mapped to the PB rotaries are fully scaled.
|
|
|
Post by uncledave on Jun 29, 2022 13:25:06 GMT
The current implementation does not include a CC handler. It only checks for MT == E0 (pitch bend). It would need a section to check for B0 (CC). I will add that because I think it would be useful. No need for the gyrations to get these simple integer values into scaled pitch bend. You could just send the CC value you want relayed on to Disting.
Edit: Incidentally, are negative values working, e.g. for Scale and Offset parameters? Does it accept the 2's complement values correctly as negative entries?
|
|
|
Post by uncledave on Jun 29, 2022 21:36:40 GMT
Here's the script updated to include the CC handler. Absolutely no changes are made to the CC data: the CC# is the parameter number, and the CC value is the parameter value. The script still handles mapped PB values as before.
Edit: General cleanup. No new functionality. #DistingPBSigned
# Receives a Pitch Bend value and sends it to # Disting EX as a set parameter SysEx message. # Route script output to a MIDI connection to disting. # Remember, all numbers are hex, unless $xx. # We assume the Pitch Bend channels follow in sequence. # Disting parameter numbers are given by a table. You can adjust # them as desired.
# This version also retransmits any CC received as a SysEx parameter # set message, with the CC# as the parameter number, and the CC # value as the parameter value. No scaling or other adjustment is # performed. This might be simpler for those parameters not requiring # a wide range or negative values.
# Note the separation of variable names: Ki for constants, # Ji for saved values, Ii for temp values. Aliases make the # program more readable, since we don't have to remember # the array indices.
If load # Note: the channel number is the actual message value (range 0..F), # not the MIDI channel number (range 0..$16). Alias 0 baseChan # Channel number for the first parameter # Mapping table for Pitch Bend inputs. # Each position corresponds to one Pitch Bend channel, starting # from baseChannel. Update this table to specify the parameters # to map, with their scale factors and signs. # Two blocks of 8 parameters. Each parameter is tied to the # PB fader channel from 0 to 15. Three lines of data for each # parameter. First line is the Disting parameter number. # Second line is the (positive) range. Third line is a flag, where # 1 indicates that the parameter is signed and symmetric. # Edit as desired, don't forget the $. Alias $14 numParams # number of parameters, ≤ $16.
Ass K10 = $64 $65 $66 $67 $68 $69 $70 $71 Ass K20 = $3 $100 $100 $100 $100 $48 $4 $5 Ass K30 = 0 1 1 0 1 0 0 0
Ass K18 = $72 $73 $74 $75 $76 $77 Ass K28 = $22 $3 $100 $100 $100 $100 $100 $100 Ass K38 = 0 0 1 1 0 1 0 0
# As configured, these numbers are one less than the documented # parameter numbers. $64 is actually parameter 65, clock mode # for envelope 3. # No adjustable values below this line #——————————————————— Set Name DistPB
# these aliases give the start index for each table row Alias 10 paramBase Alias 20 scaleBase Alias 30 flagBase # handy register names Alias I00 reg0 Alias I01 reg1 Alias I02 reg2
# specific message values for Disting DX Define distingPref F0 00 21 27 5D 00 Alias 46 setValue Alias 4A setFocus
# These registers store the last value sent for each parameter. # 16 locations for each of 16 PB channels. # This value cannot happen (it is "-0"). Ass J00 = 8000 8000 8000 8000 8000 8000 8000 8000 Ass J08 = 8000 8000 8000 8000 8000 8000 8000 8000 # combines two 7-bit bytes into a 14-bit value. Result must be 16-bit. Sub CombineBytes pResult pLSB pMSB Mat pResult = 80 * pMSB Mat pResult = pResult + pLSB End # splits the given 14-bit value into low and high bytes, and 2 extra bytes # The extra bytes will only be set for "negative" values, which start at # FFFF for -1. Note that FF9C is -$100. The three result values are in # the correct order for the 16-bit value. Sub SplitBytes pRest pMSB pLSB pValue Ass I20 = pValue # copy input for safety Mat pRest = I20 / 4000 # shift top 2 bits down Mat pLSB = I20 & 7F # mask off lowest 7 bits Mat I20 = I20 / 80 # shift middle 7 bits down Mat pMSB = I20 & 7F # and mask them End
# display the parameter and value and add to monitor stream # value is displayed in hex to show negatives Sub ShowData pParam pValue Set LB0 pParam +D Set LB1 pValue Log Param pParam +D Log Value pValue End
# generic SysEx sender for DX Sub SendDistingDXParameter pNumber pValue ShowData pNumber pValue # diagnostic display SplitBytes I11 I12 I13 pValue Send distingPref setFocus pNumber F7 Send distingPref setValue pNumber I11 I12 I13 F7 End # scales the given 14-bit value to the given maximum, returning # the updated value. This method defines Max+1 value bands, # numbered 0..Max, with the first and last being half size. # pSpan is the range of the input, 4000 for unsigned, 2000 signed. # This is suitable for a discrete (integer) parameter, and makes the # transitions "feel" natural to a hand controller. Sub ReScale pValue pMax pSpan Mat P0 = pMax * pValue Mat P1 = pSpan / 2 Mat P0 = P0 + P1 # ensure rounding (like adding 0.5) Mat pValue = P0 / pSpan # scale down End
# uses the tabulated scale and flag values to convert the given pValue # into the correct value for Disting. pSlot is the index of the table entry. Sub ProcessPBValue pValue pSlot Mat I10 = pSlot + scaleBase # index scale factor Mat I11 = pSlot + flagBase # index signed flag Ass I12 = 0 # remembers negative result Ass I13 = 4000 # span for this item Ass I14 = pValue # local copy for processing If KI11 == 1 # test the "signed" flag # here for signed value Ass I13 = 2000 # span for signed If I14 >= 2000 Mat I14 = I14 - 2000 Else # here for negative value Ass I12 = 1 # remember for later Mat I14 = 2000 - I14 End End # KI10 is the scale factor, I13 is the span ReScale I14 KI10 I13 # scale the positive value If I12 == 1 Mat I14 = 0 - I14 # negate if needed End Ass pValue = I14 # return updated result End End # Initialization ———————————————————————————
If MT == E0 # handle PB message If MC >= baseChan # require channel in expected range Mat reg0 = MC - baseChan # slot index from channel If reg0 < numParams # Order of values in PB is LSB, MSB. CombineBytes reg1 M1 M2 # combined 14-bit value ProcessPBValue reg1 reg0 # scale to given maximum # Only send if scaled value changed. This is significant since # PB has thousands of values, scaled value has less. If reg1 != JI00 # save the new value Ass JI00 = reg1 # index table parameter number Mat I0F = reg0 + paramBase # send SysEx msg to set parameter. SendDistingDXParameter KI0F reg1 End End End End
If MT == B0 # handle a CC message # Relay a CC on to Disting as Sysex. CC# is parameter number. # CC value is parameter value. SendDistingDXParameter M1 M2 End
Block
|
|
|
Post by uncledave on Jun 30, 2022 11:13:14 GMT
Please use the edited version of my post just above. It is cleaner and, I hope, easier to understand as well.
If you update the PB mapping table, please post it, so I can incorporate it into my copy of the script.
|
|
|
Post by mo13 on Jul 1, 2022 15:25:03 GMT
thanks for the update Dave, but it seems like all the SysEx parameters which are being addressed here are configured to respond to negative and positive values, or to exactly what the PB output is producing. for instance if I send in CC 64 which is equivalent to E0 then it jumps over the 4 selectable Clock Modes and causes the module to hang/restart. Is there any downside to use PB only on all the parameters as the selection seems only to be working accurately through PB? or can you already tell what the issue might be here with using CC's ?
|
|
|
Post by uncledave on Jul 1, 2022 16:27:05 GMT
thanks for the update Dave, but it seems like all the SysEx parameters which are being addressed here are configured to respond to negative and positive values, or to exactly what the PB output is producing. The Pitch Bends are configured as signed or unsigned as indicated by the 0s and 1s in the third row of the mapping table near the top of the script. This configuration has not effect on CC inputs. How is CC 64 "equivalent" to E0? E0 is the code for a Pitch Bend message. You would need to send B0 for a CC message. And if you are sending a CC message, the data you send must be the exact value you want to send to Disting, not some 2-byte value scaled as a PB value. So, if you want to set CC 64 to 3, you would send B0 40 3, simple. I tried to make this really clear in the script and in the text when I posted it. There's no downside to using PB, except it adds a lot of useless complication on your end, and limits you to only 16 parameters. CC is working perfectly for me, as shown in the attached. I'm using LK to send CCs and PBs for testing. The SB monitor shows the CC 64 coming in and being relayed as a SysEx message. Please post a screenshot of the SB monitor when you send a CC. Edit: By the way, you cannot send the two data bytes of a Pitch Bend message in a CC. The format only allows one data value: B0 CC# value. Attachments:
|
|
|
Post by mo13 on Jul 2, 2022 7:35:25 GMT
Not a good explanation on my part, I only ment that sending E0 adresses the first parameter outside of normally reachable CC range, so now when sending B0 40 XX that would be the same parameter controlled by CC64 as by E0. I've rushed in to this a little yesterday, now it's 100% clear and all is set up with both CC & PB!
E1, E2, E4, EB, EC, EE.
here is another idea, as I'm still using your other PB script to select Drum Hits on the second Disting device. and we still have 10 PB channels left: The last 2 bytes are the Device ID for the Quad Envelope Disting which I just changed from 00 to 07 for testing purposes, which is the ID for the Drum Hits (aka 6SD Trigs) Disitng.
Define distingPref F0 00 21 27 5D 07
Since your're not a fan of wasting RAM on multiple scripts, maybe it's possible to encorporate a second Device ID? In that case we'd need to dance around the alreay used PB channels as the corresponding drum hits channels are now:
E0 E1 E2 E3 E4 E5 So the ones from E5 on would do the job. Those could then correspond to K10 = $7 $8 $9 $10 $11 $12 on the Disting. I think I'd still need a filter on the end of your script to only pass those 6 SysEx parameters as the 6SD trigs Device is on the same channel as Quad Envelope for the CC's, Sounds unhandy which it is but I had to do this a long time ago to make things work in Touch Osc. Since I won't be using it anymore I could go in to fix that and change a number of other scripts, but let's see if this is a good idea first at all.
|
|
|
Post by uncledave on Jul 2, 2022 10:48:38 GMT
Hi. By the mapping table, I actually meant the initializations of K00 through K38 that define the scaling and modes for the SysEx messages.
I think I can adapt the script to handle more than one device ID. And the second device ID could have its own set of scales and modes. No need to shoehorn everything into one configuration, unless the PB messages are all coming from one source.
Not sure about needing to filter the script output. Do you mean you need to block (or pass) CC messages? Could you describe your exact hook-up: each source and the messages it sends, the SB script, and the outputs (CC and SysEx) going to the devices. Remember, you could use two instances of the script, so there's no requirement to merge the inputs. Also, you could use the script to convert CCs to SysEx, possibly mapping different CC channels to different device IDs. Let's look at the intended configuration, we can decide on the best solution.
Also, how are you handling the MIDI routing: MidiFire, AUM, Drambo?
|
|