You can use a MIDI "program change" message to tell a synthesizer to change to a different sound. The Max object for that is pgmout.
These patches use timed counting—in both cases using a metro object and a counter—to step through a series of MIDI notes.
Every MIDI note-on message must be turned off at some time by a subsequent corresponding note-off message for the same pitch (or note-on message with velocity 0). This patch shows two ways to ensure that. One is a very simple way that's illustrative but not ideal; the second way is much more versatile and is the preferred way.
In the MIDI specification, and in most DAW software, and in Max, the smallest unit of metric timing is expressed in "ticks", which is to say, partial units of a beat. Commonly the number of ticks used is 480 or 960 parts per quarter note. That number makes sense because it's divisible by 2, 3, 4, or 5 (and multiples of those).
This example plays a 12-note chromatic scale over three octaves with timed triggers.
In this example, one octave of chromatic scale is played from the middle C.
This patch uses metro, counter, and table to read through MIDI values to create an ascending and descending major scale.
This patch uses metro and counter to automate a scale with crescendo by referencing a table object containing patterns of pitch and velocity MIDI values.
This patch uses tempo to control the timing of a long crescendo in musical terms.
This patch demonstrates how to create a linear crescendo using the makenote and noteout objects.