home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / sviluppo / purebasic_demo / purebasic / examples / fullversion_sources / sound.pb < prev    next >
Encoding:
Text File  |  2000-01-27  |  2.1 KB  |  138 lines

  1.  
  2. ; *********************************
  3. ;
  4. ; Sound example file for PureBasic
  5. ;
  6. ; © 1999 - Fantaisie Software -
  7. ;
  8. ; *********************************
  9.  
  10.  
  11. #SOUNDS=2
  12.  
  13.  
  14.   If InitSound(#SOUNDS)
  15.  
  16.     PrintN("3 Sound Objects is Allocated.")
  17.  
  18.     If LoadSound(0,"PureBasic:Examples/Data/Bump.IFF")
  19.       PrintN("Loading Sound.")
  20.     Else
  21.       PrintN("Can't find 'PureBasic:Examples/Data/Bump.IFF'")
  22.     EndIf
  23.  
  24.  
  25.     If DecodeSound(1,?sound)
  26.       PrintN("Decode Sound.")
  27.     EndIf
  28.  
  29.  
  30.     If CreateSound(2,100)
  31.       PrintN("Create Sound.")
  32.  
  33.       len.l=GetSoundLength(2) : c=0
  34.  
  35.       Repeat
  36.  
  37.         If c & 1
  38.           PokeSoundData(2,c,127)
  39.         Else
  40.           PokeSoundData(2,c,128)
  41.         EndIf
  42.  
  43.         c=c+1
  44.       Until c = len
  45.  
  46.       For c=0 To 99 Step 11
  47.         Print ("Sound data nr.") : PrintNumber(c)
  48.         Print(" = ") : PrintNumberN(PeekSoundData(2,c))
  49.       Next
  50.  
  51.       PrintN("")
  52.  
  53.       SetSoundPeriod(2,13100)
  54.       SetSoundVolume(2,64)
  55.       SetSoundChannels(2,15)
  56.  
  57.     EndIf
  58.  
  59.  
  60.     chan.w=UseSoundChannels(15)
  61.     Print("Allocated channels = ") : PrintNumberN(chan)
  62.  
  63.     PrintN("Playing Sound 0.")
  64.     PlaySound(0,-1)
  65.     Gosub LMB
  66.  
  67.     PrintN("Playing Sound 1.")
  68.     PlaySound(1,10)
  69.     Gosub LMB
  70.  
  71.     PrintN("Playing Sound 2.")
  72.     PlaySound(2,-1)
  73.     Gosub LMB
  74.  
  75.     PrintN("Changeing Period.")
  76.     per.w=13100 : tmp.w=100
  77.  
  78.     For c=0 To 99
  79.  
  80.       VWait()
  81.       per=per+tmp
  82.  
  83.       If per > 18000
  84.         tmp=-100
  85.       EndIf
  86.  
  87.       ChangeSoundPeriod(2,per)
  88.     Next
  89.  
  90.     Gosub LMB
  91.     PrintN("Changeing Volume.")
  92.     vol.w=64 : tmp=-1
  93.  
  94.     For c=0 To 99
  95.  
  96.       VWait()
  97.       vol=vol+tmp
  98.  
  99.       If vol < 15
  100.         tmp=1
  101.       EndIf
  102.  
  103.       ChangeSoundVolume(2,vol)
  104.     Next
  105.  
  106.     Gosub LMB
  107.     StopSound(2)
  108.  
  109.     If SaveSound(2,"Ram:Test.IFF")
  110.       PrintN("Saving Sound to RamDisk.")
  111.     EndIf
  112.  
  113.     For c.w=0 To #SOUNDS
  114.       FreeSound(c)
  115.       Print("Deleting Sound Object nr.") : PrintNumberN(c)
  116.     Next c
  117.  
  118.   EndIf
  119.  
  120.  
  121.   PrintN("End of Program.")
  122.   End
  123.  
  124.  
  125. LMB:
  126.   PrintN(">> Press LMB to Continue <<")
  127.  
  128.   For c=0 to 24
  129.     VWait()
  130.   Next
  131.  
  132.   MouseWait()
  133.   Return
  134.  
  135.  
  136. sound: IncludeBinary "PureBasic:Examples/Data/Jump.IFF"
  137.  
  138.