Author Topic: Direct bass : Vb.net (vb2008, vb2010, vb6, vc#, vc++, devC++, delphi, AutoIt)  (Read 182715 times)

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #75 on: 17 Dec '12 - 10:22 »
The following error or errors occurred while posting this message:
The message exceeds the maximum allowed length (12000 characters).

VuMeter Class: Download
http://www.tempfiles.net/download/201212/276692/VU_MeterLibrary.html


 
« Last Edit: 17 Dec '12 - 10:41 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #76 on: 17 Dec '12 - 14:38 »
Tip: Fix error! current progress value Level meter

Used song level/33525 For balance signal level meter and *100

Setting properties:
min progress value = 0
max progress value = 100
Timer interval default = 40
peak is filter by highWord and lowWord of BASS_ChannelGetLevel()

Code: [Select]
Private Function LevelCurrentProgress(ByVal peak As Double)
        Dim v_peak As Double
        Dim limitValue As Integer = 100
        Try
            v_peak = ((peak / 33525) * 100)
        Catch ex As Exception
            peak = limitValue
        End Try
        Return v_peak
    End Function

Example:
Code: [Select]
ProgressBar1.Value = CInt(LevelCurrentProgress(peakL))
ProgressBar2.Value = CInt(LevelCurrentProgress(peakR))
« Last Edit: 17 Dec '12 - 14:55 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #77 on: 19 Dec '12 - 10:27 »
Get code Status Function (ฺBassUn4Seen)

Code: [Select]
Public Shared Function Status(ByVal handle As Integer) As String
        Dim Stt As String = Nothing
        Select Case Un4seen.Bass.Bass.BASS_ChannelIsActive(handle)
            Case Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING
                Stt = "Playing.."
            Case Un4seen.Bass.BASSActive.BASS_ACTIVE_PAUSED
                Stt = "Paused"
            Case Un4seen.Bass.BASSActive.BASS_ACTIVE_STOPPED
                Stt = "Stopped"
            Case Else
                Stt = "Stalled"
        End Select
        Return Stt
    End Function

Example:
Code: [Select]
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
   Label1.Text = String.Concat("ActiveState: ", Status(strm))
End Sub
« Last Edit: 19 Dec '12 - 10:34 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #78 on: 19 Dec '12 - 10:51 »
Get code: mciSendString Sound handle Functions (same as bass handle) ;D

Download: MciSound Sample Project Click here

MciSoundClass:
Code: [Select]
Public Class MciSoundClass
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Integer, ByVal lpstrBuffer As String, ByVal uLength As Integer) As Integer
    Private Shared returnData As String = Space(128)
    Private Shared rlBuff As Integer = 128
    Public Shared Function CloseFile() As Integer  'SameAs StreamFree.
        Return mciSendString("close song", 0, 0, 0)
    End Function
    Public Shared Function LoadFile(ByVal fileName As String) As Integer  'SameAs StreamCreateFile.
        Return mciSendString("open " & Chr(34) & fileName & Chr(34) & " type mpegvideo alias song", 0, 0, 0)
    End Function
    Public Shared Function PlayFile() As Integer  'SameAs ChannelPlay.
        Return mciSendString("play song", 0, 0, 0)
    End Function
    Public Shared Function PauseFile() As Integer  'SameAs ChannelPause.
        Return mciSendString("pause song", 0, 0, 0)
    End Function
    Public Shared Function ResumeFile() As Integer  'SameAs ChannelResume.
        Return mciSendString("resume song", 0, 0, 0)
    End Function
    Public Shared Function StopFile() As Integer  'SameAs ChannelStop.
        If MciPlayState = "Playing" Then
            Return mciSendString("stop song", 0, 0, 0)
        End If
    End Function
    Public Shared Function MciGetTickStyleFrequencyPosition()  'Set Scale trackBar.
        Return (MciGetLength() / 100) * 10
    End Function
    Public Shared Function MciScrollPosition(ByVal inttrackPos As TrackBar) As Integer
        If MciPlayState = "Playing" Then
            mciSendString("play song from " & inttrackPos.Value, 0, 0, 0)
        Else
            mciSendString("seek song to " & inttrackPos.Value, 0, 0, 0)
        End If
    End Function
    Public Shared Function MciPercentPosition()
        Dim pos As Integer = MciGetPosition()
        Dim len As Integer = MciGetLength()
        Return Math.Round((pos / len) * 100)
    End Function
    Public Shared Function MciByteToSecound(ByVal posByte As Integer) As Integer   'SameAs ChannelByteToSecound.
        Return Math.Round((posByte / 66000) * 60)
    End Function
    Public Shared Function MciTimePositionString() As String  'SameAs FixTimeSpan.
        Dim tSpan As TimeSpan
        tSpan = TimeSpan.FromSeconds(MciByteToSecound(MciGetPosition))
        Return tSpan.ToString
    End Function
    Public Shared Function MciTimeDurationString() As String  'SameAs FixTimeSpan.
        Dim tSpan As TimeSpan
        tSpan = TimeSpan.FromSeconds(MciByteToSecound(MciGetLength))
        Return tSpan.ToString
    End Function
    Public Shared Function MciVolume(ByVal nVol As TrackBar) As Integer  'SameAs BassVolume.
        Dim vol As Integer = (nVol.Value * 10)
        mciSendString("setaudio song volume to " & vol, 0, 0, 0)
    End Function
    Public Shared Property MciGetLength()  'SameAs ChannelGetLength.
        Get
            mciSendString("status song length", returnData, 128, 0)
            Return Val(returnData)
        End Get
        Set(ByVal value)
            Dim retData As Integer = Val(returnData)
            retData = value
        End Set
    End Property
    Public Shared Property MciGetPosition()  'SameAs ChannelGetPosition.
        Get
            mciSendString("status song position", returnData, 128, 0)
            Return Val(returnData)
        End Get
        Set(ByVal value)
            Dim retData As Integer = Val(returnData)
            retData = value
        End Set
    End Property
    Public Shared ReadOnly Property MciPlayState() As String  'SameAs ChannelIsActive.
        Get
            Dim ActiveState As String
            mciSendString("status song mode", returnData, rlBuff, 0)
            Select Case returnData.Substring(0, 7)
                Case "playing"
                    ActiveState = "Playing"
                Case Else
                    ActiveState = "Stopped"
            End Select
            Return ActiveState
        End Get
    End Property
End Class

Example:
Code: [Select]
Imports MciSoundSample.MciSoundClass
Public Class Form1
    Private start As Boolean  'Checked State PauseButton.
    Public Sub New()
        Me.CenterToScreen()
        InitializeComponent()
        Me.Text = "mciSendString Functions Sample"
        start = False
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Song file (*.mid, *.mp3, *.wav, *wma)|*.mid;*.mp3;*.wav;*.wma"
        btnPause.Text = "Pause"
        trackVol.TickFrequency = 10
        trackVol.Maximum = 100
        trackVol.Value = 100
    End Sub
    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Stop()
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            LoadFile(OpenFileDialog1.FileName)
            LblFilename.Text = My.Computer.FileSystem.GetName(OpenFileDialog1.FileName)
        End If
    End Sub
    Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
        If OpenFileDialog1.FileName = Nothing Then Return
        CloseFile()
        LoadFile(OpenFileDialog1.FileName)
        Lblduration.Text = MciTimeDurationString()
        trackPos.Maximum = MciGetLength()
        trackPos.TickFrequency = MciGetTickStyleFrequencyPosition()
        PlayFile()
        Timer1.Enabled = True
        start = True
    End Sub
    Private Sub btnPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPause.Click
        If start = False Then Return
        Select Case btnPause.Text
            Case "Pause"
                btnPause.Text = "Resume"
                PauseFile()
            Case Else
                btnPause.Text = "Pause"
                ResumeFile()
        End Select
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        LblTextState.Text = MciPlayState()
        trackPos.Value = MciGetPosition()
        Lblpercentage.Text = String.Concat(MciPercentPosition(), "%")
        Lblposition.Text = MciTimePositionString()
        If MciTimePositionString() = MciTimeDurationString() Then
            trackPos.Value = trackPos.Minimum
            Lblpercentage.Text = String.Concat(trackPos.Minimum, "%")
            Lblposition.Text = "00:00:00"
            start = False
            Timer1.Stop()
        End If
    End Sub
    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Strings.InStr(btnPause.Text, "Resume") Then btnPause.Text = "Pause"
        StopFile()
        start = False
    End Sub
    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        MciScrollPosition(trackPos)
    End Sub
    Private Sub trackVol_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackVol.Scroll
        MciVolume(trackVol)
    End Sub
End Class
« Last Edit: 29 Dec '12 - 04:38 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #79 on: 29 Dec '12 - 05:45 »
Get file MciSound.net.dll. Create by vb.net2008 =http://www.uploadseeds.com/download.php?uid=05MY1F6F

Using: Reference file dll to project solution and Import script functions

Example:
Code: [Select]
Imports MciSound.net.MciSound
« Last Edit: 29 Dec '12 - 06:04 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #80 on: 29 Dec '12 - 16:04 »
Get code: MciFixTimeSpan ;D For selected using in time duration or time position.
Code: [Select]
Public Shared Function MciFixTimeSpan(ByVal posByte As Integer) As String
   Dim tSpan As System.TimeSpan
   tSpan = TimeSpan.FromSeconds(MciByteToSecound(posByte))
   Return tSpan.ToString
End Function

Example:
Code: [Select]
Lblduration.Text = MciFixTimeSpan(MciGetLength)
Code: [Select]
Lblposition.Text = MciFixTimeSpan(MciGetPosition)
« Last Edit: 29 Dec '12 - 16:08 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #81 on: 29 Dec '12 - 16:38 »
Get code: MciSecoundToByte ;D SameAs ChannelSecoundToByte

Code: [Select]
Public Shared Function MciSecoundToByte(ByVal posByte As Integer) As Integer  'SameAsChannelByteToSecound
   Return CInt(System.Math.Round(System.Math.Round(((CDbl(posByte)) * 66000) / 60)))
End Function

SampleTest:
Code: [Select]
Public Class Form1
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    Private fildlg As New System.Windows.Forms.OpenFileDialog
    Private btnPOL As New System.Windows.Forms.Button
    Private lblBtS As New System.Windows.Forms.Label
    Private lblStB As New System.Windows.Forms.Label
    Private Shared returnData As String
    Private Shared buff As Integer
    Public Sub New()
        Me.CenterToScreen()
        InitializeComponent()
        btnPOL.Text = "PlayOnLoad"
        btnPOL.Location = New Point(100, 100)
        lblBtS.Text = "ByteToSecound = "
        lblStB.Text = "SecoundToByte = "
        lblBtS.Location = New Point(50, 150)
        lblStB.Location = New Point(50, 180)
        lblBtS.AutoSize = True
        lblStB.AutoSize = True
        Me.Controls.AddRange(New Control() {btnPOL, lblBtS, lblStB})
        fildlg.FileName = Nothing
        fildlg.Filter = "Song file(*.mp3)|*.mp3"
        returnData = Space(128)
        buff = 128
        AddHandler btnPOL.Click, AddressOf btnPOL_Click
    End Sub
    Private Sub btnPOL_Click(ByVal sender As Object, ByVal e As EventArgs)
        If fildlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            CloseFile()
            LoadFile(fildlg.FileName)
            lblBtS.Text = String.Concat("ByteToSecound = ", MciByteToSecound(MciGetLength), " Secounds")
            lblStB.Text = String.Concat("SecoundToByte = ", MciSecoundToByte(MciGetLength), " Bytes")
            PlayFile()
        End If
    End Sub
    '=========================MciSound Functions=================================================
    Public Shared Function CloseFile() As Integer
        Return mciSendString("close song", 0, 0, 0)
    End Function
    Public Shared Function LoadFile(ByVal fileName As String) As Integer
        Return mciSendString("open " & Chr(34) & fileName & Chr(34) & " type mpegvideo alias song", 0, 0, 0)
    End Function
    Public Shared Function PlayFile() As Integer
        Return mciSendString("play song", 0, 0, 0)
    End Function
    Public Shared Function MciByteToSecound(ByVal posByte As Integer) As Integer
        Return CInt(System.Math.Round(System.Math.Round(((CDbl(posByte)) / 66000) * 60)))
    End Function
    Public Shared Function MciSecoundToByte(ByVal posByte As Integer) As Integer
        Return CInt(System.Math.Round(System.Math.Round(((CDbl(posByte)) * 66000) / 60)))
    End Function
    Public Shared Property MciGetLength()
        Get
            mciSendString("status song length", returnData, buff, 0)
            Return Val(returnData)
        End Get
        Set(ByVal value)
            Dim retData As Integer = Val(returnData)
            retData = value
        End Set
    End Property
End Class
« Last Edit: 29 Dec '12 - 18:39 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #82 on: 29 Dec '12 - 19:18 »
Get code: MciTimeFormat ;D Can selected 3 styles is.. 00 or 00:00 or 00:00:00

Code: [Select]

Public Shared Function MciTimeFormat(ByVal posByte As Integer, ByVal formatStyle As String) As String
   Return Format(MciByteToSecound(posByte), formatStyle)
End Function

Example:
Code: [Select]
lblDuration.Text = MciTimeFormat(MciGetLength, "00:00")
lblPosition.Text = MciTimeFormat(MciGetPosition, "00:00")
« Last Edit: 29 Dec '12 - 19:35 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #83 on: 29 Dec '12 - 19:41 »
Get code: SoundDirListBox ;D Easy for select open songs player.

Add DriveListBox Control Component.
Add DirListBox Control Component.
Add FileListBox Control Component.
Add Windows Media Player Control Component.

Writting code now.

Full code Example:
Code: [Select]
Public Class Form1
    Private AxWindowsMediaPlayer1 As New AxWMPLib.AxWindowsMediaPlayer
    Private Label1 As New System.Windows.Forms.Label
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Label1.Text = "Path:"
        Label1.SetBounds(12, 17, 39, 13)
        Label1.AutoSize = True
        Me.Text = "Files List Media Player"
        Me.Size = New Size(300, 250)
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        Me.CenterToScreen()
        AxWindowsMediaPlayer1.SetBounds(0, 172, 300, 45)
        Me.Controls.AddRange(New Control() {Label1, AxWindowsMediaPlayer1})
    End Sub
    Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
        Try
            Dim Index As Integer = DriveListBox1.SelectedIndex.ToString
            DirListBox1.SetSelected(Index, False)
            DirListBox1.Path = DriveListBox1.Drive.ToString
        Catch ex As Exception
        End Try
    End Sub
    Private Sub DirListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DirListBox1.MouseDoubleClick
        Try
            Dim Index As Integer = DirListBox1.SelectedIndex.ToString
            DirListBox1.SetSelected(Index, True)
        Catch ex As Exception
        End Try
    End Sub
    Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged
        Try
            FileListBox1.Path = DirListBox1.Path
            Label1.Text = String.Concat("Path: ", DirListBox1.Path.ToString)
        Catch ex As Exception
        End Try
    End Sub
    Private Sub FileListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FileListBox1.MouseDoubleClick
        Try
            If Strings.InStr(Make3Path(DirListBox1.Path.ToString, FileListBox1.SelectedItem.ToString, ""), ".mp3") Then
                AxWindowsMediaPlayer1.URL = Make3Path(DirListBox1.Path.ToString, FileListBox1.SelectedItem.ToString, "")
            Else
                Process.Start(Make3Path(DirListBox1.Path.ToString, FileListBox1.SelectedItem.ToString, ""))
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub FileListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileListBox1.SelectedIndexChanged
        Try
            Label1.Text = Make3Path("Path: " & DirListBox1.Path.ToString, FileListBox1.SelectedItem.ToString, "")
        Catch ex As Exception
        End Try
    End Sub
    Public Shared Function Make3Path(ByVal PathName1 As String, ByVal PathName2 As String, ByVal PathName3 As String) As String
        Dim fullPath As String = Nothing
        Try
            If PathName2 = String.Empty Then
                fullPath = PathName1
            ElseIf PathName3 = String.Empty Then
                fullPath = String.Concat(PathName1, "\", PathName2)
            Else
                fullPath = String.Concat(PathName1, "\", PathName2, "\", PathName3)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Return fullPath
    End Function
End Class
« Last Edit: 25 Jan '13 - 14:03 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #84 on: 12 Jan '13 - 02:42 »
GetCode: MciSound Module

Code: [Select]
Module MCImod
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Integer, ByVal lpstrBuffer As String, ByVal uLength As Integer) As Integer
    Private rlBuff As Integer = 128
    Private returnData As String = Space(rlBuff)
    Public Function CloseFile() As Integer
        Return mciSendString("close song", 0, 0, 0)
    End Function
    Public Function LoadFile(ByVal fileName As String) As String
        Dim ret As String = fileName
        mciSendString("open " & Chr(34) & fileName & Chr(34) & " type mpegvideo alias song", 0, 0, 0)
        Return ret
    End Function
    Public Function PlayFile() As Integer
        Return mciSendString("play song", 0, 0, 0)
    End Function
    Public Function PauseFile() As Integer
        Return mciSendString("pause song", 0, 0, 0)
    End Function
    Public Function ResumeFile() As Integer
        Return mciSendString("resume song", 0, 0, 0)
    End Function
    Public Function StopFile() As Integer
        If MciPlayState() = "Playing.." Then
            Return mciSendString("stop song", 0, 0, 0)
        End If
    End Function
    Public Function MciGetTickStyleFrequencyPosition()  'Set Scale trackBar.
        Return (MciGetLength() / 100) * 10
    End Function
    Public Function MciScrollPosition(ByVal inttrackPos As TrackBar) As Integer
        If MciPlayState() = "Playing.." Then
            Return mciSendString("play song from " & (inttrackPos.Value), 0, 0, 0)
        Else
            Return mciSendString("seek song to " & (inttrackPos.Value), 0, 0, 0)
        End If
    End Function
    Public Function MciPercentPosition()
        Dim pos As Integer = MciGetPosition()
        Dim len As Integer = MciGetLength()
        Return Math.Round((pos / len) * 100)
    End Function
    Public Function MciTimePositionString() As String
        Dim tSpan As TimeSpan
        Dim ret As String
        tSpan = TimeSpan.FromSeconds(MciByteToSecound(MciGetPosition))
        ret = tSpan.ToString
        Return ret
    End Function
    Public Function MciTimeDurationString() As String
        Dim tSpan As TimeSpan
        Dim ret As String
        tSpan = TimeSpan.FromSeconds(MciByteToSecound(MciGetLength))
        ret = tSpan.ToString
        Return ret
    End Function
    Public Function MciTimeFormat(ByVal intSound As Integer, ByVal strStyle As String) As String
        Return Format(intSound, strStyle)
    End Function
    Public Function MciVolume(ByVal nVol As TrackBar) As Integer
        Dim vol As Double = (nVol.Value * 10)
        Return mciSendString("setaudio song volume to " & (vol), 0, 0, 0)
    End Function
    Public Function MciGetLength() As Integer
        mciSendString("status song length", returnData, 128, 0)
        Return Val(returnData)
    End Function
    Public Function MciGetPosition() As Integer
        mciSendString("status song position", returnData, 128, 0)
        Return Val(returnData)
    End Function
    Public Function MciByteToSecound(ByVal posByte As Integer) As Integer
        Return Math.Round((posByte / 66000) * 60)
    End Function
    Public Function MciSecoundToByte(ByVal posByte As Integer) As Integer
        Return Math.Round((posByte * 66000) / 60)
    End Function
    Public Function MciGetMaxPosition() As Integer
        Return MciGetLength()
    End Function
    Public Function MciPlayState() As String
        Dim ActiveState As String = Nothing
        mciSendString("status song mode", returnData, rlBuff, 0)
        Dim ret As String = returnData.Substring(0, 7)
        Select Case ret
            Case "playing"
                ActiveState = "Playing.."
            Case Else
                ActiveState = "Stopped"
        End Select
        Return ActiveState
    End Function
End Module

Example: MciSound Player

Code: [Select]
Public Class MciSound
    Private fileDlg As New OpenFileDialog
    Private time As New Timer
    Private file As String
    Public Sub New()
        Me.CenterToScreen()
        InitializeComponent()
        TrackBar1.AutoSize = False
        TrackBar2.Maximum = 100
        TrackBar2.Value = TrackBar2.Maximum
        TrackBar2.TickFrequency = (TrackBar2.Value / 10)
        fileDlg.FileName = Nothing
        fileDlg.Filter = "Song File(*.mp3;*.wav)|*.mp3;*.wav"
        AddHandler time.Tick, AddressOf time_Tick
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If fileDlg.ShowDialog = Windows.Forms.DialogResult.Cancel Then Return
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If fileDlg.FileName = Nothing Then Return
        If Strings.InStr(Button3.Text, "Resume") Then Button3.Text = "Pause"
        CloseFile()
        file = fileDlg.FileName
        LoadFile(file)
        Label5.Text = My.Computer.FileSystem.GetName(file)
        TrackBar1.Maximum = MciGetMaxPosition()
        TrackBar1.TickFrequency = MciGetTickStyleFrequencyPosition()
        PlayFile()
        time.Enabled = True
    End Sub
    Public Sub time_Tick(ByVal sender As Object, ByVal e As EventArgs)
        Label1.Text = MciPlayState()
        Label2.Text = String.Concat(MciPercentPosition(), "%")
        Label3.Text = MciTimeDurationString()
        Label4.Text = MciTimePositionString()
        Try
            TrackBar1.Value = MciGetPosition()
        Catch ex As Exception
        End Try
        If MciPercentPosition() >= 100 Then
            Label1.Text = "Song Ended"
            ControlReset()
        Else
            If MciPlayState() = "Stopped" Then
                ControlReset()
            End If
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Strings.InStr(Label1.Text, "Stopped") Or Strings.InStr(Label1.Text, "Song Ended") Then Return
        If file = Nothing Then Return
        Select Case Button3.Text
            Case "Pause"
                PauseFile()
                time.Enabled = False
                Button3.Text = "Resume"
                If Strings.InStr(Button3.Text, "Resume") Then
                    Label1.Text = "Paused"
                End If
            Case Else
                ResumeFile()
                Button3.Text = "Pause"
                time.Enabled = True
        End Select
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If file = Nothing Then Return
        If Strings.InStr(Label1.Text, "Song Ended") Then Return
        StopFile()
        If MciPlayState() = "Playing.." Or Strings.InStr(Label1.Text, "Paused") Then
            If Strings.InStr(Label1.Text, "Paused") Then
                Label1.Text = "Stopped"
                If Strings.InStr(Button3.Text, "Resume") Then Button3.Text = "Paused"
            End If
        Else
            TrackBar1.Value = TrackBar1.Minimum
            Label1.Text = "Stopped"
             ControlReset()
        End If
    End Sub
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        MciScrollPosition(TrackBar1)
    End Sub
    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        MciVolume(TrackBar2)
    End Sub
    Public Sub ControlReset()
        time.Enabled = False
        TrackBar1.Value = TrackBar1.Minimum
        Label2.Text = TrackBar1.Value.ToString
        Label4.Text = MciTimeFormat(0, "00:00:00")
        Return
    End Sub
End Class


« Last Edit: 14 Jan '13 - 07:29 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #85 on: 14 Jul '13 - 10:05 »
Download : BASS SpectrumLib.net.dll Click here ;D

Example:
Code: [Select]
Imports SpectrumLib.Spectrum
Public Class Form1
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_Init(ByVal device As Integer, ByVal freq As Integer, ByVal flags As BASSInit, ByVal win As System.IntPtr, ByVal clsid As System.IntPtr) As Boolean
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", EntryPoint:="BASS_StreamCreateFile", ExactSpelling:=True, CharSet:=System.Runtime.InteropServices.CharSet.[Auto], SetLastError:=False)> _
    Private Shared Function BASS_StreamCreateFileUnicode(ByVal mem As Boolean, ByVal file As String, ByVal offset As Long, ByVal length As Long, ByVal flags As BASSFlag) As Integer
    End Function
    Public Shared Function BASS_StreamCreateFile(ByVal [file] As String, ByVal offset As Long, ByVal length As Long, ByVal flags As BASSFlag) As Integer
        flags = flags Or BASSFlag.BASS_UNICODE
        Return BASS_StreamCreateFileUnicode(False, [file], offset, length, flags)
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_StreamFree(ByVal handle As Integer) As Boolean
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelPlay(ByVal handle As Integer, ByVal restart As Boolean) As Boolean
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelStop(ByVal handle As Integer) As Boolean
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelIsActive(ByVal handle As Integer) As BASSActive
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelGetLength(ByVal handle As Integer, ByVal mode As BASSMode) As Long
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelGetPosition(ByVal handle As Integer, ByVal mode As BASSMode) As Long
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelBytes2Seconds(ByVal handle As Integer, ByVal pos As Long) As Double
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelSeconds2Bytes(ByVal handle As Integer, ByVal pos As Double) As Long
    End Function
    <System.Runtime.InteropServices.DllImport("bass.dll", SetLastError:=False)> _
    Public Shared Function BASS_ChannelSetPosition(ByVal handle As Integer, ByVal pos As Long, ByVal mode As BASSMode) As Boolean
    End Function

    <Flags()> _
  Public Enum BASSInit
        BASS_DEVICE_DEFAULT = 0
        BASS_DEVICE_FREQ = 16384
    End Enum
    <Flags()> _
    Public Enum BASSFlag
        BASS_DEFAULT = 0
        BASS_SAMPLE_FLOAT = 256
        BASS_STREAM_PRESCAN = 131072
        BASS_STREAM_AUTOFREE = 262144
        BASS_STREAM_RESTRATE = 524288
        BASS_STREAM_STATUS = 8388608
        BASS_UNICODE = -2147483648
        BASS_MUSIC_FLOAT = 256
        BASS_MUSIC_LOOP = 4
    End Enum
    <Flags()> _
   Public Enum BASSMode
        BASS_POS_BYTES = 0
    End Enum
    Public Enum BASSActive
#Region "BASSActive Fields"
        BASS_ACTIVE_STOPPED = 0
        BASS_ACTIVE_PLAYING = 1
        BASS_ACTIVE_STALLED = 2
        BASS_ACTIVE_PAUSED = 3
#End Region
    End Enum
    WithEvents Button1 As New System.Windows.Forms.Button
    WithEvents Label1 As New System.Windows.Forms.Label
    WithEvents Timer1 As New System.Windows.Forms.Timer
    WithEvents TrackBar1 As New System.Windows.Forms.TrackBar
    Private PictureBox1 As New System.Windows.Forms.PictureBox
    Private FDlg As New System.Windows.Forms.OpenFileDialog
    Private strm As Integer
    Private file As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle.ToInt32, System.IntPtr.Zero)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.CenterToScreen()
        Button1.Text = "OPEN"
        Button1.Location = New Point(110, 220)
        Button1.Cursor = Cursors.Hand
        Label1.Text = "ActiveStatus"
        Label1.SetBounds(110, 145, 100, 30)
        PictureBox1.SetBounds(35, 10, 220, 120)
        PictureBox1.BackColor = Color.Black
        TrackBar1.SetBounds(50, 165, 200, 50)
        FDlg.FileName = Nothing
        Timer1.Interval = 50
        Me.Controls.AddRange(New Control() {PictureBox1, TrackBar1, Label1, Button1})
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case Button1.Text
            Case "OPEN"
                If FDlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                    If strm <> 0 Then BASS_StreamFree(strm)
                    file = FDlg.FileName
                    strm = BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT)
                    TrackBar1.Maximum = BASS_ChannelBytes2Seconds(strm, BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES))
                    TrackBar1.TickFrequency = TrackBar1.Maximum / 10
                    Button1.Text = "PLAY"
                End If
            Case "PLAY"
                BASS_ChannelPlay(strm, False)
                Button1.Text = "STOP"
                Timer1.Enabled = True
            Case "STOP"
                BASS_ChannelStop(strm)
                Timer1.Enabled = False
                Label1.Text = "Stopped"
                Button1.Text = "OPEN"
                If Strings.InStr(Label1.Text, "Stopped") Then
                    Reset()
                End If
        End Select
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            TrackBar1.Value = BASS_ChannelBytes2Seconds(strm, BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES))
            PictureBox1.Image = CreateSpectrumLinePeak(strm, PictureBox1.Width, PictureBox1.Height, Color.Aqua, Color.DeepSkyBlue, Color.White, Color.Black, 4, 2, 1, 22.5, False, False, True)
        Catch ex As Exception
        End Try

        Select Case BASS_ChannelIsActive(strm)
            Case BASSActive.BASS_ACTIVE_PLAYING
                Label1.Text = "Playing.."
            Case BASSActive.BASS_ACTIVE_STOPPED
                Label1.Text = "Stopped"
        End Select
        Repeat()
    End Sub
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        BASS_ChannelSetPosition(strm, BASS_ChannelSeconds2Bytes(strm, TrackBar1.Value), BASSMode.BASS_POS_BYTES)
    End Sub
    Public Sub Repeat()
        If BASS_ChannelBytes2Seconds(strm, BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES)) >= BASS_ChannelBytes2Seconds(strm, BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES)) Then
            Reset()
            BASS_ChannelPlay(strm, True)
            Timer1.Enabled = True
        End If
    End Sub
    Public Sub Reset()
        Timer1.Enabled = False
        PictureBox1.Image = Nothing
        CreateSpectrumLinePeak(0, 0, 0, Color.Black, Color.Black, Color.Black, Color.Black, 0, 0, 0, 0, 0, False, False)
        TrackBar1.Value = TrackBar1.Minimum
    End Sub
End Class
« Last Edit: 14 Jul '13 - 11:14 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #86 on: 14 Jul '13 - 12:22 »
Download : MciSound.net.dll (new modify) ..Please wait!;D
Discription:
-Add FileBrowse into OpenSong
-Add Repeat song, autoPlay when song ended
-Auto add songs from dataBase to the PlayList
-Add DurationTimeString (00:00)
-Add MaxPosition
-Add ScrollPosition
-Add CurrentPosition
-Other

Example:
« Last Edit: 15 Jul '13 - 09:16 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #87 on: 21 Jul '13 - 21:06 »
I created ZPlayLip.net.dll
You can using for made sound player program project.
It easy for you. Download: source code demo Click here ;D



 Using info: Mouse clicked progress, Set scrolling position.
« Last Edit: 21 Jul '13 - 21:23 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #88 on: 22 Jul '13 - 09:25 »
Download : miniBASSmod.net.dll ..please wait!
It easy for beginer learnning BASS sound player. ;D

edin_

  • Posts: 13
Re: Direct bass : Vb.net
« Reply #89 on: 22 Jul '13 - 18:49 »
Hi sak2005 could you please re-upload your download links all are broken, thanks ;)

EWeiss

  • Posts: 342
Re: Direct bass : Vb.net
« Reply #90 on: 22 Jul '13 - 19:43 »
i will nothing load nevertheless..
that is SPAM for me load or publish any code on //www.4shared.com//

Sample as Code in this thread is good!

greets
« Last Edit: 22 Jul '13 - 19:49 by EWeiss »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #91 on: 24 Jul '13 - 12:01 »
Knowledge BASS EQualizer 10 Bands ;D

1. Array enum Loop for volume EQ
2. Created functions is setEQ and updateEQ
3. Events in the form using ScrollChange and ValueChange for the volume EQ.
=============================================================

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #92 on: 24 Jul '13 - 13:11 »
Array Enum Loop Volume EQ (10 bands) and creatting functions is seteq and updateeq.

Example: EQ class
Code: [Select]
Imports Un4seen.Bass
Public Class EQ
    Inherits Object
    Private Shared paramEQ As Un4seen.Bass.BASS_DX8_PARAMEQ
    Private Shared fxEQ As Integer()
    Private Shared iCount As Integer
    Private Shared strm As Integer
    Shared Sub New()
        fxEQ = New Integer(10 - 1) {}
    End Sub
    Public Shared Sub setEQ_10(ByVal handle As Integer)
        Dim paramEQ As New Un4seen.Bass.BASS_DX8_PARAMEQ
        Try
            iCount = 0
            Do While (iCount < 10)
                fxEQ(iCount) = Bass.BASS_ChannelSetFX(handle, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
                iCount += 1
            Loop
            paramEQ.fBandwidth = 18.0F
            paramEQ.fCenter = 80.0F
            paramEQ.fGain = 0.0F
            Bass.BASS_FXSetParameters(fxEQ(0), paramEQ)
            paramEQ.fCenter = 120.0F
            Bass.BASS_FXSetParameters(fxEQ(1), paramEQ)
            paramEQ.fCenter = 250.0F
            Bass.BASS_FXSetParameters(fxEQ(2), paramEQ)
            paramEQ.fCenter = 500.0F
            Bass.BASS_FXSetParameters(fxEQ(3), paramEQ)
            paramEQ.fCenter = 1000.0F
            Bass.BASS_FXSetParameters(fxEQ(4), paramEQ)
            paramEQ.fCenter = 1800.0F
            Bass.BASS_FXSetParameters(fxEQ(5), paramEQ)
            paramEQ.fCenter = 3500.0F
            Bass.BASS_FXSetParameters(fxEQ(6), paramEQ)
            paramEQ.fCenter = 7000.0F
            Bass.BASS_FXSetParameters(fxEQ(7), paramEQ)
            paramEQ.fCenter = 10000.0F
            Bass.BASS_FXSetParameters(fxEQ(8), paramEQ)
            paramEQ.fCenter = 14000.0F
            Bass.BASS_FXSetParameters(fxEQ(9), paramEQ)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Shared Sub updateEQ(ByVal band As Integer, ByVal gain As Single)
        Dim paramEQ As New Un4seen.Bass.BASS_DX8_PARAMEQ
        Try
            If Bass.BASS_FXGetParameters(fxEQ(band), paramEQ) Then
                paramEQ.fGain = gain
                Bass.BASS_FXSetParameters(fxEQ(band), paramEQ)
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Shared Sub disEQ(ByVal handle As Integer)
        iCount = 0
        Do While (iCount < 10)
            Bass.BASS_ChannelRemoveFX(handle, fxEQ(iCount))
            iCount += 1
        Loop
    End Sub
End Class
« Last Edit: 24 Jul '13 - 20:46 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #93 on: 24 Jul '13 - 13:22 »
How to use the events form a class EQ. ;D

Referents bass.net.dll  and add bass.dll into the debug folder.

Code: [Select]
Imports Un4seen.Bass
Imports EQTest.EQ

Public Class Form1
    Inherits Form
    Private Fdlg As New OpenFileDialog
    Private stringTime As TimeSpan
    Private strm As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BassNet.Registration("email", "serial")
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle.ToInt32)
    End Sub
    Public Sub New()
        InitializeComponent()
        Me.CenterToScreen()
        Fdlg.FileName = Nothing
        Fdlg.Filter = "Song File(*.mp3;*.wav)|*.mp3;*.wav"
        oneTouch.Text = "Open"
    End Sub
    Public Sub oneTouch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles oneTouch.Click
        Select Case oneTouch.Text
            Case "Open"
                If Fdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                    Me.Text = My.Computer.FileSystem.GetName(Fdlg.FileName)
                    If strm <> 0 Then Bass.BASS_StreamFree(strm)
                    strm = Bass.BASS_StreamCreateFile(Fdlg.FileName, 0, 0, BASSFlag.BASS_DEFAULT)
                    stringTime = TimeSpan.FromSeconds(Math.Round(Bass.BASS_ChannelBytes2Seconds(strm, CLng(Bass.BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES)))))
                    Label17.Text = Strings.Right(Convert.ToString(stringTime), 5)
                    trackPos.Maximum = Bass.BASS_ChannelBytes2Seconds(strm, CLng(Bass.BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES)))
                    oneTouch.Text = "Play"
                    setEQ_10(strm)
                    resetEQ()
                End If
            Case "Play"
                If strm <> 0 Then
                    Bass.BASS_ChannelPlay(strm, True)
                    Timer1.Enabled = True
                    oneTouch.Text = "Stop"
                End If
            Case "Stop"
                Bass.BASS_ChannelStop(strm)
                Timer1.Enabled = False
                trackPos.Value = trackPos.Minimum
                oneTouch.Text = "Open"
                Label18.Text = "00:00"
        End Select
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        trackPos.Value = Bass.BASS_ChannelBytes2Seconds(strm, CLng(Bass.BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES)))
        stringTime = TimeSpan.FromSeconds(Math.Round(Bass.BASS_ChannelBytes2Seconds(strm, CLng(Bass.BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES)))))
        Label18.Text = Strings.Right(Convert.ToString(stringTime), 5)
        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_STOPPED Then
            Bass.BASS_ChannelPlay(strm, True)
        End If
    End Sub
    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        Bass.BASS_ChannelSetPosition(strm, Bass.BASS_ChannelSeconds2Bytes(strm, trackPos.Value))
    End Sub
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Try
            updateEQ(0, CSng(TrackBar1.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        Try
            updateEQ(1, CSng(TrackBar2.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        Try
            updateEQ(2, CSng(TrackBar3.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar4.Scroll
        Try
            updateEQ(3, CSng(TrackBar4.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar5_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar5.Scroll
        Try
            updateEQ(4, CSng(TrackBar5.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar6_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar6.Scroll
        Try
            updateEQ(5, CSng(TrackBar6.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar7_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar7.Scroll
        Try
            updateEQ(6, CSng(TrackBar7.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar8_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar8.Scroll
        Try
            updateEQ(7, CSng(TrackBar8.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar9_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar9.Scroll
        Try
            updateEQ(8, CSng(TrackBar9.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar10_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar10.Scroll
        Try
            updateEQ(9, CSng(TrackBar10.Value))
        Catch
        End Try
    End Sub
    Public Sub resetEQ()
        updateEQ(0, CSng(TrackBar1.Value * -1))
        updateEQ(1, CSng(TrackBar2.Value * -1))
        updateEQ(2, CSng(TrackBar3.Value * -1))
        updateEQ(3, CSng(TrackBar4.Value * -1))
        updateEQ(4, CSng(TrackBar5.Value * -1))
        updateEQ(5, CSng(TrackBar6.Value * -1))
        updateEQ(6, CSng(TrackBar7.Value * -1))
        updateEQ(7, CSng(TrackBar8.Value * -1))
        updateEQ(8, CSng(TrackBar9.Value * -1))
        updateEQ(9, CSng(TrackBar10.Value * -1))
    End Sub
    Public Sub resetVol()
        TrackBar1.Value = 0
        TrackBar2.Value = 0
        TrackBar3.Value = 0
        TrackBar4.Value = 0
        TrackBar5.Value = 0
        TrackBar6.Value = 0
        TrackBar7.Value = 0
        TrackBar8.Value = 0
        TrackBar9.Value = 0
        TrackBar10.Value = 0
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        resetVol()
    End Sub

    Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged
        Try
            updateEQ(0, CSng(TrackBar1.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar2_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar2.ValueChanged
        Try
            updateEQ(1, CSng(TrackBar2.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar3_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar3.ValueChanged
        Try
            updateEQ(2, CSng(TrackBar3.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar4_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar4.ValueChanged
        Try
            updateEQ(3, CSng(TrackBar4.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar5_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar5.ValueChanged
        Try
            updateEQ(4, CSng(TrackBar5.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar6_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar6.ValueChanged
        Try
            updateEQ(5, CSng(TrackBar6.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar7_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar7.ValueChanged
        Try
            updateEQ(6, CSng(TrackBar7.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar8_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar8.ValueChanged
        Try
            updateEQ(7, CSng(TrackBar8.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar9_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar9.ValueChanged
        Try
            updateEQ(8, CSng(TrackBar9.Value))
        Catch
        End Try
    End Sub
    Private Sub TrackBar10_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar10.ValueChanged
        Try
            updateEQ(9, CSng(TrackBar10.Value))
        Catch
        End Try
    End Sub
End Class
« Last Edit: 24 Jul '13 - 20:45 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #94 on: 26 Jul '13 - 12:25 »
BassInit get device function

Code: [Select]
Public Function InitializeBASS_Init() As Boolean
        Dim dev As Integer
        Try
            dev = Bass.BASS_ChannelGetDevice(IntPtr.Zero)
            Return Bass.BASS_Init(dev, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Function

Example:
Code: [Select]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitializeBASS_Init()
        Me.TopMost = True
    End Sub

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #95 on: 26 Jul '13 - 12:55 »
BassChannel Pause and Resume function

Code: [Select]
Public Sub BASS_PauseResume(ByVal handle As Integer, ByVal txtBtn As Button)
        Select Case txtBtn.Text
            Case "Pause"
                Try
                    Bass.BASS_ChannelPause(handle)
                    txtBtn.Text = "Resume"
                Catch ex As Exception
                End Try
            Case Else
                Try
                    Bass.BASS_ChannelPlay(handle, False)
                    txtBtn.Text = "Pause"
                Catch ex As Exception
                End Try
        End Select
    End Sub

Example:
Code: [Select]
Private Sub btnPause_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPause.Click
        If Bass.BASS_ChannelIsActive(strm) = BASSActive.BASS_ACTIVE_STOPPED Then Exit Sub
        BASS_PauseResume(strm, btnPause) 'btnPause is name of button to use.
    End Sub
« Last Edit: 26 Jul '13 - 12:58 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #96 on: 26 Jul '13 - 13:59 »
BassTimeDuration 2 digi (min&sec) function, Can using with TotalTime (Lenght) and CurrentTime (Position)

If selected 'selOption' = '1' is using with TotalTimeDuration (Lenght)
If selected 'selOption' = '2' is using with CurrentTimeDuration (Position)

Code: [Select]
Public Function BASS_TimeDurationString(ByVal handle As Integer, ByVal span As TimeSpan, ByVal selOption As Integer) As String
        Dim ret As String = Nothing
        Select Case selOption
            Case 1
                span = TimeSpan.FromSeconds(Math.Round(CDbl(Bass.BASS_ChannelBytes2Seconds(handle, Bass.BASS_ChannelGetLength(handle, BASSMode.BASS_POS_BYTES)))))
                ret = Strings.Right(Convert.ToString(span), 5)
            Case 2
                span = TimeSpan.FromSeconds(Math.Round(CDbl(Bass.BASS_ChannelBytes2Seconds(handle, Bass.BASS_ChannelGetPosition(handle, BASSMode.BASS_POS_BYTES)))))
                ret = Strings.Right(Convert.ToString(span), 5)
            Case Else
                Exit Select
        End Select
        Return ret
    End Function

Example:
Code: [Select]
Private span As TimeSpan
    Private strm As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitializeBASS_Init()
        Me.TopMost = True
    End Sub

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.CenterToScreen()
        span = New TimeSpan
        Button1.Text = "Open"
        Button2.Text = "Play"
        btnPause.Text = "Pause"
        Button4.Text = "Stop"
        Timer1.Interval = 50
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Bass.BASS_StreamFree(strm)
        Timer1.Enabled = False
        ctlRetset()
        Try
            strm = Bass.BASS_StreamCreateFile(ListBox1.SelectedItem, 0, 0, BASSFlag.BASS_DEFAULT)
        Catch ex As Exception
        End Try
        Try
            TextBox1.Text = ListBox1.SelectedItem
            TrackBar1.Maximum = MaxPosition(strm)
            Label1.Text = BASS_TimeDurationString(strm, span, 1)
            TrackBar1.TickFrequency = Convert.ToInt32(Math.Round(TrackBar1.Maximum / 10))
            setEQ(strm)
        Catch ex As Exception
        End Try
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        NoneStop(strm, ListBox1, Button2)
        Label2.Text = BASS_TimeDurationString(strm, span, 2)
        TrackBar1.Value = CurrentPosition(strm)
        PictureBox1.Image = Spectrum(strm, PictureBox1)
        LevelMeter(strm, ProgressBar1, ProgressBar2)
        Label13.Text = String.Concat("CPU : ", Convert.ToString(GetCPU()))
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        BrowsePlayList(ListBox1, OpenFileDialog1)
    End Sub
« Last Edit: 26 Jul '13 - 14:05 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #97 on: 27 Jul '13 - 06:31 »
Example programming Bass Player in C++ ;D
Using Windows Form Application (for basic programming)

1. Referent Bass.net.dll and add bass.dll into the debug folder.
2 In the namespace class form, add code.. using namespace Un4seen::Bass; 
3. Writting code BassInit into event FormLoad.
4. Add component OpenFileDialog
5. Create Open button, Play button and Stop button
5.1 Writting code BassStreamCreateFile into event Open button.
5.2 Writting code BassChannelPlay into event Play button.
5.3 Writting code BassChannelStop into event Stop button.

Easy Example:
Code: [Select]
#pragma once
namespace MyFirstBass {
    using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace Un4seen::Bass; //Referents
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
///          'Resource File Name' property for the managed resource compiler tool
///          associated with all .resx files this class depends on.  Otherwise,
///          the designers will not be able to interact properly with localized
///          resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
this->CenterToScreen();
}
     protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
private: System::Windows::Forms::Button^  button1;
private: System::Windows::Forms::Button^  button2;
private: System::Windows::Forms::Button^  button3;
protected:
    private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// openFileDialog1
//
this->openFileDialog1->FileName = L"openFileDialog1";
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 231);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(105, 231);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 23);
this->button2->TabIndex = 1;
this->button2->Text = L"button2";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(205, 231);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(75, 23);
this->button3->TabIndex = 2;
this->button3->Text = L"button3";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
        }
#pragma endregion
private: int strm; //handle
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e)
{
Bass::BASS_Init(-1, 44100,BASSInit::BASS_DEVICE_DEFAULT, IntPtr::Zero);
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
openFileDialog1->FileName = L"";
                 openFileDialog1->Filter = L"Song File(*.mp3)|*.mp3";
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
                 {
Bass::BASS_StreamFree(strm);
strm = Bass::BASS_StreamCreateFile(openFileDialog1->FileName, 0, 0, BASSFlag::BASS_DEFAULT);
}
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
{
Bass::BASS_ChannelPlay(strm, true);
}
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e)
     {
     Bass::BASS_ChannelStop(strm);
     }
    }; //end class
} //end namespace
« Last Edit: 27 Jul '13 - 07:43 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #98 on: 27 Jul '13 - 07:49 »
Creatting Bass Class functions code to use. ;D

=========================================
Set 'MaxPosition' function, for balance trackBar progress with current sound position (max lenght value)
Try! writting code into form class.

Example:
Code: [Select]
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
openFileDialog1->FileName = L"";
                 openFileDialog1->Filter = L"Song File(*.mp3)|*.mp3";
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
                 {
Bass::BASS_StreamFree(strm);
strm = Bass::BASS_StreamCreateFile(openFileDialog1->FileName, 0, 0, BASSFlag::BASS_DEFAULT);
}
{
trackBar1->Maximum = MaxPosition(strm);
trackBar1->TickFrequency = Convert::ToInt32(trackBar1->Maximum / 10);
}
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
{
Bass::BASS_ChannelPlay(strm, true);
}
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e)
     {
     Bass::BASS_ChannelStop(strm);
     }
//=====================start max position function===========================
    public: int MaxPosition(int handle)
{
                             return Convert::ToInt32(Bass::BASS_ChannelBytes2Seconds(handle,Bass::BASS_ChannelGetLength(handle, BASSMode::BASS_POS_BYTES)));
}
//==================== end max position function===========================
    }; //end class
} //end namespace
« Last Edit: 27 Jul '13 - 09:06 by sak2005 »

sak2005

  • Posts: 1007
Re: Direct bass : Vb.net
« Reply #99 on: 27 Jul '13 - 09:03 »
CurrentPosition function, for progress to playing.
Add this code into event Timer and set enabled = true on event play button and -
enabled = false on event stop button.

Code: [Select]
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e)
{
Bass::BASS_ChannelPlay(strm, true);
timer1->Enabled = true;
}
    private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e)
     {
     Bass::BASS_ChannelStop(strm);
                 timer1->Enabled = false;
     }
    public: int MaxPosition(int handle)
{
return Convert::ToInt32( Bass::BASS_ChannelBytes2Seconds(handle, Bass::BASS_ChannelGetLength(handle, BASSMode::BASS_POS_BYTES)));
}
public: int CurrentPosition(int handle)
{
return Convert::ToInt32( Bass::BASS_ChannelBytes2Seconds(handle, Bass::BASS_ChannelGetPosition(handle, BASSMode::BASS_POS_BYTES)));
}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e)
{
trackBar1->Value = CurrentPosition(strm);
}
}; //end class
} //end namespace

If you wanted repeat playing, add this code on event timer.

Code: [Select]
public: void Repeat(int handle)
{
if (CurrentPosition(handle)== MaxPosition(handle))
    {
button2->PerformClick(); //The button2 is playing button.
}
}
« Last Edit: 27 Jul '13 - 11:49 by sak2005 »