In the application of Alpha’s AM4E series IC, you can change the envelope of melody in EzCode4E as your required. In this article, we introduce how to edit or change envelope of melody.
In EzCode4E, two methods can change envelope as illustrated below:
Method 1: Use PowerMelody to add envelope codes in Melody. In this way, the envelope can be changed.
Method 2: Use commands in program to change envelope.
Editing Envelope
In envelope column, click “New” to pop up a window, then you can edit envelope in this window. Up to 8 envelopes can be added. See the figure 1 (Trill effect):

Adding Envelope Codes in Melody
1. Envelope codes should be placed in Channel 1 and Channel 2 but not in Channel 3. If you place envelope codes in the Channel 1, the envelopes in Channel 1 can be changed. Likewise, if place envelope codes in the Channel 2, the envelopes in Channel 2 can be changed.
2. At most up to 8 Envelope codes can be added. The range of index number is E1 to E8, and the corresponding codes in PowerMelody are 1 to 8.

Programming
1.Create and save an EzCode project file, then select a suitable IC, such as, AM4EC015.
2.Fill in Project option with the correct info. Note that the username cannot be ignored.
3.Set IO pins and Input State in IO pin option.
4.Edit envelope in Envelope column (see the figure 1).
5.Add melody in Melody column.
Steps for programming: First play Melody after adding envelope codes, or use Envelope command, then select the Channel whose timbres need to be replaced, finally use playm to play the original melody.

Program Example Description
The figure 3 shows the program example in which 4 Envelopes are added. Among them, E1 and E2 are the self-defined envelopes, while E3, E4 are the envelopes copied from the defaulted envelopes. The defaulted envelopes are placed in the installation directory of EzCode4E
As figure 3 shown, in Path k_a0 the envelope is changed by codes adding in playing melody. In this way, the envelopes will be auto-changed when playing.
In Path k_a1, since the envelope codes are not added in melody, the envelope is changed by commands.
In Path k_a2, if you use commands to change envelope and add codes in melody, the envelope will be changed by envelope codes during melody playing.
In Path k_a3, this example means to use the defaulted envelope of EzCode4E.
Note:
1. If you both use command and add codes to change envelope in melody, the envelope will be changed by codes adding when playing melody.
2. If you want that the envelope be returned to the defaulted one in melody playing, you should copy EnvelopeDefault8.dat and EnvelopeDefault6.dat in installation path, then save them as another names to add into Envelope column as the E3 and E4 shown in figure 3. When playing melody, they can be called for again.
3. The last used envelope code or command is valid for the following melody playing, unless you change envelope again.