Is it possible to make the switch patch from when receiving an input from a switch...

I mean like when we load a patch in the web server ?

Best,
Hjalte

The short answer is yes, it can be done.

It won't be "seamless" -- it will be like when you do it from the IDE. Each patch is compiled as its own program so you have to trigger the "stop bela" script, and then trigger the start script with the new patch.

With my guitar multi effects processor I'm just compiling everything I want to switch in real-time into a single patch:

http://cackleberrypines.net/transmogrifox/src/bela/05_MultiDelay_16_Mar_2017.zip

3 switches right now:
Control context (which bank of control parameters in an effect gets inputs from pots on AnalogIns)
Effect context (which effect gets inputs from the pots on AnalogIns)
Bypass -- effect on or off

The easiest way to do this is probably to edit your ~/Bela_startup.sh file.
Once you set a program on boot, ~/Bela_startup.sh will look something like this:

#!/bin/sh
#
# This file is autogenerated by Bela. Do not edit!

echo Running Bela...
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin"
 cd /root/Bela/projects/1-digital-out && screen -S Bela -d -m  /root/Bela/projects/1-digital-out/1-digital-out -p16 -C8 -B16 -H-6 -N1 -G1 -M0 -D0 -A0 --pga-gain-left=10 --pga-gain-right=10  -X0

This file is executed at boot and runs your program. You could then edit it so that it runs multiple programs one after the other. You would then have to stop the currently running program which would automatically run the next one. You can use the button on the Bela cape to do this: if you tap it briefly, it will stop the currently running program.
So assuming you have the projects listed in the $PROJECTS environmental variable already compiled and ready to go, and that you use the same command line $OPTIONS for all of them, if you put the following in your ~/Bela_startup.sh then you should be able to achieve what you ask by pressing the button on the Bela cape.

#!/bin/sh

OPTIONS="-p16 -C8 -B16 -H-6 -N1 -G1 -M0 -D0 -A0 --pga-gain-left=10 --pga-gain-right=10  -X0"
PROJECTS="duck basic exampleTempProject"

echo Running Bela...
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin"
screen -S Bela -d -m bash -c "\
while sleep 0.1;
do for PROJECT in $PROJECTS;
do sleep 0.3;\
echo Running \$PROJECT, press a button to load the next project;\
cd /root/Bela/projects/\$PROJECT && ./\$PROJECT $OPTIONS;\
done;\
done;"

Note that is you hold press that button for over 2seconds then the board will do a graceful shutdown. If you are concerned that this may happen inadvertently, you can disable it by editing the content of ~/Bela_capeButtonHold.sh.

    giuliomoro Am I correct in assuming ~/Bela_startup.sh gets over-written any time you use the IDE to select a program to load at boot time from the IDE? Are there any other actions that cause ~/Bela_startup.sh to get overwritten, for example pressing "start" on the IDE?

    Maybe this user action could be edited with the ability to automatically generate a start script so you could either select a single project or select an alternate script?

    That way the IDE does not overwrite your script and also gives an option to run the alternative script.

    The IDE only overwrites that file when you select a project to run on boot, so it's safe to do.
    If you really want to, you could put all the content of that script in an executable file in /root/Bela/projects/StartupProjects/StartupProjects and select the StartupProjects as the project to run on boot. This way you get both easy IDE access to the file and avoid unexpected overwrites.