How do I define Envelopes?

Envelopes are Defined with the Env object. For example, if you want to define the Triangular envelope, you say

Env([0.0, 13.0, 0.0], [5, 10],'linear');

Look at the help file of Env for parameters specifications

How do I use the Envelopes I defined?

To use the envelopes, you need to use the class EnvGen. This is because Env is just a specification for a segmented envelope. EnvGen is the UGen that actually can be played. For example, with out previous example:

~env = Env([0.0, 13.0, 0.0], [5, 10],'linear');
EnvGen(~env); //this is creating the UGen

Look at the help files for EnvGen for details.

Do I need to use Env.adsr and Env.triangle?

No, you can do evrething with arrays, as explained in the question above

I'm using the Env.adsr but I don't know how to specify the length of the note.

Env.adsr are what's called trigered envelopes. That's the same that happens in consumer synthesizer, you press your key, and the note goes on until you realease it. The gate message does that. When you send a gate message of 0, the envelope releases (like realeasing your synth keyboard) and it goes to decay phase.

We where assuming that you where confortable with the notion of envelopes from 220a, but if you need more info, read Cottle book on chapter 12 (page 96) or/and chapter 2 in the Computer Music Tutorial (page 95).

For the specific excercise of the HW, if you defined a SynthDef (with a Env.adsr inside) for your instrument and what to play it for 9 seconds and then realease it, you can use a Routine like the example we saw in class with PianoPhase:

{a = Synth("envFM_hw1");
a.set(\gate, 0);

I don't undesrtand what you mean by "Add amplitude envelope in the phasing process".

This paragraph refers to the overall amplitude envelope of the phasing transition (and to the piano that accelerates to "skip" one note), not to the individual envelope shapes of the notes themselves... It would be an overall crescendo and decrescendo that highlights that part.