Advertisement
meanhacker

SYNCtest (SYNCtest.bas)

Mar 12th, 2011
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '//////////////////////////////////////////////////////////////////////////////
  2. ' SYNCtest.bas - Copyright (c) 2001-2007 (: JOBnik! :) [Arthur Aminov, ISRAEL]
  3. '                                                      [http://www.jobnik.org]
  4. '                                                      [  jobnik@jobnik.org  ]
  5. '
  6. ' Other sources: frmMemory.frm & CBASS_TIME.cls
  7. '
  8. ' * Updates:
  9. '    . Now uses only VB functions without any Memory APIs
  10. '    . Threading
  11. '
  12. ' SYNC callback example...
  13. '//////////////////////////////////////////////////////////////////////////////
  14.  
  15. Option Explicit
  16.  
  17. Public Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
  18.  
  19. ' THREADING
  20. Public cthread As Long
  21. Public Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
  22. Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  23.  
  24. Public chan As Long             ' stream or music handle
  25. Public SyncEnd As Long          ' sync at end handle
  26.  
  27. Public DataStore() As Byte      ' data array
  28. Public bassTime As cbass_time   ' Class module Handle
  29.  
  30. ' display error messages
  31. Public Sub Error_(ByVal es As String)
  32.     Call MessageBox(frmMemory.hwnd, es & vbCrLf & "(error code: " & BASS_ErrorGetCode() & ")", "Error", vbExclamation)
  33. End Sub
  34.  
  35. Public Sub MemoryFileThread(ByVal DataLength As Long, Res_Index As Long)
  36.     If (DataLength) Then
  37.         ' free old stream (if any) and create new one
  38.        Call BASS_StreamFree(chan)
  39.         Call BASS_MusicFree(chan)
  40.  
  41.         ' reallocate data array
  42.        ReDim DataStore(DataLength) As Byte
  43.  
  44.         ' insert all the file data into a byte array
  45.        DataStore = LoadResData(Res_Index, "CUSTOM")
  46.  
  47.  
  48.         ' read data from memory location (our data array)
  49.        chan = BASS_StreamCreateFile(BASSTRUE, VarPtr(DataStore(0)), 0, DataLength, BASS_SAMPLE_LOOP)
  50.         If (chan = 0) Then chan = BASS_MusicLoad(BASSTRUE, VarPtr(DataStore(0)), 0, DataLength, BASS_MUSIC_LOOP Or BASS_MUSIC_RAMP Or BASS_MUSIC_PRESCAN, 0)
  51.  
  52.         If (chan = 0) Then
  53.             ' free stream and music (if any)
  54.            Call BASS_StreamFree(chan)
  55.             Call BASS_MusicFree(chan)
  56.  
  57.             ' free memory
  58.            Erase DataStore()
  59.  
  60.             Call Error_("Couldn't Get Data from Memory")
  61.         Else
  62.  
  63.             Call BASS_ChannelPlay(chan, BASSFALSE)
  64.         End If
  65.     End If
  66.  
  67.     ' close thread
  68.    Call CloseHandle(cthread)
  69.     cthread = 0
  70. End Sub
  71.  
  72. Public Sub SyncEndTest(ByVal handle As Long, ByVal channel As Long, ByVal data As Long, ByVal user As Long)
  73.     Call MessageBox(frmMemory.hwnd, "End...", "SYNCtest", vbInformation)
  74. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement