Skip to content

Commit

Permalink
Upgrade to dotnet9
Browse files Browse the repository at this point in the history
  • Loading branch information
ReBiliBin committed Nov 16, 2024
1 parent 92f592f commit 68beae3
Show file tree
Hide file tree
Showing 38 changed files with 16,270 additions and 16,259 deletions.
15 changes: 15 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="CSCore" Version="1.2.1.2" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0-preview.3.24172.9" />
<PackageVersion Include="NVorbis" Version="0.10.5" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="9.0.0-preview.3.24172.9" />
<PackageVersion Include="System.Text.Json" Version="9.0.0-preview.3.24172.9" />
</ItemGroup>
</Project>
62 changes: 31 additions & 31 deletions iBMSC/ApplicationEvents.vb
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
Namespace My

Partial Friend Class MyApplication

Private Sub MyApplication_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown

End Sub

Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup

End Sub

Private Sub MyApplication_UnhandledException(sender As Object, e As ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
Dim xRes As MsgBoxResult = MsgBox("An unhandled exception has occurred in the application: " & vbCrLf &
e.Exception.Message & vbCrLf &
vbCrLf &
"Click Yes to save a back-up, click No otherwise, or click Cancel to ignore this exception and continue.",
MsgBoxStyle.YesNoCancel + MsgBoxStyle.Critical,
"Unhandled Exception")
If xRes = MsgBoxResult.Cancel Then e.ExitApplication = False
If xRes = MsgBoxResult.Yes Then
Dim xFN As String
Dim xDate As Date = Date.Now
With xDate
xFN = "\AutoSave_" & .Year & "_" & .Month & "_" & .Day & "_" & .Hour & "_" & .Minute & "_" & .Second & "_" & .Millisecond & ".IBMSC"
End With

'My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & xFN, Form1.ExceptionSave, False)
MainWindow.ExceptionSave(Application.Info.DirectoryPath & xFN)
Dim unused = MsgBox("A back-up has been saved to " & Application.Info.DirectoryPath & xFN, MsgBoxStyle.Information)
End If
End Sub
End Class
Partial Friend Class MyApplication

Private Sub MyApplication_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown

End Sub

Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup

End Sub

Private Sub MyApplication_UnhandledException(sender As Object, e As ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
Dim xRes As MsgBoxResult = MsgBox("An unhandled exception has occurred in the application: " & vbCrLf &
e.Exception.Message & vbCrLf &
vbCrLf &
"Click Yes to save a back-up, click No otherwise, or click Cancel to ignore this exception and continue.",
MsgBoxStyle.YesNoCancel + MsgBoxStyle.Critical,
"Unhandled Exception")
If xRes = MsgBoxResult.Cancel Then e.ExitApplication = False
If xRes = MsgBoxResult.Yes Then
Dim xFN As String
Dim xDate As Date = Date.Now
With xDate
xFN = "\AutoSave_" & .Year & "_" & .Month & "_" & .Day & "_" & .Hour & "_" & .Minute & "_" & .Second & "_" & .Millisecond & ".IBMSC"
End With

'My.Computer.FileSystem.WriteAllText(My.Application.Info.DirectoryPath & xFN, Form1.ExceptionSave, False)
MainWindow.ExceptionSave(Application.Info.DirectoryPath & xFN)
Dim unused = MsgBox("A back-up has been saved to " & Application.Info.DirectoryPath & xFN, MsgBoxStyle.Information)
End If
End Sub
End Class

End Namespace

250 changes: 125 additions & 125 deletions iBMSC/Audio.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,133 +4,133 @@ Imports CSCore.SoundOut
Imports NVorbis

Friend Module Audio
Private Output As WasapiOut
Private Source As IWaveSource

Public Sub Initialize()
Output = New WasapiOut()
CodecFactory.Instance.Register("ogg", New CodecFactoryEntry(Function(s)
Return New NVorbisSource(s).ToWaveSource()
End Function, ".ogg"))
End Sub

Public Sub Finalize()
Output.Stop()
Output.Dispose()
Output = Nothing
End Sub

Public Function CheckFilename(filename As String) As String
If File.Exists(filename) Then
Return filename
End If
Dim ext = Path.GetExtension(filename)
If String.Compare(ext, ".wav") = 0 OrElse String.Compare(ext, ".ogg") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".flac")
If File.Exists(wpath) Then
Return wpath
End If
End If
If String.Compare(ext, ".ogg") = 0 OrElse String.Compare(ext, ".flac") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".wav")
If File.Exists(wpath) Then
Return wpath
End If
End If
If String.Compare(ext, ".wav") = 0 OrElse String.Compare(ext, ".flac") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".ogg")
If File.Exists(wpath) Then
Return wpath
End If
End If
Return filename
End Function

Public Sub Play(filename As String)

If Source IsNot Nothing Then
Output.Stop()
Source.Dispose()
Source = Nothing
End If

If filename Is String.Empty Then
Return
End If

Dim fn = CheckFilename(filename)

If Not File.Exists(fn) Then
Return
End If

Source = CodecFactory.Instance.GetCodec(fn)
Output.Initialize(Source)
Output.Play()
End Sub

Public Sub StopPlaying()
Output.Stop()
End Sub
Private Output As WasapiOut
Private Source As IWaveSource

Public Sub Initialize()
Output = New WasapiOut()
CodecFactory.Instance.Register("ogg", New CodecFactoryEntry(Function(s)
Return New NVorbisSource(s).ToWaveSource()
End Function, ".ogg"))
End Sub

Public Sub Finalize()
Output.Stop()
Output.Dispose()
Output = Nothing
End Sub

Public Function CheckFilename(filename As String) As String
If File.Exists(filename) Then
Return filename
End If
Dim ext = Path.GetExtension(filename)
If String.Compare(ext, ".wav") = 0 OrElse String.Compare(ext, ".ogg") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".flac")
If File.Exists(wpath) Then
Return wpath
End If
End If
If String.Compare(ext, ".ogg") = 0 OrElse String.Compare(ext, ".flac") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".wav")
If File.Exists(wpath) Then
Return wpath
End If
End If
If String.Compare(ext, ".wav") = 0 OrElse String.Compare(ext, ".flac") = 0 Then
Dim wpath = Path.ChangeExtension(filename, ".ogg")
If File.Exists(wpath) Then
Return wpath
End If
End If
Return filename
End Function

Public Sub Play(filename As String)

If Source IsNot Nothing Then
Output.Stop()
Source.Dispose()
Source = Nothing
End If

If filename Is String.Empty Then
Return
End If

Dim fn = CheckFilename(filename)

If Not File.Exists(fn) Then
Return
End If

Source = CodecFactory.Instance.GetCodec(fn)
Output.Initialize(Source)
Output.Play()
End Sub

Public Sub StopPlaying()
Output.Stop()
End Sub
End Module

Friend Class NVorbisSource
Implements ISampleSource

Private ReadOnly _stream As Stream
Private ReadOnly _vorbisReader As VorbisReader
Private _disposed As Boolean

Public Sub New(stream As Stream)
If stream Is Nothing Or Not stream.CanRead Then
Throw New ArgumentException(Nothing, NameOf(stream))
End If
_stream = stream
_vorbisReader = New VorbisReader(stream, Nothing)
WaveFormat = New WaveFormat(_vorbisReader.SampleRate, 32, _vorbisReader.Channels, AudioEncoding.IeeeFloat)
End Sub

Public ReadOnly Property CanSeek As Boolean Implements IAudioSource.CanSeek
Get
Return _stream.CanSeek
End Get
End Property

Public ReadOnly Property WaveFormat As WaveFormat Implements IAudioSource.WaveFormat

Public ReadOnly Property Length As Long Implements IAudioSource.Length
Get
Return IIf(CanSeek, _vorbisReader.TotalTime.TotalSeconds * WaveFormat.SampleRate * WaveFormat.Channels, 0)
End Get
End Property

Public Property Position As Long Implements IAudioSource.Position
Get
Return IIf(CanSeek, _vorbisReader.TimePosition.TotalSeconds * _vorbisReader.SampleRate * _vorbisReader.Channels, 0)
End Get
Set(value As Long)
If Not CanSeek Then
Throw New InvalidOperationException("Can't seek this stream.")
End If
If value < 0 Or value >= Length Then
Throw New ArgumentOutOfRangeException(NameOf(value))
End If
_vorbisReader.TimePosition = TimeSpan.FromSeconds(value / _vorbisReader.SampleRate / _vorbisReader.Channels)
End Set
End Property


Public Function Read(buffer As Single(), offset As Integer, count As Integer) As Integer Implements ISampleSource.Read
Return _vorbisReader.ReadSamples(buffer, offset, count)
End Function

Public Sub Dispose() Implements IDisposable.Dispose
If Not _disposed Then
'_vorbisReader.Dispose()
Else
'Throw New ObjectDisposedException("NVorbisSource")
End If
_disposed = True
End Sub
Implements ISampleSource

Private ReadOnly _stream As Stream
Private ReadOnly _vorbisReader As VorbisReader
Private _disposed As Boolean

Public Sub New(stream As Stream)
If stream Is Nothing Or Not stream.CanRead Then
Throw New ArgumentException(Nothing, NameOf(stream))
End If
_stream = stream
_vorbisReader = New VorbisReader(stream, Nothing)
WaveFormat = New WaveFormat(_vorbisReader.SampleRate, 32, _vorbisReader.Channels, AudioEncoding.IeeeFloat)
End Sub

Public ReadOnly Property CanSeek As Boolean Implements IAudioSource.CanSeek
Get
Return _stream.CanSeek
End Get
End Property

Public ReadOnly Property WaveFormat As WaveFormat Implements IAudioSource.WaveFormat

Public ReadOnly Property Length As Long Implements IAudioSource.Length
Get
Return IIf(CanSeek, _vorbisReader.TotalTime.TotalSeconds * WaveFormat.SampleRate * WaveFormat.Channels, 0)
End Get
End Property

Public Property Position As Long Implements IAudioSource.Position
Get
Return IIf(CanSeek, _vorbisReader.TimePosition.TotalSeconds * _vorbisReader.SampleRate * _vorbisReader.Channels, 0)
End Get
Set(value As Long)
If Not CanSeek Then
Throw New InvalidOperationException("Can't seek this stream.")
End If
If value < 0 Or value >= Length Then
Throw New ArgumentOutOfRangeException(NameOf(value))
End If
_vorbisReader.TimePosition = TimeSpan.FromSeconds(value / _vorbisReader.SampleRate / _vorbisReader.Channels)
End Set
End Property


Public Function Read(buffer As Single(), offset As Integer, count As Integer) As Integer Implements ISampleSource.Read
Return _vorbisReader.ReadSamples(buffer, offset, count)
End Function

Public Sub Dispose() Implements IDisposable.Dispose
If Not _disposed Then
'_vorbisReader.Dispose()
Else
'Throw New ObjectDisposedException("NVorbisSource")
End If
_disposed = True
End Sub

End Class
40 changes: 20 additions & 20 deletions iBMSC/BMS.vb
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
Imports iBMSC.Editor

Friend Module BMS
Public Function IsChannelLongNote(I As String) As Boolean
Dim LongStart = C36to10("50")
Dim LongEnd = C36to10("8Z")
Public Function IsChannelLongNote(I As String) As Boolean
Dim LongStart = C36to10("50")
Dim LongEnd = C36to10("8Z")

Dim xI As Integer = C36to10(I)
Dim xI As Integer = C36to10(I)

Return xI > LongStart And xI < LongEnd
End Function
Return xI > LongStart And xI < LongEnd
End Function

Public Function IsChannelHidden(I As String) As Boolean
Dim HiddenStart = C36to10("30")
Dim HiddenEnd = C36to10("4Z")
Dim OptionStart = C36to10("70")
Dim OptionEnd = C36to10("8Z")
Public Function IsChannelHidden(I As String) As Boolean
Dim HiddenStart = C36to10("30")
Dim HiddenEnd = C36to10("4Z")
Dim OptionStart = C36to10("70")
Dim OptionEnd = C36to10("8Z")

Dim xI As Integer = C36to10(I)
Dim xI As Integer = C36to10(I)

Return (xI > HiddenStart And xI < HiddenEnd) Or (xI > OptionStart And xI < OptionEnd)
End Function
Return (xI > HiddenStart And xI < HiddenEnd) Or (xI > OptionStart And xI < OptionEnd)
End Function

Public Function IsChannelLandmine(I As String) As Boolean
Dim LandmineStart = C36to10("D0")
Dim LandmineEnd = C36to10("EZ")
Public Function IsChannelLandmine(I As String) As Boolean
Dim LandmineStart = C36to10("D0")
Dim LandmineEnd = C36to10("EZ")

Dim xI As Integer = C36to10(I)
Dim xI As Integer = C36to10(I)

Return xI > LandmineStart And xI < LandmineEnd
End Function
Return xI > LandmineStart And xI < LandmineEnd
End Function
End Module
Loading

0 comments on commit 68beae3

Please sign in to comment.