Section5: Using Synthetic Audio
Here, compose the audio for this demo. Both the ocean and seagull
classes have static methods for defining the sound. This tutorial
discusses how the sound is generated for the ocean module. |
setSound(mix(ocean.getSound(sndBase), seagull.getSound(sndBase)));
The ocean module makes use of periodic and cycling sounds played by
parametrically controlling the rate, gain, and periodicity. By describing
how these parameters vary in time with methods, relatively small sound
bites can form the basis for rich dynamic sounds. The first implementation
of the algorithmic interface defines the characteristics of the pounding
surf. Define the roughness (based on the wind speed), gain and rate. |
class surf1 extends Statics implements algoFunc {
private NumberBvr _roughness;
public surf1(NumberBvr roughness) {
_roughness = roughness;
}
public Behavior periodFunc() {
return toBvr(0);
}
public Behavior gainFunc() {
return add(toBvr(0.45),mul(toBvr(.4),_roughness));
}
public Behavior rateFunc() {
return add(toBvr(1), sub(toBvr(.5),_roughness));
}
}
After implementing all the algorithmic descriptions for the sounds,
define the oceanSynth class. The constructor for this class creates
periodicSounds and cyclingSounds based on those descriptors. For more info
on periodSound and cyclingSound examine their Java source code in the
Lighthouse/utility directory. |
public class oceanSynth extends Statics {
public oceanSynth(NumberBvr roughness) {
_wave1 = new periodicSound(new wave1(roughness));
_wave2 = new periodicSound(new wave2(roughness));
_surf1 = new cyclingSound(new surf1(roughness));
_surf2 = new cyclingSound(new surf2(roughness));
}
Now put the sound together. First import the surf and wave components
(30K and 60K) each. Then query the sound method for each algoSound,
passing it the actual wav files to use. This will return sound behaviors
that can be mixed together to give the final sounds. |
public SoundBvr getSound(URL importBase) {
SoundBvr wave = importSound(buildURL(importBase, "wave.mp2"),null);
SoundBvr surf = importSound(buildURL(importBase, "surf.mp2"),null);
return mix(_wave1.Sound(wave), mix(_wave2.Sound(wave),
mix(_surf1.Sound(surf), _surf2.Sound(surf))));
}
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.