As a next step, Peter,
- Try the patch I posted as is,
- see whether the “demo pipelines” give the behaviour you want
(ie. switching pipes on & off when toggling CC66)
and, if so, - build in the other pipes you want
When you’ve seen it working and monitored what each pipe is doing in line 1, you’ll see that it’s no big thing!