Clip detection crashes Live
I’m adding automatic clip creation to a Max for Live device I created which records MIDI notes automatically so if you forgot to press record, the last take can instantly be recalled to a clip. Previously a user had to create a clip before placing the notes into the clip. I’m working on the ability for the device to create a clip and place the notes inside the new clip in a single step. So far that has worked flawlessly. The problem I’m running into is likely with my error checking.
When triggered, the device will check which clip slot is selected, create a clip then add the notes into the new clip. Before doing so I’m checking to see if a clip already exists in the selected slot. If there is a clip in the selected clip slot I increment to the next slot and check for a clip in the new slot. The process continues until an empty slot is detected. This is when trouble starts.
When I detect there is a clip in the selected slot, Live unexpectedly quits. I’ve added breakpoints to the subpatch which does the clip detection and data is flowing exactly how I’d like it to so I’m pretty confident the error checking is sound. Thinking perhaps the numbers representing the track and clip were floats rather than ints I tried incrementing with both and it crashes the same. Before trying an entirely different approach to the problem I thought I’d see if anyone has ideas.
Here is the sub patch which does the clip detection. Does anyone have thoughts or a suggestion?
----------begin_max5_patcher---------- 1098.3oc4X0saaaCE9Z6mBBgd2bLHo9u.8hsc0.Fvd.F1BjkXrYqLklDUhyJ 569HOTJ01wRlZYlEnCAwPGxiDOee77G4mWtvaS0AVqG58neGsXwmWtXALjdf E8xK71mcHuLqETyKuZ+dlP5sxLmjcPBi+m2c2uIxYnhLYFRoDqEU0IQUOfj6 3vykL4JjropaSIC0JyZjsqQ+J+QF5IdYIpSvNTyxkrhxmQ+UGWtdXMJ4BVdU m.VH+9AenY6FsLdMteDQ2dtPsHfcRFTqRHa4+MCF6DcMVDn7vn0Yx7cbw16a T1ggTn3X0Kg7CSVGtBQBCzRApOD5O5eIdAf+pMe7tTuiVUQ1dXU89wFdVI5m pJK7zy9kkK0+rxR9VvdR8oeEcKQk5+7dyXefOMCIetlY.tm2p9+eAoWfdB7i zDBEGB7BHPRtL63eCXmw7F+4cr7O0hjUnVFCw0NgJetxJIR4Kx1WKedM5Wd. w0xqT5HJ.uUsVk7VILonR4uxE4ML8RXdaE2sg0fxT5qHA8hbYuz.25kZ7N8C n.+a1SBIirM3++OuTSTaJ7aOIMlSJwcrScV9mPXD9hzCcNzCYT5whfWRBPOQ SxKzX2wK+.hbCoDtNBcJVIF7SHQXHwOEx6OFqj3NVoSLo+xrBmnSQNqrfi58 b7Ssvy4VTUT0dQa1V125HGhOjoEabXFIiB1c9HplqjpxcEucdgNYB2qmrklB jRP7TtFDp6nFUO.uiSPe3CpHHUYdAZSlXKhU1xzU9of3MLvxRZymXHr9bPiv aNLqSop+70JycmSqgmWUV0XlEuNMIvmDrR8TBIMBmneBGhSUObbKNi6JFELz Oz3TZ7sOI0Q08k6PZh89VlpmylLcqpuifxK402qayTIQAouY42LDW.wzb+j4 2h9NL8toeQe3PMTeLzBvHvO3F.ei0NYDm0GMnGKQPdEZ3vuWrRs2KgelSUom 3ei8Cl6EM++62kHQWGXjqAL3kfSvc1cg.Kqd7SQaaUWS9fQNzHH5qqcAqUxE YRdk3XkTIYPjWTZGunfINlUdRuZ0Uptut2X8Dxqm4gxrsmDHTvay1TxfW.ew cKqQQ5IF3Hn3TnZCJvNEE1rUDLWLD6bHbs8AcekShg87BvP6cooplU0WRfoN nePh4dsNVhfSLGQNDx3gOtV4qXjDmxHwVropambd6pgNECQVfg34Bg.mBg.a RyM67CtM3ReEOWEDQyED9tGCDKRxMqxMT2iApMY4lWMS2BBrMQDoy0aJ0sf3 VDPPhbNFdqADmUwLHzbiwTr4XjguHMdUQRnyQ8aND5bXGC24I0bsVg9TSq0G KkZnh3HshogSRHAtuEVqZDedNytM0H0l1c7mMHbaMpyZG6xfX1GlvsYUroUg y5m30XXLywbpyr55GYMs8eSvRTml9il6+BPqJ.UXDgZadMrG4C5Coa7xZTGN VpNYbWi49GNjDoNeqZc9xx+guF7WW -----------end_max5_patcher-----------
I figured out what was going on. Previously the device had been working because the user had to manually create a clip. After the user created an empty clip they would click a bang button in the device which would call replace_selected_notes to add notes to the empty clip. Everything was good.
In my update I added the create_clip call to create a clip so the user wouldn’t have to. When I detected a clip in the selected slot I would move on to the next slot until an empty one was found. The plan was to create a clip and add notes. However, when I called replace_selected_notes on a clip that wasn’t selected, Live would crash. Since there were no notes in the clip previously it never occurred to me to make a call to select_all_notes. As long as I call that before replace_selected_notes on an empty clip that isn’t selected, everything works just fine.
In the end I learned I should select notes before replacing them and that replace_selected_notes can crash Live if no notes are selected. Here is a sample patch if anyone wants to try crashing Live for themselves.
----------begin_max5_patcher---------- 1291.3oc6Zt0biZCE.9Y6eEZX5KYFudzEt121849VerSGFYPIlsXfAImMs6r +2qjNPhShMVNEvtS6DGLRBCG8oCmav2WtvaS8SBoG5mQ+FZwhuubwBaWlNVz 0dg2N9SYkbo8v7xp2sSTo7VAioDOor86eG5y44HonTjoR4kkoU0JgDopQpsB jTwaUn560MJj5ipsPOltYl9HkHdUNRuCROz2Dkkq6O6kEUhr58U1KAqqyp86 p2qJEJq.g65891G1XautumFtJaaQ0CosZIBlhAThdXDKwrkDDX9xW+KP+d2u oH2NYp270OQi6kh6qqTU7cB6PetsfWh9RcY9gCKK9K6vjWt7ZwrnpWJIl99w xklMqbjz6DRI+Aw6HsAYuiydGENjtdgtT+Yi.3fm2yy3SSoXrkR3H6WgmfRg iHkne.JcJ8Q1cnuvqdvn+0JZJ4YBDnPZz0xZ4xsneo3QwZu+4ZULJyfHq1DE a2mDeBbQtxJUmBWzWvUVqfqDnrxhlieiHcDPV3yDKjZ4VxwAFI3FEXj6P+pP gTs7r+.zoz7BIKqUnsh1QQuhPCWSC5vDIfsN3zJVgWYLUI9lVLdGkJM2hoGv LmFQKTrPqsIJIxvjfjgtkKwQxjUWV2Bmd75jXeFwekduXRRHN1rGN.mn2gbv kwIiZccJ4OJxSAVjxUp1hM6Ufu2EOC0EdoMhVYgTIpxDOuX.qFikCDMP2hLq LoxdMXI5mHVM3TiFrtE01ZLWy7wf+j.BXmDOjak3qrWkgTmM363fgcRvrp6e W.Tbr01HYHkZ1UVo9iXhPqtqpqtPUpMZmRCRMZRxANe62dTeuLuI1ZmBso+u iOMCFbZt5Le6.Fn1sQCFCBgcKGXadckXT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