Ooops
November 27, 2020, 05:26:58 PM

Author Topic: [bb] Windows Audio Mixer Blitz Functions by Ziltch [ 1+ years ago ]  (Read 1394 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Windows Audio Mixer Blitz Functions
Author : Ziltch
Posted : 1+ years ago

Description : examples

Code: [Select]
Include "audiomixer.bb"
; Watch the windows audio mixer while running this to see levels change.

; examples of setvolume function
; SetVolume(4,2000) this sets main volume to 2000 (0 to 65535 range)
; MixerName$ = SetVolume( MIXERLINE_COMPONENTTYPE_DST_SPEAKERS,NewVolume)  This sets main volume
; MixerName$ = SetVolume( 262145,NewVolume,10000 ) This uses LineID to set LineIn/Mic record level.


While Not KeyHit(1)

  Cls
  Locate 1,10
  For controls% =  MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED To MIXERLINE_COMPONENTTYPE_SRC_LAST
  ; loop through all stanard window mixer lines.
  ; look in audiomixer include file for list of 'standard' types.
  ; your card will not have all types.

    If controls = MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED Then
      MixerControl =  MIXERLINE_COMPONENTTYPE_DST_SPEAKERS ; this is the main volume (NOTE: value is 4)
    Else
      MixerControl = controls
    EndIf

    OldVolume = GetVolume( MixerControl)
    ; Depending on sound card some special controls will fail
    ; if OldVolume = -1 it has failed.

    If OldVolume =>0 Then

      NewVolume = OldVolume + Rand(-1000,1000)
      MixerName$ = SetVolume( MixerControl, NewVolume)

      ; MixerName$ will contain name of Mixer control if volume was set OK.
      If MixerName$ <> "" Then
        Print MixerName$ + " number " + controls + " new value " +  NewVolume
      End If
    End If

  Next
  Delay 500
Wend
End


Code: [Select]
; This displays all your mixer line details.
; This info is very different for each sound card.

; It also creates a file containing the Name and lineID's of each mixer line.

graphics 800,600,16,2
include "audiomixer.bb"

setfont LoadFont("Arial",12,False,False,False)

local hMixer%
local uMixerCaps.MIXERCAPS = new MIXERCAPS
local uMixerDestinationLine.MIXERLINE = new MIXERLINE
local uMixerLineControls.MIXERLINECONTROLS = new MIXERLINECONTROLS
local uDetails.MIXERCONTROLDETAILS = new MIXERCONTROLDETAILS

local mxbank   = createbank(52)
local mxlbank  = createbank(168)
local mxlcbank = createbank(24)
local mxcbank = createbank(148)
local zerobank = createbank(4)


rc=mixerGetDevCaps(hmixer, mxbank, 52)
wMid%            = peekint(mxbank,0)
wPid%            = peekint(mxbank,4)
vDriverVersion%  = peekint(mxbank,8)
szPname$         = peekstr(mxbank,40,8)
fdwSupport       = peekint(mxbank,48)
cDestinations    = peekint(mxbank,44)

print
print "MIXER FOR " + szPname$
print
print "  DESTIMATIONS"
For iDestIndex = 0 To cDestinations - 1

  pokeint(mxlbank,0,banksize(mxlbank))   ;size of the struct
  pokeint(mxlbank,4,iDestIndex)          ;Destination index
  pokeint(mxlbank,8,0)                   ;This must be set to zero  when calling mixerGetLineInfo
                                         ;with the  MIXER_GETLINEINFOF_DESTINATION flag.


  rc=mixerGetLineInfo(hMixer, mxlbank, MIXER_GETLINEINFOF_DESTINATION)

  if rc = 0 then
    dwDestination%   = peekint(mxlbank,4);   zero based destination index
    dwSource%        = peekint(mxlbank,8);   zero based source index (if source)
    dwLineID%        = peekint(mxlbank,12);  unique line id for mixer device
    fdwLine%         = peekint(mxlbank,16);  state/information about line
    dwUser%          = peekint(mxlbank,20);  driver specific information
    cChannels%       = peekint(mxlbank,28);  number of channels line supports
    cConnections%    = peekint(mxlbank,32);  number of connections (possible)
    cControls%       = peekint(mxlbank,36);  number of controls at this line
    szShortName$     = peekstr(mxlbank,16,40)
    szName$          = peekstr(mxlbank,64,56)
    dwType%          = peekint(mxlbank, 120)
    dwDeviceID%      = peekint(mxlbank,124)
    wMid%            = peekint(mxlbank,128)
    wPid%            = peekint(mxlbank,130)
    vDriverVersion%  = peekint(mxlbank,132)
    szPname$         = peekstr(mxlbank,32,136)

    print
    print "    "+szName$ +"   Connections "+ cConnections% + "   Controls "+ cControls% +  "   Channels "+ cChannels% +    "   LineID "+ dwLineID%
  End if
Next

print
print "  LINE ID's"

out=writefile("lineIDs.txt")
For Index = -65536 To 655350
  pokeint(mxlbank,12,Index)          ;LineID index
  pokeint(mxlbank,8,0)                   ;This must be set to zero  when calling mixerGetLineInfo
  rc=mixerGetLineInfo(hMixer, mxlbank, MIXER_GETLINEINFOF_LINEID)

  if rc = 0 then
    dwDestination%   = peekint(mxlbank,4);   zero based destination index
    dwSource%        = peekint(mxlbank,8);   zero based source index (if source)
    dwLineID%        = peekint(mxlbank,12);  unique line id for mixer device
    fdwLine%         = peekint(mxlbank,16);  state/information about line
    dwUser%          = peekint(mxlbank,20);  driver specific information
    cChannels%       = peekint(mxlbank,28);  number of channels line supports
    cConnections%    = peekint(mxlbank,32);  number of connections (possible)
    cControls%       = peekint(mxlbank,36);  number of controls at this line
    szShortName$     = peekstr(mxlbank,16,40)
    szName$          = peekstr(mxlbank,64,56)
    dwType%          = peekint(mxlbank, 120)
    dwDeviceID%      = peekint(mxlbank,124)
    wMid%            = peekint(mxlbank,128)
    wPid%            = peekint(mxlbank,130)
    vDriverVersion%  = peekint(mxlbank,132)
    szPname$         = peekstr(mxlbank,32,136)

    print
    print "    "+szName$ +    "   LineID "+ dwLineID%     +    "    Type "+ dwType% + "    Connections "+ cConnections% + "  Controls "+ cControls%  +   "  Channels "+ cChannels%  +   " Source "+dwSource%
    writeline out,"data "+dwLineID% + ","+ chr(34) + szName$ + chr(34)

    if cControls > 0 then
      outsize = 148*cControls
      resizebank mxcbank,outsize
      pokeint(mxlcbank,0, banksize(mxlcbank))
      pokeint(mxlcbank,4,dwLineID)
      pokeint(mxlcbank,8,0)
      pokeint(mxlcbank,12,ccontrols)
      pokeint(mxlcbank,16,148)
      mem = GlobalAlloc($40, outsize)
      pokeint(mxlcbank,20,mem)

      pokeint(mxcbank,0, banksize(mxcbank))
      pokeint(mxcbank,4, 0)
      pokeint(mxcbank,8, 0)
      pokeint(mxcbank,12,0)


    ; Get the control
      rc = mixerGetLineControls(hmixer, mxlcbank, MIXER_GETLINECONTROLSF_ALL)
   ;    stop
 ;     printbank mxlcbank
      If (  MMSYSERR_NOERROR= rc) Then  ; 11

         ; Copy the control into the destination structure
         CopyStructFromPtr mxcbank, peekint(mxlcbank,20), outsize

         for numctrl = 0 to cControls-1
           cbStruct%      = peekint(mxcbank,numctrl*148+0)  ;  size in Byte of MIXERCONTROL
           dwControlID%   = peekint(mxcbank,numctrl*148+4)  ;  unique control id for mixer device
           dwControlType% = peekint(mxcbank,numctrl*148+8)  ;  MIXERCONTROL_CONTROLTYPE_xxx
           fdwControl%    = peekint(mxcbank,numctrl*148+12) ;  MIXERCONTROL_CONTROLF_xxx
           cMultipleItems%= peekint(mxcbank,numctrl*148+16) ;  if MIXERCONTROL_CONTROLF_MULTIPLE
           szShortName$   = peekstr(mxcbank,numctrl*148+16,20) ;  set short name of control
           szName$        = peekstr(mxcbank,numctrl*148+64,36) ;  long name of control
           lMinimum%      = peekint(mxcbank,numctrl*148+100);  Minimum value
           lMaximum%      = peekint(mxcbank,numctrl*148+104);  Maximum value
           print "          * "+szName$ + " ControlType "+GetControlName$(dwControlType%)
         next
        End If
      End If
      GlobalFree (mem)
    End If

if keyhit(1) end
next

closefile out
print
print "hit any key."
while not getkey()
wend


Code :
Code: BlitzBasic
  1. ; Windows Audio Mixer Blitz Functions
  2. ; audiomixer.bb
  3. ; v1  ADAmor ZILTCH 31 July 2003
  4.  
  5. ;---------------------- USERLIBS DECLS NEEDED
  6. ;  .lib "Kernel32.dll"
  7. ;  CopyStructFromPtr(struct*,ptr%,cb%):"RtlMoveMemory"
  8. ;  CopyPtrFromStruct(ptr%, struct*, cb%):"RtlMoveMemory"
  9. ;  GlobalAlloc%(wFlags%, dwBytes%)
  10. ;  GlobalLock%(hmem%)
  11. ;  GlobalFree%(hmem%)
  12.  
  13. ;----------------------
  14. ;  .lib "winmm.dll"
  15. ;  mixerOpen%(phmx%, uMxId%, dwCallback%, dwInstance%, fdwOpen%)
  16. ;  mixerClose%(hmx%)
  17.  
  18. ;  mixerGetControlDetails%(hmxobj%, pmxcd*, fdwDetails%):"mixerGetControlDetailsA"
  19. ;  mixerGetDevCaps%(uMxId%, pmxcaps*, cbmxcaps%): "mixerGetDevCapsA"
  20. ;  mixerGetID%(hmxobj%, pumxID%, fdwId%)
  21. ;  mixerGetLineControls%(hmxobj%, pmxlc*, fdwControls%): "mixerGetLineControlsA"
  22. ;  mixerGetLineInfo%(hmxobj%, pmxl*, fdwInfo%):"mixerGetLineInfoA"
  23. ;  mixerGetNumDevs%()
  24. ;  mixerMessage%(hmx%, uMsg%, dwParam1%, dwParam2%)
  25. ;  mixerSetControlDetails%(hmxobj%, pmxcd*, fdwDetails%)
  26. ;----------------------
  27. ;  .lib "Kernel32.dll"
  28. ;  CopyStructFromPtr(struct*,ptr%,cb%):"RtlMoveMemory"
  29. ;  CopyPtrFromStruct(ptr%, struct*, cb%):"RtlMoveMemory"
  30. ;  GlobalAlloc%(wFlags%, dwBytes%)
  31. ;  GlobalLock%(hmem%)
  32. ;  GlobalFree%(hmem%)
  33.  
  34. ;----------------------
  35.  
  36. Const MMSYSERR_NOERROR       = 0
  37. Const MMSYSERR_ERROR         = 1  ; unspecified error
  38. Const MMSYSERR_BADDEVICEID   = 2  ; device ID out of range
  39. Const MMSYSERR_NOTENABLED    = 3  ; driver failed enable
  40. Const MMSYSERR_ALLOCATED     = 4  ; device already allocated
  41. Const MMSYSERR_INVALHANDLE   = 5  ; device handle is invalid
  42. Const MMSYSERR_NODRIVER      = 6  ; no device driver present
  43. Const MMSYSERR_NOMEM         = 7  ; memory allocation error
  44. Const MMSYSERR_NOTSUPPORTED  = 8  ; function isn't supported
  45. Const MMSYSERR_BADERRNUM     = 9  ; error value out of range
  46. Const MMSYSERR_INVALFLAG     = 10 ; invalid flag passed
  47. Const MMSYSERR_INVALPARAM    = 11 ; invalid parameter passed
  48. Const MMSYSERR_HANDLEBUSY    = 12 ; handle being used
  49.  
  50. Const MAXPNAMELEN            = 32
  51. Const MIXER_LONG_NAME_CHARS  = 64
  52. Const MIXER_SHORT_NAME_CHARS = 16
  53.  
  54. Const MIXER_GETLINEINFOF_DESTINATION       = $00000000
  55. Const MIXER_GETLINEINFOF_SOURCE            = $00000001
  56. Const MIXER_GETLINEINFOF_LINEID            = $00000002
  57. Const MIXER_GETLINEINFOF_COMPONENTTYPE     = $00000003
  58. Const MIXER_GETLINEINFOF_TARGETTYPE        = $00000004
  59.  
  60. Const MIXER_GETCONTROLDETAILSF_VALUE       = $0
  61.  
  62. Const MIXER_GETLINECONTROLSF_ALL           = $0
  63. Const MIXER_GETLINECONTROLSF_ONEBYID       = $1
  64. Const MIXER_GETLINECONTROLSF_ONEBYTYPE     = $2
  65.  
  66. ;--  MIXERCONTROL.fdwControl
  67.  
  68. Const MIXERCONTROL_CONTROLF_UNIFORM        = $00000001
  69. Const MIXERCONTROL_CONTROLF_MULTIPLE       = $00000002
  70. Const MIXERCONTROL_CONTROLF_DISABLED       = $80000000
  71.  
  72.  
  73.  
  74. ;--  MIXERCONTROL_CONTROLTYPE_xxx building block defines
  75.  
  76.  
  77. Const MIXERCONTROL_CT_CLASS_MASK           = $F0000000
  78. Const MIXERCONTROL_CT_CLASS_CUSTOM         = $00000000
  79. Const MIXERCONTROL_CT_CLASS_METER          = $10000000
  80. Const MIXERCONTROL_CT_CLASS_SWITCH         = $20000000
  81. Const MIXERCONTROL_CT_CLASS_NUMBER         = $30000000
  82. Const MIXERCONTROL_CT_CLASS_SLIDER         = $40000000
  83. Const MIXERCONTROL_CT_CLASS_FADER          = $50000000
  84. Const MIXERCONTROL_CT_CLASS_TIME           = $60000000
  85. Const MIXERCONTROL_CT_CLASS_LIST           = $70000000
  86.  
  87.  
  88. Const MIXERCONTROL_CT_SUBCLASS_MASK        = $0F000000
  89.  
  90. Const MIXERCONTROL_CT_SC_SWITCH_BOOLEAN    = $00000000
  91. Const MIXERCONTROL_CT_SC_SWITCH_BUTTON     = $01000000
  92.  
  93. Const MIXERCONTROL_CT_SC_METER_POLLED      = $00000000
  94.  
  95. Const MIXERCONTROL_CT_SC_TIME_MICROSECS    = $00000000
  96. Const MIXERCONTROL_CT_SC_TIME_MILLISECS    = $01000000
  97.  
  98. Const MIXERCONTROL_CT_SC_LIST_SINGLE       = $00000000
  99. Const MIXERCONTROL_CT_SC_LIST_MULTIPLE     = $01000000
  100.  
  101.  
  102. Const MIXERCONTROL_CT_UNITS_MASK           = $00FF0000
  103. Const MIXERCONTROL_CT_UNITS_CUSTOM         = $00000000
  104. Const MIXERCONTROL_CT_UNITS_BOOLEAN        = $00010000
  105. Const MIXERCONTROL_CT_UNITS_SIGNED         = $00020000
  106. Const MIXERCONTROL_CT_UNITS_UNSIGNED       = $00030000
  107. Const MIXERCONTROL_CT_UNITS_DECIBELS       = $00040000 ;in 10ths
  108. Const MIXERCONTROL_CT_UNITS_PERCENT        = $00050000 ;in 10ths
  109.  
  110.  
  111.  
  112. ;--  Commonly used control types for specifying MIXERCONTROL.dwControlType
  113.  
  114.  
  115. Const MIXERCONTROL_CONTROLTYPE_CUSTOM        = (MIXERCONTROL_CT_CLASS_CUSTOM Or MIXERCONTROL_CT_UNITS_CUSTOM)
  116. Const MIXERCONTROL_CONTROLTYPE_BOOLEANMETER  = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  117. Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER   = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
  118. Const MIXERCONTROL_CONTROLTYPE_PEAKMETER     = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
  119. Const MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  120. Const MIXERCONTROL_CONTROLTYPE_BOOLEAN       = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BOOLEAN Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  121. Const MIXERCONTROL_CONTROLTYPE_ONOFF         = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1)
  122. Const MIXERCONTROL_CONTROLTYPE_MUTE          = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
  123. Const MIXERCONTROL_CONTROLTYPE_MONO          = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
  124. Const MIXERCONTROL_CONTROLTYPE_LOUDNESS      = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
  125. Const MIXERCONTROL_CONTROLTYPE_STEREOENH     = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)
  126. Const MIXERCONTROL_CONTROLTYPE_BASS_BOOST    = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + $00002277)
  127. Const MIXERCONTROL_CONTROLTYPE_BUTTON        = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BUTTON Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  128. Const MIXERCONTROL_CONTROLTYPE_DECIBELS      = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
  129. Const MIXERCONTROL_CONTROLTYPE_SIGNED        = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_SIGNED)
  130. Const MIXERCONTROL_CONTROLTYPE_UNSIGNED      = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  131. Const MIXERCONTROL_CONTROLTYPE_PERCENT       = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_PERCENT)
  132. Const MIXERCONTROL_CONTROLTYPE_SLIDER        = (MIXERCONTROL_CT_CLASS_SLIDER Or MIXERCONTROL_CT_UNITS_SIGNED)
  133. Const MIXERCONTROL_CONTROLTYPE_PAN           = (MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
  134. Const MIXERCONTROL_CONTROLTYPE_QSOUNDPAN     = (MIXERCONTROL_CONTROLTYPE_SLIDER + 2)
  135. Const MIXERCONTROL_CONTROLTYPE_FADER         = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  136. Const MIXERCONTROL_CONTROLTYPE_VOLUME        = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
  137. Const MIXERCONTROL_CONTROLTYPE_BASS          = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
  138. Const MIXERCONTROL_CONTROLTYPE_TREBLE        = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
  139. Const MIXERCONTROL_CONTROLTYPE_EQUALIZER     = (MIXERCONTROL_CONTROLTYPE_FADER + 4)
  140. Const MIXERCONTROL_CONTROLTYPE_SINGLESELECT  = (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_SINGLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  141. Const MIXERCONTROL_CONTROLTYPE_MUX           = (MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)
  142. Const MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT= (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_MULTIPLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  143. Const MIXERCONTROL_CONTROLTYPE_MIXER         = (MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1)
  144. Const MIXERCONTROL_CONTROLTYPE_MICROTIME     = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MICROSECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  145. Const MIXERCONTROL_CONTROLTYPE_MILLITIME     = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MILLISECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  146.  
  147. .CONTROLTYPES
  148. Data "MIXERCONTROL_CONTROLTYPE_CUSTOM       ",(MIXERCONTROL_CT_CLASS_CUSTOM Or MIXERCONTROL_CT_UNITS_CUSTOM)
  149. Data "MIXERCONTROL_CONTROLTYPE_BOOLEANMETER ",(MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  150. Data "MIXERCONTROL_CONTROLTYPE_SIGNEDMETER  ",(MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
  151. Data "MIXERCONTROL_CONTROLTYPE_PEAKMETER    ",(MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
  152. Data "MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER",(MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  153. Data "MIXERCONTROL_CONTROLTYPE_BOOLEAN      ",(MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BOOLEAN Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  154. Data "MIXERCONTROL_CONTROLTYPE_ONOFF        ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1)
  155. Data "MIXERCONTROL_CONTROLTYPE_MUTE         ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
  156. Data "MIXERCONTROL_CONTROLTYPE_MONO         ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
  157. Data "MIXERCONTROL_CONTROLTYPE_LOUDNESS     ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
  158. Data "MIXERCONTROL_CONTROLTYPE_STEREOENH    ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)
  159. Data "MIXERCONTROL_CONTROLTYPE_BASS_BOOST   ",(MIXERCONTROL_CONTROLTYPE_BOOLEAN + $00002277)
  160. Data "MIXERCONTROL_CONTROLTYPE_BUTTON       ",(MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BUTTON Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  161. Data "MIXERCONTROL_CONTROLTYPE_DECIBELS     ",(MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
  162. Data "MIXERCONTROL_CONTROLTYPE_SIGNED       ",(MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_SIGNED)
  163. Data "MIXERCONTROL_CONTROLTYPE_UNSIGNED     ",(MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  164. Data "MIXERCONTROL_CONTROLTYPE_PERCENT      ",(MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_PERCENT)
  165. Data "MIXERCONTROL_CONTROLTYPE_SLIDER       ",(MIXERCONTROL_CT_CLASS_SLIDER Or MIXERCONTROL_CT_UNITS_SIGNED)
  166. Data "MIXERCONTROL_CONTROLTYPE_PAN          ",(MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
  167. Data "MIXERCONTROL_CONTROLTYPE_QSOUNDPAN    ",(MIXERCONTROL_CONTROLTYPE_SLIDER + 2)
  168. Data "MIXERCONTROL_CONTROLTYPE_FADER        ",(MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  169. Data "MIXERCONTROL_CONTROLTYPE_VOLUME       ",(MIXERCONTROL_CONTROLTYPE_FADER + 1)
  170. Data "MIXERCONTROL_CONTROLTYPE_BASS         ",(MIXERCONTROL_CONTROLTYPE_FADER + 2)
  171. Data "MIXERCONTROL_CONTROLTYPE_TREBLE       ",(MIXERCONTROL_CONTROLTYPE_FADER + 3)
  172. Data "MIXERCONTROL_CONTROLTYPE_EQUALIZER    ",(MIXERCONTROL_CONTROLTYPE_FADER + 4)
  173. Data "MIXERCONTROL_CONTROLTYPE_SINGLESELECT ",(MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_SINGLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  174. Data "MIXERCONTROL_CONTROLTYPE_MUX          ",(MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)
  175. Data "MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT", (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_MULTIPLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
  176. Data "MIXERCONTROL_CONTROLTYPE_MIXER        ",(MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1)
  177. Data "MIXERCONTROL_CONTROLTYPE_MICROTIME    ",(MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MICROSECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  178. Data "MIXERCONTROL_CONTROLTYPE_MILLITIME    ",(MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MILLISECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
  179.  
  180. Restore CONTROLTYPES
  181. Dim CONTROLTYPES_Name$(31)
  182. Dim CONTROLTYPES_Val$(31)
  183. For count = 1 To 31
  184.   Read CONTROLTYPES_Name$(count),CONTROLTYPES_Val$(count)
  185. Next
  186.  
  187. ; -- Component types for mixer destinations and sources
  188.  
  189. Const MIXERLINE_COMPONENTTYPE_DST_FIRST = $0
  190. Const MIXERLINE_COMPONENTTYPE_DST_UNDEFINED   = MIXERLINE_COMPONENTTYPE_DST_FIRST + 0
  191. Const MIXERLINE_COMPONENTTYPE_DST_DIGITAL     = MIXERLINE_COMPONENTTYPE_DST_FIRST + 1
  192. Const MIXERLINE_COMPONENTTYPE_DST_LINE        = MIXERLINE_COMPONENTTYPE_DST_FIRST + 2
  193. Const MIXERLINE_COMPONENTTYPE_DST_MONITOR     = MIXERLINE_COMPONENTTYPE_DST_FIRST + 3
  194. Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS    = MIXERLINE_COMPONENTTYPE_DST_FIRST + 4
  195. Const MIXERLINE_COMPONENTTYPE_DST_HEADPHONES  = MIXERLINE_COMPONENTTYPE_DST_FIRST + 5
  196. Const MIXERLINE_COMPONENTTYPE_DST_TELEPHONE   = MIXERLINE_COMPONENTTYPE_DST_FIRST + 6
  197. Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN      = MIXERLINE_COMPONENTTYPE_DST_FIRST + 7
  198. Const MIXERLINE_COMPONENTTYPE_DST_VOICEIN     = MIXERLINE_COMPONENTTYPE_DST_FIRST + 8
  199. Const MIXERLINE_COMPONENTTYPE_DST_LAST        = MIXERLINE_COMPONENTTYPE_DST_FIRST + 8
  200.  
  201. Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = $1000
  202. Const MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED   = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0
  203. Const MIXERLINE_COMPONENTTYPE_SRC_DIGITAL     = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1
  204. Const MIXERLINE_COMPONENTTYPE_SRC_LINE        = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2
  205. Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE  = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3
  206. Const MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4
  207. Const MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5
  208. Const MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE   = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6
  209. Const MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER   = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7
  210. Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT     = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8
  211. Const MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY   = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9
  212. Const MIXERLINE_COMPONENTTYPE_SRC_ANALOG      = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10
  213. Const MIXERLINE_COMPONENTTYPE_SRC_LAST        = MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10
  214.  
  215.  
  216. ; --  MIXERLINE.Target.dwType
  217.  
  218. Const MIXERLINE_TARGETTYPE_UNDEFINED    = 0
  219. Const MIXERLINE_TARGETTYPE_WAVEOUT      = 1
  220. Const MIXERLINE_TARGETTYPE_WAVEIN       = 2
  221. Const MIXERLINE_TARGETTYPE_MIDIOUT      = 3
  222. Const MIXERLINE_TARGETTYPE_MIDIIN       = 4
  223. Const MIXERLINE_TARGETTYPE_AUX          = 5
  224.  
  225. Type MIXERCAPS
  226.   Field wMid%                             ;0   manufacturer id
  227.   Field wPid%                             ;4   product id
  228.   Field vDriverVersion%                   ;8   version of the driver
  229.   Field szPname$                          ;12  product name
  230.   Field fdwSupport%                       ;44  misc. support bits
  231.   Field cDestinations%                    ;48  count of destinations
  232. End Type                                  ;Size 52
  233.  
  234. Type MIXERCONTROL
  235.   Field cbStruct%                  ;0    size in Byte of MIXERCONTROL
  236.   Field dwControlID%               ;4    unique control id for mixer device
  237.   Field dwControlType%             ;8    MIXERCONTROL_CONTROLTYPE_xxx
  238.   Field fdwControl%                ;12   MIXERCONTROL_CONTROLF_xxx
  239.   Field cMultipleItems%            ;16   if MIXERCONTROL_CONTROLF_MULTIPLE
  240.   Field szShortName$               ;20   short name of control
  241.   Field szName$                    ;36   long name of control
  242.   Field lMinimum%                  ;100  Minimum value
  243.   Field lMaximum%                  ;104  Maximum value
  244. ;  field reserved()%               ;108  reserved structure space
  245. End Type                           ;size 148
  246.  
  247. Type MIXERCONTROLDETAILS
  248.   Field cbStruct%              ;0   size in Byte of MIXERCONTROLDETAILS
  249.   Field dwControlID%           ;4   control id to get/set details on
  250.   Field cChannels%             ;8   number of channels in paDetails array
  251.   Field item%                  ;12  hwndOwner or cMultipleItems
  252.   Field cbDetails%             ;16  size of _one_ details_XX struct
  253.   Field paDetails%             ;20  pointer to array of details_XX structs
  254. End Type                       ;size 24
  255.  
  256. Type MIXERCONTROLDETAILS_UNSIGNED
  257.   Field dwValue%               ;0  value of the control
  258. End Type                       ;size 4
  259.  
  260. Type MIXERLINE
  261.   Field cbStruct%                      ;0   size of MIXERLINE structure
  262.   Field dwDestination%                 ;4   zero based destination index
  263.   Field dwSource%                      ;8   zero based source index (if source)
  264.   Field dwLineID%                      ;12  unique line id for mixer device
  265.   Field fdwLine%                       ;16  state/information about line
  266.   Field dwUser%                        ;20  driver specific information
  267.   Field dwComponentType%               ;24  component type line connects to
  268.   Field cChannels%                     ;28  number of channels line supports
  269.   Field cConnections%                  ;32  number of connections (possible)
  270.   Field cControls%                     ;36  number of controls at this line
  271.   Field szShortName$                   ;40
  272.   Field szName$                        ;56
  273.   Field dwType%                        ;120
  274.   Field dwDeviceID%                    ;124
  275.   Field wMid%                          ;128
  276.   Field wPid%                          ;130
  277.   Field vDriverVersion%                ;132
  278.   Field szPname$                       ;136
  279. End Type                               ;size 168
  280.  
  281. Type MIXERLINECONTROLS
  282.   Field cbStruct%              ;0   size in Byte of MIXERLINECONTROLS
  283.   Field dwLineID%              ;4   line id (from MIXERLINE.dwLineID)
  284.                                ;    MIXER_GETLINECONTROLSF_ONEBYID or
  285.   Field dwControl%             ;8   MIXER_GETLINECONTROLSF_ONEBYTYPE
  286.   Field cControls%             ;12  count of controls pmxctrl points to
  287.   Field cbmxctrl%              ;16  size in Byte of _one_ MIXERCONTROL
  288.   Field pamxctrl%              ;20  pointer to first MIXERCONTROL array
  289. End Type                       ;size 24
  290.  
  291. Type MIXERCONTROLDETAILS_LISTTEXT
  292.   Field  dwParam1             ;0
  293.   Field  dwParam2             ;4
  294.   Field  szname$              ;8
  295. End Type                      ;len 72
  296.  
  297.  
  298.  
  299. Function GetControlName$(ControlNum)
  300.  
  301.   Local count
  302.  
  303.   For count = 1 To 31
  304.      If controlnum = CONTROLTYPES_Val$(count) Then
  305.       Return CONTROLTYPES_Name$(count)
  306.     End If
  307.   Next
  308.   Return "Control type unkown " + Controlnum
  309. End Function
  310.  
  311.  
  312. Function GetMixerControl(hmixer%, componentType%, ctrlType%, mxc.MIXERCONTROL,mode=0)
  313.  
  314. ; This function attempts to obtain a mixer control.
  315. ; Returns True if successful.
  316. ;mode 1 uses lineID instead of control type
  317.  
  318.    Local mxlc.MIXERLINECONTROLS = New MIXERLINECONTROLS
  319.    Local mxl.MIXERLINE = New MIXERLINE
  320.    Local hmem%
  321.    Local rc%
  322.    Local mxlcbank = CreateBank(24)
  323.    Local mxlbank  = CreateBank(168)
  324.  
  325.    mxlcbStruct = BankSize(mxlbank)
  326.    mxldwComponentType = componentType
  327.  
  328.    PokeInt(mxlbank,0,BankSize(mxlbank))
  329.  
  330.    Select mode
  331.      Case 0; Obtain a line corresponding to the component type
  332.        PokeInt(mxlbank,24,componentType)
  333.        rc = mixerGetLineInfo(hmixer, mxlbank, MIXER_GETLINEINFOF_COMPONENTTYPE)
  334.      Case 1; Obtain a line from its lineID
  335.        PokeInt(mxlbank,8,0)
  336.        PokeInt(mxlbank,12,componentType)
  337.        rc=mixerGetLineInfo(hMixer, mxlbank, MIXER_GETLINEINFOF_LINEID)
  338.    End Select
  339.  
  340.    If (MMSYSERR_NOERROR <> rc) Then
  341.      DebugLog "error "+rc+" mixer get line info failed. For lineID/componentType of "+componentType
  342.    Else
  343.      mxldwDestination%   = PeekInt(mxlbank,4);   zero based destination index
  344.      mxldwSource%        = PeekInt(mxlbank,8);   zero based source index (if source)
  345.      mxldwLineID%        = PeekInt(mxlbank,12);  unique line id for mixer device
  346.      mxlfdwLine%         = PeekInt(mxlbank,16);  state/information about line
  347.      mxldwUser%          = PeekInt(mxlbank,20);  driver specific information
  348.      mxlcChannels%       = PeekInt(mxlbank,28);  number of channels line supports
  349.      mxlcConnections%    = PeekInt(mxlbank,32);  number of connections (possible)
  350.      mxlcControls%       = PeekInt(mxlbank,36);  number of controls at this line
  351.      mxlszShortName$     = peekstr(mxlbank,16,40)
  352.      mxlszName$          = peekstr(mxlbank,64,56)
  353.      mxldwType%          = PeekInt(mxlbank, 120)
  354.      mxldwDeviceID%      = PeekInt(mxlbank,124)
  355.      mxlwMid%            = PeekInt(mxlbank,128)
  356.      mxlwPid%            = PeekInt(mxlbank,130)
  357.      mxlvDriverVersion%  = PeekInt(mxlbank,132)
  358.      mxlszPname$         = peekstr(mxlbank,32,136)
  359.  
  360.      mxlccbStruct = BankSize(mxlcbank);24
  361.      mxlcdwLineID = mxldwLineID
  362.      mxlcdwControl = ctrlType
  363.      mxlccControls = 1
  364.      PokeInt(mxlcbank,0, BankSize(mxlcbank));24
  365.      PokeInt(mxlcbank,4,mxldwLineID)
  366.      PokeInt(mxlcbank,8,ctrlType)
  367.      PokeInt(mxlcbank,12,1)
  368.  
  369.      outsize=148
  370.      ; Allocate a buffer for the control
  371.      hmem = GlobalAlloc($40, outsize)  ;$40
  372.      mxlcpamxctrl = GlobalLock(hmem)
  373.      mxlccbmxctrl = outsize
  374.      PokeInt(mxlcbank,16,outsize)
  375.      PokeInt(mxlcbank,20,mxlcpamxctrl)
  376.  
  377.      mxccbStruct = outsize
  378.      mxcbank = CreateBank(outsize)
  379.      PokeInt(mxcbank,0,mxccbStruct)
  380.  
  381.      ; Get the control
  382.      rc = mixerGetLineControls(hmixer, mxlcbank, MIXER_GETLINECONTROLSF_ONEBYTYPE)
  383. ;     debuglog componentType%+" " +mxlszShortName$
  384.      GetMixerControl = False
  385.  
  386.      If (  MMSYSERR_NOERROR= rc) Then
  387.          GetMixerControl = True
  388.          ; Copy the control into the destination structure
  389.  
  390.          CopyStructFromPtr mxcbank, mxlcpamxctrl, outsize
  391.  
  392.          mxccbStruct%      = PeekInt(mxcbank,0)  ;  size in Byte of MIXERCONTROL
  393.          mxcdwControlID%   = PeekInt(mxcbank,4)  ;  unique control id for mixer device
  394.          mxcdwControlType% = PeekInt(mxcbank,8)  ;  MIXERCONTROL_CONTROLTYPE_xxx
  395.          mxcfdwControl%    = PeekInt(mxcbank,12) ;  MIXERCONTROL_CONTROLF_xxx
  396.          mxccMultipleItems%= PeekInt(mxcbank,16) ;  if MIXERCONTROL_CONTROLF_MULTIPLE
  397.          mxcszShortName$   = peekstr(mxcbank,16,20) ;  set short name of control
  398.          mxcszName$        = peekstr(mxcbank,64,36) ;  long name of control
  399.          mxclMinimum%      = PeekInt(mxcbank,100);  Minimum value
  400.          mxclMaximum%      = PeekInt(mxcbank,104);  Maximum value
  401.      End If
  402.  
  403.      GlobalFree (hmem)
  404.      FreeBank mxcbank
  405.  
  406.    End If
  407.  
  408.    FreeBank mxlcbank
  409.    FreeBank mxcbank
  410.    FreeBank mxlbank
  411.    Return GetMixerControl
  412. End Function
  413.  
  414. Function SetVolumeControl(hmixer% , mxc.MIXERCONTROL, volume% )
  415. ; This function sets the value for a volume control.
  416. ; Returns True if successful
  417.  
  418.    Local mxcd.MIXERCONTROLDETAILS = New MIXERCONTROLDETAILS
  419.    Local vol.MIXERCONTROLDETAILS_UNSIGNED = New MIXERCONTROLDETAILS_UNSIGNED
  420.    Local mxcdbank   = CreateBank(24)
  421.    Local volbank    = CreateBank(4)
  422.    Local mem,rc
  423.  
  424.    mxcdcbStruct    = BankSize(mxcdbank)
  425.    mxcdcbDetails   = 4
  426.    mxcditem        = 0
  427.    mxcddwControlID = mxcdwControlID
  428.  
  429.    PokeInt(mxcdbank,0, BankSize(mxcdbank));24
  430.    PokeInt(mxcdbank,4, mxcdwControlID)
  431.    PokeInt(mxcdbank,8, 1)
  432.    PokeInt(mxcdbank,12,0)
  433.    PokeInt(mxcdbank,16,BankSize(volbank) )
  434.  
  435.    ; Allocate a buffer for the control value buffer
  436.    mem = GlobalAlloc($40, 4)
  437.    mxcdpaDetails = GlobalLock(mem)
  438.    mxcdcChannels = 1
  439.  
  440.    PokeInt(mxcdbank,20,mxcdpaDetails )
  441. ;   debuglog "max "+mxclMaximum%
  442.    If volume < mxclMinimum% Then volume = mxclMinimum%
  443.    voldwValue%  = volume Mod mxclMaximum%
  444.    PokeInt volbank,0,volume
  445.  
  446.    ; Copy the data into the control value buffer
  447.    CopyPtrFromStruct mxcdpaDetails, vol, BankSize(volbank)
  448.  
  449.    ; Set the control value
  450.    rc = mixerSetControlDetails(hmixer, mxcdbank, MIXER_SETCONTROLDETAILSF_VALUE)
  451.  
  452.    GlobalFree (mem)
  453.  
  454.    FreeBank mxcdbank
  455.    FreeBank volbank
  456.    If (MMSYSERR_NOERROR = rc) Then
  457.        SetVolumeControl = True
  458.    Else
  459.        SetVolumeControl = False
  460.    End If
  461.  
  462.    Return SetVolumeControl
  463.  
  464. End Function
  465.  
  466.  
  467.  
  468. Function GetVolumeControlLevel(hmixer% , mxc.MIXERCONTROL)
  469. ; This function sets the value for a volume control.
  470. ; Returns True if successful
  471.  
  472.    Local mxcd.MIXERCONTROLDETAILS = New MIXERCONTROLDETAILS
  473.    Local vol.MIXERCONTROLDETAILS_UNSIGNED = New MIXERCONTROLDETAILS_UNSIGNED
  474.    Local mxcdbank   = CreateBank(24)
  475.    Local volbank    = CreateBank(4)
  476.    Local mem,rc
  477.  
  478.    mxcdcbStruct    = BankSize(mxcdbank)
  479.    mxcdcbDetails   = 4
  480.    mxcditem        = mxccMultipleItems
  481.    mxcddwControlID = mxcdwControlID
  482.  
  483.    PokeInt(mxcdbank,0, BankSize(mxcdbank));24
  484.    PokeInt(mxcdbank,4, mxcdwControlID)
  485.    PokeInt(mxcdbank,8, 1)
  486.    PokeInt(mxcdbank,12,mxccMultipleItems)
  487.    PokeInt(mxcdbank,16,BankSize(volbank) )
  488.  
  489.    ; Allocate a buffer for the control value buffer
  490.    mem = GlobalAlloc($40, 4)
  491.    mxcdpaDetails = GlobalLock(mem)
  492.    mxcdcChannels = 1
  493.  
  494.    PokeInt(mxcdbank,20,mxcdpaDetails )
  495.  
  496.   ; Set the control value
  497.    rc = mixerGetControlDetails(hmixer, mxcdbank, MIXER_GETCONTROLDETAILSF_VALUE)
  498.  
  499.    If rc <> 0 Then
  500.      DebugLog "error "+rc+" can not get control"
  501.    End If
  502.  
  503.    CopyStructFromPtr volbank, mxcdpaDetails, 4
  504.    OUTvolume = PeekInt(volbank,0)
  505.    If (OUTvolume < 0) Then OUTvolume = -OUTvolume
  506.  
  507.    GlobalFree (mem)
  508.  
  509.    FreeBank mxcdbank
  510.    FreeBank volbank
  511.    If (MMSYSERR_NOERROR = rc) Then
  512.        SetVolumeControl = True
  513.    Else
  514.        SetVolumeControl = False
  515.        OUTvolume = -1
  516.    End If
  517.  
  518.    Return OUTVolume
  519.  
  520. End Function
  521.  
  522.  
  523.  
  524. Function SetVolume$(Control=4,NewVolume,mode=0)
  525. ;returns name of Control if OK
  526.  
  527. ;mode 1 uses lineID instead of control type
  528.  
  529.   Local ok, hmixer = 0
  530.   volCtrl.mixercontrol = New mixercontrol ;
  531.  
  532.   ok = GetMixerControl(hmixer, Control, MIXERCONTROL_CONTROLTYPE_VOLUME, volCtrl.mixercontrol,mode)
  533.  
  534.   If ok Then ok = SetVolumeControl(hmixer, volCtrl, NewVolume)
  535.   If ok Then
  536.     ShortName$ = volCtrlszShortName$
  537.     Delete volctrl
  538.     Return ShortName$
  539.   End If
  540. End Function
  541.  
  542.  
  543.  
  544. Function GetVolume$(Control=4)
  545. ;returns name of Control if OK
  546.  
  547.   Local ok, hmixer = 0
  548.   volCtrl.mixercontrol = New mixercontrol
  549.  
  550.   ok = GetMixerControl(hmixer, Control,MIXERCONTROL_CONTROLTYPE_VOLUME , volCtrl.mixercontrol)
  551.  
  552.   If ok Then
  553.     OUTVolume = GetVolumeControlLevel(hmixer, volCtrl)
  554.   Else
  555.     OUTVolume = - 1
  556.   End If
  557.  
  558.   Delete volctrl
  559.   Return OUTVolume
  560.  
  561. End Function
  562.  
  563.  
  564. ;-- bank funcions
  565.  
  566. Function PeekStr$(Tbank,Size=64,Offset=0)
  567. ;note offset is 3rd param not 2nd like peekint, etc.
  568.  
  569.   Local count,newchr
  570.   Local NewStr$ = ""
  571.   Local bsize = BankSize(tbank)
  572.   Local lastbyte = (offset+size-1)
  573.  
  574.   If lastbyte > bsize Then lastbyte = bsize
  575.  
  576.   For count = offset To lastbyte
  577.     newchr = PeekByte(Tbank,count)
  578.  
  579.     If (newchr = 0) Then  Exit
  580.  
  581.     newstr$ = newstr$ + Chr$(newchr)
  582.   Next
  583.   Return Newstr$
  584.  
  585. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal