home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / dxma.exe / DXMA05.cab / samples / da / java / exercises / Sound / Sound.java < prev   
Encoding:
Java Source  |  1997-11-13  |  1.3 KB  |  44 lines

  1. // This applet illustrates importing, scale to fit and rotating an image
  2. //
  3. // Copyright (c) 1997 Microsoft Corporation
  4.  
  5. import com.ms.dxmedia.*;
  6. import java.net.*;
  7.  
  8. class SoundModel extends Model {
  9.  
  10.   // Create the animation in the createModel method.
  11.   public void createModel(BvrsToRun blist) {
  12.     // Build up a URL to import relative to.
  13.     URL mediaBase = getImportBase();
  14.     URL imgBase = buildURL(mediaBase, "image/");    
  15.     URL sndBase = buildURL(mediaBase, "sound/");
  16.  
  17.     // Create an image behavior by importing a bitmap.
  18.     ImageBvr img = importImage(buildURL(imgBase, "phantom.jpg"));
  19.     // Create a sound behavior by importing a wave file.
  20.     SoundBvr snd = importSound(buildURL(sndBase, "earth.mp2"), null);
  21.  
  22.     // make the image wiggle
  23.     img = img.transform(rotate(mul(sin(localTime), toBvr(0.25))));
  24.     // make the image oscillate
  25.     img = img.transform(translate(vector2(mul(sin(localTime), 
  26.                           toBvr(2*cm)), toBvr(0))));
  27.  
  28.     setImage(overlay(img, solidColorImage(black)));
  29.  
  30.     // Create a sound that loops continuously.
  31.     snd = snd.loop().pan(sin(localTime));
  32.  
  33.     // And set the sound that gets played using setSound()
  34.     setSound(snd);
  35.   }
  36. }
  37.  
  38. public class Sound extends DXMApplet {
  39.   public void init() {
  40.     super.init() ;
  41.     setModel(new SoundModel());
  42.   }
  43. }
  44.