FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

SOUND

Use the Sound Manager


_gestaltMultiChannels = 11:' missing from the constants in FB
'
DIM channel1&,channel2&:' pointers to the sound channels
DIM sndHndl1&,sndHndl2&:' for two sounds
DIM result,pigsCanFly
DIM sndLoop,doSound,soundsOn
DIM rect;8:' used for drawing on the screen
DIM gPt;0,mY,mX
'
DIM sndChanRec;24:' we allow 24 bytes for the sound channel record
DIM sndManRec;6:' used for info about the sound manager
'
END GLOBALS
LOCAL FN SndCmdNow(whichChannel&,theCmd,pram1,pram2&)
  DIM SndCmd,SndParam1,SndParam2&
  SndCmd=theCmd
  SndParam1=pram1
  SndParam2&=pram2&
  OSErr=FN SNDDOIMMEDIATE(whichChannel&,SndCmd)
END FN
'
LOCAL FN SndCmdOnly(whichChannel&,theCmd,pram1,pram2&)
  DIM SndCmd,SndParam1,SndParam2&
  SndCmd=theCmd
  SndParam1=pram1
  SndParam2&=pram2&
  OSErr=FN SNDDOCOMMAND(whichChannel&,SndCmd,_False)
LOCAL FN SndChannelStatus(sndChanPtr&,scStatusPtr&)
  ` SUBQ.W #2,sp ;clear space for osErr
  ` MOVE.L ^sndChanPtr&,-(sp) ;point to sound channel
  ` MOVE.W #24,-(sp) ;size of the snd chan record
  ` MOVE.L ^scStatusPtr&,-(sp) ;address of snd chan record
  ` MOVE.L #$00100008,D0 ;selector for this toolbox call
  ` DC.W $A800 ;_soundDispatch trap code
  ` MOVE.W (sp)+,^osErr% ;D0 = osErr
END FN = osErr%
'
LOCAL FN SndManagerStatus(smStatusPtr&)
  ` SUBQ.W #2,sp ;clear space for osErr
  ` MOVE.W #6,-(sp) ;length of the record fo smstatus
  ` MOVE.L ^smStatusPtr&,-(sp) ;move the pointer onto stack
  ` MOVE.L #$00140008,D0 ;put selector into DO reg
  ` DC.W $A800 ;_soundDispatch trap
  ` MOVE.W (sp)+,^osErr% ;D0 = osErr
END FN = osErr%
'
LOCAL FN CheckSndManagerStatus:' check some of the info for sound manager
  smStatusPtr&=@sndManRec:' pointer to the record for the info to show up
  OSErr=FN SndManagerStatus(smStatusPtr&):' and go do it now
  LONG IF OSErr=_noErr:' make sure there was no error first
    maxLoad=smStatusPtr&.smMaxCPULoad%:' get the maximum loading on all
    temp$="Maximum loading, all channels:"+STR$(maxLoad)
    FN ShowMessage$(temp$):DELAY 1500
    numChannels=smStatusPtr&.smNumChannels%:' gets the number of channels
    temp$="Number of Allocated channels :"+STR$(numChannels)
    FN ShowMessage$(temp$):DELAY 1500
    cpuLoad=smStatusPtr&.smCurCPULoad%:' get the current load ALL channels
    temp$="Current CPU Load :"+STR$(cpuLoad)
    FN ShowMessage$(temp$):DELAY 1500
  END IF
END FN

Mel Patrick