VERSION 5.00
Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "MSDXM.ocx"
Object = "{D27CDB6B-AE6D-11CF-96B8-444553540000}#1.0#0"; "Flash9e.ocx"
Begin VB.Form frmHypno 
   BackColor       =   &H00000000&
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   8250
   ClientLeft      =   3090
   ClientTop       =   2280
   ClientWidth     =   7095
   ControlBox      =   0   'False
   ForeColor       =   &H00000000&
   Icon            =   "Hypno.frx":0000
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   8250
   ScaleWidth      =   7095
   Visible         =   0   'False
   Begin VB.CommandButton Command1 
      Caption         =   "GO"
      Height          =   375
      Left            =   960
      TabIndex        =   11
      Top             =   840
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Timer Timer9 
      Enabled         =   0   'False
      Left            =   2280
      Top             =   600
   End
   Begin VB.Timer Timer8 
      Enabled         =   0   'False
      Left            =   1800
      Top             =   600
   End
   Begin VB.PictureBox PopupPic 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00FFFFFF&
      BorderStyle     =   0  'None
      ForeColor       =   &H00000000&
      Height          =   1935
      Left            =   4080
      ScaleHeight     =   1935
      ScaleWidth      =   2175
      TabIndex        =   10
      Top             =   4800
      Visible         =   0   'False
      Width           =   2175
   End
   Begin VB.Timer Timer6 
      Enabled         =   0   'False
      Interval        =   10
      Left            =   3720
      Top             =   120
   End
   Begin VB.Timer Timer5 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   3240
      Top             =   120
   End
   Begin VB.PictureBox CustomBox 
      Appearance      =   0  'Flat
      BackColor       =   &H00000000&
      ForeColor       =   &H00000000&
      Height          =   2820
      Left            =   1560
      ScaleHeight     =   2790
      ScaleWidth      =   3135
      TabIndex        =   8
      Top             =   4320
      Visible         =   0   'False
      Width           =   3165
   End
   Begin VB.Timer Timer4 
      Enabled         =   0   'False
      Left            =   2760
      Top             =   120
   End
   Begin VB.Timer Timer3 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   2280
      Top             =   120
   End
   Begin VB.Timer Timer2 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   1800
      Top             =   120
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   10
      Left            =   120
      Top             =   720
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   9
      Left            =   840
      Top             =   6840
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   8
      Left            =   120
      Top             =   6840
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   7
      Left            =   840
      Top             =   6360
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   6
      Left            =   840
      Top             =   5880
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   5
      Left            =   840
      Top             =   5400
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   4
      Left            =   840
      Top             =   4920
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   3
      Left            =   120
      Top             =   6360
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   2
      Left            =   120
      Top             =   5880
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   1
      Left            =   120
      Top             =   5400
      Visible         =   0   'False
      Width           =   615
   End
   Begin VB.Shape CustShape 
      BackColor       =   &H00000000&
      BorderColor     =   &H00FFFFFF&
      Height          =   375
      Index           =   0
      Left            =   120
      Top             =   4920
      Visible         =   0   'False
      Width           =   615
   End
   Begin MediaPlayerCtl.MediaPlayer MediaPlayer3 
      Height          =   2685
      Left            =   3840
      TabIndex        =   9
      Top             =   6840
      Visible         =   0   'False
      Width           =   3585
      AudioStream     =   -1
      AutoSize        =   -1  'True
      AutoStart       =   -1  'True
      AnimationAtStart=   -1  'True
      AllowScan       =   -1  'True
      AllowChangeDisplaySize=   -1  'True
      AutoRewind      =   0   'False
      Balance         =   0
      BaseURL         =   ""
      BufferingTime   =   5
      CaptioningID    =   ""
      ClickToPlay     =   -1  'True
      CursorType      =   0
      CurrentPosition =   -1
      CurrentMarker   =   0
      DefaultFrame    =   ""
      DisplayBackColor=   0
      DisplayForeColor=   16777215
      DisplayMode     =   0
      DisplaySize     =   0
      Enabled         =   -1  'True
      EnableContextMenu=   -1  'True
      EnablePositionControls=   -1  'True
      EnableFullScreenControls=   0   'False
      EnableTracker   =   -1  'True
      Filename        =   ""
      InvokeURLs      =   -1  'True
      Language        =   -1
      Mute            =   0   'False
      PlayCount       =   1
      PreviewMode     =   0   'False
      Rate            =   1
      SAMILang        =   ""
      SAMIStyle       =   ""
      SAMIFileName    =   ""
      SelectionStart  =   -1
      SelectionEnd    =   -1
      SendOpenStateChangeEvents=   -1  'True
      SendWarningEvents=   -1  'True
      SendErrorEvents =   -1  'True
      SendKeyboardEvents=   0   'False
      SendMouseClickEvents=   0   'False
      SendMouseMoveEvents=   0   'False
      SendPlayStateChangeEvents=   -1  'True
      ShowCaptioning  =   0   'False
      ShowControls    =   -1  'True
      ShowAudioControls=   -1  'True
      ShowDisplay     =   0   'False
      ShowGotoBar     =   0   'False
      ShowPositionControls=   -1  'True
      ShowStatusBar   =   0   'False
      ShowTracker     =   -1  'True
      TransparentAtStart=   0   'False
      VideoBorderWidth=   0
      VideoBorderColor=   0
      VideoBorder3D   =   0   'False
      Volume          =   -600
      WindowlessVideo =   0   'False
   End
   Begin VB.Label Label2 
      BackColor       =   &H00000000&
      Caption         =   "Press ESC to Exit, or right-click the screen for options"
      ForeColor       =   &H80000005&
      Height          =   645
      Left            =   240
      TabIndex        =   6
      Top             =   120
      Width           =   1335
   End
   Begin VB.Shape Shape2 
      BackColor       =   &H00FFFFFF&
      BorderColor     =   &H00FFFFFF&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00FFFFFF&
      FillStyle       =   0  'Solid
      Height          =   4695
      Left            =   6240
      Top             =   0
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.Shape Shape1 
      BackColor       =   &H00FFFFFF&
      BorderColor     =   &H00FFFFFF&
      BorderStyle     =   0  'Transparent
      FillColor       =   &H00FFFFFF&
      FillStyle       =   0  'Solid
      Height          =   4695
      Left            =   0
      Top             =   0
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.Label Label3 
      BackColor       =   &H00000000&
      ForeColor       =   &H00FFFFFF&
      Height          =   375
      Left            =   3000
      TabIndex        =   7
      Top             =   120
      Width           =   975
   End
   Begin MediaPlayerCtl.MediaPlayer MediaPlayer2 
      Height          =   2685
      Left            =   480
      TabIndex        =   4
      Top             =   6960
      Visible         =   0   'False
      Width           =   3585
      AudioStream     =   -1
      AutoSize        =   -1  'True
      AutoStart       =   -1  'True
      AnimationAtStart=   -1  'True
      AllowScan       =   -1  'True
      AllowChangeDisplaySize=   -1  'True
      AutoRewind      =   0   'False
      Balance         =   0
      BaseURL         =   ""
      BufferingTime   =   5
      CaptioningID    =   ""
      ClickToPlay     =   -1  'True
      CursorType      =   0
      CurrentPosition =   -1
      CurrentMarker   =   0
      DefaultFrame    =   ""
      DisplayBackColor=   0
      DisplayForeColor=   16777215
      DisplayMode     =   0
      DisplaySize     =   0
      Enabled         =   -1  'True
      EnableContextMenu=   -1  'True
      EnablePositionControls=   -1  'True
      EnableFullScreenControls=   0   'False
      EnableTracker   =   -1  'True
      Filename        =   ""
      InvokeURLs      =   -1  'True
      Language        =   -1
      Mute            =   0   'False
      PlayCount       =   1
      PreviewMode     =   0   'False
      Rate            =   1
      SAMILang        =   ""
      SAMIStyle       =   ""
      SAMIFileName    =   ""
      SelectionStart  =   -1
      SelectionEnd    =   -1
      SendOpenStateChangeEvents=   -1  'True
      SendWarningEvents=   -1  'True
      SendErrorEvents =   -1  'True
      SendKeyboardEvents=   0   'False
      SendMouseClickEvents=   0   'False
      SendMouseMoveEvents=   0   'False
      SendPlayStateChangeEvents=   -1  'True
      ShowCaptioning  =   0   'False
      ShowControls    =   -1  'True
      ShowAudioControls=   -1  'True
      ShowDisplay     =   0   'False
      ShowGotoBar     =   0   'False
      ShowPositionControls=   -1  'True
      ShowStatusBar   =   0   'False
      ShowTracker     =   -1  'True
      TransparentAtStart=   0   'False
      VideoBorderWidth=   0
      VideoBorderColor=   0
      VideoBorder3D   =   0   'False
      Volume          =   -600
      WindowlessVideo =   0   'False
   End
   Begin ShockwaveFlashObjectsCtl.ShockwaveFlash Flash1 
      Height          =   2415
      Left            =   480
      TabIndex        =   2
      Top             =   1680
      Visible         =   0   'False
      Width           =   2655
      _cx             =   4683
      _cy             =   4260
      FlashVars       =   ""
      Movie           =   ""
      Src             =   ""
      WMode           =   "Opaque"
      Play            =   -1  'True
      Loop            =   -1  'True
      Quality         =   "High"
      SAlign          =   ""
      Menu            =   -1  'True
      Base            =   ""
      AllowScriptAccess=   "always"
      Scale           =   "ExactFit"
      DeviceFont      =   0   'False
      EmbedMovie      =   0   'False
      BGColor         =   ""
      SWRemote        =   ""
      MovieData       =   ""
      SeamlessTabbing =   -1  'True
      Profile         =   0   'False
      ProfileAddress  =   ""
      ProfilePort     =   0
      AllowNetworking =   "all"
      AllowFullScreen =   "false"
   End
   Begin VB.Label Label1 
      BackColor       =   &H80000012&
      ForeColor       =   &H8000000E&
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Top             =   840
      Visible         =   0   'False
      Width           =   1335
   End
   Begin MediaPlayerCtl.MediaPlayer MediaPlayer1 
      Height          =   3375
      Left            =   2520
      TabIndex        =   0
      Top             =   1560
      Visible         =   0   'False
      Width           =   4290
      AudioStream     =   -1
      AutoSize        =   -1  'True
      AutoStart       =   -1  'True
      AnimationAtStart=   -1  'True
      AllowScan       =   -1  'True
      AllowChangeDisplaySize=   -1  'True
      AutoRewind      =   0   'False
      Balance         =   0
      BaseURL         =   ""
      BufferingTime   =   5
      CaptioningID    =   ""
      ClickToPlay     =   -1  'True
      CursorType      =   0
      CurrentPosition =   -1
      CurrentMarker   =   0
      DefaultFrame    =   ""
      DisplayBackColor=   0
      DisplayForeColor=   16777215
      DisplayMode     =   0
      DisplaySize     =   0
      Enabled         =   -1  'True
      EnableContextMenu=   -1  'True
      EnablePositionControls=   -1  'True
      EnableFullScreenControls=   0   'False
      EnableTracker   =   -1  'True
      Filename        =   ""
      InvokeURLs      =   -1  'True
      Language        =   -1
      Mute            =   0   'False
      PlayCount       =   1
      PreviewMode     =   0   'False
      Rate            =   1
      SAMILang        =   ""
      SAMIStyle       =   ""
      SAMIFileName    =   ""
      SelectionStart  =   -1
      SelectionEnd    =   -1
      SendOpenStateChangeEvents=   -1  'True
      SendWarningEvents=   -1  'True
      SendErrorEvents =   -1  'True
      SendKeyboardEvents=   0   'False
      SendMouseClickEvents=   0   'False
      SendMouseMoveEvents=   0   'False
      SendPlayStateChangeEvents=   -1  'True
      ShowCaptioning  =   0   'False
      ShowControls    =   -1  'True
      ShowAudioControls=   -1  'True
      ShowDisplay     =   0   'False
      ShowGotoBar     =   0   'False
      ShowPositionControls=   -1  'True
      ShowStatusBar   =   0   'False
      ShowTracker     =   -1  'True
      TransparentAtStart=   0   'False
      VideoBorderWidth=   0
      VideoBorderColor=   0
      VideoBorder3D   =   0   'False
      Volume          =   -600
      WindowlessVideo =   0   'False
   End
   Begin VB.Label Subliminal 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackColor       =   &H00000000&
      Caption         =   "Subliminals"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   300
      Left            =   4650
      TabIndex        =   3
      Top             =   120
      Width           =   1395
   End
   Begin VB.Label Subliminal2 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      BackColor       =   &H00000000&
      Caption         =   "Subliminals2"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   300
      Left            =   4575
      TabIndex        =   5
      Top             =   480
      Width           =   1545
   End
End
Attribute VB_Name = "frmHypno"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Virtual Hypnotist - Session Interface
'©2003-2008 FollowTheWatch Software
'http://vhypno.sourceforge.net
'http://sourceforge.net/projects/vhypno
'Contact - followthewatch55@yahoo.com

'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.

'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Private PrevX As Single
Private PrevY As Single
Private PrevX1 As Single
Private PrevY1 As Single
Public WithEvents VDict1 As Vdict
Attribute VDict1.VB_VarHelpID = -1
Option Explicit

Private Sub CustomBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then Quit = True
If KeyCode = vbKeyF10 Then Call ConsoleShow
KeyResult = GetKeyName(KeyCode)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = True
End Sub

Private Sub CustomBox_KeyUp(KeyCode As Integer, Shift As Integer)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = False
End Sub

Private Sub CustomBox_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
If Button = 1 And Me.WindowState = 0 Then
   PrevX = X
   PrevY = Y
End If
End Sub

Private Sub CustomBox_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And Me.WindowState = 0 Then
    Me.Move Me.Left + (X - PrevX), Me.Top + (Y - PrevY)
    If frmSession.chkTextOnly.Value >= 1 Then
        TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
        TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top
    End If
End If
End Sub

Private Sub Flash1_GotFocus()
'frmHypno.SetFocus
End Sub

Private Sub Form_Click()
MouseClicked = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then Quit = True
If KeyCode = vbKeyF10 Then Call ConsoleShow
KeyResult = GetKeyName(KeyCode)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = True
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = False
End Sub

Private Sub Form_Load()
Dim I As Integer

If ExceptionHandlers = True Then On Error GoTo ErrorHandler

If Preview = False Then SessionRunning = True

'Set the menu options, since if the graphics are too intense, the frmMain timer won't set them
frmMain.mnuStartSession.Enabled = False
frmMain.mnuStopSession.Enabled = True
frmMain.mnuPresets.Enabled = False
frmMain.mnuConfig.Enabled = False
frmMain.mnuMode.Enabled = False

'Turn on/off the exit message
If frmSession.chkExitMessage.Value = 0 Then Label2.Visible = False Else Label2.Visible = True

'Load speech recognition component
If SynthSpeech = True And UseSAPI5 = False And EnableSpeechRec = True Then Set VDict1 = New Vdict

If Preview = True Then GoTo PreviewOnly1

If HypnoWinState > 0 Then Me.WindowState = HypnoWinState

'Resolution change
    If ScreenRes > 1 And frmSession.optSessionSubliminal.Value = False And frmSession.optSessionBackground.Value = False Then
        If ScreenRes = 2 Then Call ChangeRes(1024, 768)
        If ScreenRes = 3 Then Call ChangeRes(800, 600)
        If ScreenRes = 4 Then Call ChangeRes(640, 480)
        If ScreenRes = 5 Then Call ChangeRes(320, 240)
    End If

If frmSession.optFullScreen.Value = True Then
    Me.Width = ScreenX
    Me.Height = ScreenY
    Me.Caption = ""
Else
    Me.Width = Val(frmSession.txtHorizSize.Text) * Screen.TwipsPerPixelX
    Me.Height = Val(frmSession.txtVertSize.Text) * Screen.TwipsPerPixelY
    Me.Left = (ScreenX / 2) - (Me.Width / 2)
    Me.Top = (ScreenY / 2) - (Me.Height / 2)
    Me.Caption = "Virtual Hypnotist"
End If

'show progress bar dialog
LoadDialog.ProgressBar1.Value = 0
If autorun = False And frmSession.optSessionStandard.Value = True Then LoadDialog.Show

FlashVideo = False

'are scripts on?
If frmSession.chkEnableInduction.Value = 1 Or frmSession.chkEnableDeepener.Value = 1 Or frmSession.chkEnableSuggestions.Value = 1 Or frmSession.chkEnableWakener.Value = 1 Then
    ScriptsOn = True
Else
    ScriptsOn = False
End If
    
'are subliminals on?
If frmSession.chkEnableSubliminals.Value = 1 Then
    SubsOn = True
Else
    SubsOn = False
End If

'----determine the progress percentage that each function should have
Dim itemnums As Integer

If ScriptsOn = True Or SubsOn = True Then
    If SkipScripts = False Then itemnums = 7 'tasks 1-6 and 8
    If SkipScripts = True Then itemnums = 3
Else
    itemnums = 2 'tasks 1 and 8
End If

If frmSession.chkEnableBinaural.Value = 1 Then itemnums = itemnums + 1 'task 7
If frmSession.chkEnableVideo.Value = 1 Then itemnums = itemnums + 1 'task 9
If frmSession.chkEnableAudio.Value = 1 Then itemnums = itemnums + 1 'task 10
If frmSession.chkEnableCustom.Value = 1 Then itemnums = itemnums + 1 'task 11
If frmSession.chkEnable3D.Value = 1 Then itemnums = itemnums + 1 'task 12

'get percentage
ProgPercent = 100 / itemnums

'-----end of determination

PreviewOnly1:

'clear user variables
For I = 0 To 255
    DoEvents
    ScriptVars(I) = ""
Next I

'reset recursion values
RecursiveIndex = 0
RecurseMaxLines = 0

If Preview = True Then GoTo PreviewOnly2

'progress task 1
LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent

'clear arrays
If SkipScripts = False Then Call ClearArrays

'run the script loader
'progress tasks 2-6
If ScriptsOn = True Or SubsOn = True Then
    If SkipScripts = False Then
        If frmSession.chkEnableInduction.Value = 1 Then Call ScriptLoader(1, InductionFile)
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
        If frmSession.chkEnableDeepener.Value = 1 Then Call ScriptLoader(2, DeepenerFile)
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
        If frmSession.chkEnableSuggestions.Value = 1 Then Call ScriptLoader(3, SuggestionsFile)
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
        If frmSession.chkEnableWakener.Value = 1 Then Call ScriptLoader(4, WakenerFile)
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    End If
    If frmSession.chkEnableSubliminals.Value = 1 Then Call ScriptLoader(5, SubliminalsFile)
    LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
End If

'configure subliminals
SubCycleTime = frmSession.sliderCycleTime.Value
SubCycles = frmSession.sliderCyclesPerMessage.Value
SubDuration = frmSession.sliderDuration.Value

'start subliminal processor
If SubsOn = True Then Timer2.Enabled = True
'this needs to happen after the ScriptLoader function is called,
'since ScriptLoader inits the subliminals() array

'set colors and fonts of subliminal messages
frmSub.Label1.ForeColor = frmSession.lblPopupSample.ForeColor
frmSub.Label1.FontName = frmSession.lblPopupSample.FontName
frmSub.Label1.FontSize = frmSession.lblPopupSample.FontSize
frmSub.Label1.FontBold = frmSession.lblPopupSample.FontBold
frmSub.Label1.FontItalic = frmSession.lblPopupSample.FontItalic
frmSub.BackColor = frmSession.lblPopupSample.BackColor
Subliminal.ForeColor = frmSession.lblFlasherSample.ForeColor
Subliminal.BackColor = frmSession.lblFlasherSample.BackColor
Subliminal.FontName = frmSession.lblFlasherSample.FontName
Subliminal.FontSize = frmSession.lblFlasherSample.FontSize
Subliminal.FontBold = frmSession.lblFlasherSample.FontBold
Subliminal.FontItalic = frmSession.lblFlasherSample.FontItalic
Subliminal2.ForeColor = frmSession.lblFlasherSample.ForeColor
Subliminal2.BackColor = frmSession.lblFlasherSample.BackColor
Subliminal2.FontName = frmSession.lblFlasherSample.FontName
Subliminal2.FontSize = frmSession.lblFlasherSample.FontSize
Subliminal2.FontBold = frmSession.lblFlasherSample.FontBold
Subliminal2.FontItalic = frmSession.lblFlasherSample.FontItalic

    'Reset the performance timer data
    MaxLatency = 0
    OldTickCount = 0
    AverageLatency = 0
    LatencySum = 0
    LatencySamples = 0
    LatencyWarn = False
    
    'hide this offscreen; fixes some problems with it showing up anyway
    MediaPlayer1.Left = -10000
    
    'Set up Media Player objects
    With MediaPlayer2
        .ShowControls = False
        .ClickToPlay = False
        .SendMouseClickEvents = True
        .SendMouseMoveEvents = True
        .SendKeyboardEvents = True
        .EnableContextMenu = False
        .PlayCount = 0
        .AnimationAtStart = False
        .AutoSize = True
        .Visible = False
        .Rate = frmSession.AudioSpeedSlider.Value / 100
        .volume = frmSession.volBackground.Value
        .Balance = frmSession.balBackground.Value * 36
    End With
    With MediaPlayer3
        .ShowControls = False
        .ClickToPlay = False
        .SendMouseClickEvents = True
        .SendMouseMoveEvents = True
        .SendKeyboardEvents = True
        .EnableContextMenu = False
        .PlayCount = 0
        .AutoSize = True
        .Visible = False
        .AnimationAtStart = False
        .Rate = frmSession.CustomSpeedSlider.Value / 100
        .volume = frmSession.volCustom.Value
        .Balance = frmSession.balCustom.Value * 36
    End With
    
    'Set up and turn on binaurals (brainwave synchronizer)
    Binaural.SetValues
    Binaural.OldFreq1 = Binaural.SpinButton1.Value
    Binaural.OldFreq2 = Binaural.SpinButton2.Value
    If frmSession.chkEnableBinaural.Value = 1 Then
        Call Binaural.Start_Gen
        'progress task 7
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    End If
    
    'Set up and turn on phrase flasher subliminals
    Timer3.Interval = frmSession.sliderMessageSpeed.Value
    Subliminal.Caption = ""
    Subliminal2.Caption = ""
    Subliminal.Left = (Me.Width / 2) - (Subliminal.Width / 2)
    Subliminal2.Left = (Me.Width / 2) - (Subliminal2.Width / 2)
    Subliminal2.Top = Me.Height - Subliminal2.Height - 120
    If frmSession.chkEnableSubliminals.Value = 1 And frmSession.optSessionSubliminal.Value = False And frmSession.optSessionBackground.Value = False Then
        Timer3.Enabled = True
        Subliminal.Visible = True
        Subliminal2.Visible = True
    End If
    If Me.WindowState <> 1 Then Label3.Left = Me.Width - Label3.Width

PreviewOnly2:
    
    'Reload animated character for session
    If SynthSpeech = True And frmSession.chkTextOnly.Value <> 1 And UseSAPI5 = False Then
        Char.Hide True
        frmMain.Agent1.Characters.Unload "Hypnotist"
        frmMain.Agent1.Characters.Load "Hypnotist", CharacterFile
        Set Char = frmMain.Agent1.Characters("Hypnotist")
        Char.LanguageID = &H409
        Char.TTSModeID = "{" + frmSession.txtModeID.Text + "}"
    End If
    
    'Hide character for text-only sessions
    If SynthSpeech = True And frmSession.chkTextOnly.Value >= 1 And UseSAPI5 = False Then Char.Hide True
    
    If Preview = True Then GoTo PreviewOnly3
    
    'progress task 8
    LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    If frmSession.optSessionBackground.Value = True Or frmSession.optSessionSubliminal.Value = True Then frmHypno.Visible = False
    If frmSession.optSessionSubliminal.Value = True Then GoTo BackgroundOnly
    
'start the performance timer (unless 3D graphics are turned on)
If PerfMon = True And frmSession.chkEnable3D.Value = 0 Then Timer6.Enabled = True

'Video/animation loader
If frmSession.chkEnableVideo.Value = 1 Then
    If InStr(VideoFile, "://") = 0 Then
        Call InitVideo(False, False, App.path + "\videos\" + VideoFile)
    Else
        Call InitVideo(False, False, VideoFile)
    End If
    'progress task 9
    LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
End If
    
    'Turn off popup subliminals timer if subliminals are off
    If frmSession.chkEnableSubliminals.Value = 0 Then Timer2.Enabled = False
    
    'Load background audio
    If frmSession.chkEnableAudio.Value = 1 Then
        If InStr(VideoFile, "://") = 0 Then
            MediaPlayer2.Filename = App.path + "\audio\" + AudioFile
        Else
            MediaPlayer2.Filename = AudioFile
        End If
        'progress task 10
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    End If
    
    'Load custom audio
    If frmSession.chkEnableCustom.Value = 1 Then
        MediaPlayer3.Filename = frmSession.txtCustomAudio.Text
        'progress task 11
        LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    End If
    
    'Set up and enable flashers
    If Me.WindowState <> 1 Then
        Loading = True 'Dont make binaural form show
        TempBarWidth = BarWidth
        Shape1.Height = Me.Height * (Binaural.Slider3.Value / 100)
        Shape2.Height = Shape1.Height
        Shape1.Top = (Me.Height / 2) - (Shape1.Height / 2)
        Shape2.Top = Shape1.Top
        Shape1.Shape = Binaural.ShapeType.Value
        Shape2.Shape = Shape1.Shape
        
        If Binaural.Slider1.Value = 2 Then
            Shape1.Width = Int((Me.Width / 2) * (BarWidth / 100))
            Shape2.Width = Shape1.Width
            Shape2.Left = Me.Width - Shape2.Width
            Shape1.Left = 0
        Else
            Shape1.Width = Int(Me.Width * (BarWidth / 100))
            Shape1.Left = Int((Me.Width / 2) - (Shape1.Width / 2))
        End If
        
        If Binaural.chkAlternate.Value = 1 Then
            Timer4.Interval = Int(1000 / Val(Binaural.Label5.Caption))
        Else
            Timer4.Interval = Int(1000 / (Val(Binaural.Label5.Caption) * 2))
        End If
        
        If frmSession.chkEnableFlashers.Value = 1 Then
            If Binaural.Slider1.Value = 2 Then
                Shape1.Visible = True
                Shape2.Visible = True
            Else
                Shape1.Visible = True
            End If
            Timer4.Enabled = True
        Else
            Shape1.Visible = False
            Shape2.Visible = False
            Timer4.Enabled = False
        End If
        
        Loading = False
    End If
    
    'Custom hypnotic visuals
    CustomBox.Visible = False
    CustomBox.Width = Me.Width * (frmSession.SliderCustomZoom.Value / 100)
    CustomBox.Height = Me.Height * (frmSession.SliderCustomZoom.Value / 100)
    CustomBox.Left = (Me.Width / 2) - (CustomBox.Width / 2)
    CustomBox.Top = (Me.Height / 2) - (CustomBox.Height / 2)
    If frmSession.chkEnableVisuals.Value = 1 And Me.WindowState <> 1 And VisualMode <> 2 Then
        CF.StartColor = vbRed
        CF.EndColor = vbYellow
        CF.Steps = 100
        CF.PingPong = False
        CurD = 10000
        CustomBox.Visible = True
        CustomBox.Cls
        CustomBox.ScaleMode = 3
        
        If VisualMode = 3 Then
            CustomBox.DrawWidth = GrockWidth
            CustomBox.AutoRedraw = False
            Call ScriptLoader(9, GrockFile)
            GrockReset = True
        End If
        If VisualMode = 1 Then
            CustomBox.DrawWidth = SpiralThickness
            CustomBox.AutoRedraw = True
            
            'reset spiral
            Cextern = Val(VisualMaker.Label16.Caption)
            ChangeSpiral = True
        End If
        If VisualMode = 0 Then
            CustomBox.DrawWidth = CircleWidth
            CustomBox.AutoRedraw = False
            InitTunnel = False
        End If
        Timer5.Interval = VisualMaker.Slider2.Value
        Timer5.Enabled = True
        
    ElseIf frmSession.chkEnableVisuals.Value = 1 And Me.WindowState <> 1 And VisualMode = 2 Then
        Call SetCustomShapes(Me)
        Timer5.Interval = VisualMaker.Slider2.Value
        Timer5.Enabled = True
    End If
    
    'Text-only session window
    TextForm.Label1.FontName = frmSession.lblTextOnlySample.FontName
    TextForm.Label1.FontSize = frmSession.lblTextOnlySample.FontSize
    TextForm.Label1.FontBold = frmSession.lblTextOnlySample.FontBold
    TextForm.Label1.FontItalic = frmSession.lblTextOnlySample.FontItalic
    
    'progress task 12
    'LoadDialog.ProgressBar1.Value = LoadDialog.ProgressBar1.Value + ProgPercent
    
    'Screen slide-up
    If frmSession.chkScroll.Value = 1 Then
        Scrolling = True
        ScreenCap.Picture = fScreenCap
        ScreenCap.Show
        frmHypno.Show
        If MediaPlayer1.Visible = True Then MediaPlayer1.Pause
        If Flash1.Visible = True Then Flash1.Stop
        Do Until Scrolling = False
            DoEvents
        Loop
        If MediaPlayer1.Visible = True Then MediaPlayer1.Play
        If Flash1.Visible = True Then Flash1.Play
    End If
    
frmHypno.Show
Timer1.Enabled = True

    '3D Engine
    If frmSession.chkEnable3D.Value = 1 Then
        Call frm3D.Load3D
        Call frm3D.Start3D
    End If

BackgroundOnly:
    LoadDialog.Hide
    'On Error Resume Next
    
    If frmSession.optSessionSubliminal.Value = True Then frmSub.Show
    
PreviewOnly3:
    'initialize animated character if scripts are on or
    'if "enable visible character" is selected
    If (ScriptsOn = True Or frmSession.chkEnableChar.Value = 1) And SynthSpeech = True And UseSAPI5 = False And frmSession.chkTextOnly.Value <> 1 Then
    
        Char.Width = Char.Width * (frmSession.SliderCharZoom.Value / 100)
        Char.Height = Char.Height * (frmSession.SliderCharZoom.Value / 100)
    
        If frmSession.chkEnableChar.Value = 1 Then
            Char.MoveTo (ScreenX / Screen.TwipsPerPixelX) * (frmSession.SliderCharHoriz.Value / 100) - (Char.Width / 2), (ScreenY / Screen.TwipsPerPixelY) * (frmSession.SliderCharVert.Value / 100) - (Char.Height / 2)
        Else
            Char.MoveTo -10000, -10000
        End If
    
        Char.Show True
        Char.Balloon.Style = &H21C000C
        UpdateSpeechSettings frmSession.sliderVoicePitch.Value, frmSession.sliderVoiceSpeed.Value, frmSession.sliderVoiceVolume.Value
    End If

'SAPI5-related settings
If SynthSpeech = True And UseSAPI5 = True Then
    SpeechSettings = "<pitch middle=""" + LTrim$(Str$(frmSession.sliderVoicePitch.Value)) + """>"
End If

'get start time in ticks
SessionStartTime = GetTickCount

If Preview = True Then Exit Sub

    'Process scripts
    If ScriptsOn = True And InSession = False Then
        If SkipScripts = False Then
            Call Process(1, DisplayConsole, 0)
            Call Process(2, DisplayConsole, 0)
            Call Process(3, DisplayConsole, 0)
            Call Process(4, DisplayConsole, 0)
            Console.Text1.Text = Console.Text1.Text + "-Session Complete-" + vbCrLf
        Else
            Call Process(6, DisplayConsole, 0)
        End If
    End If
    
    'Monitor loop for remote session mode
    If InSession = True Then
        Do While Quit = False
            DoEvents
            If QueueSize <> 0 Then Call Process(7, DisplayConsole, 0)
        Loop
        If InSession = True Then SendCommand "<ack> Stopping session...", ServerSN
    End If
    
    'exit if a subliminal-only session
    If frmSession.optSessionSubliminal.Value = True Then Exit Sub
    
    'loop here if scripts are off
    If ScriptsOn = False Then
        Do While Quit = False
            DoEvents
        Loop
    End If
    
    'Clean up and quit
    
    'get end time in ticks
    SessionEndTime = GetTickCount
    Quit = False
    Timer1.Enabled = False
    Timer5.Enabled = False
    InitTunnel = False
    If frmSession.chkEnableBinaural.Value = 1 Then
        Call Binaural.Stop_Gen
        'Reset the brainwave generator values
        Binaural.DoNotPlay = True
        Binaural.SpinButton1.Value = Binaural.OldFreq1
        Binaural.SpinButton2.Value = Binaural.OldFreq2
        Binaural.DoNotPlay = False
    End If
    
    If SynthSpeech = True Then
        If frmSession.chkTextOnly.Value <> 1 And UseSAPI5 = False Then
            'SAPI4 stop code
            Char.StopAll
            Char.Hide
            frmMain.DSS.AudioReset
        End If
        If UseSAPI5 = True Then
            'SAPI5 stop code
            frmMain.Voice5.Speak vbNullString, SVSFPurgeBeforeSpeak
            If m_bPaused Then frmMain.Voice5.Resume
            SetSpeakingState False, False
        End If
    End If
    
    TextForm.Visible = False
    If ScreenRes > 1 And frmSession.optSessionSubliminal.Value = False And frmSession.optSessionBackground.Value = False Then Call ChangeRes(0, 0)
    If AutoExit = True Then
        Set VDict1 = Nothing
        Unload frmMain
    End If
    If SkipScripts = False Then
        frmMain.WindowState = 0
        frmMain.Show
        frmMain.SetFocus
    Else
        SkipScripts = False
        ScriptMaker.Show
        ScriptMaker.SetFocus
    End If
    frmSub.Visible = False
    SessionRunning = False
    InSession = False
    Set VDict1 = Nothing
    Unload frmHypno

Exit Sub
ErrorHandler:
err.Source = "Session Interface - Loader"
   Call ErrorReport("An error occurred while running the session.", vbExclamation)

End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
If Button = 1 And Me.WindowState = 0 Then
   PrevX = X
   PrevY = Y
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And Me.WindowState = 0 Then
Me.Move Me.Left + (X - PrevX), Me.Top + (Y - PrevY)
    If frmSession.chkTextOnly.Value >= 1 Then
        TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
        TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top
    End If
End If
End Sub

Private Sub Form_Resize()
If MediaPlayer1.Visible = True Then
    MediaPlayer1.Width = Me.Width * (frmSession.SliderVideoZoom.Value / 100)
    MediaPlayer1.Height = Me.Height * (frmSession.SliderVideoZoom.Value / 100)
    MediaPlayer1.Left = (Me.Width / 2) - (MediaPlayer1.Width / 2)
    MediaPlayer1.Top = (Me.Height / 2) - (MediaPlayer1.Height / 2)
End If
If frm3D.isRunning = True Then frm3D.TV.ResizeDevice
If frmSession.chkTextOnly.Value >= 1 Then
    TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
    TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top
End If
End Sub

Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
End Sub

Private Sub MediaPlayer1_Click(Button As Integer, ShiftState As Integer, X As Single, Y As Single)
MouseClicked = True
End Sub

Private Sub MediaPlayer1_DblClick(Button As Integer, ShiftState As Integer, X As Single, Y As Single)
'this fixes a problem where the form moves off screen when the
'video is double-clicked (maximized)
If Me.WindowState = 0 Then
    Me.Left = (ScreenX / 2) - (Me.Width / 2)
    Me.Top = (ScreenY / 2) - (Me.Height / 2)
End If
End Sub

Private Sub MediaPlayer1_KeyDown(KeyCode As Integer, ShiftState As Integer)
If KeyCode = 27 Then Quit = True
If KeyCode = vbKeyF10 Then Call ConsoleShow
KeyResult = GetKeyName(KeyCode)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = True
End Sub

Private Sub MediaPlayer1_KeyUp(KeyCode As Integer, ShiftState As Integer)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = False
End Sub

Private Sub MediaPlayer1_MouseDown(Button As Integer, ShiftState As Integer, X As Single, Y As Single)
If Button = 2 And MenuOff = False Then frmMain.PopupMenu frmMain.mnuPopUp
If Button = 1 And Me.WindowState = 0 Then
   PrevX1 = X
   PrevY1 = Y
End If
End Sub

Private Sub MediaPlayer1_MouseMove(Button As Integer, ShiftState As Integer, X As Single, Y As Single)
If Button = 1 And Me.WindowState = 0 Then
    Me.Move Me.Left + (X - PrevX1), Me.Top + (Y - PrevY1)
    If frmSession.chkTextOnly.Value >= 1 Then
        TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
        TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top
    End If
End If
End Sub

Private Sub MediaPlayer2_KeyDown(KeyCode As Integer, ShiftState As Integer)
If KeyCode = 27 Then Quit = True
If KeyCode = vbKeyF10 Then Call ConsoleShow
KeyResult = GetKeyName(KeyCode)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = True
End Sub

Private Sub MediaPlayer2_KeyUp(KeyCode As Integer, ShiftState As Integer)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = False
End Sub

Private Sub MediaPlayer3_KeyDown(KeyCode As Integer, ShiftState As Integer)
If KeyCode = 27 Then Quit = True
If KeyCode = vbKeyF10 Then Call ConsoleShow
KeyResult = GetKeyName(KeyCode)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = True
End Sub

Private Sub MediaPlayer3_KeyUp(KeyCode As Integer, ShiftState As Integer)
If LCase$(KeyCheck) = LCase$(GetKeyName(KeyCode)) Then KeyPressed = False
End Sub

Private Sub Timer1_Timer()
'Check for window movement
Static PrevX As Single
Static PrevY As Single

If Me.Left <> PrevX Or Me.Top <> PrevY Then
    'window moved
    If frmSession.chkTextOnly.Value >= 1 Then
        TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
        TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top
    End If
End If

PrevX = Me.Left
PrevY = Me.Top

End Sub

Private Sub Timer2_Timer()
'Standard subliminals

Dim I As Integer

    Timer2.Interval = SubCycleTime
    frmSub.Left = -1000
    frmSub.Top = -1000
    If frmSession.optSessionSubliminal.Value = True Then frmHypno.Visible = False
    Randomize Timer
    I = Int(SubCycles * Rnd) + 1
    If I = 1 Then
        I = Int(SubCount * Rnd) + 1
        frmSub.Label1.Caption = Subliminals(I)
        frmSub.Label1.Top = 0
        frmSub.Label1.Left = 0
        frmSub.Width = frmSub.Label1.Width
        frmSub.Height = frmSub.Label1.Height
        frmSub.Left = ((ScreenX - frmSub.Width) * Rnd) + 1
        frmSub.Top = ((ScreenY - frmSub.Height) * Rnd) + 1
        Call SetWindowPos(frmSub.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags)
        Timer9.Interval = SubDuration
        Timer9.Enabled = True
    End If

End Sub

Private Sub Timer3_Timer()
'Phrase flasher subliminals

Dim I As Integer
Dim NumSubs As Integer
Dim Values(8) As Integer
Values(1) = frmSession.chkFlash1.Value
Values(2) = frmSession.chkFlash2.Value
Values(3) = frmSession.chkFlash3.Value
Values(4) = frmSession.chkFlash4.Value
Values(5) = frmSession.chkFlash5.Value
Values(6) = frmSession.chkFlash6.Value
Values(7) = frmSession.chkFlash7.Value
Values(8) = frmSession.chkFlash8.Value

NumSubs = Values(1) + Values(2) + Values(3) + Values(4) + Values(5) + Values(6) + Values(7) + Values(8)

If NumSubs > 0 Then
ReDim SubLoc(NumSubs) As Integer
For I = 1 To NumSubs
    If Values(I) = 1 Then SubLoc(I) = I: GoTo Skip
    If Values(I + 1) = 1 Then SubLoc(I) = I + 1: GoTo Skip
    If Values(I + 2) = 1 Then SubLoc(I) = I + 2: GoTo Skip
    If Values(I + 3) = 1 Then SubLoc(I) = I + 3: GoTo Skip
    If Values(I + 4) = 1 Then SubLoc(I) = I + 4: GoTo Skip
    If Values(I + 5) = 1 Then SubLoc(I) = I + 5: GoTo Skip
    If Values(I + 6) = 1 Then SubLoc(I) = I + 6: GoTo Skip
    If Values(I + 7) = 1 Then SubLoc(I) = I + 7
Skip:
Next I

Randomize Timer
I = Int(Rnd * NumSubs) + 1
If SubLoc(I) = 1 Then Subliminal.Caption = frmSession.txtFlash1.Text
If SubLoc(I) = 2 Then Subliminal.Caption = frmSession.txtFlash2.Text
If SubLoc(I) = 3 Then Subliminal.Caption = frmSession.txtFlash3.Text
If SubLoc(I) = 4 Then Subliminal.Caption = frmSession.txtFlash4.Text
If SubLoc(I) = 5 Then Subliminal.Caption = frmSession.txtFlash5.Text
If SubLoc(I) = 6 Then Subliminal.Caption = frmSession.txtFlash6.Text
If SubLoc(I) = 7 Then Subliminal.Caption = frmSession.txtFlash7.Text
If SubLoc(I) = 8 Then Subliminal.Caption = frmSession.txtFlash8.Text

Randomize Timer
I = Int(Rnd * NumSubs) + 1
If SubLoc(I) = 1 Then Subliminal2.Caption = frmSession.txtFlash1.Text
If SubLoc(I) = 2 Then Subliminal2.Caption = frmSession.txtFlash2.Text
If SubLoc(I) = 3 Then Subliminal2.Caption = frmSession.txtFlash3.Text
If SubLoc(I) = 4 Then Subliminal2.Caption = frmSession.txtFlash4.Text
If SubLoc(I) = 5 Then Subliminal2.Caption = frmSession.txtFlash5.Text
If SubLoc(I) = 6 Then Subliminal2.Caption = frmSession.txtFlash6.Text
If SubLoc(I) = 7 Then Subliminal2.Caption = frmSession.txtFlash7.Text
If SubLoc(I) = 8 Then Subliminal2.Caption = frmSession.txtFlash8.Text

End If

End Sub


Private Sub Timer4_Timer()
'Flasher Bars

If ShapeData = False Then
    Shape1.FillColor = ShapeAColor1
    If Binaural.Slider1.Value = 2 Then Shape2.FillColor = ShapeBColor1
    ShapeData = True
    Exit Sub
End If

If ShapeData = True Then
    Shape1.FillColor = ShapeAColor2
    If Binaural.Slider1.Value = 2 Then Shape2.FillColor = ShapeBColor2
    ShapeData = False
    Exit Sub
End If

End Sub

Private Sub Timer5_Timer()
'Custom Visuals

If Quit = True Then Exit Sub 'this is needed - otherwise it might be hard to stop the session

If VisualMode = 1 Then Draw CustomBox
If VisualMode = 0 And cbf = 0 Then rtnCircleForward CustomBox
If VisualMode = 0 And cbf = 1 Then rtnCircleBackward CustomBox
If VisualMode = 2 Then Call AnimateShapes(Me)
If VisualMode = 3 Then Call GrockTunnel(CustomBox)
End Sub

Private Sub Timer6_Timer()
'performance timer

Dim latency As Integer
If ResetTimer = True Then
    ResetTimer = False
    OldTickCount = GetTickCount
End If

If OldTickCount > 0 Then
    latency = GetTickCount - OldTickCount - 10 'timer has 10ms latency
    LatencySamples = LatencySamples + 1
    LatencySum = LatencySum + latency
    AverageLatency = LatencySum / LatencySamples
    If AverageLatency > MaxLatency And LatencySamples > 100 Then MaxLatency = AverageLatency
End If

If MaxLatency > 60 Then
    Timer6.Enabled = False
    MediaPlayer1.Stop
    MediaPlayer2.Stop
    Flash1.Stop
    If SynthSpeech = True And UseSAPI5 = False Then Char.Hide True
    DialogText.Hide
    DialogYesNo.Hide
    frmSub.Hide
    Timer5.Enabled = False
    Timer4.Enabled = False
    Timer3.Enabled = False
    MsgBox "The video/animation resolution is too high, and is greatly affecting the performance of Virtual Hypnotist." + vbCrLf + "Please change the video/animation settings.  This session will now exit..", vbOKOnly + vbCritical, "Virtual Hypnotist"
    Quit = True
    Exit Sub
End If

If MaxLatency > 50 And LatencyWarn = False Then
    LatencyWarn = True
    MsgBox "The video/animation is beginning to affect the performance of Virtual Hypnotist." + vbCrLf + "If it gets worse, the session will end.", vbOKOnly + vbExclamation, "Warning"
End If

OldTickCount = GetTickCount
End Sub

Private Sub Timer8_Timer()
PopupPic.Visible = False
Timer8.Enabled = False
End Sub

Private Sub Timer9_Timer()
'hide subliminals
frmSub.Left = -1000
frmSub.Top = -1000
Timer9.Enabled = False
End Sub

Private Sub Vdict1_PhraseFinish(ByVal flags As Long, ByVal phrase As String)
Label3.Caption = phrase
VoiceResult = phrase
End Sub

Public Sub ShowText(TextValue As String)
'Process and display text
Dim Position As Integer
Dim Position2 As Integer
Dim test1 As Integer
Dim test1b As Integer
Dim test2 As Integer
Dim test2b As Integer
Dim test3 As Integer
Dim test3b As Integer
Dim result As String
Dim result2 As String
Dim I As Integer
Dim TextToShow As String

Position = 1
Position2 = 1
'strip off SAPI tags
TextToShow = CmdConvert(TextValue, True, False)

Do

test1 = InStr(Position, TextToShow, "... ", vbTextCompare)
test1b = InStr(Position2, TextValue, "... ", vbTextCompare)
If test1 = 0 Then test2 = InStr(Position, TextToShow, ". ", vbTextCompare) Else test2 = 0
If test1b = 0 Then test2b = InStr(Position2, TextValue, ". ", vbTextCompare) Else test2b = 0
test3 = InStr(Position, TextToShow, ", ", vbTextCompare)
test3b = InStr(Position2, TextValue, ", ", vbTextCompare)

If test1 > 0 Then test1 = test1 + 3
If test1b > 0 Then test1b = test1b + 3
If test2 > 0 Then test2 = test2 + 1
If test2b > 0 Then test2b = test2b + 1
If test3 > 0 Then test3 = test3 + 1
If test3b > 0 Then test3b = test3b + 1

If test1 + test2 + test3 = 0 Then result = Mid$(TextToShow, Position, Len(TextToShow)): Position = Len(TextToShow)
If test1b + test2b + test3b = 0 Then result2 = Mid$(TextValue, Position2, Len(TextValue)): Position2 = Len(TextValue)

If test1 = 0 Then test1 = Len(TextToShow)
If test1b = 0 Then test1b = Len(TextValue)
If test2 = 0 Then test2 = Len(TextToShow)
If test2b = 0 Then test2b = Len(TextValue)
If test3 = 0 Then test3 = Len(TextToShow)
If test3b = 0 Then test3b = Len(TextValue)

If test1 < test2 And test1 < test3 Then result = Mid$(TextToShow, Position, test1 - Position): Position = test1 + 1
If test2 < test1 And test2 < test3 Then result = Mid$(TextToShow, Position, test2 - Position): Position = test2 + 1
If test3 < test1 And test3 < test2 Then result = Mid$(TextToShow, Position, test3 - Position): Position = test3 + 1

If test1b < test2b And test1b < test3b Then result2 = Mid$(TextValue, Position2, test1b - Position2): Position2 = test1b + 1
If test2b < test1b And test2b < test3b Then result2 = Mid$(TextValue, Position2, test2b - Position2): Position2 = test2b + 1
If test3b < test1b And test3b < test2b Then result2 = Mid$(TextValue, Position2, test3b - Position2): Position2 = test3b + 1

TextForm.Label1.ForeColor = vbBlack
If Trim2(result) <> "" Then TextForm.Visible = True Else TextForm.Visible = False
TextForm.Label1.AutoSize = True
TextForm.Label1.Caption = Trim2(result)
TextForm.Label1.Left = 100
TextForm.Label1.Top = 50
TextForm.Width = TextForm.Label1.Width + 200
TextForm.Height = TextForm.Label1.Height + 100
TextForm.Left = (frmHypno.Width / 2) - (TextForm.Width / 2) + frmHypno.Left
TextForm.Top = (frmHypno.Height / 2) - (TextForm.Height / 2) + frmHypno.Top

If Trim2(result) <> "" Then Call SetWindowPos(TextForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, flags)

'fade in
For I = 1 To 255 Step frmSession.sliderTextFadeSpeed.Value
    TextForm.Label1.ForeColor = RGB(I, I, I)
    Call Sleep2(1)
Next I

If frmSession.chkTextOnly.Value = 1 Then
    'pause after, if speech is off
    Call Sleep2(frmSession.sliderTextSpeed.Value)
Else
    '*** Output speech
    
    'SAPI4 DSS output
    If UseSAPI5 = False Then
        frmMain.DSS.TextData 0, 1, SpeechSettings + result2
    
        'DSS output handler
        Do Until DSSFinished = True
            DoEvents
            If frmSession.optSessionBackground.Value = True Or frmSession.optSessionSubliminal.Value = True Then frmHypno.Visible = False
            If Quit = True Then
                Console.Text1.Text = Console.Text1.Text + vbCrLf + "***Quitting session" + vbCrLf
                DSSFinished = False
                Exit Sub
            End If
        Loop
        DSSFinished = False
    Else
        'SAPI5 output
        'Pause
        Call Sleep2(frmSession.sliderTextSpeed.Value)
        frmMain.Voice5.Rate = frmSession.sliderVoiceSpeed.Value
        frmMain.Voice5.volume = frmSession.sliderVoiceVolume.Value
        Set frmMain.Voice5.AudioOutput = frmMain.Voice5.GetAudioOutputs().Item(frmSession.AudioOutputCB.ListIndex)
        frmMain.Voice5.AllowAudioOutputFormatChangesOnNextSet = False
        frmMain.Voice5.AudioOutputStream.Format.Type = frmSession.FormatCB.ItemData(frmSession.FormatCB.ListIndex)
        Set frmMain.Voice5.AudioOutputStream = frmMain.Voice5.AudioOutputStream
        frmMain.Voice5.Speak SpeechSettings + result2, m_speakFlags
        SetSpeakingState True, False
    
        'SAPI5 speech handler
        Do Until m_bSpeaking = False And m_bPaused = False
            DoEvents
            If frmSession.optSessionBackground.Value = True Or frmSession.optSessionSubliminal.Value = True Then frmHypno.Visible = False
            If Quit = True Then
                Console.Text1.Text = Console.Text1.Text + vbCrLf + "***Quitting session" + vbCrLf
                Exit Sub
            End If
        Loop
    End If
    
End If

If Quit = True Then
    Call SetWindowPos(TextForm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags)
    TextForm.Visible = False
    Exit Sub
End If
'fade out
For I = 255 To 1 Step -frmSession.sliderTextFadeSpeed.Value
    TextForm.Label1.ForeColor = RGB(I, I, I)
    Call Sleep2(1)
Next I

If Position = Len(TextToShow) Then
    Call SetWindowPos(TextForm.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, flags)
    TextForm.Visible = False
    Exit Sub
End If

Loop
End Sub
