diff --git a/SLAM/AdvWaveViewer.vb b/SLAM/AdvWaveViewer.vb
new file mode 100644
index 0000000..c9b9360
--- /dev/null
+++ b/SLAM/AdvWaveViewer.vb
@@ -0,0 +1,294 @@
+
+Imports System.Collections
+Imports System.ComponentModel
+Imports System.Drawing
+Imports System.Data
+Imports System.Windows.Forms
+Imports NAudio.Wave
+
+'''
+''' Control for viewing waveforms
+'''
+Public Class AdvWaveViewer
+ Inherits System.Windows.Forms.UserControl
+ '''
+ ''' Required designer variable.
+ '''
+ Private components As System.ComponentModel.Container = Nothing
+ Private m_waveStream As WaveStream
+ Private m_samplesPerPixel As Integer = 128
+ Private m_startPosition As Long
+ Private bytesPerSample As Integer = 2
+ '''
+ ''' Creates a new WaveViewer control
+ '''
+ Public Sub New()
+ ' This call is required by the Windows.Forms Form Designer.
+ InitializeComponent()
+
+ Me.DoubleBuffered = True
+
+ End Sub
+
+ Public Sub Fit()
+ If m_waveStream Is Nothing Then
+ Return
+ End If
+
+ If Not Me.Width > 0 Then
+ Return
+ End If
+
+ Dim samples As Integer = CInt(m_waveStream.Length / bytesPerSample)
+ m_startPosition = 0
+ SamplesPerPixel = samples / Me.Width
+
+ End Sub
+
+ Protected Overrides Sub OnResize(e As EventArgs)
+ MyBase.OnResize(e)
+ Fit()
+ End Sub
+
+ Private mousePos As Point, startPos As Point
+ Private mouseDrag As Boolean = False
+
+ Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
+ If e.Button = System.Windows.Forms.MouseButtons.Left And Me.Enabled Then
+
+ startPos = e.Location
+ mousePos = New Point(-1, -1)
+ mouseDrag = True
+ DrawVerticalLine(e.X)
+
+ End If
+
+ MyBase.OnMouseDown(e)
+ End Sub
+
+ Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
+ If e.X >= 0 And e.X <= Me.Width And Me.Enabled Then
+ If mouseDrag Then
+ DrawVerticalLine(e.X)
+ If mousePos.X <> -1 Then
+ DrawVerticalLine(mousePos.X)
+ End If
+ mousePos = e.Location
+ End If
+ End If
+ MyBase.OnMouseMove(e)
+ End Sub
+
+ Public ReadOnly Property MaxSamples As Integer
+ Get
+ Return m_waveStream.Length / bytesPerSample
+ End Get
+ End Property
+
+ Private m_leftSample As Integer = -1
+ Public Property leftSample As Integer
+ Get
+ Return m_leftSample
+ End Get
+ Set(value As Integer)
+ m_leftSample = value
+ Me.Invalidate()
+ End Set
+ End Property
+ Private m_rightSample As Integer = -1
+ Public Property rightSample As Integer
+ Get
+ Return m_rightSample
+ End Get
+ Set(value As Integer)
+ m_rightSample = value
+ Me.Invalidate()
+ End Set
+ End Property
+
+ Public Property leftpos As Integer
+ Get
+ Return m_leftSample * bytesPerSample
+ End Get
+ Set(value As Integer)
+ m_leftSample = value / bytesPerSample
+ Me.Invalidate()
+ End Set
+ End Property
+
+ Public Property rightpos As Integer
+ Get
+ Return m_rightSample * bytesPerSample
+ End Get
+ Set(value As Integer)
+ m_rightSample = value / bytesPerSample
+ Me.Invalidate()
+ End Set
+ End Property
+
+ Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
+ If mouseDrag AndAlso e.Button = System.Windows.Forms.MouseButtons.Left AndAlso Me.Enabled Then
+ mouseDrag = False
+ 'DrawVerticalLine(startPos.X)
+
+ If mousePos.X = -1 Then
+
+ If Not startPos.X = 0 Then
+ DrawVerticalLine(startPos.X)
+ End If
+
+ Return
+ End If
+ 'DrawVerticalLine(mousePos.X)
+
+ m_leftSample = CInt(StartPosition \ bytesPerSample + m_samplesPerPixel * Math.Min(startPos.X, mousePos.X))
+ m_rightSample = CInt(StartPosition \ bytesPerSample + m_samplesPerPixel * Math.Max(startPos.X, mousePos.X))
+ Me.Invalidate()
+ End If
+
+ MyBase.OnMouseUp(e)
+ End Sub
+
+ Private Sub DrawVerticalLine(x As Integer)
+ ControlPaint.DrawReversibleLine(PointToScreen(New Point(x, 0)), PointToScreen(New Point(x, Height)), Color.Black)
+ End Sub
+
+ '''
+ ''' sets the associated wavestream
+ '''
+ Public Property WaveStream() As WaveStream
+ Get
+ Return m_waveStream
+ End Get
+ Set(value As WaveStream)
+ m_waveStream = value
+ If m_waveStream IsNot Nothing Then
+ bytesPerSample = (m_waveStream.WaveFormat.BitsPerSample / 8) * m_waveStream.WaveFormat.Channels
+ Fit()
+ End If
+ Me.Invalidate()
+ End Set
+ End Property
+
+ Public ReadOnly Property SampleRate As Integer
+ Get
+ Return m_waveStream.WaveFormat.SampleRate
+ End Get
+ End Property
+
+ '''
+ ''' The zoom level, in samples per pixel
+ '''
+ Public Property SamplesPerPixel() As Integer
+ Get
+ Return m_samplesPerPixel
+ End Get
+ Set(value As Integer)
+ m_samplesPerPixel = value
+ Me.Invalidate()
+ End Set
+ End Property
+
+ '''
+ ''' Start position (currently in bytes)
+ '''
+ Public Property StartPosition() As Long
+ Get
+ Return m_startPosition
+ End Get
+ Set(value As Long)
+ m_startPosition = value
+ End Set
+ End Property
+
+ Private m_marker As Integer
+ Public Property marker() As Long
+ Get
+ Return m_marker
+ End Get
+ Set(value As Long)
+ If value <= MaxSamples Then
+ m_marker = value
+ Me.Invalidate()
+ End If
+ End Set
+ End Property
+
+ '''
+ ''' Clean up any resources being used.
+ '''
+ Protected Overrides Sub Dispose(disposing As Boolean)
+ If disposing Then
+ If components IsNot Nothing Then
+ components.Dispose()
+ End If
+ End If
+ MyBase.Dispose(disposing)
+ End Sub
+
+ '''
+ '''
+ '''
+ Protected Overrides Sub OnPaint(e As PaintEventArgs)
+ If m_waveStream IsNot Nothing Then
+ m_waveStream.Position = 0
+ Dim bytesRead As Integer
+ Dim waveData As Byte() = New Byte(m_samplesPerPixel * bytesPerSample - 1) {}
+ m_waveStream.Position = m_startPosition + (e.ClipRectangle.Left * bytesPerSample * m_samplesPerPixel)
+
+ Dim leftpos As Integer = CInt(m_leftSample \ m_samplesPerPixel - StartPosition \ bytesPerSample \ m_samplesPerPixel)
+ Dim rightpos As Integer = CInt(m_rightSample \ m_samplesPerPixel - StartPosition \ bytesPerSample \ m_samplesPerPixel)
+ Dim markerpos As Integer = CInt((m_marker + m_leftSample) \ m_samplesPerPixel - StartPosition \ bytesPerSample \ m_samplesPerPixel)
+
+ For x As Single = e.ClipRectangle.X To e.ClipRectangle.Right - 1
+ Dim low As Short = 0
+ Dim high As Short = 0
+ bytesRead = m_waveStream.Read(waveData, 0, m_samplesPerPixel * bytesPerSample)
+ If bytesRead = 0 Then
+ Exit For
+ End If
+ For n As Integer = 0 To bytesRead - 1 Step 2
+ Dim sample As Short = BitConverter.ToInt16(waveData, n)
+ If sample < low Then
+ low = sample
+ End If
+ If sample > high Then
+ high = sample
+ End If
+ Next
+ Dim lowPercent As Single = ((CSng(low) - Short.MinValue) / UShort.MaxValue)
+ Dim highPercent As Single = ((CSng(high) - Short.MinValue) / UShort.MaxValue)
+ Using DodgerBluePen As New Pen(Color.DodgerBlue), BluePen As New Pen(Color.Blue), RedPen As New Pen(Color.Red), GreenPen As New Pen(Color.Green)
+
+ If x = leftpos And Not leftSample = rightSample Or x = rightpos And Not rightSample = leftSample Then
+ e.Graphics.DrawLine(RedPen, x, 0, x, Me.Height)
+
+ ElseIf x = markerpos And m_marker > 0 Then
+ e.Graphics.DrawLine(GreenPen, x, 0, x, Me.Height)
+
+ ElseIf x > leftpos And x < rightpos Then
+ e.Graphics.DrawLine(BluePen, x, Me.Height * lowPercent, x, Me.Height * highPercent)
+
+ Else
+ e.Graphics.DrawLine(DodgerBluePen, x, Me.Height * lowPercent, x, Me.Height * highPercent)
+
+ End If
+
+ End Using
+ Next
+ End If
+
+ MyBase.OnPaint(e)
+ End Sub
+
+
+#Region "Component Designer generated code"
+ '''
+ ''' Required method for Designer support - do not modify
+ ''' the contents of this method with the code editor.
+ '''
+ Private Sub InitializeComponent()
+ components = New System.ComponentModel.Container()
+ End Sub
+#End Region
+End Class
diff --git a/SLAM/App.config b/SLAM/App.config
index 96b2c49..6c1ecb4 100644
--- a/SLAM/App.config
+++ b/SLAM/App.config
@@ -37,6 +37,9 @@
=
+
+ C:\Program Files (x86)\Steam\userdata\
+
\ No newline at end of file
diff --git a/SLAM/Form1.Designer.vb b/SLAM/Form1.Designer.vb
index d9d0e6a..235a2b3 100644
--- a/SLAM/Form1.Designer.vb
+++ b/SLAM/Form1.Designer.vb
@@ -47,7 +47,9 @@ Partial Class Form1
Me.RemoveHotkeyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ContextHotKey = New System.Windows.Forms.ToolStripMenuItem()
Me.SetVolumeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
+ Me.TrimToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.PlayKeyButton = New System.Windows.Forms.Button()
+ Me.Trimmed = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader)
Me.TrackContextMenu.SuspendLayout()
Me.SuspendLayout()
'
@@ -60,7 +62,7 @@ Partial Class Form1
Me.GameSelector.Location = New System.Drawing.Point(56, 12)
Me.GameSelector.MaxDropDownItems = 100
Me.GameSelector.Name = "GameSelector"
- Me.GameSelector.Size = New System.Drawing.Size(335, 21)
+ Me.GameSelector.Size = New System.Drawing.Size(435, 21)
Me.GameSelector.TabIndex = 0
'
'Label1
@@ -88,13 +90,13 @@ Partial Class Form1
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TrackList.AutoArrange = False
- Me.TrackList.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.LoadedCol, Me.TrackCol, Me.HotKeyCol, Me.VolumeCol, Me.TagsCol})
+ Me.TrackList.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.LoadedCol, Me.TrackCol, Me.HotKeyCol, Me.VolumeCol, Me.Trimmed, Me.TagsCol})
Me.TrackList.FullRowSelect = True
Me.TrackList.HideSelection = False
Me.TrackList.ImeMode = System.Windows.Forms.ImeMode.Off
Me.TrackList.Location = New System.Drawing.Point(15, 39)
Me.TrackList.Name = "TrackList"
- Me.TrackList.Size = New System.Drawing.Size(457, 252)
+ Me.TrackList.Size = New System.Drawing.Size(557, 252)
Me.TrackList.TabIndex = 4
Me.TrackList.UseCompatibleStateImageBehavior = False
Me.TrackList.View = System.Windows.Forms.View.Details
@@ -144,7 +146,7 @@ Partial Class Form1
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ProgressBar1.Location = New System.Drawing.Point(15, 326)
Me.ProgressBar1.Name = "ProgressBar1"
- Me.ProgressBar1.Size = New System.Drawing.Size(457, 23)
+ Me.ProgressBar1.Size = New System.Drawing.Size(557, 23)
Me.ProgressBar1.Step = 1
Me.ProgressBar1.TabIndex = 6
'
@@ -160,7 +162,7 @@ Partial Class Form1
'ChangeDirButton
'
Me.ChangeDirButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
- Me.ChangeDirButton.Location = New System.Drawing.Point(397, 10)
+ Me.ChangeDirButton.Location = New System.Drawing.Point(497, 10)
Me.ChangeDirButton.Name = "ChangeDirButton"
Me.ChangeDirButton.Size = New System.Drawing.Size(75, 23)
Me.ChangeDirButton.TabIndex = 7
@@ -169,9 +171,9 @@ Partial Class Form1
'
'TrackContextMenu
'
- Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.LoadToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem})
+ Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.LoadToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem, Me.TrimToolStripMenuItem})
Me.TrackContextMenu.Name = "TrackContextMenu"
- Me.TrackContextMenu.Size = New System.Drawing.Size(145, 158)
+ Me.TrackContextMenu.Size = New System.Drawing.Size(145, 180)
'
'ContextDelete
'
@@ -215,21 +217,31 @@ Partial Class Form1
Me.SetVolumeToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
Me.SetVolumeToolStripMenuItem.Text = "Set Volume"
'
+ 'TrimToolStripMenuItem
+ '
+ Me.TrimToolStripMenuItem.Name = "TrimToolStripMenuItem"
+ Me.TrimToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
+ Me.TrimToolStripMenuItem.Text = "Trim"
+ '
'PlayKeyButton
'
Me.PlayKeyButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
- Me.PlayKeyButton.Location = New System.Drawing.Point(247, 297)
+ Me.PlayKeyButton.Location = New System.Drawing.Point(347, 297)
Me.PlayKeyButton.Name = "PlayKeyButton"
Me.PlayKeyButton.Size = New System.Drawing.Size(225, 23)
Me.PlayKeyButton.TabIndex = 8
Me.PlayKeyButton.Text = "Play key: """"{0}"""" (change)"
Me.PlayKeyButton.UseVisualStyleBackColor = True
'
+ 'Trimmed
+ '
+ Me.Trimmed.Text = "Trimmed"
+ '
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
- Me.ClientSize = New System.Drawing.Size(484, 361)
+ Me.ClientSize = New System.Drawing.Size(584, 361)
Me.Controls.Add(Me.PlayKeyButton)
Me.Controls.Add(Me.ChangeDirButton)
Me.Controls.Add(Me.ProgressBar1)
@@ -272,5 +284,7 @@ Partial Class Form1
Friend WithEvents PlayKeyButton As System.Windows.Forms.Button
Friend WithEvents VolumeCol As System.Windows.Forms.ColumnHeader
Friend WithEvents SetVolumeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
+ Friend WithEvents TrimToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
+ Friend WithEvents Trimmed As System.Windows.Forms.ColumnHeader
End Class
diff --git a/SLAM/Form1.vb b/SLAM/Form1.vb
index dab58c8..be72209 100644
--- a/SLAM/Form1.vb
+++ b/SLAM/Form1.vb
@@ -24,6 +24,7 @@ Public Class Form1
Dim csgo As New SourceGame
csgo.name = "Counter-Strike: Global Offensive"
+ csgo.id = 730
csgo.directory = "common\Counter-Strike Global Offensive\"
csgo.ToCfg = "csgo\cfg\"
csgo.libraryname = "csgo\"
@@ -181,7 +182,13 @@ Public Class Form1
Dim Game As SourceGame = GetCurrentGame()
For Each Track In Game.tracks
- TrackList.Items.Add(New ListViewItem({"False", Track.name, Track.hotkey, Track.volume & "%", """" & String.Join(""", """, Track.tags) & """"}))
+
+ Dim trimmed As String = ""
+ If Track.endpos > 0 Then
+ trimmed = "Yes"
+ End If
+
+ TrackList.Items.Add(New ListViewItem({"False", Track.name, Track.hotkey, Track.volume & "%", trimmed, """" & String.Join(""", """, Track.tags) & """"}))
Next
@@ -189,7 +196,8 @@ Public Class Form1
TrackList.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent)
TrackList.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.HeaderSize)
TrackList.AutoResizeColumn(3, ColumnHeaderAutoResizeStyle.HeaderSize)
- TrackList.AutoResizeColumn(4, ColumnHeaderAutoResizeStyle.ColumnContent)
+ TrackList.AutoResizeColumn(4, ColumnHeaderAutoResizeStyle.HeaderSize)
+ TrackList.AutoResizeColumn(5, ColumnHeaderAutoResizeStyle.ColumnContent)
End Sub
Private Sub StartButton_Click(sender As Object, e As EventArgs) Handles StartButton.Click
@@ -293,16 +301,34 @@ Public Class Form1
Dim trackfile As String = Game.libraryname & Track.name & Game.FileExtension
If File.Exists(trackfile) Then
- If Track.volume = 100 Then
+ If Track.volume = 100 And Track.startpos = -1 And Track.endpos = -1 Then
File.Copy(trackfile, voicefile)
Else
+
Dim WaveFloat As New WaveChannel32(New WaveFileReader(trackfile))
+
+ If Not Track.volume = 100 Then
+ WaveFloat.Volume = (Track.volume / 100) ^ 6
+ End If
+
+ If Not Track.startpos = Track.endpos And Track.endpos > 0 Then
+ Dim bytes((Track.endpos - Track.startpos) * 4) As Byte
+
+ WaveFloat.Position = Track.startpos * 4
+ WaveFloat.Read(bytes, 0, (Track.endpos - Track.startpos) * 4)
+
+ WaveFloat = New WaveChannel32(New RawSourceWaveStream(New MemoryStream(bytes), WaveFloat.WaveFormat))
+ End If
+
WaveFloat.PadWithZeroes = False
- WaveFloat.Volume = (Track.volume / 100) ^ 6
- Dim Wave16 As New Wave32To16Stream(WaveFloat)
Dim outFormat = New WaveFormat(Game.samplerate, Game.bits, Game.channels)
- Dim resampler = New MediaFoundationResampler(Wave16, outFormat)
+ Dim resampler = New MediaFoundationResampler(WaveFloat, outFormat)
+ resampler.ResamplerQuality = 60
WaveFileWriter.CreateWaveFile(voicefile, resampler)
+
+ resampler.Dispose()
+ WaveFloat.Dispose()
+
End If
Dim GameCfgFolder As String = Path.Combine(SteamappsPath, Game.directory, Game.ToCfg)
@@ -338,11 +364,16 @@ Public Class Form1
Dim GameDir As String = Path.Combine(SteamappsPath, Game.directory)
Dim GameCfg As String = Path.Combine(GameDir, Game.ToCfg) & "slam_relay.cfg"
+
Do
If PollRelayWorker.CancellationPending Then
Exit Do
End If
+ If Not String.IsNullOrEmpty(Game.id) Then
+ GameCfg = UserDataCFG(Game)
+ End If
+
If File.Exists(GameCfg) Then
Dim RelayCfg As String
Using reader As StreamReader = New StreamReader(GameCfg)
@@ -365,10 +396,26 @@ Public Class Form1
Loop
End Sub
+ Public Function UserDataCFG(Game As SourceGame) As String
+ For Each userdir As String In Directory.GetDirectories(My.Settings.UserdataPath)
+ Dim CFGPath As String = Path.Combine(userdir, Game.id.ToString) & "\local\cfg\slam_relay.cfg"
+ If File.Exists(CFGPath) Then
+ Return CFGPath
+ End If
+ Next
+ Return vbNullString
+ End Function
+
Private Sub PollRelayWorker_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles PollRelayWorker.ProgressChanged
DisplayLoaded(e.ProgressPercentage)
End Sub
+ Private Sub PollRelayWorker_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles PollRelayWorker.RunWorkerCompleted
+ If running Then
+ StopPoll()
+ End If
+ End Sub
+
Private Sub CreateTags(ByVal Game As SourceGame)
Dim NameWords As New Dictionary(Of String, Integer)
@@ -479,8 +526,11 @@ Public Class Form1
For Each Track In Game.tracks
For Each SetTrack In SettingsList
If Track.name = SetTrack.name Then
+ 'Please tell me that there is a better way to do the following...
Track.hotkey = SetTrack.hotkey
Track.volume = SetTrack.volume
+ Track.startpos = SetTrack.startpos
+ Track.endpos = SetTrack.endpos
End If
Next
Next
@@ -492,7 +542,7 @@ Public Class Form1
Dim SettingsFile As String = Path.Combine(Game.libraryname, "TrackSettings.xml")
For Each Track In Game.tracks
- If Not String.IsNullOrEmpty(Track.hotkey) Or Not Track.volume = 100 Then
+ If Not String.IsNullOrEmpty(Track.hotkey) Or Not Track.volume = 100 Or Track.endpos > 0 Then
SettingsList.Add(Track)
@@ -530,6 +580,7 @@ Public Class Form1
Else
If running Then
LoadToolStripMenuItem.Visible = True 'visible when only one selected AND is running
+ TrimToolStripMenuItem.Visible = True
Else
For Each Control In TrackContextMenu.Items 'visible when only one selected AND is not running (all)
Control.visible = True
@@ -652,6 +703,24 @@ Public Class Form1
End Sub
+ Private Sub TrimToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TrimToolStripMenuItem.Click
+ Dim Game As SourceGame = GetCurrentGame()
+ Dim TrimDialog As New TrimForm
+
+ TrimDialog.WavFile = Path.Combine(Game.libraryname, Game.tracks(TrackList.SelectedIndices(0)).name & Game.FileExtension)
+ TrimDialog.startpos = Game.tracks(TrackList.SelectedIndices(0)).startpos
+ TrimDialog.endpos = Game.tracks(TrackList.SelectedIndices(0)).endpos
+
+
+ If TrimDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
+ Game.tracks(TrackList.SelectedIndices(0)).startpos = TrimDialog.startpos
+ Game.tracks(TrackList.SelectedIndices(0)).endpos = TrimDialog.endpos
+ SaveTrackKeys(GetCurrentGame)
+ ReloadTracks(GetCurrentGame)
+ RefreshTrackList()
+ End If
+ End Sub
+
Private Async Sub CheckForUpdate()
Dim UpdateText As String
@@ -732,6 +801,7 @@ End Class
Public Class SourceGame
Public name As String
+ Public id As Integer
Public directory As String
Public ToCfg As String
Public libraryname As String
@@ -750,5 +820,7 @@ Public Class SourceGame
Public tags As New List(Of String)
Public hotkey As String = vbNullString
Public volume As Integer = 100
+ Public startpos As Integer
+ Public endpos As Integer
End Class
End Class
diff --git a/SLAM/My Project/AssemblyInfo.vb b/SLAM/My Project/AssemblyInfo.vb
index 928d7f3..6c7f4c9 100644
--- a/SLAM/My Project/AssemblyInfo.vb
+++ b/SLAM/My Project/AssemblyInfo.vb
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
'
-
-
+
+
diff --git a/SLAM/My Project/Settings.Designer.vb b/SLAM/My Project/Settings.Designer.vb
index af346bf..17632bd 100644
--- a/SLAM/My Project/Settings.Designer.vb
+++ b/SLAM/My Project/Settings.Designer.vb
@@ -161,6 +161,18 @@ Namespace My
Me("RelayKey") = value
End Set
End Property
+
+ _
+ Public Property UserdataPath() As String
+ Get
+ Return CType(Me("UserdataPath"),String)
+ End Get
+ Set
+ Me("UserdataPath") = value
+ End Set
+ End Property
End Class
End Namespace
diff --git a/SLAM/My Project/Settings.settings b/SLAM/My Project/Settings.settings
index 35d8f33..aa3ab4b 100644
--- a/SLAM/My Project/Settings.settings
+++ b/SLAM/My Project/Settings.settings
@@ -29,5 +29,8 @@
=
+
+ C:\Program Files (x86)\Steam\userdata\
+
\ No newline at end of file
diff --git a/SLAM/SLAM.vbproj b/SLAM/SLAM.vbproj
index e919cb8..02be6cf 100644
--- a/SLAM/SLAM.vbproj
+++ b/SLAM/SLAM.vbproj
@@ -133,11 +133,21 @@
Form
+
+ UserControl
+
+
+ TrimForm.vb
+
+
+ Form
+
Form1.vb
+ Designer
SettingsForm.vb
@@ -154,6 +164,9 @@
SelectKey.vb
+
+ TrimForm.vb
+
@@ -164,6 +177,7 @@
SettingsSingleFileGenerator
My
Settings.Designer.vb
+ Designer
diff --git a/SLAM/SettingsForm.Designer.vb b/SLAM/SettingsForm.Designer.vb
index 8d823fa..cc69419 100644
--- a/SLAM/SettingsForm.Designer.vb
+++ b/SLAM/SettingsForm.Designer.vb
@@ -38,12 +38,18 @@ Partial Class SettingsForm
Me.ChangeDirButton = New System.Windows.Forms.Button()
Me.DirText = New System.Windows.Forms.TextBox()
Me.TabControl1 = New System.Windows.Forms.TabControl()
+ Me.TabPage2 = New System.Windows.Forms.TabPage()
+ Me.GroupBox4 = New System.Windows.Forms.GroupBox()
+ Me.Button1 = New System.Windows.Forms.Button()
+ Me.UserDataDir = New System.Windows.Forms.TextBox()
Me.StatusStrip1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.GroupBox3.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.GroupBox1.SuspendLayout()
Me.TabControl1.SuspendLayout()
+ Me.TabPage2.SuspendLayout()
+ Me.GroupBox4.SuspendLayout()
Me.SuspendLayout()
'
'StatusStrip1
@@ -70,8 +76,8 @@ Partial Class SettingsForm
'
'TabPage1
'
+ Me.TabPage1.Controls.Add(Me.GroupBox4)
Me.TabPage1.Controls.Add(Me.GroupBox3)
- Me.TabPage1.Controls.Add(Me.GroupBox2)
Me.TabPage1.Controls.Add(Me.GroupBox1)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
@@ -107,7 +113,7 @@ Partial Class SettingsForm
Me.GroupBox2.Controls.Add(Me.LogCheckBox)
Me.GroupBox2.Controls.Add(Me.HintCheckBox)
Me.GroupBox2.Controls.Add(Me.UpdateCheckBox)
- Me.GroupBox2.Location = New System.Drawing.Point(8, 147)
+ Me.GroupBox2.Location = New System.Drawing.Point(8, 6)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(260, 132)
Me.GroupBox2.TabIndex = 2
@@ -195,6 +201,7 @@ Partial Class SettingsForm
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
+ Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.TabControl1.Location = New System.Drawing.Point(0, 0)
Me.TabControl1.Name = "TabControl1"
@@ -202,6 +209,45 @@ Partial Class SettingsForm
Me.TabControl1.Size = New System.Drawing.Size(284, 331)
Me.TabControl1.TabIndex = 0
'
+ 'TabPage2
+ '
+ Me.TabPage2.Controls.Add(Me.GroupBox2)
+ Me.TabPage2.Location = New System.Drawing.Point(4, 22)
+ Me.TabPage2.Name = "TabPage2"
+ Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
+ Me.TabPage2.Size = New System.Drawing.Size(276, 305)
+ Me.TabPage2.TabIndex = 1
+ Me.TabPage2.Text = "Misc."
+ Me.TabPage2.UseVisualStyleBackColor = True
+ '
+ 'GroupBox4
+ '
+ Me.GroupBox4.Controls.Add(Me.Button1)
+ Me.GroupBox4.Controls.Add(Me.UserDataDir)
+ Me.GroupBox4.Location = New System.Drawing.Point(8, 147)
+ Me.GroupBox4.Name = "GroupBox4"
+ Me.GroupBox4.Size = New System.Drawing.Size(260, 75)
+ Me.GroupBox4.TabIndex = 2
+ Me.GroupBox4.TabStop = False
+ Me.GroupBox4.Text = "UserData Directory"
+ '
+ 'Button1
+ '
+ Me.Button1.Location = New System.Drawing.Point(179, 45)
+ Me.Button1.Name = "Button1"
+ Me.Button1.Size = New System.Drawing.Size(75, 23)
+ Me.Button1.TabIndex = 1
+ Me.Button1.Text = "Change"
+ Me.Button1.UseVisualStyleBackColor = True
+ '
+ 'UserDataDir
+ '
+ Me.UserDataDir.Location = New System.Drawing.Point(6, 19)
+ Me.UserDataDir.Name = "UserDataDir"
+ Me.UserDataDir.ReadOnly = True
+ Me.UserDataDir.Size = New System.Drawing.Size(248, 20)
+ Me.UserDataDir.TabIndex = 0
+ '
'SettingsForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -222,6 +268,9 @@ Partial Class SettingsForm
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.TabControl1.ResumeLayout(False)
+ Me.TabPage2.ResumeLayout(False)
+ Me.GroupBox4.ResumeLayout(False)
+ Me.GroupBox4.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
@@ -242,4 +291,8 @@ Partial Class SettingsForm
Friend WithEvents ConTagsCheckBox As System.Windows.Forms.CheckBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents ChangeRelayButton As System.Windows.Forms.Button
+ Friend WithEvents GroupBox4 As System.Windows.Forms.GroupBox
+ Friend WithEvents Button1 As System.Windows.Forms.Button
+ Friend WithEvents UserDataDir As System.Windows.Forms.TextBox
+ Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
End Class
diff --git a/SLAM/SettingsForm.vb b/SLAM/SettingsForm.vb
index 8383299..8764c74 100644
--- a/SLAM/SettingsForm.vb
+++ b/SLAM/SettingsForm.vb
@@ -3,6 +3,7 @@
Private Sub SettingsForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
VersionLabel.Text = Join({My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build}, ".")
DirText.Text = My.Settings.SteamAppsFolder
+ UserDataDir.Text = My.Settings.UserdataPath
UpdateCheckBox.Checked = My.Settings.UpdateCheck
HintCheckBox.Checked = My.Settings.NoHint
LogCheckBox.Checked = My.Settings.LogError
@@ -49,4 +50,15 @@
ChangeRelayButton.Text = String.Format("Relay key: ""{0}"" (change)", My.Settings.RelayKey)
End If
End Sub
+
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
+ Dim ChangeDirDialog As New FolderBrowserDialog
+ ChangeDirDialog.Description = "Select your userdata folder:"
+ ChangeDirDialog.ShowNewFolderButton = False
+
+ If ChangeDirDialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then
+ My.Settings.UserdataPath = ChangeDirDialog.SelectedPath & "\"
+ UserDataDir.Text = My.Settings.UserdataPath
+ End If
+ End Sub
End Class
\ No newline at end of file
diff --git a/SLAM/TrimForm.Designer.vb b/SLAM/TrimForm.Designer.vb
new file mode 100644
index 0000000..d9e6086
--- /dev/null
+++ b/SLAM/TrimForm.Designer.vb
@@ -0,0 +1,244 @@
+ _
+Partial Class TrimForm
+ Inherits System.Windows.Forms.Form
+
+ 'Form overrides dispose to clean up the component list.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Required by the Windows Form Designer
+ Private components As System.ComponentModel.IContainer
+
+ 'NOTE: The following procedure is required by the Windows Form Designer
+ 'It can be modified using the Windows Form Designer.
+ 'Do not modify it using the code editor.
+ _
+ Private Sub InitializeComponent()
+ Me.NumericRight = New System.Windows.Forms.NumericUpDown()
+ Me.DoneButton = New System.Windows.Forms.Button()
+ Me.NumericLeft = New System.Windows.Forms.NumericUpDown()
+ Me.ResetButton = New System.Windows.Forms.Button()
+ Me.GroupBox1 = New System.Windows.Forms.GroupBox()
+ Me.Label3 = New System.Windows.Forms.Label()
+ Me.NumericLeftS = New System.Windows.Forms.NumericUpDown()
+ Me.Label1 = New System.Windows.Forms.Label()
+ Me.GroupBox2 = New System.Windows.Forms.GroupBox()
+ Me.Label4 = New System.Windows.Forms.Label()
+ Me.NumericRightS = New System.Windows.Forms.NumericUpDown()
+ Me.Label2 = New System.Windows.Forms.Label()
+ Me.BackgroundPlayer = New System.ComponentModel.BackgroundWorker()
+ Me.PlayButton = New System.Windows.Forms.Button()
+ Me.AdvWaveViewer1 = New SLAM.AdvWaveViewer()
+ CType(Me.NumericRight, System.ComponentModel.ISupportInitialize).BeginInit()
+ CType(Me.NumericLeft, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.GroupBox1.SuspendLayout()
+ CType(Me.NumericLeftS, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.GroupBox2.SuspendLayout()
+ CType(Me.NumericRightS, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.SuspendLayout()
+ '
+ 'NumericRight
+ '
+ Me.NumericRight.Location = New System.Drawing.Point(57, 19)
+ Me.NumericRight.Name = "NumericRight"
+ Me.NumericRight.Size = New System.Drawing.Size(150, 20)
+ Me.NumericRight.TabIndex = 2
+ Me.NumericRight.ThousandsSeparator = True
+ '
+ 'DoneButton
+ '
+ Me.DoneButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.DoneButton.Location = New System.Drawing.Point(557, 203)
+ Me.DoneButton.Name = "DoneButton"
+ Me.DoneButton.Size = New System.Drawing.Size(215, 23)
+ Me.DoneButton.TabIndex = 5
+ Me.DoneButton.Text = "Done"
+ Me.DoneButton.UseVisualStyleBackColor = True
+ '
+ 'NumericLeft
+ '
+ Me.NumericLeft.Location = New System.Drawing.Point(57, 19)
+ Me.NumericLeft.Name = "NumericLeft"
+ Me.NumericLeft.Size = New System.Drawing.Size(150, 20)
+ Me.NumericLeft.TabIndex = 6
+ Me.NumericLeft.ThousandsSeparator = True
+ '
+ 'ResetButton
+ '
+ Me.ResetButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.ResetButton.Location = New System.Drawing.Point(557, 174)
+ Me.ResetButton.Name = "ResetButton"
+ Me.ResetButton.Size = New System.Drawing.Size(100, 23)
+ Me.ResetButton.TabIndex = 7
+ Me.ResetButton.Text = "Reset"
+ Me.ResetButton.UseVisualStyleBackColor = True
+ '
+ 'GroupBox1
+ '
+ Me.GroupBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.GroupBox1.Controls.Add(Me.Label3)
+ Me.GroupBox1.Controls.Add(Me.NumericLeftS)
+ Me.GroupBox1.Controls.Add(Me.Label1)
+ Me.GroupBox1.Controls.Add(Me.NumericLeft)
+ Me.GroupBox1.Location = New System.Drawing.Point(557, 12)
+ Me.GroupBox1.Name = "GroupBox1"
+ Me.GroupBox1.Size = New System.Drawing.Size(215, 75)
+ Me.GroupBox1.TabIndex = 8
+ Me.GroupBox1.TabStop = False
+ Me.GroupBox1.Text = "Start"
+ '
+ 'Label3
+ '
+ Me.Label3.AutoSize = True
+ Me.Label3.Location = New System.Drawing.Point(6, 47)
+ Me.Label3.Name = "Label3"
+ Me.Label3.Size = New System.Drawing.Size(47, 13)
+ Me.Label3.TabIndex = 9
+ Me.Label3.Text = "Second:"
+ '
+ 'NumericLeftS
+ '
+ Me.NumericLeftS.DecimalPlaces = 3
+ Me.NumericLeftS.Location = New System.Drawing.Point(57, 45)
+ Me.NumericLeftS.Name = "NumericLeftS"
+ Me.NumericLeftS.Size = New System.Drawing.Size(150, 20)
+ Me.NumericLeftS.TabIndex = 8
+ Me.NumericLeftS.ThousandsSeparator = True
+ '
+ 'Label1
+ '
+ Me.Label1.AutoSize = True
+ Me.Label1.Location = New System.Drawing.Point(6, 21)
+ Me.Label1.Name = "Label1"
+ Me.Label1.Size = New System.Drawing.Size(45, 13)
+ Me.Label1.TabIndex = 7
+ Me.Label1.Text = "Sample:"
+ '
+ 'GroupBox2
+ '
+ Me.GroupBox2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.GroupBox2.Controls.Add(Me.Label4)
+ Me.GroupBox2.Controls.Add(Me.NumericRightS)
+ Me.GroupBox2.Controls.Add(Me.Label2)
+ Me.GroupBox2.Controls.Add(Me.NumericRight)
+ Me.GroupBox2.Location = New System.Drawing.Point(557, 93)
+ Me.GroupBox2.Name = "GroupBox2"
+ Me.GroupBox2.Size = New System.Drawing.Size(215, 75)
+ Me.GroupBox2.TabIndex = 9
+ Me.GroupBox2.TabStop = False
+ Me.GroupBox2.Text = "End"
+ '
+ 'Label4
+ '
+ Me.Label4.AutoSize = True
+ Me.Label4.Location = New System.Drawing.Point(6, 47)
+ Me.Label4.Name = "Label4"
+ Me.Label4.Size = New System.Drawing.Size(47, 13)
+ Me.Label4.TabIndex = 10
+ Me.Label4.Text = "Second:"
+ '
+ 'NumericRightS
+ '
+ Me.NumericRightS.DecimalPlaces = 3
+ Me.NumericRightS.Location = New System.Drawing.Point(57, 45)
+ Me.NumericRightS.Name = "NumericRightS"
+ Me.NumericRightS.Size = New System.Drawing.Size(150, 20)
+ Me.NumericRightS.TabIndex = 9
+ Me.NumericRightS.ThousandsSeparator = True
+ '
+ 'Label2
+ '
+ Me.Label2.AutoSize = True
+ Me.Label2.Location = New System.Drawing.Point(6, 21)
+ Me.Label2.Name = "Label2"
+ Me.Label2.Size = New System.Drawing.Size(45, 13)
+ Me.Label2.TabIndex = 8
+ Me.Label2.Text = "Sample:"
+ '
+ 'BackgroundPlayer
+ '
+ Me.BackgroundPlayer.WorkerReportsProgress = True
+ Me.BackgroundPlayer.WorkerSupportsCancellation = True
+ '
+ 'PlayButton
+ '
+ Me.PlayButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.PlayButton.Location = New System.Drawing.Point(672, 174)
+ Me.PlayButton.Name = "PlayButton"
+ Me.PlayButton.Size = New System.Drawing.Size(100, 23)
+ Me.PlayButton.TabIndex = 10
+ Me.PlayButton.Text = "Play"
+ Me.PlayButton.UseVisualStyleBackColor = True
+ '
+ 'AdvWaveViewer1
+ '
+ Me.AdvWaveViewer1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
+ Or System.Windows.Forms.AnchorStyles.Left) _
+ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.AdvWaveViewer1.BackColor = System.Drawing.Color.White
+ Me.AdvWaveViewer1.leftpos = 0
+ Me.AdvWaveViewer1.leftSample = 0
+ Me.AdvWaveViewer1.Location = New System.Drawing.Point(0, 0)
+ Me.AdvWaveViewer1.Name = "AdvWaveViewer1"
+ 'Me.AdvWaveViewer1.Position = CType(0, Long)
+ Me.AdvWaveViewer1.rightpos = 0
+ Me.AdvWaveViewer1.rightSample = 0
+ Me.AdvWaveViewer1.SamplesPerPixel = 128
+ Me.AdvWaveViewer1.Size = New System.Drawing.Size(551, 231)
+ Me.AdvWaveViewer1.StartPosition = CType(0, Long)
+ Me.AdvWaveViewer1.TabIndex = 0
+ Me.AdvWaveViewer1.WaveStream = Nothing
+ '
+ 'TrimForm
+ '
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.ClientSize = New System.Drawing.Size(784, 231)
+ Me.Controls.Add(Me.PlayButton)
+ Me.Controls.Add(Me.ResetButton)
+ Me.Controls.Add(Me.DoneButton)
+ Me.Controls.Add(Me.AdvWaveViewer1)
+ Me.Controls.Add(Me.GroupBox1)
+ Me.Controls.Add(Me.GroupBox2)
+ Me.MinimizeBox = False
+ Me.MinimumSize = New System.Drawing.Size(16, 270)
+ Me.Name = "TrimForm"
+ Me.ShowIcon = False
+ Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
+ Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
+ Me.Text = "Trim"
+ CType(Me.NumericRight, System.ComponentModel.ISupportInitialize).EndInit()
+ CType(Me.NumericLeft, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.GroupBox1.ResumeLayout(False)
+ Me.GroupBox1.PerformLayout()
+ CType(Me.NumericLeftS, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.GroupBox2.ResumeLayout(False)
+ Me.GroupBox2.PerformLayout()
+ CType(Me.NumericRightS, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.ResumeLayout(False)
+
+ End Sub
+ Friend WithEvents AdvWaveViewer1 As SLAM.AdvWaveViewer
+ Friend WithEvents NumericRight As System.Windows.Forms.NumericUpDown
+ Friend WithEvents DoneButton As System.Windows.Forms.Button
+ Friend WithEvents NumericLeft As System.Windows.Forms.NumericUpDown
+ Friend WithEvents ResetButton As System.Windows.Forms.Button
+ Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
+ Friend WithEvents Label3 As System.Windows.Forms.Label
+ Friend WithEvents NumericLeftS As System.Windows.Forms.NumericUpDown
+ Friend WithEvents Label1 As System.Windows.Forms.Label
+ Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
+ Friend WithEvents Label2 As System.Windows.Forms.Label
+ Friend WithEvents Label4 As System.Windows.Forms.Label
+ Friend WithEvents NumericRightS As System.Windows.Forms.NumericUpDown
+ Friend WithEvents BackgroundPlayer As System.ComponentModel.BackgroundWorker
+ Friend WithEvents PlayButton As System.Windows.Forms.Button
+End Class
diff --git a/SLAM/TrimForm.resx b/SLAM/TrimForm.resx
new file mode 100644
index 0000000..ec6cae3
--- /dev/null
+++ b/SLAM/TrimForm.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/SLAM/TrimForm.vb b/SLAM/TrimForm.vb
new file mode 100644
index 0000000..10fc31e
--- /dev/null
+++ b/SLAM/TrimForm.vb
@@ -0,0 +1,158 @@
+Imports NAudio
+Imports NAudio.Wave
+Imports System.Threading
+Imports System.IO
+
+Public Class TrimForm
+ Public WavFile As String
+ Public startpos As Integer
+ Public endpos As Integer
+
+ Private Sub TrimForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
+ If Not String.IsNullOrEmpty(WavFile) Then
+ Using reader As New Wave.WaveFileReader(WavFile)
+ AdvWaveViewer1.WaveStream = New Wave.WaveFileReader(WavFile)
+ 'reader.WaveFormat.SampleRate
+ End Using
+
+ NumericRightS.Maximum = Decimal.MaxValue
+ NumericRight.Maximum = AdvWaveViewer1.MaxSamples
+ NumericRight.Increment = AdvWaveViewer1.SamplesPerPixel
+
+ NumericLeftS.Maximum = Decimal.MaxValue
+ NumericLeft.Maximum = Decimal.MaxValue
+ NumericLeft.Increment = AdvWaveViewer1.SamplesPerPixel
+
+ If startpos = endpos And endpos = 0 Then
+ NumericRight.Value = AdvWaveViewer1.MaxSamples
+ Else
+ AdvWaveViewer1.rightpos = endpos
+ AdvWaveViewer1.leftpos = startpos
+ NumericRight.Value = AdvWaveViewer1.rightSample
+ NumericLeft.Value = AdvWaveViewer1.leftSample
+ End If
+
+ End If
+ End Sub
+
+ Private Sub TrimForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
+ If BackgroundPlayer.IsBusy Then
+ BackgroundPlayer.CancelAsync()
+ End If
+ End Sub
+
+ Private Sub AdvWaveViewer1_MouseUp(sender As Object, e As MouseEventArgs) Handles AdvWaveViewer1.MouseUp
+ NumericRight.Value = AdvWaveViewer1.rightSample
+ NumericLeft.Value = AdvWaveViewer1.leftSample
+ End Sub
+
+ Private Sub NumericLeft_ValueChanged(sender As Object, e As EventArgs) Handles NumericLeft.ValueChanged
+ If NumericLeft.Value >= AdvWaveViewer1.rightSample Then
+ NumericLeft.Value = NumericRight.Value - 1
+ End If
+ AdvWaveViewer1.leftSample = NumericLeft.Value
+ NumericLeftS.Value = NumericLeft.Value / AdvWaveViewer1.SampleRate
+ End Sub
+
+ Private Sub NumericRight_ValueChanged(sender As Object, e As EventArgs) Handles NumericRight.ValueChanged
+ If NumericRight.Value <= AdvWaveViewer1.leftSample Then
+ NumericRight.Value = NumericLeft.Value + 1
+ End If
+ AdvWaveViewer1.rightSample = NumericRight.Value
+ NumericRightS.Value = NumericRight.Value / AdvWaveViewer1.SampleRate
+ End Sub
+
+ Private Sub DoneButton_Click(sender As Object, e As EventArgs) Handles DoneButton.Click
+ startpos = AdvWaveViewer1.leftpos
+
+ If AdvWaveViewer1.rightSample = AdvWaveViewer1.MaxSamples And AdvWaveViewer1.leftpos = 0 Then
+ endpos = 0
+ Else
+ endpos = AdvWaveViewer1.rightpos
+ End If
+
+
+ DialogResult = Windows.Forms.DialogResult.OK
+ End Sub
+
+ Private Sub TrimForm_Resize(sender As Object, e As EventArgs) Handles Me.Resize
+ NumericLeft.Increment = AdvWaveViewer1.SamplesPerPixel
+ NumericRight.Increment = AdvWaveViewer1.SamplesPerPixel
+ End Sub
+
+ Private Sub ResetButton_Click(sender As Object, e As EventArgs) Handles ResetButton.Click
+ NumericLeft.Value = 0
+ NumericRight.Value = AdvWaveViewer1.MaxSamples
+ End Sub
+
+ Private Sub NumericLeftS_ValueChanged(sender As Object, e As EventArgs) Handles NumericLeftS.ValueChanged
+ NumericLeft.Value = NumericLeftS.Value * AdvWaveViewer1.SampleRate
+ End Sub
+
+ Private Sub NumericRightS_ValueChanged(sender As Object, e As EventArgs) Handles NumericRightS.ValueChanged
+ If (NumericRightS.Value * AdvWaveViewer1.SampleRate) <= NumericRight.Maximum Then
+ NumericRight.Value = NumericRightS.Value * AdvWaveViewer1.SampleRate
+ Else
+ NumericRight.Value = NumericRight.Maximum
+ NumericRightS.Value = NumericRight.Value / AdvWaveViewer1.SampleRate
+ End If
+
+ End Sub
+
+ Private Sub PlayButton_Click(sender As Object, e As EventArgs) Handles PlayButton.Click
+ If BackgroundPlayer.IsBusy = False Then
+ BackgroundPlayer.RunWorkerAsync(New Object(2) {AdvWaveViewer1.WaveStream, AdvWaveViewer1.leftpos, AdvWaveViewer1.rightpos})
+ PlayButton.Text = "Stop"
+ DisableInterface()
+ PlayButton.Enabled = True
+ Else
+ BackgroundPlayer.CancelAsync()
+ PlayButton.Text = "Play"
+ End If
+ End Sub
+
+ Private Sub BackgroundPlayer_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundPlayer.DoWork
+ Dim WaveFloat As WaveStream = e.Argument(0)
+ Dim LeftPos As Integer = e.Argument(1)
+ Dim RightPos As Integer = e.Argument(2)
+
+ Dim bytes((RightPos - LeftPos)) As Byte
+
+ WaveFloat.Position = LeftPos
+ WaveFloat.Read(bytes, 0, (RightPos - LeftPos))
+
+ WaveFloat = New RawSourceWaveStream(New MemoryStream(bytes), WaveFloat.WaveFormat)
+ 'WaveFloat.PadWithZeroes = False
+
+ Using output = New WaveOutEvent()
+ output.Init(WaveFloat)
+ output.Play()
+ While output.PlaybackState = PlaybackState.Playing And Not BackgroundPlayer.CancellationPending
+ Thread.Sleep(45)
+ BackgroundPlayer.ReportProgress(output.GetPosition() / (WaveFloat.WaveFormat.BitsPerSample / 8))
+ End While
+ End Using
+ End Sub
+
+ Private Sub BackgroundPlayer_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundPlayer.ProgressChanged
+ AdvWaveViewer1.marker = e.ProgressPercentage
+ End Sub
+
+ Private Sub BackgroundPlayer_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundPlayer.RunWorkerCompleted
+ PlayButton.Text = "Play"
+ AdvWaveViewer1.marker = 0
+ EnableInterface()
+ End Sub
+
+ Private Sub EnableInterface()
+ For Each Control In Me.Controls
+ Control.Enabled = True
+ Next
+ End Sub
+
+ Private Sub DisableInterface()
+ For Each Control In Me.Controls
+ Control.Enabled = False
+ Next
+ End Sub
+End Class
\ No newline at end of file