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

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #25 on: 9 Jul '12 - 11:44 »
Hey brotha, Loving the VB.NET stuff.. Do you have an example that I can use to play one song after another? 

Did you mean.. create list of songs and can select playing a song in the list?
« Last Edit: 10 Jul '12 - 10:33 by sak2005 »

dregalia

  • Posts: 10
Re: Direct bass : Vb.net
« Reply #26 on: 10 Jul '12 - 07:32 »
Yeah... either play an entire list of songs, or have it use the crossfade between 2 different songs and send that one stream to the broadcast server.

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #27 on: 10 Jul '12 - 10:25 »
Yeah... either play an entire list of songs, or have it use the crossfade between 2 different songs and send that one stream to the broadcast server.

For you.. try. Click here

If you wanted modify. You must decompile *.exe with.. - Spices.Net - application.
=============================================================
Example: Create SongsList

Create Form1 and writting code now.

Code: [Select]
Public Class Form1
    'Call DLLs
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    (ByVal strCommand As String, _
     ByVal strReturn As System.Text.StringBuilder, _
     ByVal iReturnLength As Integer, _
     ByVal hwndCallback As System.IntPtr) As Long

    'Creaet New Object
    Private Lbl1 As New Label
    Private sList1 As New ListBox
    Private btn1 As New Button
    Private btn2 As New Button
    Private btn3 As New Button
    Private fDlg1 As New OpenFileDialog

    'Operate Variable
    Private FileName As String

    'Call Form.Desinger
    Public Sub New()
        InitializeComponent()
        Me.CenterToScreen()
        Me.Text = "SongsList Sample"
        Lbl1.Text = "SongsList:"
        Lbl1.Location = New Point(20, 20)
        sList1.Size = New Size(250, 100)
        sList1.Location = New Point(20, 50)
        btn1.Text = "Open"
        btn2.Text = "Play"
        btn3.Text = "Stop"
        btn1.Location = New Point(20, 200)
        btn2.Location = New Point(110, 200)
        btn3.Location = New Point(200, 200)
        Me.Controls.Add(Lbl1)
        Me.Controls.Add(sList1)
        Me.Controls.Add(btn1)
        Me.Controls.Add(btn2)
        Me.Controls.Add(btn3)

        'Create EventHandle
        AddHandler btn1.Click, AddressOf ButtonOpen_Click
        AddHandler btn2.Click, AddressOf ButtonPlay_Click
        AddHandler btn3.Click, AddressOf ButtonStop_Click
        AddHandler sList1.SelectedIndexChanged, AddressOf ListBox1_SelectedIndexChanged
    End Sub

    'Load file to the list
    Public Sub ButtonOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        fDlg1.FileName = String.Empty
        fDlg1.Filter = "MpegFile(*.mp3)|*.mp3"
        If fDlg1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim nIndex As Integer = sList1.Items.Add(FileIO.FileSystem.GetName(fDlg1.FileName))
            sList1.SelectedIndex = nIndex
            ResetFilePosition()
        End If
    End Sub
    Public Sub ButtonPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        ResetFilePosition()
        Dim strCommand As String = "play oursong"
        mciSendString(strCommand, Nothing, 0, System.IntPtr.Zero)
      End Sub
    Public Sub ButtonStop_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strCommand As String = "stop oursong"
        mciSendString(strCommand, Nothing, 0, IntPtr.Zero)
        ResetFilePosition()
    End Sub

    'Selected ItemFileIndex to Playing
    Public Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        mciSendString("close oursong", Nothing, 0, IntPtr.Zero)
        FileName = sList1.SelectedItem.ToString
        Dim strCommand As String = String.Concat("open """, FileName, """ type mpegvideo alias oursong")
        mciSendString(strCommand, Nothing, 0, IntPtr.Zero)
    End Sub
    Public Sub ResetFilePosition()
        Dim pCommand As String = String.Concat("play oursong to ", 0)
        mciSendString(pCommand, Nothing, 0, IntPtr.Zero)
    End Sub
    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        ResetFilePosition()     
        mciSendString("close oursong", Nothing, 0, IntPtr.Zero)
    End Sub
End Class
===============================================================
DoubleClick Item to Playing

Code: [Select]
Public Class Form1
    'Call DLLs
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    (ByVal strCommand As String, _
     ByVal strReturn As System.Text.StringBuilder, _
     ByVal iReturnLength As Integer, _
     ByVal hwndCallback As System.IntPtr) As Long

    'Creaet New Object
    Private Lbl1 As New Label
    Private sList1 As New ListBox
    Private btn1 As New Button

    Private btn3 As New Button
    Private fDlg1 As New OpenFileDialog

    'Operate Variable
    Private FileName As String

    'Call Form.Desinger
    Public Sub New()
        InitializeComponent()
        Me.CenterToScreen()
        Me.Text = "SongsList Sample"
        Lbl1.Text = "SongsList:"
        Lbl1.Location = New Point(20, 20)
        sList1.Size = New Size(250, 100)
        sList1.Location = New Point(20, 50)
        btn1.Text = "Open"

        btn3.Text = "Stop"
        btn1.Location = New Point(20, 200)

        btn3.Location = New Point(200, 200)
        Me.Controls.Add(Lbl1)
        Me.Controls.Add(sList1)
        Me.Controls.Add(btn1)

        Me.Controls.Add(btn3)

        'Create EventHandle
        AddHandler btn1.Click, AddressOf ButtonOpen_Click

        AddHandler btn3.Click, AddressOf ButtonStop_Click
        AddHandler sList1.MouseDoubleClick, AddressOf ListBox1_MouseDoubleClick
    End Sub

    'Add files to the list
    Public Sub ButtonOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        fDlg1.FileName = String.Empty
        fDlg1.Filter = "MpegFile(*.mp3)|*.mp3"
        If fDlg1.ShowDialog = Windows.Forms.DialogResult.OK Then
            sList1.Items.Add(FileIO.FileSystem.GetName(fDlg1.FileName))
        End If
    End Sub
   
    Public Sub ButtonStop_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strCommand As String = "stop oursong"
        mciSendString(strCommand, Nothing, 0, IntPtr.Zero)
        ResetFilePosition()
    End Sub

    'DoubleClick Item to Playing
    Public Sub ListBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
        mciSendString("close oursong", Nothing, 0, IntPtr.Zero)
        Try
            FileName = sList1.SelectedItem.ToString
            Dim strCommand As String = String.Concat("open """, FileName, """ type mpegvideo alias oursong")
            mciSendString(strCommand, Nothing, 0, IntPtr.Zero)
        Catch
        End Try
        ResetFilePosition()
        Try
            Dim strCommand As String = "play oursong"
            mciSendString(strCommand, Nothing, 0, IntPtr.Zero)
        Catch
        End Try
    End Sub
    Public Sub ResetFilePosition()
        Dim pCommand As String = String.Concat("play oursong to ", 0)
        mciSendString(pCommand, Nothing, 0, IntPtr.Zero)
    End Sub
    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        ResetFilePosition()
        mciSendString("close oursong", Nothing, 0, IntPtr.Zero)
    End Sub
End Class
« Last Edit: 12 Jul '12 - 14:56 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #28 on: 15 Jul '12 - 07:56 »
Get creating object event handle

Download: BassUn4SeenPlayer.exe Sample project Click here
Download: SourceCode Click here


« Last Edit: 15 Jul '12 - 08:15 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #29 on: 17 Jul '12 - 06:09 »
Free File INI.Net.dll  ..For mem data. :: Download Click here

Using: Create Form1 and Referents file.dll into your project solution.

Example: IniWrite  ..Write or Create ini file name.. 'Setting.ini'
Code: [Select]
Public Class Form1
    Private fileName As String = String.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\Setting.ini")
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim vb As New INI.Class1
        vb.IniWrite("Section", "Key", "Value", fileName)
    End Sub
End Class
===========================================================
Example: IniRead  ..read value of the ini file.
Code: [Select]
Private RetString As New System.Text.StringBuilder(128)
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim vb As New INI.Class1
        Dim defultValue As String = "Not Found"
        vb.IniRead("Section", "Key", defultValue, RetString, RetString.Capacity, fileName)
        MsgBox(RetString.ToString)
    End Sub
« Last Edit: 17 Jul '12 - 06:47 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #30 on: 19 Jul '12 - 10:46 »
nbass Stream Player Sample Project VB2008 SourceCode :: Download: Click here


====================================================
Get function code folder browser : AddItemsSongsList

Paste all code in to the class form.

Create ListBox and Button and Paste headcode: AddItemsSongsList() in to the button event click function.

Code: [Select]
Public Sub AddItemsSongsList()
    Dim folderBrowserDialog1 As New FolderBrowserDialog
    If folderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
       Dim arrayList As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
       arrayList = My.Computer.FileSystem.FindInFiles(folderBrowserDialog1.SelectedPath, Nothing, False, FileIO.SearchOption.SearchTopLevelOnly, "*.mp3", "*.wma")
       For Each filesName As String In arrayList
           listBox1.Items.Add(filesName)
       Next filesName
    End If
End Sub
« Last Edit: 23 Jul '12 - 02:55 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #31 on: 23 Jul '12 - 03:12 »
Tip: Get code win player out of bass player. Try now.

Create Form1

Add References Com and select Windows Media Player ..click OK

Writting code now

Code: [Select]
Public Class Form1
    Private WinMedia As New WMPLib.WindowsMediaPlayer
    Private filedlg As New OpenFileDialog
    Private btnLoad As New Button
    Private btnPlay As New Button
    Private btnStop As New Button
    Private lblSongName As New Label
    Private lblDuration As New Label
    Private lblPosition As New Label
    Private lblState As New Label
    Private checkPol As New CheckBox
    Private checkRp As New CheckBox
    Private timer1 As New Timer
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.CenterToScreen()
        Me.Size = New Size(340, 200)
        Me.Text = "WMPLip Player (References Com)"
        Me.MaximizeBox = False
        filedlg.FileName = ""
        filedlg.Filter = "Song file(*.mp3;*.mid;*.wma)|*.mp3;*.mid;*.wma|All file(*.*)|*.*"
        btnLoad.Text = "Load"
        btnPlay.Text = "Play"
        btnStop.Text = "Stop"
        checkPol.Text = "PlayOnLoad"
        checkRp.Text = "RePlay"
        lblSongName.Text = "SongName:"
        lblDuration.Text = "00:00"
        lblPosition.Text = "00:00"
        lblState.Text = "State: - - - - -"
        btnLoad.Location = New Point(45, 130)
        btnPlay.Location = New Point(125, 130)
        btnStop.Location = New Point(205, 130)
        lblSongName.Location = New Point(50, 10)
        lblDuration.Location = New Point(10, 45)
        lblPosition.Location = New Point(10, 75)
        lblState.Location = New Point(100, 100)
        checkPol.Location = New Point(120, 40)
        checkRp.Location = New Point(120, 70)
        checkPol.Checked = True
        checkRp.Checked = True
        lblSongName.AutoSize = True
        lblSongName.Cursor = Cursors.Hand
        Me.Controls.AddRange(New Control() {btnLoad, btnPlay, btnStop, lblSongName, checkPol, lblDuration, lblPosition, lblState, checkRp})
        AddHandler btnLoad.Click, AddressOf btnLoad_Click
        AddHandler btnPlay.Click, AddressOf btnPlay_Cilck
        AddHandler btnStop.Click, AddressOf btnStop_Click
        AddHandler lblSongName.Click, AddressOf lblSongName_Click
        AddHandler timer1.Tick, AddressOf timer1_Tick
    End Sub
    Public Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If filedlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            lblSongName.Text = "SongName: " & My.Computer.FileSystem.GetName(filedlg.FileName)
            If checkPol.CheckState = CheckState.Checked Then btnPlay.PerformClick()
        End If
    End Sub
    Public Sub btnPlay_Cilck(ByVal sender As System.Object, ByVal e As System.EventArgs)
        WinMedia.URL = filedlg.FileName
        timer1.Enabled = True
    End Sub
    Public Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        lblPosition.Text = "00:00"
        lblState.Text = "State: Stopped"
        WinMedia.close()
    End Sub
    Public Sub lblSongName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        btnPlay.PerformClick()
    End Sub
    Public Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Select Case WinMedia.playState
            Case WMPLib.WMPPlayState.wmppsPlaying
                lblState.Text = "State: Playing..."
                lblDuration.Text = WinMedia.currentMedia.durationString
                lblPosition.Text = WinMedia.controls.currentPositionString
            Case WMPLib.WMPPlayState.wmppsStopped
                If checkRp.CheckState = CheckState.Checked Then
                    btnPlay.PerformClick()
                Else
                    lblState.Text = "State: Stopped"
                    lblPosition.Text = "00:00"
                    timer1.Enabled = False
                End If
        End Select
    End Sub
End Class



« Last Edit: 24 Jul '12 - 19:41 by sak2005 »

steph_tsf

  • Posts: 7
Re: Direct bass : Vb.net
« Reply #32 on: 23 Jul '12 - 07:26 »
Thank you so much for the two examples you have provided.
I am running WinXp SP3
Loaded your two VB2008 projects on VB 2010, no problem when VB2010 converts them to VB2010.
Build happens without error.

First example without spectrum analyzer runs OK in debug mode.

Second example labelled "StreamTest" with spectrum analyzer behaves differently. In debug mode I'm getting the following fatal error:

System.InvalidOperationException was unhandled
Exception.InnerException.
L'erreur est : C:\Documents and Settings\Administrator\My Documents\DvRE.v3164812328.AiO.Hypnox\logo2010.png
  Source=StreamTest
  StackTrace:
        My.MyProject.MyForms.Create__Instance__[T](T Instance) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 190
        My.MyProject.MyForms.get_Form1()
        StreamTest.Form1.Main() dans C:\SC documents\Audio DSP on WinPC\BASS examples\sak2005 Direct bass Vb.net\Example_02\StreamTest\Form1.Designer.vb:ligne 0
        System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
        System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
        Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
        System.Threading.ThreadHelper.ThreadStart_Context(Object state)
        System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
        System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
        System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileNotFoundException
       Message=C:\Documents and Settings\Administrator\My Documents\DvRE.v3164812328.AiO.Hypnox\logo2010.png
       Source=System.Drawing
       StackTrace:
            System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
            System.Drawing.Image.FromFile(String filename)
            StreamTest.Form1..ctor() dans C:\SC documents\Audio DSP on WinPC\BASS examples\sak2005 Direct bass Vb.net\Example_02\StreamTest\Form1.vb:ligne 42

Is it related to INI.dll that I may have omitted or misplaced?

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #33 on: 23 Jul '12 - 11:39 »
You must is 'Advance Programming' to modify Code to Error!. Please wait!.. Now I'll help.

Try create code with your own.

Example: Draw Graphic Visualizer. Use bass.dll for nBass 1.8

Code: [Select]
Private Const BASS_DATA_FFT1024 As Integer = &H80000001
Public Sub DrawGraphicVisualizer()
        Dim bit As Bitmap = New Bitmap(PicVis1.Width, PicVis1.Height)
        Dim graph As Graphics = Graphics.FromImage(bit)
        Dim WhitePen As New Pen(Color.Azure, 2)
        Dim PurplePen As New Pen(Color.BlueViolet, 2)
        Dim d(1023) As Single
        Dim X As Integer
        playing = BASS_ChannelIsActive(Strm)
        If playing = 0 Then Exit Sub
        BASS_ChannelGetData(Strm, d(0), BASS_DATA_FFT1024)
        For X = 0 To PicVis1.Width Step 4
            Y = Sqrt(d(X + 1)) * 3 * PicVis1.Height ' - 4
            If Y > PicVis1.Height Then Y = PicVis1.Height
            If Y < 0 Then Y = 0
            graph.DrawLine(WhitePen, X + 2, PicVis1.Height \ 2, X + 2, PicVis1.Height \ 2 - Y) ' \ 2)
            graph.DrawLine(PurplePen, X + 2, PicVis1.Height \ 2 + Y, X + 2, PicVis1.Height \ 2)  '- Y \ 2)
        Next
        PicVis1.Image = bit
    End Sub
« Last Edit: 23 Jul '12 - 12:16 by sak2005 »

steph_tsf

  • Posts: 7
Re: Direct bass : Vb.net
« Reply #34 on: 23 Jul '12 - 16:58 »
You must is 'Advance Programming' to modify Code to Error!. Please wait!.. Now I'll help. Try create code with your own. Example: Draw Graphic Visualizer. Use bass.dll for nBass 1.8

Indeed, I am not an experienced programmer. I understand there are three different ways to get VB2010 connecting to BASS:

1. the "direct" approach where the needed wrapper fragments are provided in a ModuleBASS.vb file (your first example)
2. relying on the nBASS wrapper - in VB2010, how do you specify that you are using the nBASS wrapper?
3. installing the BASSNET wrapper, supplied by from un4seen

I like your minimalist "direct" VB approach. It enables me to concentrate on the VB Form, on the VB Code and on the wrapper fragments that are required to talk with BASS, in the .net context. I only need to concentrate on few BASS function calls. A particular BASS demo that's catching my eyes is the \BASS\bass24\vb\DSPtest demo supplied by un4seen. It is catching my eyes because this is a genuine sample-by-sample audio DSP. I would like to have that particular demo working in VB2010, so I can start modifying a few lines in the audio DSP, and measure the result.

In my computer, the \BASS\bass24\delphi\DspTest demo is already running on Delphi 7, but due to the fact that I already have a few graphical front-ends written for VB2010, containing Charts elements introduced in VB2010, I prefear  working with VB2010.

I also tried \BASS\bass24\c\dsptest using VC++2010, but no luck, it completely fails.
As I am using VC++2010, the project automatically gets converted when doing "file" then "open", but after the conversion I'm getting this warning saying:
MSB8012: $(TargetPath) ('C:\Documents and Settings\Administrateur\Mes documents\Downloads\Audio DSP on WinPC\BASS and BASSASIO audio lib\BASS\bass24\c\dsptest\..\bin\dsptest.exe') does not match the Linker's OutputFile property value '..\bin\dsptest.exe' ('C:\Documents and Settings\Administrateur\Mes documents\Downloads\Audio DSP on WinPC\BASS and BASSASIO audio lib\BASS\bass24\c\bin\dsptest.exe') in project configuration 'Release|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).
Unfortunately, I don't know how to correct the wrong path that's invoved there. Anyway, from there everything goes weird. Upon rebuilding the app, I get a warning saying that the debug info is missing. Browsing the files, I can find the C++ code but I cannot find the Form. And I see there is a 27 megabyte dsptest.sdf file, I particulary hate this. If I try a "run", nothing happens. That's my misery with VC++2010.

Would be a fantastic help if you show your minimalist "direct" .net BASS wrapper approach, applied to the  \BASS\bass24\vb\DSPtest demo supplied by un4seen. "The less, the best".

Regards,
Steph

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #35 on: 29 Jul '12 - 01:38 »
Free SourceCode : Mini BASS Player Click here


================================================================
Free Best SourceCode: Bass Player Pro. Download: Click here

PullUp keep songs list.

Auto Update Files to the List. But cannot clear items in the list ..modifying


===============================================================
Free SourceCode: Bass Pro LED Level Meter Click here


=================================================================
Download: Mini Bass Player Advance :: SourceCode Click here


=============================================================
Download: Bass_LED_Visualizer SourceCode Click here








« Last Edit: 4 Aug '12 - 12:52 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #36 on: 5 Aug '12 - 22:23 »
To Create your own waves visualizer. Draw graphics on the PictureBoxs (VB.Net2008)

1. Use 1 or 2 PictureBox Object Component.
2. Use BASS FFT command or other.
3. Use draw bitmap command or paint form command.

Example: Creatting 2 waves visaulizer (Draw image). Not use FFT
Code: [Select]
Please wait!
« Last Edit: 5 Aug '12 - 22:32 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #37 on: 11 Aug '12 - 16:53 »
WmpLipMod Player SourceCode (Decompile from WMPLip.dll)
Code: [Select]
Module WMPLipMod
    Private sForm1 As New System.Windows.Forms.Form
    Private button1 As New System.Windows.Forms.Button
    Private button2 As New System.Windows.Forms.Button
    Private button3 As New System.Windows.Forms.Button
    Private fdlg As New System.Windows.Forms.OpenFileDialog
    Private label1 As New System.Windows.Forms.Label
    Private label2 As New System.Windows.Forms.Label
    Private label3 As New System.Windows.Forms.Label
    Private label4 As New System.Windows.Forms.Label
    Private label5 As New System.Windows.Forms.Label
    Private media As New WMPLib.WindowsMediaPlayer
    Private timer1 As New System.Windows.Forms.Timer
    Private fileName As String
    Sub New()
        sForm1.StartPosition = FormStartPosition.CenterScreen
        sForm1.Size = New Size(300, 170)
        sForm1.Text = "WMP Player"
        sForm1.MaximizeBox = False
        sForm1.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        button1.Text = "Open"
        button2.Text = "Pause"
        button3.Text = "Stop"
        button1.Cursor = Cursors.Hand
        button2.Cursor = Cursors.Hand
        button3.Cursor = Cursors.Hand
        label1.Text = "00:00"
        label2.Text = "00:00"
        label3.Text = "No Song"
        label4.Text = "Stopped"
        label5.Text = "0%"
        button1.Location = New System.Drawing.Point(27, 100)
        button2.Location = New System.Drawing.Point(107, 100)
        button3.Location = New System.Drawing.Point(187, 100)
        label1.Location = New System.Drawing.Point(30, 10)
        label2.Location = New System.Drawing.Point(225, 10)
        label3.Location = New System.Drawing.Point(90, 43)
        label4.Location = New System.Drawing.Point(110, 68)
        label5.Location = New System.Drawing.Point(130, 10)
        sForm1.Controls.AddRange(New Control() _
        {button1, button2, button3, label1, label2, label3, label4, label5})
        AddHandler sForm1.FormClosing, AddressOf sForm1_FormClosing
        AddHandler button1.Click, AddressOf Button1_Click
        AddHandler button2.Click, AddressOf Button2_Click
        AddHandler button3.Click, AddressOf Button3_Click
        AddHandler timer1.Tick, AddressOf Timer1_Tick
        timer1.Enabled = False
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If button2.Text = "Resume" Then button2.Text = "Pause"
        LoadPlaySound()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SoundPause()
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If button2.Text = "Resume" Then button2.Text = "Pause"
        SoundStop()
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        label1.Text = media.currentMedia.durationString
        label2.Text = media.controls.currentPositionString
        label5.Text = Math.Round((media.controls.currentPosition / media.currentMedia.duration) * 100, 0) & "%"
        Select Case media.playState
            Case WMPLib.WMPPlayState.wmppsPlaying
                label4.Text = "Playing.."
            Case WMPLib.WMPPlayState.wmppsPaused
                label4.Text = "Paused"
            Case WMPLib.WMPPlayState.wmppsStopped
                label2.Text = "00:00"
                label4.Text = "Song end"
                label5.Text = "0%"
        End Select
    End Sub
    Public Sub LoadPlaySound()
        Select Case button1.Text
            Case "Open"
                fdlg.FileName = ""
                fdlg.Filter = "Media Files(*.mp3;*.wav)|*.mp3;*.wav|All files(*.*)|*.*"
                If fdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
                    fileName = fdlg.FileName
                    button1.Text = "Play"
                    label3.Text = My.Computer.FileSystem.GetName(fileName)
                End If
            Case "Play"
                media.URL = fileName
                timer1.Enabled = True
        End Select
    End Sub
    Public Sub SoundPause()
        Select Case button2.Text
            Case "Pause"
                If media.playState = WMPLib.WMPPlayState.wmppsPlaying Then
                    media.controls.pause()
                    button2.Text = "Resume"
                End If
            Case "Resume"
                If media.playState = WMPLib.WMPPlayState.wmppsPaused Then
                    media.controls.play()
                    button2.Text = "Pause"
                End If
        End Select
    End Sub
    Public Sub SoundStop()
        Select Case media.playState
            Case WMPLib.WMPPlayState.wmppsPaused
                label2.Text = "00:00"
                label4.Text = "Stopped"
                label5.Text = "0%"
                button1.Text = "Open"
                timer1.Enabled = False
            Case WMPLib.WMPPlayState.wmppsPlaying
                media.controls.stop()
                label2.Text = "00:00"
                label4.Text = "Stopped"
                label5.Text = "0%"
                button1.Text = "Open"
                timer1.Enabled = False
            Case WMPLib.WMPPlayState.wmppsStopped
                If label4.Text = "Stopped" Then
                    label2.Text = "00:00"
                    label5.Text = "0%"
                    timer1.Enabled = False
                End If
        End Select
    End Sub
    Public Sub GuiWMPLipMediaPlayer()
        sForm1.ShowDialog()
    End Sub
    Private Sub sForm1_FormClosing(ByVal mySender As System.Object, ByVal myEvent As System.EventArgs)
        If timer1.Enabled = True Then timer1.Enabled = False
        media.close()
        Application.Exit()
    End Sub
End Module
=================================================================
Example:
Code: [Select]
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GuiWMPLipMediaPlayer()
    End Sub
End Class
« Last Edit: 11 Aug '12 - 17:50 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #38 on: 14 Aug '12 - 10:12 »
Bass EQualizer
« Last Edit: 14 Aug '12 - 21:18 by sak2005 »

hexsharp

  • Posts: 4
Re: Direct bass : Vb.net
« Reply #39 on: 16 Aug '12 - 07:51 »
Could you upload the project files again please?... can't seem to download it from the links you've given ...

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #40 on: 16 Aug '12 - 20:05 »
Could you upload the project files again please?... can't seem to download it from the links you've given ...

OK I'll send new links download given.

Download: nBASS Visualizer SourceCode Click here
« Last Edit: 18 Aug '12 - 06:06 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #41 on: 18 Aug '12 - 16:35 »
Tip: BASS_TimeSpanCalculator SourceCode

Code: [Select]
Public Function BASS_TimeSpanCalculator(ByVal Seconds As Double) As String
        Dim tSpan As System.TimeSpan
        tSpan = TimeSpan.FromSeconds(Seconds)
        Return Strings.Right(tSpan.ToString, 5)
    End Function
==================================================================
Tip: BASS_PercentPosition SourceCode

Code: [Select]
Public Function BASS_PercentPosition(ByVal posByte As Integer, ByVal lenByte As Integer) As Integer
        Return Math.Round((posByte / lenByte) * 100)
    End Function
=================================================================
Example:
Code: [Select]
Public Class Form1
    Declare Function nBASS_Init Lib "bass.dll" Alias "BASS_Init" _
    (ByVal device As Integer, _
     ByVal freq As Integer, _
     ByVal flags As Integer, _
     ByVal win As Integer) As Integer
    Declare Sub nBASS_StreamFree Lib "bass.dll" Alias "BASS_StreamFree" _
    (ByVal handle As Integer)
    Declare Function nBASS_StreamCreateFile Lib "bass.dll" Alias "BASS_StreamCreateFile" _
    (ByVal mem As Integer, _
     ByVal f As String, _
     ByVal offset As Integer, _
     ByVal Length As Integer, _
     ByVal flags As Integer) As Integer
    Declare Function nBASS_StreamPlay Lib "bass.dll" Alias "BASS_StreamPlay" _
    (ByVal handle As Integer, _
     ByVal flush As Integer, _
     ByVal flags As Integer) As Integer
    Declare Function nBASS_ChannelGetPosition Lib "bass.dll" Alias "BASS_ChannelGetPosition" _
    (ByVal handle As Integer) As Long
    Declare Function nBASS_StreamGetLength Lib "bass.dll" Alias "BASS_StreamGetLength" _
    (ByVal handle As Integer) As Long
    Declare Function nBASS_ChannelBytes2Seconds Lib "bass.dll" Alias "BASS_ChannelBytes2Seconds" _
    (ByVal handle As Integer, _
     ByVal pos As Long) As Single
    Declare Function nBASS_Start Lib "bass.dll" Alias "BASS_Start" () As Integer
    Declare Function nBASS_ChannelIsActive Lib "bass.dll" Alias "BASS_ChannelIsActive" _
    (ByVal handle As Integer) As Integer
    Public Const BASS_ACTIVE_STOPPED As Short = 0
    Public Const BASS_ACTIVE_PLAYING As Short = 1
    Dim strm As Integer
    Public Sub New()
        InitializeComponent()
        nBASS_Init(-1, 44100, 0, Me.Handle.ToInt32)
        Me.CenterToScreen()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fileName As String
        OpenFileDialog1.FileName = ""
        OpenFileDialog1.Filter = "Media file(*.mp3;*.wav|*.mp3;*.wav)"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            fileName = My.Computer.FileSystem.GetName(OpenFileDialog1.FileName)
            Label5.Text = fileName
            nBASS_StreamFree(strm)
            nBASS_Start()
            strm = nBASS_StreamCreateFile(0, fileName, 0, 0, 0)
            nBASS_StreamPlay(strm, 0, 0)
            Timer1.Enabled = True
        End If
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim posByte As Integer
        Dim lenByte As Integer
        Dim nSecond1 As Integer
        Dim nSecond2 As Integer
        lenByte = nBASS_StreamGetLength(strm)
        posByte = nBASS_ChannelGetPosition(strm)
        nSecond1 = nBASS_ChannelBytes2Seconds(strm, lenByte)
        nSecond2 = nBASS_ChannelBytes2Seconds(strm, posByte)
        Label1.Text = nBASS_TimeSpanCalculator(nSecond1)
        Label2.Text = nBASS_TimeSpanCalculator(nSecond2)
        Label4.Text = nBASS_PercentPosition(posByte, lenByte) & "%"
        Select Case nBASS_ChannelIsActive(strm)
            Case BASS_ACTIVE_PLAYING
                Label3.Text = "Playing.."
            Case BASS_ACTIVE_STOPPED
                Label2.Text = "00:00"
                Label3.Text = "Song End"
                Label4.Text = "0%"
                Timer1.Enabled = False
        End Select
    End Sub
    Public Function nBASS_TimeSpanCalculator(ByVal Seconds As Double) As String
        Dim tSpan As System.TimeSpan
        tSpan = TimeSpan.FromSeconds(Seconds)
        Return Strings.Right(tSpan.ToString, 5)
    End Function
    Public Function nBASS_PercentPosition(ByVal posByte As Integer, ByVal lenByte As Integer) As Integer
        Return Math.Round((posByte / lenByte) * 100)
    End Function
End Class
« Last Edit: 19 Aug '12 - 01:12 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #42 on: 17 Sep '12 - 11:57 »
GetCode: FlashDrive SongList Player

Paste songs.mp3 to the FlashDrive.

DoubleClick songName in the listbox to playing.

Code: [Select]
Public Class Form1
    Private listBox1 As New ListBox
    Public Sub New()
        InitializeComponent()
        Me.Size = New Size(300, 220)
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        Me.CenterToScreen()
        listBox1.Bounds = New Rectangle(12, 12, 268, 160)
        Me.Controls.Add(listBox1)
        FoundDriveLetter()
        AddHandler listBox1.DoubleClick, AddressOf listBox1_DoubleClick
    End Sub
    Public Sub FilesListBox(ByVal Source As String)
        Try
            For Each foundFiles As String In FileIO.FileSystem.GetFiles(Source, FileIO.SearchOption.SearchTopLevelOnly Or FileIO.SearchOption.SearchAllSubDirectories, "*.mp3")
                listBox1.Items.Add(foundFiles)
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub FoundDriveLetter()
        Dim nDrive As String = Nothing
        Dim d As Object = Nothing
        Dim btn As String = Nothing
        Dim fso As Object = CreateObject("Scripting.FileSystemObject")
        Dim dc As Object = fso.Drives
        Try
            For Each d In dc
                If d.IsReady Then
                    If d.DriveType = 1 Then
                        nDrive &= d.DriveLetter
                    End If
                End If
            Next
            Select Case nDrive
                Case "D"
                    Me.Text = "DriveListBox (D:)"
                    FilesListBox("D:\")
                Case "E"
                    Me.Text = "DriveListBox (E:)"
                    FilesListBox("E:\")
                Case "F"
                    Me.Text = "DriveListBox (F:)"
                    FilesListBox("F:\")
                Case "G"
                    Me.Text = "DriveListBox (G:)"
                    FilesListBox("G:\")
                Case "H"
                    Me.Text = "DriveListBox (H:)"
                    FilesListBox("H:\")
                Case "I"
                    Me.Text = "DriveListBox (I:)"
                    FilesListBox("I:\")
                Case Else
                    MsgBox("No,FlashDrive")
            End Select
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub listBox1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Process.Start(listBox1.SelectedItem)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class
« Last Edit: 26 Sep '12 - 17:29 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #43 on: 8 Oct '12 - 07:26 »
Try! LED meter. Modify to Sound VU meter (LED white top)

Code: [Select]
Public Class Form1
    Private iL As Integer = 0
    Private iR As Integer = 0
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        iL += 1
        Select Case iL
            Case 0
                TableLayoutPanel1.BackColor = Color.Black
                TableLayoutPanel2.BackColor = Color.Black
            Case 1
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.White
            Case 2
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.White
            Case 3
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.White
            Case 4
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.White
            Case 5
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.Green
                TableLayoutPanel6.BackColor = Color.White
            Case 6
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.Green
                TableLayoutPanel6.BackColor = Color.Green
                TableLayoutPanel7.BackColor = Color.White
            Case 7
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.Green
                TableLayoutPanel6.BackColor = Color.Green
                TableLayoutPanel7.BackColor = Color.Green
                TableLayoutPanel8.BackColor = Color.White
            Case 8
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.Green
                TableLayoutPanel6.BackColor = Color.Green
                TableLayoutPanel7.BackColor = Color.Green
                TableLayoutPanel8.BackColor = Color.Green
                TableLayoutPanel9.BackColor = Color.White
            Case 9
                TableLayoutPanel1.BackColor = Color.Green
                TableLayoutPanel2.BackColor = Color.Green
                TableLayoutPanel3.BackColor = Color.Green
                TableLayoutPanel4.BackColor = Color.Green
                TableLayoutPanel5.BackColor = Color.Green
                TableLayoutPanel6.BackColor = Color.Green
                TableLayoutPanel7.BackColor = Color.Green
                TableLayoutPanel8.BackColor = Color.Green
                TableLayoutPanel9.BackColor = Color.Green
                TableLayoutPanel10.BackColor = Color.White
                ColorResetL()
                iL = 0
        End Select
    End Sub
    Public Sub ColorResetL()
        TableLayoutPanel1.BackColor = Color.Green
        TableLayoutPanel2.BackColor = Color.Black
        TableLayoutPanel3.BackColor = Color.Black
        TableLayoutPanel4.BackColor = Color.Black
        TableLayoutPanel5.BackColor = Color.Black
        TableLayoutPanel6.BackColor = Color.Black
        TableLayoutPanel7.BackColor = Color.Black
        TableLayoutPanel8.BackColor = Color.Black
        TableLayoutPanel9.BackColor = Color.Black
        TableLayoutPanel10.BackColor = Color.Black
    End Sub
    Public Sub ColorResetR()
        TableLayoutPanel11.BackColor = Color.Green
        TableLayoutPanel12.BackColor = Color.Black
        TableLayoutPanel13.BackColor = Color.Black
        TableLayoutPanel14.BackColor = Color.Black
        TableLayoutPanel15.BackColor = Color.Black
        TableLayoutPanel16.BackColor = Color.Black
        TableLayoutPanel17.BackColor = Color.Black
        TableLayoutPanel18.BackColor = Color.Black
        TableLayoutPanel19.BackColor = Color.Black
        TableLayoutPanel20.BackColor = Color.Black
    End Sub
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        iR += 1
        Select Case iR
            Case 0
                TableLayoutPanel11.BackColor = Color.Black
                TableLayoutPanel12.BackColor = Color.Black
            Case 1
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.White
            Case 2
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.White
            Case 3
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.White
            Case 4
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.White
            Case 5
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.Green
                TableLayoutPanel16.BackColor = Color.White
            Case 6
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.Green
                TableLayoutPanel16.BackColor = Color.Green
                TableLayoutPanel17.BackColor = Color.White
            Case 7
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.Green
                TableLayoutPanel16.BackColor = Color.Green
                TableLayoutPanel17.BackColor = Color.Green
                TableLayoutPanel18.BackColor = Color.White
            Case 8
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.Green
                TableLayoutPanel16.BackColor = Color.Green
                TableLayoutPanel17.BackColor = Color.Green
                TableLayoutPanel18.BackColor = Color.Green
                TableLayoutPanel19.BackColor = Color.White
            Case 9
                TableLayoutPanel11.BackColor = Color.Green
                TableLayoutPanel12.BackColor = Color.Green
                TableLayoutPanel13.BackColor = Color.Green
                TableLayoutPanel14.BackColor = Color.Green
                TableLayoutPanel15.BackColor = Color.Green
                TableLayoutPanel16.BackColor = Color.Green
                TableLayoutPanel17.BackColor = Color.Green
                TableLayoutPanel18.BackColor = Color.Green
                TableLayoutPanel19.BackColor = Color.Green
                TableLayoutPanel20.BackColor = Color.White
                ColorResetR()
                iR = 0
        End Select
    End Sub
    Public Sub New()
        InitializeComponent()
        Me.CenterToScreen()
        Me.MinimizeBox = False
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        Timer3.Enabled = True
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case Button1.Text
            Case "Start"
                Timer1.Enabled = True
                Timer2.Enabled = True
                Button1.Text = "Pause"
            Case Else
                Timer1.Enabled = False
                Timer2.Enabled = False
                Button1.Text = "Start"
        End Select
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        If RadioButton1.Checked = True Then
            Timer1.Interval = 390
            Timer2.Interval = 390
        ElseIf RadioButton2.Checked = True Then
            Timer1.Interval = 90
            Timer2.Interval = 90
        Else
            Timer1.Interval = 30
            Timer2.Interval = 30
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Enabled = False
        Timer2.Enabled = False
        ColorResetL()
        TableLayoutPanel1.BackColor = Color.Black
        ColorResetR()
        TableLayoutPanel11.BackColor = Color.Black
        If Button1.Text = "Pause" Then Button1.Text = "Start"
        iL = 0
        iR = 0
    End Sub
End Class


=================================================
Download: Sound UV meter Sample Click here

« Last Edit: 8 Oct '12 - 14:09 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #44 on: 29 Oct '12 - 05:31 »
Reference BASS Functions Sample Code ;D

1.Reference BASS.net.dll

2.Add BASS.dll in to the debug folder

Copied all code and paste in to the form editor. Try run now!

You're not must setting properties Form Object.

Code: [Select]
Imports Un4seen.Bass
Imports Un4seen.Bass.BASSActive
Public Class Form1
    Private tSpan As TimeSpan
    Private lSpan As TimeSpan
    Private Lbl1 As New Label
    Private Lbl2 As New Label
    Private Lbl3 As New Label
    Private Lbl4 As New Label
    Private Btn1 As New Button
    Private Btn2 As New Button
    Private Btn3 As New Button
    Private Btn4 As New Button
    Private ChkBox1 As New CheckBox
    Private ChkBox2 As New CheckBox
    Private prog1 As New ProgressBar
    Private StatusBar1 As New StatusBar
    Private time1 As New Timer
    Private time2 As New Timer
    Private strm As Integer = 0
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.CenterToScreen()
        Me.Text = "BASSUN4SEEN"
        Me.Size = New Size(229, 157)
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        Me.ShowIcon = False
        CtlProperties()
        Me.Controls.AddRange(New Control() {Lbl1, Lbl2, Btn1, Btn2, Btn3, Btn4, ChkBox1, ChkBox2, StatusBar1})
        StatusBar1.Controls.AddRange(New Control() {Lbl3, Lbl4, prog1})
        BassNet.Registration("xxx@gmail.com", "2xxxxxxxxx")
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
        AddHandler Btn1.Click, AddressOf Btn1_Click
        AddHandler Btn2.Click, AddressOf Btn2_Click
        AddHandler Btn3.Click, AddressOf Btn3_Click
        AddHandler Btn4.Click, AddressOf Btn4_Click
        AddHandler time1.Tick, AddressOf time1_Tick
        AddHandler time2.Tick, AddressOf time2_Tick
        prog1.Maximum = 100
        time1.Enabled = True
    End Sub
    Private Sub Btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        LoadSong(Lbl2, ChkBox1)
    End Sub
    Private Sub Btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PlaySong(Lbl1, time2)
    End Sub
    Private Sub Btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PauseSong(Lbl1, Btn3)
    End Sub
    Private Sub Btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ResumeButton()
        StopSong(Lbl1, time2)
    End Sub
    Public Sub time1_Tick(ByVal sender As Object, ByVal e As EventArgs)
        BassActive(Lbl1, ChkBox2, prog1, Lbl4)
    End Sub
    Public Sub time2_Tick(ByVal sender As Object, ByVal e As EventArgs)
        BassPosition(prog1)
        BassTimeCalc(Lbl3, Lbl4)
        If prog1.Value >= prog1.Maximum Then
            If ChkBox2.CheckState = CheckState.Checked Then
                Btn2.PerformClick()
            End If
        End If
    End Sub
    Public Sub LoadSong(ByVal LblSongObj As Label, ByVal loadPlayObj As CheckBox)
        Dim file As String
        Dim openFdlg As New OpenFileDialog
        openFdlg.FileName = String.Empty
        openFdlg.Filter = "Song file(*.mp3)|*.mp3"
        If openFdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            Bass.BASS_StreamFree(strm)
            file = openFdlg.FileName
            strm = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT)
            LblSongObj.Text = My.Computer.FileSystem.GetName(file)
            ResumeButton()
            If loadPlayObj.CheckState = CheckState.Checked Then Btn2.PerformClick()
        End If
    End Sub
    Public Sub PlaySong(ByVal txtActiveLbl As Label, ByVal timePosObj As Timer)
        If txtActiveLbl.Text = "Paused" Then Return
        Bass.BASS_ChannelPlay(strm, True)
        timePosObj.Enabled = True
    End Sub
    Public Sub PauseSong(ByVal txtActiveLbl As Label, ByVal btnPauseObj As Button)
        If txtActiveLbl.Text = "Stopped" Then Return
        If strm = 0 Then Return
        Select Case btnPauseObj.Text
            Case "Pause"
                Bass.BASS_ChannelPause(strm)
                btnPauseObj.Text = "Resume"
            Case Else
                Bass.BASS_ChannelPlay(strm, False)
                btnPauseObj.Text = "Pause"
        End Select
    End Sub
    Public Sub StopSong(ByVal txtActiveLbl As Label, ByVal timePosObj As Timer)
        If txtActiveLbl.Text = "Stopped" Then Return
        Bass.BASS_ChannelStop(strm)
        timePosObj.Enabled = False
    End Sub
    Public Sub BassActive(ByVal LblActiveObj As Label, ByVal chkBoxObj As CheckBox, ByVal progPosObj As ProgressBar, ByVal leftTimeObj As Label)
        Select Case Bass.BASS_ChannelIsActive(strm)
            Case BASS_ACTIVE_PAUSED
                LblActiveObj.Text = "Paused"
            Case BASS_ACTIVE_PLAYING
                LblActiveObj.Text = "Playing.." & prog1.Value.ToString & "%"
            Case BASS_ACTIVE_STALLED
                LblActiveObj.Text = "Stalled"
            Case BASS_ACTIVE_STOPPED
                LblActiveObj.Text = "Stopped"
                time2.Enabled = False
                progPosObj.Value = prog1.Minimum
                leftTimeObj.Text = "00:00"
        End Select
    End Sub
    Public Sub ResumeButton()
        If Btn3.Text = "Resume" Then Btn3.Text = "Pause"
    End Sub
    Public Sub BassPosition(ByVal PbarObj As ProgressBar)
        PbarObj.Value = Math.Round((Bass.BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES) / Bass.BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES)) * 100)
    End Sub
    Public Sub BassTimeCalc(ByVal lenTextObj As Label, ByVal posTextObj As Label)
        Dim tTime, lTime As Double
        tTime = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetLength(strm, BASSMode.BASS_POS_BYTES))
        tSpan = TimeSpan.FromSeconds(Math.Round(tTime))
        lenTextObj.Text = Strings.Right(tSpan.ToString, 5)
        lTime = Bass.BASS_ChannelBytes2Seconds(strm, Bass.BASS_ChannelGetPosition(strm, BASSMode.BASS_POS_BYTES))
        lSpan = TimeSpan.FromSeconds(Math.Round(lTime))
        posTextObj.Text = Strings.Right(lSpan.ToString, 5)
    End Sub
    Public Sub CtlProperties()
        Lbl3 = New Label
        Lbl1.Text = "Active"
        Lbl1.SetBounds(78, 23, 37, 13)
        Lbl1.AutoSize = True
        Lbl2.Text = "*     *     *     *     *     *     *     *     *     *     *"
        Lbl2.SetBounds(7, 4, 208, 13)
        Lbl2.AutoSize = True
        Lbl3.Text = "00:00"
        Lbl3.SetBounds(4, 5, 34, 13)
        Lbl3.AutoSize = True
        Lbl4.Text = "00:00"
        Lbl4.SetBounds(182, 5, 34, 13)
        Lbl4.AutoSize = True
        ChkBox1.Text = "PlayOnLoad"
        ChkBox1.SetBounds(35, 46, 84, 17)
        ChkBox2.Text = "RePlay"
        ChkBox2.SetBounds(125, 46, 60, 17)
        Btn1.Text = "Load"
        Btn1.SetBounds(5, 69, 46, 23)
        Btn1.Cursor = Cursors.Hand
        Btn2.Text = "Play"
        Btn2.SetBounds(57, 69, 46, 23)
        Btn2.Cursor = Cursors.Hand
        Btn3.Text = "Pause"
        Btn3.SetBounds(109, 69, 55, 23)
        Btn3.Cursor = Cursors.Hand
        Btn4.Text = "Stop"
        Btn4.SetBounds(170, 69, 46, 23)
        Btn4.Cursor = Cursors.Hand
        prog1.SetBounds(44, 7, 132, 10)
        StatusBar1.SetBounds(0, 102, 221, 22)
    End Sub
End Class

« Last Edit: 29 Oct '12 - 07:24 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #45 on: 29 Oct '12 - 14:56 »
ฺBASS EQualizer and Bass booster Easy code (Please wait!) ;D

Get ColorSlider.net.dll (eq1 - eq10) for reference Bass solution Click here

Sample:ClassCode1:: Set Array for EQ 10 bands
Code: [Select]
Imports Un4seen.Bass 'reference bass.net
Public Class BassEqPlayer
    Inherits Object
    Private stream As Integer
    Private fxEQ As Integer()
    Public Sub New()
        MyBase.New()
        Dim arr As Integer()
        Try
            arr = New Integer(10 - 1) {} 'set band array.
            fxEQ = arr
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Try                    'set frequency and bass registration.
            BassNet.Registration("xxxx@gmail.com", "2Xxxxxxxxxxxxxx")
            Bass.BASS_Init(1, 41000, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
             Return
        End Sub
End Class
==================================================
Sample:ClassCode2:: Writting Code bass EQ functions
Code: [Select]
Public Sub SetEQ10()
        Dim paramEQ As New BASS_DX8_PARAMEQ
        Try
            fxEQ(0) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(1) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(2) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(3) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(4) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(5) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(6) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(7) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(8) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            fxEQ(9) = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 0)
            paramEQ.fBandwidth = 18.0!
            paramEQ.fGain = 0.0!
            paramEQ.fCenter = 80.0!
            Bass.BASS_FXSetParameters(fxEQ(0), paramEQ)
            paramEQ.fCenter = 120.0!
            Bass.BASS_FXSetParameters(fxEQ(1), paramEQ)
            paramEQ.fCenter = 250.0!
            Bass.BASS_FXSetParameters(fxEQ(2), paramEQ)
            paramEQ.fCenter = 500.0!
            Bass.BASS_FXSetParameters(fxEQ(3), paramEQ)
            paramEQ.fCenter = 1000.0!
            Bass.BASS_FXSetParameters(fxEQ(4), paramEQ)
            paramEQ.fCenter = 1800.0!
            Bass.BASS_FXSetParameters(fxEQ(5), paramEQ)
            paramEQ.fCenter = 3500.0!
            Bass.BASS_FXSetParameters(fxEQ(6), paramEQ)
            paramEQ.fCenter = 7000.0!
            Bass.BASS_FXSetParameters(fxEQ(7), paramEQ)
            paramEQ.fCenter = 10000.0!
            Bass.BASS_FXSetParameters(fxEQ(8), paramEQ)
            paramEQ.fCenter = 14000.0!
            Bass.BASS_FXSetParameters(fxEQ(9), paramEQ)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Return
    End Sub
    Public Sub UpdateEQ(ByVal band As Integer, ByVal gain As Single)
        Dim paramEQ As New BASS_DX8_PARAMEQ
        Try
            paramEQ.fGain = gain
            Bass.BASS_FXSetParameters(fxEQ(band), paramEQ)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Return
    End Sub

=========================================
Bass Boost Code (Loundness) Function
Code: [Select]
Public Sub BassBoost(ByVal BoostButton As Button, ByVal TextButtonOn As String, ByVal TextButtonOff As String, ByVal valueEQ As Integer)
        Select Case BoostButton.Text
            Case TextButtonOn
                UpdateEQ(0, CSng(-10 * -1))
                BoostButton.Text = "OFF"
            Case TextButtonOff
                UpdateEQ(0, CSng(valueEQ * -1))
                BoostButton.Text = "ON"
        End Select
        Return
    End Sub
------------------------------------------------------
Example: Loundness Button
Code: [Select]
Private Sub Btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        BassBoost(Btn5, "ON", "OFF", eq1.Value)
    End Sub
« Last Edit: 30 Oct '12 - 18:12 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #46 on: 30 Oct '12 - 16:48 »
Sample:ClassCode3:: Writting Code bass Player Functions

LoadSong Function: 3 Options
1. LblTextSongObj is Song name to display.
2. LoadOnPlayObj is CheckBox for open song and playing.
3. PlayButton is set event click play button when set state PlayOnLoad.
Code: [Select]
Public Sub LoadSong(ByVal LblTextSongObj As Label, ByVal LoadOnPlayObj As CheckBox, ByVal PlayButton As Button)
        Dim file As String
        Dim openFdlg As New OpenFileDialog
        openFdlg.FileName = String.Empty
        openFdlg.Filter = "Song file(*.mp3)|*.mp3"
        If openFdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            Bass.BASS_StreamFree(stream)
            file = openFdlg.FileName
            stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT)
            LblTextSongObj.Text = My.Computer.FileSystem.GetName(file)
            ResumeButton()
            If LoadOnPlayObj.CheckState = CheckState.Checked Then PlayButton.PerformClick()
        End If
    End Sub

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #47 on: 30 Oct '12 - 17:15 »
Sample:ClassCode4:: Writting Code bass Player Functions

PlaySong , PauseSong and StopSong  Functions

Play Function: 2 Options
1. TextActiveLbl is Text Label for BassChannelIsActive to display
2. timePosObj is set start Timer for song Position when start playing.
Code: [Select]
Public Sub PlaySong(ByVal TextActiveLbl As Label, ByVal timePosObj As Timer)
        If TextActiveLbl.Text = "Paused" Then Return
        Bass.BASS_ChannelPlay(stream, True)
        SetEQ10() 'start eq 10 bands.
        UpdateEQ(0, CSng(eq1.Value * -1))
        UpdateEQ(1, CSng(eq2.Value * -1))
        UpdateEQ(2, CSng(eq3.Value * -1))
        UpdateEQ(3, CSng(eq4.Value * -1))
        UpdateEQ(4, CSng(eq5.Value * -1)) 'reset eq value. 
        UpdateEQ(5, CSng(eq6.Value * -1))
        UpdateEQ(6, CSng(eq7.Value * -1))
        UpdateEQ(7, CSng(eq8.Value * -1))
        UpdateEQ(8, CSng(eq9.Value * -1))
        UpdateEQ(9, CSng(eq10.Value * -1))
        timePosObj.Enabled = True
    End Sub

=================================================
Pause Function: 2 Options
1. txtActiveLbl is same as
2. btnPauseObj is chage text button between paused and resume.
Code: [Select]
Public Sub PauseSong(ByVal txtActiveLbl As Label, ByVal btnPauseObj As Button)
        If txtActiveLbl.Text = "Stopped" Then Return
        If stream = 0 Then Return
        Select Case btnPauseObj.Text
            Case "Pause"
                Bass.BASS_ChannelPause(stream)
                btnPauseObj.Text = "Resume"
            Case Else
                Bass.BASS_ChannelPlay(stream, False)
                btnPauseObj.Text = "Pause"
        End Select
    End Sub
===============================================
Stop Function: 2 Options
Code: [Select]
Public Sub StopSong(ByVal txtActiveLbl As Label, ByVal timePosObj As Timer)
        If txtActiveLbl.Text = "Stopped" Then Return
        Bass.BASS_ChannelStop(stream)
        timePosObj.Enabled = False
    End Sub

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #48 on: 30 Oct '12 - 17:28 »
Sample:ClassCode5:: Writting Code bass Player Functions

BassChannelIsActive: 4 Options
1.  LblActiveObj is same as
2.  chkBoxObj is state checked for RePlay.
3.  chkBoxObj is reset progressbar position song to playing when song ended.
4. leftTimeObj  is reset duration text Label to display.

You must create new Timer2 for tick Active every time.

Code: [Select]
Public Sub BassActive(ByVal LblActiveObj As Label, ByVal chkBoxObj As CheckBox, ByVal chkBoxObj As ProgressBar, ByVal leftTimeObj As Label)
        Select Case Bass.BASS_ChannelIsActive(stream)
            Case BASS_ACTIVE_PAUSED
                LblActiveObj.Text = "Paused"
            Case BASS_ACTIVE_PLAYING
                LblActiveObj.Text = "Playing.." & prog1.Value.ToString & "%"
            Case BASS_ACTIVE_STALLED
                LblActiveObj.Text = "Stalled"
            Case BASS_ACTIVE_STOPPED
                LblActiveObj.Text = "Stopped"
                time2.Enabled = False
                progPosObj.Value = prog1.Minimum
                leftTimeObj.Text = "00:00"
        End Select
    End Sub
« Last Edit: 30 Oct '12 - 17:30 by sak2005 »

sak2005

  • Posts: 997
Re: Direct bass : Vb.net
« Reply #49 on: 30 Oct '12 - 17:39 »
Sample:ClassCode5:: Writting Code bass Player Functions

TimeCalc Duration (Lenth and Position): 2 Options
1. Fix text time Format for total time of song to display.
2. Text time Format for left time of song to display.

Code: [Select]
Public Sub BassTimeCalc(ByVal lenTextObj As Label, ByVal posTextObj As Label)
        Dim tTime, lTime As Double
        tTime = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream, BASSMode.BASS_POS_BYTES))
        tSpan = TimeSpan.FromSeconds(Math.Round(tTime))
        lenTextObj.Text = Strings.Right(tSpan.ToString, 5)
        lTime = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream, BASSMode.BASS_POS_BYTES))
        lSpan = TimeSpan.FromSeconds(Math.Round(lTime))
        posTextObj.Text = Strings.Right(lSpan.ToString, 5)
    End Sub