How can I make this Max MSP/M4L patch update zl.len and zl.mth for an empty list? - max-msp-jitter

Background
I'm trying to build a Max for Live device as a solution to the problem presented in this related question. As part of my solution I need to keep track of a group of notes (i.e. the selected, or in-scale notes).
My patch (see below) works great for any combination of held notes, but fails once the last note is released. When that happens, zl.len stays stuck at 1 and zl.mth continues to output whatever note was released last.
The question
How can I update my patch so that the length is 0 and the selected note is empty when the input list of held notes is empty?
What I have tried
I have tried banging the left inlet of the various zl objects manually and as part of the kslider update but this only produces the same unwanted behavior.
Here is a screen-shot of the patch:
and here is the corresponding code:
----------begin_max5_patcher----------
917.3ocyX0zbaCBD8ryL4+.iN6jAPHaodr8P+AzicxjQePrIUB4AgRcal9eu
7gUrSprJJF5zKlQqA18s6agmzyWe0hnh18ztHvG.eErXwyJKKL1zVVLXXQTS
99x57NyDi38METQzxC+m5QFulJM+I5Dqs8xAy3AypoxZ5az1fKOt4C1Pur9c
4h7FpjJtmxyKpouZE1cV9icTajGEsDDUjy2DAtaXNrJSv1V73MIwQG2VY4VF
ey8BZoztXbRxsvk.BYkdHNV+KFeKDbmYM+55qzipgkNmgJaaZnb4KdUR2abV
zmZ64RfbKErkVWA3sRUxeXV0LNsTOgWkwbI8BGCz3o.8ZnArYFLmhLOPtHLW
zKks7YwJdmE6IJzvovLxVniIolRLY32PTn+nJFM0YcIFnfPzkVOIYSgsXnkD
mYpqnDy.FFFv8EpDv3Uz8f1G.UzNlfVA5Jyqo2ng6kC0zI6WyHmzuhxPAEps
BosMUgXPdWIkWoBGPqnZlGANJPWOMPOzWlY.55rPBzOKZ628lSlTPV1BxA0r
NOveSlj+d3zWHxVTiCM+cn2zTW0OX3uWNJm7pFBw1dptdIwWco+Obta7j20f
WYNvkj5uyc4zuq76eVY+Y8scpN1wyF3+h1jQUULNfwS23FSN4hFBxCJJNGfk
B1lMTAn38Q.lQMFSlDxqSsMtlCoRhCHj2ITGKA5n0JmSqt3NVLxgRYhkBmBC
HtTb2F41fScQYtfW6PPot153F88NWbQDs1AwQGT6tZUXKhSfHeVFW4P6XLzP
XSBeYrlx2bNx6bpiwNHfmfMfy1RFt5nBRguJ5zKrX4swq8.d+VWM6TkqsO7P
G03tUv2EXmmDBlVNlc3X9nosh9JdhPcIj0BdjbV5z5HMoLDz9hsjgaiB.EoH
eyr3GnIyJiSOb.pXqlRblVR4nrC6Va97Bu8K8X1V8e7lDPWaunbH7F9DJ.3w
fT8VeRFOWxTROONK8cK.zT4ZmcnVgkiN7jYYesLcx1CgfVUq6gfGb3aQy3NT
KXwSNzwjL7LIYrGBgD3bBAefYhSI40ADyNl1OWH.+mkEzhLBV6kigP.SBoNw
DHALGfbi8G6uiXVMG1uOb3b3YdplhbgTg7l67FG9vE04618DUzcXOr9VII4w
VyhRWZelwsOakUDInOwFVRh0TtPIYPpzKzKLgbz9UGdGdijKAumMvi0nW6Zi
pGtRPW2tbKNMpit9J0D9MXvABqM
-----------end_max5_patcher-----------

Indeed the only way to know if there is nothing in a zl group object is to somehow keep track of whether something came in.
Here is an example that should do what you are looking for if I understand correctly:
----------begin_max5_patcher----------
1066.3ocwY1rbaaCDG+rzSAFdVQC9fe1iIGxCPO1wiGJQXYlRBpgDLUsYx6d
AVPZoXCICYBxbQ1DBlK9s6+cwB3erdUvtlS7t.zef9KzpU+X8pUvP5AVM77p
f57S6qx6foEH3+SytuErw7UR9IILrDsCUNNZYALlZdehMNlnutTTwkvagbdv
ld43nzgQMCI+2ibyBKXWt3PvFTPoPYrGFl0wb49mKEGdrkuWZlHkw1Ri1fHL
5V7FDMaq5Ap52QOn+a94505O1LMRsQI0JkTqTRtFkuGcDEcJpBYwyGbRD1VP
L5NhhSkOFk.7QG+zm70wqPXDwFigVYjYkQ16oTG+oK.SS.fCCmCfslSxVP4J
MjNmx0R6AShOJ6nI7dp5jk5CR6q2waGW9puprtuFV7j2xYzKQxi4s40bIu8Q
tHeWEf.1C9fWDy2zCDEBdfHLFxfYmUxibTJF4.+AbJ6apq45nwqh+eooWHQx
m4nm4UEHQiTsY1vjpJE785u+R9tz2QuCMB95vaJGGFBPmRFc.enf+tdorQXQ
PGg8TflbyJW2LeFm.fhGRqG+7CA50BneVsJf3oNThTKRK9hvLOE3vCpVSkWR
DHdoXOizexUUoDE7SnlmPE7txVdApaedE+SZHsAXpe.jlwtLsjjQlG.aZklT
OEmn7t8bQgZgfZZKNWH6R7R7EdX.OVHT2kjjMK3801l9iupFiBTYCJGUU1YU
gF4YBoCAP1roPGy4fXn9APgZiMlux9.XhX5cKmZt2Uqaxn+1qaRiSFJyP8Pg
yqzHz+UssSkFZ6nII2Qyd2rM.mZBZHYLjLGMyBGxz5ITng2gpj4x4LcowOro
vCFfMNaNP9XqZUfTGaQYUdgMxIdpVyP.L1bvqT7bPiRlVKe1BEjrEUkFkNip
TSH6fdaCajl32tWXlMEhimo30U4HdYqqX1BLZFiXUbwA6hSOsk23E3XNueb5
LEwTbXCB7hDuHQT8F5CmRfkLIF+6tpxK5gr4om53fchwuEvz6dmd57bc.lcE
LnmFNzjyEGEtofeo7oUsoiY.p+jA6xOXSCrD26yKWGhQfGktMw18g.uB3P5u
55mgWod7ek5tl918iqgg3M5rWUcvJYoHWVpZC77bzsEftl1yUCM9Rtokz2ol
erD0EKQ7gkHumk7.RLG7cDOYGxBXG8Ew79xNenEbww4kHTzBQDYwbcIt3690
Ui4xJzUCmjoScTFN072Hmxqx7fkXNU8KxGBQWpIoa6b5VxEuGyG6cvntFmlr
kHtTQ2G6cvHtvT7hkHmYOQlr.lNwtowSqNYlK0I8wlYiAoaaoDeXIWR3dKRl
lDyOd7671tgYC1P0D72Z.ec5l0l++RlGg1VCZ4eubb9lIj2p5SUpZRsuEVWA
mhMWYDzOdqnubPynnSYRnAag5XDcGyMf.8gu9mq+eNu4kL.
-----------end_max5_patcher-----------

With the help of the Cycling74 forum, I came up with this solution that uses borax to count the held notes, and as a trigger to clear the zl object when the count is 0.
----------begin_max5_patcher----------
866.3ocuX1zaaBCFG+bxmBKzNlEgMP.lTOsO.6vNNMUYHtItCL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MlygM1o+gwTjhZdSdfFOsjv.BB8fHU
kTKIvbDKec4eADs2DjA
-----------end_max5_patcher-----------

Related

Cimplicity Screen - one object/button that is dependent on hundreds of points

So I have created a huge screen that essentially just shows the robot status for every robot in this factory (individually)… At the very end of the project, they decided they want one object on the screen that blinks if any of the 300 robots fault. I am trying to think of a way to make this work. Maybe a global script of some kind? Problem is, I do not do much scripting in Cimplicity, so any help is appreciated.
All the points that are currently used on this screen (to indicate a fault) have very similar names… as in, the beginning is the same… so I was thinking of a script that could maybe recognize if a bit is high based on PART of it's string name characteristic. The end will change a little each time, but I am sure there is a way to only look for part of a string and negate the rest. If the end has to be hard coded, that's fine.
You can use a Python script in Cimplicity.
I will not go into detail on the use of python in Cimplicity, which is well described in the documentation indicated above.
Here's an example of what can be done... note that I don't have a way to test it and, of course, this will work if the name of your robots in the declaration follows the format Robot_1, Robot_2, Robot_3 ... Robot_10 ... Robot_300 and it also depends on the Name and the Type of the fault variable... as you didn't define it, I imagine it can be an integer, with ZERO indicating no error. But if you use something other than that, you can easily change it.
import cimplicity
(...)
OneRobotWithFault = False
# Here you get the values and check for fault
for i in range(0, 300):
pointName = f'MyFactory.Robot_{i}.FaultCode'
robotFaultCode = cimplicity.point_get(pointName)
if robotFaultCode > 0:
OneRobotWithFault = True
break
# Set the status to the variable "WeHaveRobotWithFault"
cimplicity.point_set("WeHaveRobotWithFault", OneRobotWithFault)

How to setup a condition in anylogic, that will return true, only when specific message is received?

Good day,
I'm trying in AnyLogic to make block "Ped Select Output" (from Pedestrian library) select output based on the received message, using the command in conditions table receive("go");. This block is located in Main, while the message is supposed to be sent from the agent tab (MyAgent) using the command send("go", main.pedSource);. Yet if I try to launch this model I get the error "Type mismatch, cannot convert void to boolean". I believe I have incorrectly selected one of the commands (or maybe both), thus I hope for advice about it. Thanks in advance for the answer.
P.s. check screenshots, for more detailed information.
P.p.s. the model, that is presented on screenshots is just an oversimplified example of the real model (that's why 4 out of 5 outputs of the block are connected to one place).
main
agent
Each condition in the selectoutput should return a boolean... a boolean can be true or false
Some example of booleans are 3==2, 5>4, agent.priority==1, etc
These things are booleand because they are true or false
you are putting in the condition a function that doesn't return anything (receive) and I have absolutely no idea what is in your head that would suggest that this might work in any way...
I suggest you add a variable in your ped agent that defines what the pedestrian should do...

SAPUI5: set Timepicker configuration for 15 min interval

Is is possible to configure the sap.m.TimePicker to display only 15 minute intervals?
At the moment the user can enter any time they like.
It's possible now with version 1.40.+
There was incorrect information in the API documentation and it wasn't possible even on version 1.38
Change it to a DropDownBox with a value range of 00:00, 00:15, 00:30, ... 23:30, 23:45? This makes the limitation to specific intervals clear at a glance, is easy to implement and avoids entry of undesired values altogether.
While #vwegert 's answer is function I think there is a better way where you you still get the look and feel of the TimePicker.
In the source of the control there is a property minutesStep. If you can set this in the xml or js definition I think you could be onto a winner.
In fact there is a setter (yay) setMinutesStep.
oTimer.setMinutesStep(15); should be a winner for you.
Hope that helps,
Nigel

Inserting different map object to CartoType map

I can add one mapobject by using:
m_framework.InsertPointMapObject(m_framework.GetMemoryMapHandle(),"amenity",
32.791576, 39.909264,
CartoType.CoordType.Degree,
"AHMET YILMAZ\n06DY1998\n",
CartoType.Util.IntAttribute("fue",1),ref id,false);
But adding another with same code to another location is impossible. It is not drawing the second one. I have tried changing id but not worked.
Can I only add one map point?
Thanks.
Muzaffer, I'm sorry I didn't notice this question. As the CTO of CartoType I ought to have done. Yes, you can insert as many points as you like.
The problem you're having is caused by a conflict in object IDs. The first call sets the ID to one assigned by CartoType. If you leave that ID as it is, and use it in a new call, it will conflict with the ID of the object you just inserted.
The best way fix this problem is to change the ID to zero each time, just before you call InsertPointMapObject. Then CartoType will assign an ID and return it to you in 'ref id'.
If that doesn't work, please post a small repeatable example with all the code needed to reproduce the problem, and I'll look into it further.

Remove Matlab r2014b Plot Browser limit

Among many distressing graphics changes to r2014b, the Plot Browser now only displays a certain number of lines per plot (looks like the limit is 50). Any number of plots above this limit are not displayed in the Plot Browser - it just says "and 78 more..."
Is there anyway to remove the limit? I want to see all my lines in the plot browser.
Unfortunately the answer is currenty:
No you cannot remove this limit
This was already reported to mathworks a while ago, and here is the reply:
I am writing in reference to your Technical Support Case #01143663
regarding 'plot browser with "and xxxx more...." indication'.
Really interesting question (and even a bit surprising). Basically
this limitation has been introduced with MATLAB 2014b!
Our developers are aware of that, and they are working to solve it. An
enhancement/bug request has been already submitted, and I am going to
add this case to the list. However, I cannot guarantee you a release
date.
If you think this limitation is crucial for your work, I would
strongly suggest you to contact your account manager, which will have
a bit more influence on the developers than a simple engineer :).
Of course, if there is anything else I can do for you, please let me
know
So it seems that you will have to deal with this limitation if you keep using 2014b.
This was also an issue for me; in particular I wanted to see the DisplayName property of the graphics object in the list. I used a workaround where I created a callback function, so that when clicking on a data point, the DisplayName would be shown. This can be helpful if you have a plot of many lines and want to see the DisplayName of a particular one. You would first need to set the DisplayName property of the graphics objects for this to work, as it's empty by default. You could also use this to show other properties, such as Color or LineStyle, that are shown in the plot browser:
%Based on
%http://www.mathworks.com/help/matlab/ref/datacursormode.html
%'fig_h' is the figure handle
dcm_obj = datacursormode(fig_h);
set(dcm_obj,'UpdateFcn',#myupdatefcn)
And then include this function as a separate file on the Matlab path, or paste into the function you're currently writing, and include an extra 'end' at the end of that function:
function name = myupdatefcn(empt,event_obj)
% Customizes text of data tips
tar = get(event_obj,'Target');
name = get(tar,'DisplayName');
end