home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 November / CDVD1105.ISO / Software / Freeware / programare / bass / vb / Multi / frmMulti.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2005-09-22  |  5.6 KB  |  155 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Begin VB.Form frmMulti 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "BASS multiple output example"
  6.    ClientHeight    =   1515
  7.    ClientLeft      =   45
  8.    ClientTop       =   435
  9.    ClientWidth     =   4575
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   1515
  14.    ScaleWidth      =   4575
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.Frame frameMulti 
  17.       Caption         =   " device 1 "
  18.       Height          =   735
  19.       Index           =   0
  20.       Left            =   120
  21.       TabIndex        =   0
  22.       Top             =   0
  23.       Width           =   4335
  24.       Begin VB.CommandButton cmdOpen 
  25.          Caption         =   "click here to open a file..."
  26.          Height          =   375
  27.          Index           =   0
  28.          Left            =   120
  29.          TabIndex        =   1
  30.          Top             =   240
  31.          Width           =   4095
  32.       End
  33.    End
  34.    Begin MSComDlg.CommonDialog cmd 
  35.       Left            =   3960
  36.       Top             =   960
  37.       _ExtentX        =   847
  38.       _ExtentY        =   847
  39.       _Version        =   393216
  40.    End
  41.    Begin VB.Frame frameMulti 
  42.       Caption         =   " device 2 "
  43.       Height          =   735
  44.       Index           =   1
  45.       Left            =   120
  46.       TabIndex        =   2
  47.       Top             =   720
  48.       Width           =   4335
  49.       Begin VB.CommandButton cmdOpen 
  50.          Caption         =   "click here to open a file..."
  51.          Height          =   375
  52.          Index           =   1
  53.          Left            =   120
  54.          TabIndex        =   3
  55.          Top             =   240
  56.          Width           =   4095
  57.       End
  58.    End
  59. Attribute VB_Name = "frmMulti"
  60. Attribute VB_GlobalNameSpace = False
  61. Attribute VB_Creatable = False
  62. Attribute VB_PredeclaredId = True
  63. Attribute VB_Exposed = False
  64. '//////////////////////////////////////////////////////////////////////////////
  65. ' frmMulti.frm - Copyright (c) 2003-2005 (: JOBnik! :) [Arthur Aminov, ISRAEL]
  66. '                                                      [http://www.jobnik.org]
  67. '                                                      [  jobnik@jobnik.org  ]
  68. ' Other source: frmDevice.frm
  69. ' BASS Multiple output example
  70. ' Originally translated from - multi.c - Example of Ian Luck
  71. '//////////////////////////////////////////////////////////////////////////////
  72. Option Explicit
  73. Dim outdev(2) As Long   'output devices
  74. Dim chan(2) As Long     'the streams
  75. 'display error messages
  76. Sub Error_(ByVal es As String)
  77.     Call MsgBox(es & vbCrLf & vbCrLf & "Error Code : " & BASS_ErrorGetCode, vbExclamation, "Error")
  78. End Sub
  79. Private Sub Form_Load()
  80.     'change and set the current path
  81.     'so VB won't ever tell you, that "bass.dll" isn't found
  82.     ChDrive App.Path
  83.     ChDir App.Path
  84.     'check if "bass.dll" is exists
  85.     If (Not FileExists(RPP(App.Path) & "bass.dll")) Then
  86.         Call MsgBox("BASS.DLL does not exists", vbCritical, "BASS.DLL")
  87.         End
  88.     End If
  89.     'Check that BASS 2.2 was loaded
  90.     If (BASS_GetVersion <> MakeLong(2, 2)) Then
  91.         Call MsgBox("BASS version 2.2 was not loaded", vbCritical, "Incorrect BASS.DLL")
  92.         End
  93.     End If
  94.     'Let the user choose the output devices
  95.     With frmDevice
  96.         .SelectDevice 1
  97.         .Show vbModal, Me
  98.         outdev(0) = .device
  99.         .SelectDevice 2
  100.         .Show vbModal, Me
  101.         outdev(1) = .device
  102.     End With
  103.     'setup output devices
  104.     If (BASS_Init(outdev(0), 44100, 0, Me.hWnd, 0) = 0) Then
  105.         Call Error_("Can't initialize device 1")
  106.         Unload Me
  107.     End If
  108.     If (BASS_Init(outdev(1), 44100, 0, Me.hWnd, 0) = 0) Then
  109.         Call Error_("Can't initialize device 2")
  110.         Unload Me
  111.     End If
  112.     frameMulti(0).Caption = " " & VBStrFromAnsiPtr(BASS_GetDeviceDescription(outdev(0))) & " "
  113.     frameMulti(1).Caption = " " & VBStrFromAnsiPtr(BASS_GetDeviceDescription(outdev(1))) & " "
  114. End Sub
  115. Private Sub Form_Unload(Cancel As Integer)
  116.     'release both devices
  117.     Call BASS_SetDevice(outdev(0))
  118.     Call BASS_Free
  119.     Call BASS_SetDevice(outdev(1))
  120.     Call BASS_Free
  121.     End
  122. End Sub
  123. Private Sub cmdOpen_Click(Index As Integer)
  124.     On Local Error Resume Next    'if Cancel pressed...
  125.     'open a file to play on selected device
  126.     cmd.CancelError = True
  127.     cmd.flags = cdlOFNExplorer Or cdlOFNFileMustExist Or cdlOFNHideReadOnly
  128.     cmd.DialogTitle = "Open"
  129.     cmd.Filter = "streamable files|*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif|All files|*.*"
  130.     cmd.ShowOpen
  131.     'if cancel was pressed, exit the procedure
  132.     If Err.Number = 32755 Then Exit Sub
  133.     Call BASS_StreamFree(chan(Index))
  134.     Call BASS_SetDevice(outdev(Index)) 'set the device to create stream on
  135.     chan(Index) = BASS_StreamCreateFile(BASSFALSE, cmd.FileName, 0, 0, BASS_SAMPLE_LOOP)
  136.     If (chan(Index) = 0) Then
  137.         cmdOpen(Index).Caption = "click here to open a file..."
  138.         Call Error_("Can't play the file")
  139.         Exit Sub
  140.     End If
  141.     cmdOpen(Index).Caption = cmd.FileName
  142.     Call BASS_ChannelPlay(chan(Index), BASSFALSE)
  143. End Sub
  144. '--------------------------
  145. ' some useful functions :)
  146. '--------------------------
  147. 'check if any file exists
  148. Public Function FileExists(ByVal fp As String) As Boolean
  149.   FileExists = (Dir(fp) <> "")
  150. End Function
  151. ' RPP = Return Proper Path
  152. Function RPP(ByVal fp As String) As String
  153.     RPP = IIf(Mid(fp, Len(fp), 1) <> "\", fp & "\", fp)
  154. End Function
  155.