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

Play back sounds


You may want to play it back so try this.

' sndStartFilePlay

'INCLUDE FILE _aplIncl

'___________________________________________________________________________

' FUNCTION SndStartFilePlay (chan: SndChannelPtr; fRefNum: Integer;
' resNum: Integer; bufferSize: LongInt; theBuffer: Ptr;
' theSelection: AudioSelectionPtr; theCompletion: ProcPtr;
' async: Boolean): OSErr
' Ref IM : Sound p1-26, p1-36

' chan: SndChannelPtr; NIL - Sound Manager allocates channel
' fRefNum: Integer; provide a fRefNum of a file
' resNum: Integer; 0 - play a sound file, not a resource
' bufferSize: LongInt; 20480 min buffer size
' theBuffer: Ptr; NIL - Sound Manager allocate memory
' theSelection: AudioSelectionPtr; NIL - Sound Manager plays entire sund
' theCompletion: ProcPtr; NIL - No completion routine
' async: Boolean FALSE - Synchronous playback
' OSErr

'___________________________________________________________________________

CLEAR LOCAL MODE
LOCAL FN fbsndStartFilePlay (fRefNum%)
  sndChanPtr& = _NIL
'fRefNum%
  resID% = 0
  bSize& = 20480
  bPtr& = _NIL
  selPtr& = _NIL
  procPtr& = _NIL
  aSync = _FALSE

  sndErr% = FN SNDSTARTFILEPLAY (sndChanPtr&, fRefNum%, resID%, bSize&, bPtr&, selPtr&, procPtr&, aSync)

  SELECT sndErr%
    CASE 0 : PRINT "sndErr% = 0 noErr"
    CASE -201 : PRINT "sndErr% = -201 notEnoughHardwareErr"
    CASE -203 : PRINT "sndErr% = -203 queueFull"
    CASE -204 : PRINT "sndErr% = -204 resProblem"
    CASE -205 : PRINT "sndErr% = -205 badChannel"
    CASE -206 : PRINT "sndErr% = -206 badFormat"
    CASE -207 : PRINT "sndErr% = -207 notEnoughBufferSpace"
    CASE -208 : PRINT "sndErr% = -208 badFileFormat"
    CASE -209 : PRINT "sndErr% = -209 channelBusy"
    CASE -210 : PRINT "sndErr% = -210 buffersTooSmall"
    CASE -223 : PRINT "sndErr% = -223 siInvalidCompression"
  END SELECT

END FN

'___________________________________________________________________________

CLEAR LOCAL
  DIM 255 ParamBlock$
  DIM volRefNum%, 63 filename$

LOCAL FN srfGetFileInfo (filename$, volRefNum%)
  _myIOFRefNum = 24
  pbPtr& = @ParamBlock$

  pbPtr&.ioCompletion& = 0 ' NO IOCOMPLETION
  pbPtr&.ioNamePtr& = @filename$ ' FILENAME TO READ
  pbPtr&.ioVRefNum% = volRefNum% ' VOLUME TO READ
  pbPtr&.ioFDirIndex% = 0 ' DEFAULT DRIVE
'pbPtr&.ioDirID& = 0

  GET FILE INFO ParamBlock$

  PRINT "Name=", filename$
  fRefNum% = pbPtr&.myIOFRefNum%
  PRINT "fRefNum% =", fRefNum%
END FN = fRefNum%

'___________________________________________________________________________

CLEAR
LOCAL FN sSFPOpenFile$ (filename$)

  filename$= FILES$(_fOpen,,, volRefNum%)
  action = LEN(filename$)

  SELECT action
    CASE 0
      PRINT "Cancel Selected"
    CASE ELSE
      PRINT "Open Selected"
      OPEN "I", 1, filename$,, volRefNum%
      PRINT "File Opened"
      fRefNum% = FN srfGetFileInfo (filename$, volRefNum%)
      FN fbsndStartFilePlay (fRefNum%)
  END SELECT

END FN = filename$
'___________________________________________________________________________

CLEAR LOCAL FN srfCloseFile
  IF LEN (filename$) > 0 THEN CLOSE #1
  PRINT "File Closed"
END FN

'___________________________________________________________________________
'LOCAL FN sndStartFilePlay
WINDOW OFF
WINDOW #1
CLS : TEXT _monaco,9,0 : DEF TAB 30
FN sSFPOpenFile$ (filename$)
FN srfCloseFile

'END FN

Peter