I was reading the manual.. how do you do volume and vibrato envelopes?
All control over an instrument's envelope is done through its macro script. If you look at
./HuListen/SASS/Instruments.txt in the library download or
./Instruments.txt in the Secret SASS download you can see the basic instrument set I've used for most of the test songs and covers.
The big learning curve is that everything in SASS is a script, there are no predefined envelopes. So you're free to do ADSRAR or whatever you want instead of just ADSR.
The first instrument is actually a good example of a volume envelope among other things.
Let's walk through it :
CasioTrumpet
; Approximation of Earthbound / Mother's Trumpets.
; Uses the same waveform as the CasioTone instrument, but has
; a much slower attack phase giving it a brass / wind quality.
;-----------------------
{
wave 0,4,12,24,28,29,28,24,12,8,4,3,2,2,1,1 0,2,6,12,14,15,14,12,6,4,2,2,1,1,0,0
frequency 6 -1
volume 20 2
tuning 16.0
{
rest 4
volume 30 -1
rest 2
frequency 0
volume 28 -2
rest 2
volume 22 0.113
loop -1
wait 9
volume 26 -0.113
wait 9
volume 22 0.113
endloop
noteoff
volume 24 -1
wait 18
end
}
}
The parameters inside the first set of curlybraces right after the instrument name are the initial settings. I set the waveform and initial envelope operations here. We're interested in the latter, which are :
frequency 6 -1
volume 20 2
...
The first line (
frequency 6 -1) sets the instrument's frequency offset, and how that will change over time. When an instrument is played, its final frequency is the
sum of its
current note, any active
pitch bends, and
this offset value. We're setting this to
6, which increases the divider value and gives us a lower frequency. The second parameter of
-1 indicates how the frequency offset will change over time. In this case it
decreases by 1 per tick. So the pitch of the instrument is
increasing.
The next line (
volume 20 2) does the same, except for amplitude. We set an initial volume of
20 (out of 31), and will add
2 to it each driver tick. So we're getting
louder.
That's our attack phase.
Continuing onward :
{
rest 4
volume 30 -1
...
We've hit a
rest command, whose argument indicates we're not going to advance our script for
4 frames. Note that
rest and
wait are interchangeable in instrument scripts, but have different meaning in music scripts. I use both here.
Meanwhile, the frequency and volume envelopes are still calculating in the background. So by the time four frames expires :
Volume = 20 + (2 * (4 + 1)) = 30
Frequency / Divider Offset = 6 + (-1 * (4 + 1)) = 1
Some drivers I wrote pre-add these values on any change, so you need to bias the frame count by one. I think HuSound is one of these. Yay, standards.
Anyway, our next command is
volume 30 -1. The volume is getting quieter, and we're starting our decay phase.
Let's skip ahead, since you've likely picked up what's going on by now. A little further down is our first loop :
...
volume 22 0.113
loop -1
wait 9
volume 26 -0.113
wait 9
volume 22 0.113
endloop
...
We set the volume to increase and then enter the loop body with a loop count of -1. This is an infinite loop, and it will continue until either the song hits a note off command, is manually stopped, or the channel is taken over by a sound effect.
Looking at the body of the loop, I'm just delaying for a bit, then reversing the direction of the volume envelope, effectively doing this : /\/\/\/\/ ... during the instrument's sustain period.
Replacing this with a frequency command will effectively give you vibrato. You can make the differentials very large and the delays very small to get arpeggios.
Now about note off commands -
We're effective looping in the sustain period above, and will stay there until we hit a rest / note off command in the music script. Once we hit one of those, the instrument script will JMP to the tagged note off area of its script (if the instrument still has control of the channel).
If we look right below the loop body, you'll see :
...
endloop
noteoff
volume 24 -1
wait 18
end
}
The
noteoff tag is where the instrument will jump. If you look right after it, I'm setting the volume to decrease and then telling the instrument to terminate.
Hopefully all this is clear! SASS can be a little difficult.