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

sak2005

  • Posts: 1007
Free Download: BassMidiActiveX.dll  ::) Clickhere

Example:
Code: [Select]
Public Class Form1
    Public Declare Auto Function BASS_PluginLoad Lib "bass.dll" (ByVal strFile As String, ByVal BASSFlag As Integer) As Integer
    Public Declare Auto Function BASS_StreamFree Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Public Declare Auto Function BASS_StreamCreateFile Lib "bass.dll" (ByVal mem As Boolean, ByVal strFile As String, ByVal offset As Long, ByVal length As Long, ByVal BASSFlag As Integer) As Integer
    Public Declare Auto Function BASS_ChannelPlay Lib "bass.dll" (ByVal handle As Integer, ByVal restart As Boolean) As Boolean
    Public md As New BassMidiATLActiveXLib.BassMidiATL
    Public Const BASS_UNICODE As Integer = -2147483648
    Public chan As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        md.BASS_MIDI_Init(chan, Me.Handle)
        BASS_PluginLoad("bassmidi.dll", BASS_UNICODE)
        Button2.Enabled = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.FileName = String.Empty
        OpenFileDialog1.Filter = "MediaFile|*.*"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then BASS_StreamFree(chan)
            chan = BASS_StreamCreateFile(False, OpenFileDialog1.FileName, 0, 0, BASS_UNICODE)
            If Not CBool(chan) Then Return
            Me.Text = OpenFileDialog1.SafeFileName
            BASS_ChannelPlay(chan, False)
            Button2.Enabled = True
            md.BASS_MIDI_SetFont(chan, OpenFileDialog2.FileName)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        OpenFileDialog2.FileName = String.Empty
        OpenFileDialog2.Filter = "SoundFont(*.sf2)|*.sf2"
        If OpenFileDialog2.ShowDialog = Windows.Forms.DialogResult.OK Then
            md.BASS_MIDI_SetFont(chan, OpenFileDialog2.FileName)
        End If
    End Sub
End Class
« Last Edit: 25 Feb '17 - 12:05 by sak2005 »

sak2005

  • Posts: 1007
FreeDownload: BassMidiAPI  ::) Clickhere

Info: Include defualtfont in the resource and hidden.

Example:
Code: [Select]
Public Class Form1
    Public Declare Auto Function BASS_MIDI_Init Lib "BassMidiAPI.dll" (ByVal handle As Integer, ByVal win As IntPtr) As Boolean
    Public Declare Auto Function BASS_MIDI_SetFont Lib "BassMidiAPI.dll" (ByVal handle As Integer, ByVal newfont As String) As Boolean
    Public Declare Auto Function BASS_PluginLoad Lib "bass.dll" (ByVal strFile As String, ByVal BASSFlag As Integer) As Integer
    Public Declare Auto Function BASS_StreamFree Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Public Declare Auto Function BASS_StreamCreateFile Lib "bass.dll" (ByVal mem As Boolean, ByVal strFile As String, ByVal offset As Long, ByVal length As Long, ByVal BASSFlag As Integer) As Integer
    Public Declare Auto Function BASS_ChannelPlay Lib "bass.dll" (ByVal handle As Integer, ByVal restart As Boolean) As Boolean
    Public Const BASS_UNICODE As Integer = -2147483648
    Public chan As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BASS_MIDI_Init(chan, Me.Handle)
        BASS_PluginLoad("bassmidi.dll", BASS_UNICODE)
        Button2.Enabled = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then BASS_StreamFree(chan)
            chan = BASS_StreamCreateFile(False, OpenFileDialog1.FileName, 0, 0, BASS_UNICODE)
            BASS_ChannelPlay(chan, False)
            BASS_MIDI_SetFont(chan, OpenFileDialog2.FileName)
            Button2.Enabled = True
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        OpenFileDialog2.FileName = Nothing
        OpenFileDialog2.Filter = "SoundFont(*.sf2)|*.sf2"
        If OpenFileDialog2.ShowDialog = Windows.Forms.DialogResult.OK Then
            BASS_MIDI_SetFont(chan, OpenFileDialog2.FileName)
        End If
    End Sub
End Class
« Last Edit: 27 Feb '17 - 13:41 by sak2005 »

sak2005

  • Posts: 1007
TryNow! with BassCom.dll  ::) Download: Clickhere

Info: Include bass and aac , midi , wma dlls plugins to the resource and hidden.

Some methods sample:
Code: [Select]
BASS_StreamCreateFile(ฺByval strFile As String, Byval BASSFlag As Integer, ByVal sf As SoundFormat)
Code: [Select]
Pulic Enum SoundFormat
    AUTO = 0
    MIDI = 1
    MP4 = 2
    WMA = 3
End Enum

Example:
Code: [Select]
Public Class Form1
    Public Bass As New BassCom.BassClass
    Public chan As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Bass.BASS_Init(-1, 44100, 0, Me.Handle)
        ProgressBar1.Maximum = 32768
        ProgressBar2.Maximum = ProgressBar1.Maximum
        OpenFileDialog1.FileName = Nothing
        OpenFileDialog1.Filter = "Media Files(*.mid;*.wav;*.wma;*.mp3;*.mp4)|*.mid;*.wav;*.wma;*.mp3;*.mp4"
        TrackBar2.Maximum = 100
        TrackBar2.Value = TrackBar2.Maximum
        TrackBar3.Maximum = 100
        TrackBar3.Minimum = -100
        TrackBar3.Value = 0
        AddHandler Bass.PositionChanged, AddressOf Bass_PositionChanged
        AddHandler Bass.EndingChanged, AddressOf Bass_EndingChanged
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then Bass.BASS_StreamFree(chan)
            chan = Bass.BASS_StreamCreateFile(OpenFileDialog1.FileName, 0, BassCom.BassClass.SoundFormat.AUTO)
            If chan = 0 Then Return
            Label3.Text = Bass.BASS_FixTimeSpan(Bass.BASS_Duration, "mm:ss")
            TrackBar1.Maximum = CInt(Bass.BASS_MaxPosition)
            TrackBar2_Scroll(sender, e)
            If Label5.ForeColor = Color.Red Then
                Label5.ForeColor = Color.Black
                Bass.BASS_Volume(TrackBar2.Value)
            End If
            Button2_Click(sender, e)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Bass.BASS_ChannelPlay(chan, False)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Bass.BASS_ChannelPause(chan)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Bass.BASS_ChannelStop(chan)
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Bass.BASS_ChangePosition = CDbl(TrackBar1.Value)
    End Sub

    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        If Label5.ForeColor = Color.Black Then
            Bass.BASS_Volume(TrackBar2.Value)
        End If
    End Sub

    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        Bass.BASS_Balance(TrackBar3.Value)
    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        If CBool(chan) Then
            If Bass.BASS_GetIntVol <> 0 Then
                Bass.BASS_Volume(0)
                Label5.ForeColor = Color.Red
            Else
                Bass.BASS_Volume(TrackBar2.Value)
                Label5.ForeColor = Color.Black
            End If
        End If
    End Sub

    Private Sub Bass_PositionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Label1.Text = Bass.BASS_FixTimeSpan(Bass.BASS_CurrentPosition, "mm:ss")
        TrackBar1.Value = Bass.BASS_CurrentPosition
        Label2.Text = Bass.BASS_Status
        Label4.Text = Bass.BASS_CPU
        If Label5.ForeColor = Color.Red Then
            ProgressBar1.Value = 0
            ProgressBar2.Value = ProgressBar1.Value
            Return
        End If
        ProgressBar1.Value = Bass.BASS_LevelMeter(BassCom.BassClass.SoundChannel.LEFT)
        ProgressBar2.Value = Bass.BASS_LevelMeter(BassCom.BassClass.SoundChannel.RIGHT)
    End Sub

    Private Sub Bass_EndingChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If CheckBox1.Checked Then
            Button2_Click(sender, e)
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Bass.BASS_SetVolume(1)
        Bass.BASS_Close()
    End Sub
End Class
« Last Edit: 27 Feb '17 - 21:55 by sak2005 »

sak2005

  • Posts: 1007
Free Download: LibZPlayNet.dll  ::) Clickhere

Info: Include libzplay dll api to resource and hidden.

Example:
Code: [Select]
Imports LibZPlayNet

Public Class Form1
    Public zp As New LibZPlayNet.Zplay

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If zp.OpenFile(OpenFileDialog1.FileName, TStreamFormat.sfAutodetect) Then
                Dim StreamInfo As New TStreamInfo()
                zp.GetStreamInfo(StreamInfo)
                Label3.Text = ZPlay_Duration()
                TrackBar1.Maximum = ZPlay_MaxPosition()
                Button2_Click(sender, e)
                If Timer1.Interval <> 50 Then Timer1.Interval = 50
                If Not Timer1.Enabled Then Timer1.Start()
            Else
                MsgBox("Error! file not support.")
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        zp.StartPlayback()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        zp.PausePlayback()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        zp.StopPlayback()
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        ZPlay_SetPosition(TrackBar1.Value)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        TrackBar1.Value = ZPlay_CurrentPosition()
        Label1.Text = ZPlay_Position()
        Label2.Text = Zplay_Status()
        Zplay_VUMeter(ProgressBar1, ProgressBar2)
    End Sub

    Public Function ZPlay_Duration() As String
        Dim StreamInfo As New TStreamInfo()
        zp.GetStreamInfo(StreamInfo)
        Return String.Concat(StreamInfo.Length.hms.minute, " : ", StreamInfo.Length.hms.second)
    End Function

    Public Function ZPlay_MaxPosition() As Integer
        Dim StreamInfo As New TStreamInfo()
        zp.GetStreamInfo(StreamInfo)
        Return CInt(StreamInfo.Length.sec)
    End Function

    Public Function ZPlay_CurrentPosition() As Integer
        Dim pos As New TStreamTime()
        zp.GetPosition(pos)
        Return CInt(pos.sec)
    End Function

    Public Function ZPlay_Position() As String
        Dim pos As New TStreamTime()
        zp.GetPosition(pos)
        Return Format(Format(pos.hms.minute, "00") & " : " & Format(pos.hms.second, "00"))
    End Function

    Public Function ZPlay_SetPosition(ByVal pos As Integer) As Boolean
        Dim newpos As New TStreamTime()
        Dim StreamInfo As New TStreamInfo()
        zp.GetStreamInfo(StreamInfo)
        newpos.sec = CUInt(pos)
        Return zp.Seek(TTimeFormat.tfSecond, newpos, TSeekMethod.smFromBeginning)
    End Function

    Public Function Zplay_Status() As String
        Dim Status As New TStreamStatus()
        zp.GetStatus(Status)
        Dim str As String = Nothing
        If Status.fPlay Then
            str = "Playing"
        ElseIf Status.fPause Then
            str = "Paused"
        Else
            str = "Stopped"
        End If
        Return str
    End Function

    Public Sub Zplay_VUMeter(ByVal vuL As ProgressBar, ByVal vuR As ProgressBar)
        Dim left As Integer = 0
        Dim right As Integer = 0
        zp.GetVUData(left, right)
        If Zplay_IsPlaying Then
            vuL.Value = left
            vuR.Value = right
        Else
            vuL.Value = 0
            vuR.Value = vuL.Value
        End If
    End Sub

    Public ReadOnly Property Zplay_IsPlaying() As Boolean
        Get
            Dim bl As Boolean = False
            Dim Status As New TStreamStatus()
            zp.GetStatus(Status)
            If Status.fPlay Then
                bl = True
            End If
            Return bl
        End Get
    End Property

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        zp.Close()
    End Sub
End Class
« Last Edit: 28 Feb '17 - 17:14 by sak2005 »

sak2005

  • Posts: 1007
Free Download : BassEQLib.dll  ::) Clickhere

Info: Hidden bass.dll, BassNet.dll and bass_fx.dll
        Get Overload  methods function

Example1:
'Using type enums option is PARAM_EQ and PEAK_EQ

Code: [Select]
Public fx As Integer() = New Integer(4-0){}
Public chan As Integer

For i As Integer = 0 To 4
    fx(i) = BASS_EQ_SetFX(chan,  PEAK_EQ)
Next i
OR
Code: [Select]
BASS_EQ_SetFX(chan, fx, PEAK_EQ, 4)
« Last Edit: 2 Mar '17 - 15:30 by sak2005 »

sak2005

  • Posts: 1007
Free Download : VisualsLib.dll (Shared Library WithOut BassNet). Easy to used.  ::) Clickhere

New thread LevelMeter is AutoSet MaxValue properties progress.

Tip: Changed display between SpectrumLinePeak and SpectrumWave on a PictureBox.

Code: [Select]
Import VisualsLib
Private bl As Boolean = False
Public chan As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Not bl Then
            Visuals.CreateSpectrumLinePeak(chan, PictureBox1, Color.Green, Color.Orange, Color.White, Color.Black, 3, 2, 1, 20, False, False, True)
        Else
            Visuals.CreateSpectrumWave(chan, PictureBox1, Color.Green, Color.Orange, Color.Black, 2, False, False, True)
        End If
    End Sub

   Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If Not bl Then
            bl = True
        Else
            bl = False
        End If
    End Sub


Set timeCount toggle Display:
Code: [Select]
Private iCount As Integer = 0
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        iCount += 1
        If iCount < 500 Then
            Visuals.CreateSpectrumLinePeak(chan, PictureBox1, Color.Green, Color.Orange, Color.White, Color.Black, 3, 2, 1, 20, False, False, True)
        Else
            Visuals.CreateSpectrumWave(chan, PictureBox1, Color.Green, Color.Orange, Color.Black, 2, False, False, True)
            If iCount > 1000 Then iCount = 0
        End If
      End Sub

Example:
Code: [Select]
Imports VisualsLib

Public Class Form1
    Public Declare Auto Function BASS_Init Lib "bass.dll" (ByVal device As Integer, ByVal freq As Integer, ByVal flags As BASSInit, ByVal win As IntPtr, ByVal clsid As IntPtr) As Boolean
    Public Declare Auto Function BASS_StreamFree Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Public Declare Auto Function BASS_StreamCreateFile Lib "bass.dll" (ByVal mem As Boolean, ByVal strFile As String, ByVal offset As Long, ByVal length As Long, ByVal flags As BASSFlag) As Integer
    Public Declare Auto Function BASS_ChannelPlay Lib "bass.dll" (ByVal handle As Integer, ByVal restart As Boolean) As Boolean
    Public Declare Auto Function BASS_ChannelPause Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Public Declare Auto Function BASS_ChannelStop Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Public Declare Auto Function BASS_ChannelIsActive Lib "bass.dll" (ByVal handle As Integer) As Integer
    Public Declare Auto Function BASS_Free Lib "bass.dll" () As Boolean

    Private bl As Boolean = False
    Public chan As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle, IntPtr.Zero)
        Timer1.Interval = 50
        Visuals.MaxFFT = BASSData.BASS_DATA_FFT16384
        Me.CenterToScreen()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then BASS_StreamFree(chan)
            chan = BASS_StreamCreateFile(False, OpenFileDialog1.FileName, 0, 0, BASSFlag.BASS_UNICODE)
            Button2_Click(sender, e)
            Timer1.Enabled = True
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If BASS_ChannelIsActive(chan) = 0 Then
            BASS_ChannelPlay(chan, True)
        Else
            BASS_ChannelPlay(chan, False)
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        BASS_ChannelPause(chan)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        BASS_ChannelStop(chan)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Not bl Then
            Visuals.CreateSpectrumLinePeak(chan, PictureBox1, Color.Green, Color.Orange, Color.White, Color.Black, 3, 2, 1, 20, False, False, True)
        Else
            Visuals.CreateSpectrumWave(chan, PictureBox1, Color.Green, Color.Orange, Color.Black, 2, False, False, True)
        End If
        Visuals.LevelMeter(chan, ProgressBar1, ProgressBar2)
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If Not bl Then
            bl = True
        Else
            bl = False
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        BASS_Free()
    End Sub
End Class

<Flags()> _
Public Enum BASSInit
    BASS_DEVICE_DEFAULT = 0
End Enum
<Flags()> _
Public Enum BASSFlag
    BASS_DEFAULT = 0
    BASS_UNICODE = -2147483648
    BASS_MUSIC_LOOP = 4
End Enum
« Last Edit: 4 Mar '17 - 12:54 by sak2005 »

sak2005

  • Posts: 1007
How to easy Create BassPlugin sample ::) Download Lib only: Clickhere

Example:
Code: [Select]
Imports BASSPlugin
Public Class Form1
    Public Bass As IBASS = PluginLoader.LoadPlugin("BASSPlugin.dll")
    Public chan As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)
        ProgressBar1.Maximum = 32768
        ProgressBar2.Maximum = ProgressBar1.Maximum
        Me.CenterToScreen()
        AddHandler Bass.PositionChanged, New IBASS.PositionChangeEventHandler(AddressOf Bass_PositionChanged)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then Bass.BASS_StreamFree(chan)
            chan = Bass.BASS_StreamCreateFile(OpenFileDialog1.FileName, 0, 0, BASSFlag.BASS_MUSIC_LOOP)
            Label3.Text = Bass.FixTimeSpan(Bass.Duration, "mm:ss")
            TrackBar1.Maximum = CInt(Bass.MaxPosition)
            Button2_Click(sender, e)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Bass.BASS_ChannelPlay(chan, False)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Bass.BASS_ChannelPause(chan)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Bass.BASS_ChannelStop(chan)
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Bass.ChangePosition = CDbl(TrackBar1.Value)
    End Sub

    Private Sub Bass_PositionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TrackBar1.Value = CInt(Bass.CurrentPosition)
        Label1.Text = Bass.FixTimeSpan(Bass.CurrentPosition, "mm:ss")
        Label2.Text = Bass.Status
        Label4.Text = Bass.CPU
        ProgressBar1.Value = Bass.Level_Left
        ProgressBar2.Value = Bass.Level_Right
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Bass.BASS_Free()
    End Sub
End Class
« Last Edit: 14 Mar '17 - 21:18 by sak2005 »

sak2005

  • Posts: 1007
Video&AudioConvert Sample ;D Using FFmpeg and process hidden command.
eg: mp4 to mp3, mp4 to flv, mp4 to swf, mp3 to wav and other.

Example:
Code: [Select]
Public Sub StartAVConversion(ByVal proc As Process, ByVal ffmpeg As String, ByVal input As OpenFileDialog, ByVal output As SaveFileDialog, ByVal qualityAdj As TrackBar, ByVal bkw As System.ComponentModel.BackgroundWorker, ByVal prog As TextBox)
        Control.CheckForIllegalCrossThreadCalls = False
        If qualityAdj.Maximum <> 15 Then qualityAdj.Maximum = 15
        qualityAdj.Value = 5
        Dim quality As Integer = qualityAdj.Value * 2
        Dim startinfo As New System.Diagnostics.ProcessStartInfo
        Dim sr As StreamReader
        Dim args As String = " -i """ + input.FileName + """ -ar 22050 -qscale " & quality & " -y """ + output.FileName + """"
        Dim ffmpegOutput As String
        startinfo.FileName = ffmpeg
        startinfo.Arguments = args
        startinfo.UseShellExecute = False
        startinfo.WindowStyle = ProcessWindowStyle.Hidden
        startinfo.RedirectStandardError = True
        startinfo.RedirectStandardOutput = True
        startinfo.CreateNoWindow = True
        proc.StartInfo = startinfo
        proc.Start()
        sr = proc.StandardError
        Do
            If bkw.CancellationPending Then
                Exit Sub
            End If
            ffmpegOutput = sr.ReadLine
            prog.Text = ffmpegOutput
        Loop Until proc.HasExited And ffmpegOutput = Nothing Or ffmpegOutput = ""
        prog.Text = "Finished"
        Return
    End Sub

Download: VideoAudioConverter Application Sample : Clickhere

« Last Edit: 6 Jun '17 - 18:25 by sak2005 »

sak2005

  • Posts: 1007
Easy Sound Recorder Sample ::)

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
    Public Const MM_MCINOTIFY As Integer = 953
    Public Sub New()
        MyBase.New()
        StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Button1.Text = "Start"
        Button1.Cursor = Cursors.Hand
        Button2.Text = "Play"
        Button2.Cursor = Cursors.Hand
        Label1.Text = String.Empty
        Label2.Text = String.Empty
        MaximizeBox = False
        AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        Select Case Button1.Text
            Case "Start"
                mciSendString("open new type waveaudio alias recsound", Nothing, 0, 0)
                mciSendString("set recsound bitspersample 16", Nothing, 0, 0)
                mciSendString("set recsound samplespersec 44100", Nothing, 0, 0)
                mciSendString("set recsound channels 2", Nothing, 0, 0)
                mciSendString("record recsound", Nothing, 0, 0)
                Button1.Text = "Stop"
                Button2.Enabled = False
                Label1.Text = "Recording..."
            Case "Stop"
                mciSendString("save recsound c:\docume~1\admini~1\desktop\recsound.wav", Nothing, 0, 0)
                mciSendString("close recsound", "", 0, 0)
                Button1.Text = "Start"
                Button2.Enabled = True
                Label1.Text = "Stopped"
        End Select
    End Sub
    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Select Case Button2.Text
            Case "Play"
                If My.Computer.FileSystem.FileExists("c:\docume~1\admini~1\desktop\recsound.wav") Then
                    mciSendString("open c:\docume~1\admini~1\desktop\recsound.wav type waveaudio alias playsound", Nothing, 0, 0)
                    mciSendString("play playsound notify", Nothing, 0, Me.Handle.ToInt64)
                    Button1.Enabled = False
                    Button2.Text = "Stop"
                    Label2.Text = "Playing..."
                Else
                    MsgBox("File not found to record.")
                End If
            Case "Stop"
                mciSendString("close playsound", Nothing, 0, 0)
                Label2.Text = "Stopped"
                Button1.Enabled = True
                Button2.Text = "Play"
        End Select
    End Sub
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = MM_MCINOTIFY Then
            mciSendString("close playsound", Nothing, 0, 0)
            Label2.Text = "Stopped"
            Button1.Enabled = True
            Button2.Text = "Play"
        End If
        MyBase.WndProc(m)
    End Sub
End Class
« Last Edit: 9 Jun '17 - 10:48 by sak2005 »

sak2005

  • Posts: 1007
Sound Level Speakers Sample ;D

Code: [Select]
Public Class Form1
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As System.Text.StringBuilder, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    Private retdata As New System.Text.StringBuilder(128)
   
    Public Sub New()
        MyBase.New()
        StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        mciSendString("open new type waveaudio alias capture", Nothing, 0, 0)
        mciSendString("set capture bitspersample 16", Nothing, 0, 0)
        mciSendString("set capture samplespersec 11025", Nothing, 0, 0)
        mciSendString("set capture channels 2", Nothing, 0, 0)
        Timer1.Interval = 50
        Timer1.Enabled = True
        ProgressBar1.Maximum = 32768
        ProgressBar2.Maximum = 32768
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        mciSendString("status capture level", retdata, retdata.Capacity, 0)
        Dim Level As Integer = Integer.Parse(retdata.ToString)
        Me.Text = "Level: " & CInt(Level / 98000000).ToString
        If CInt(Level / 98000000) > 0 Then
            ProgressBar1.Value = CInt(Level And 65535)
            ProgressBar2.Value = CInt((Level >> 16) And 65535)
        Else
            ProgressBar1.Value = 0
            ProgressBar2.Value = 0
        End If
    End Sub
End Class
« Last Edit: 9 Jun '17 - 13:34 by sak2005 »

sak2005

  • Posts: 1007
NAudio MP3Player Sample ;D

Code: [Select]
Imports NAudio.Wave 'Referances NAudio.dll

Public Class Form1
    Private _Mp3FileReader As Mp3FileReader
    Private _WaveOut As WaveOut
    Public Sub New()
        MyBase.New()
        StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Button1.Text = "Load"
        Me.Button2.Text = "Play"
        Me.Button3.Text = "Pause"
        Me.Button4.Text = "Stop"
        Me.CheckBox1.Text = "Repeat"
        Me.Label1.Text = "00:00"
        Me.Label2.Text = "Stopped"
        Me.Label3.Text = "00:00"
        Me.PosTIme.Interval = 50
        Me._WaveOut = New WaveOut
        Me.OpenFileDialog1.FileName = Nothing
        Me.OpenFileDialog1.Filter = "MP3|*.mp3"
        AddHandler _WaveOut.PlaybackStopped, AddressOf Me._WaveOut_PlaybackStopped
        AddHandler Me.PositionChanged, AddressOf Me_PositionChanged
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If _WaveOut.PlaybackState = PlaybackState.Playing Then _Mp3FileReader.Close()
            _Mp3FileReader = New Mp3FileReader(OpenFileDialog1.FileName)
            _WaveOut.Init(_Mp3FileReader)
            Label3.Text = Mid(_Mp3FileReader.TotalTime.ToString, 4, 5)
            TrackBar1.Maximum = Bytes2Seconds(_Mp3FileReader.Length)
            Button2_Click(sender, e)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Not PosTIme.Enabled Then PosTIme.Start()
        _WaveOut.Play()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        _WaveOut.Pause()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        _Mp3FileReader.Seek(0, IO.SeekOrigin.Begin)
        _WaveOut.Stop()
    End Sub

    Private Sub _WaveOut_PlaybackStopped(ByVal sender As System.Object, ByVal e As StoppedEventArgs)
        If CheckBox1.Checked Then
            Button4_Click(sender, New EventArgs)
            Button2_Click(sender, New EventArgs)
        Else
            Button4_Click(sender, New EventArgs)
        End If
    End Sub

    Private Sub Me_PositionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Label1.Text = Mid(_Mp3FileReader.CurrentTime.ToString, 4, 5)
        TrackBar1.Value = Bytes2Seconds(_Mp3FileReader.Position)
        Label2.Text = _WaveOut.PlaybackState.ToString
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        SetPosition(Seconds2Bytes(TrackBar1.Value))
    End Sub

#Region "Length & Position Convert"
    Public Function Bytes2Seconds(ByVal lenpos As Long) As Integer
        Return CInt(lenpos / 100000)
    End Function

    Public Function Seconds2Bytes(ByVal lenpos As Integer) As Long
        Return CLng(lenpos * 100000)
    End Function

    Public Function SetPosition(ByVal pos As Long) As Boolean
        _Mp3FileReader.Position = pos
    End Function
#End Region

#Region "PositionChanged EventHandler"
    Private WithEvents PosTIme As New System.Windows.Forms.Timer
    Private Sub PosTime_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles PosTIme.Tick
        If _Mp3FileReader.Position < _Mp3FileReader.Length Then
            RaiseEvent PositionChanged(sender, New EventArgs)
        Else
            _WaveOut_PlaybackStopped(sender, New StoppedEventArgs)
        End If
    End Sub
    Public Event PositionChanged As EventHandler
#End Region
End Class


sak2005

  • Posts: 1007
SpectrumWaveEx Sample ::)

Code: [Select]
Public Class Form1
    Private Declare Auto Function BASS_PluginLoad Lib "bass.dll" (ByVal [file] As String, ByVal flags As Integer) As Integer
    Private Declare Auto Function BASS_PluginFree Lib "bass.dll" (ByVal fhandle As Integer) As Boolean
    Private Declare Auto Function BASS_Init Lib "bass.dll" (ByVal device As Integer, ByVal freq As Integer, ByVal flags As Integer, ByVal win As IntPtr, ByVal clsid As IntPtr) As Boolean
    Private Declare Auto Function BASS_StreamFree Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Private Declare Auto Function BASS_StreamCreateFile Lib "bass.dll" (ByVal mem As Boolean, ByVal [file] As String, ByVal offset As Long, ByVal length As Long, ByVal flags As Integer) As Integer
    Private Declare Auto Function BASS_ChannelPlay Lib "bass.dll" (ByVal handle As Integer, ByVal restart As Boolean) As Boolean
    Private Declare Auto Function BASS_ChannelPause Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Private Declare Auto Function BASS_ChannelStop Lib "bass.dll" (ByVal handle As Integer) As Boolean
    Private Declare Auto Function BASS_Free Lib "bass.dll" () As Boolean
    Private Declare Auto Function BASS_ChannelBytes2Seconds Lib "bass.dll" (ByVal handle As Integer, ByVal pos As Long) As Double
    Private Declare Auto Function BASS_ChannelGetLength Lib "bass.dll" (ByVal handle As Integer, ByVal mode As Integer) As Long
    Private Declare Auto Function BASS_ChannelGetPosition Lib "bass.dll" (ByVal handle As Integer, ByVal mode As Integer) As Long
    Private Declare Auto Function BASS_ChannelSeconds2Bytes Lib "bass.dll" (ByVal handle As Integer, ByVal pos As Double) As Long
    Private Declare Auto Function BASS_ChannelSetPosition Lib "bass.dll" (ByVal handle As Integer, ByVal pos As Long, ByVal mode As Integer) As Boolean

    Private OpenFileDialog1 As New System.Windows.Forms.OpenFileDialog
    Private Const BASS_UNICODE As Integer = -2147483648
    Private Const BASS_MUSIC_LOOP As Integer = 4

    Private Const FFT1024 As Integer = -2147483646
    Private Const FFT2048 As Integer = -2147483645
    Private chan, fplug1, fplug2, fft As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CenterToScreen()
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        PosTime.Interval = 50
        PosTime.SynchronizingObject = Me
        ComboBox1.SelectedIndex = 0
        FileIO.FileSystem.WriteAllBytes(IO.Path.Combine(Application.StartupPath, "bass.dll"), My.Resources.bass, True)
        FileIO.FileSystem.WriteAllBytes(IO.Path.Combine(Application.StartupPath, "bass_aac.dll"), My.Resources.bass_aac, True)
        FileIO.FileSystem.WriteAllBytes(IO.Path.Combine(Application.StartupPath, "basswma.dll"), My.Resources.basswma, True)
        BASS_Init(-1, 44100, 0, Me.Handle, IntPtr.Zero)
        fplug1 = BASS_PluginLoad("bass_aac.dll", BASS_UNICODE)
        fplug2 = BASS_PluginLoad("basswma.dll", BASS_UNICODE)
        AddHandler Me.PositionChanged, AddressOf Me_PositionChanged
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(chan) Then BASS_StreamFree(chan)
            Me.Text = OpenFileDialog1.SafeFileName
            chan = BASS_StreamCreateFile(False, OpenFileDialog1.FileName, 0, 0, 0 Or BASS_UNICODE)
            TrackBar1.Maximum = CInt(BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetLength(chan, 0)))
            Label4.Text = TimeSpan.FromSeconds(TrackBar1.Maximum).ToString
            Button2_Click(sender, e)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Not PosTime.Enabled Then PosTime.Start()
        BASS_ChannelPlay(chan, False)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        BASS_ChannelPause(chan)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        BASS_ChannelSetPosition(chan, 0, 0)
        BASS_ChannelStop(chan)
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        BASS_ChannelSetPosition(chan, BASS_ChannelSeconds2Bytes(chan, CDbl(TrackBar1.Value)), 0)
    End Sub

    Private Sub Me_PositionChanged(ByVal sender As System.Object, ByVal e As PositionChangeEventArgs)
        'TrackBar1.Value = CInt(BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetPosition(chan, 0)))
        'OR
        TrackBar1.Value = CInt(e.CurrentPosition(chan))
        Label3.Text = TimeSpan.FromSeconds(TrackBar1.Value).ToString
        If RadioButton1.Checked Then
            'Visual.SpectrumLineOne(chan, PictureBox1, Color.Green, Color.White, TrackBar2.Value, TrackBar3.Value, fft)
            'OR
            Visual.SpectrumLineOne(chan, PictureBox1, Color.Green, Color.White)
        Else
            'Visual.SpectrumLineTwo(chan, PictureBox1, Color.White, Color.Green, TrackBar2.Value, TrackBar3.Value, fft)
            'OR
            Visual.SpectrumLineTwo(chan, PictureBox1, Color.White, Color.Green)
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        BASS_PluginFree(fplug1)
        BASS_PluginFree(fplug2)
        BASS_Free()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedItem.ToString
            Case "1024"
                fft = FFT1024
            Case "2048"
                fft = FFT2048
            Case Else
                Exit Select
        End Select
    End Sub

    Private WithEvents PosTime As New System.Timers.Timer
    Private Sub PosTime_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles PosTime.Elapsed
        If BASS_ChannelGetPosition(chan, 0) < BASS_ChannelGetLength(chan, 0) Then
            RaiseEvent PositionChanged(sender, New PositionChangeEventArgs)
        Else
            Button4_Click(sender, New EventArgs)
        End If
    End Sub
    Public Event PositionChanged As PositionChangeEventHandler

    Private Sub Label5_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.MouseHover
        Label5.BackColor = System.Drawing.SystemColors.Info
    End Sub

    Private Sub Label5_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.MouseLeave
        Label5.BackColor = System.Drawing.SystemColors.ButtonFace
    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        Label5.BackColor = System.Drawing.SystemColors.ButtonFace
        If CBool(chan) Then BASS_StreamFree(chan)
        Me.Text = IO.Path.GetFileName(IO.Path.Combine(Application.StartupPath, "Sound\Test.mp3"))
        chan = BASS_StreamCreateFile(False, IO.Path.Combine(Application.StartupPath, "Sound\" & Me.Text), 0, 0, BASS_UNICODE Or BASS_MUSIC_LOOP)
        TrackBar1.Maximum = CInt(BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetLength(chan, 0)))
        Label4.Text = TimeSpan.FromSeconds(TrackBar1.Maximum).ToString
        Button2_Click(sender, e)
    End Sub
End Class

Public NotInheritable Class Visual
    Private Declare Auto Function BASS_ChannelGetData Lib "bass.dll" (ByVal handle As Integer, ByVal buffer As Single(), ByVal length As Integer) As Integer
    Private Declare Auto Function BASS_ChannelIsActive Lib "bass.dll" (ByVal handle As Integer) As Integer

    Public Shared Sub SpectrumLineOne(ByVal handle As Integer, ByVal pic As PictureBox, ByVal color1 As Color, ByVal color2 As Color, Optional ByVal gain1 As Integer = 2, Optional ByVal gain2 As Integer = 2, Optional ByVal datafft As Integer = -2147483645)
        Dim bit As Bitmap = New Bitmap(pic.Width, pic.Height)
        Dim graph As Graphics = Graphics.FromImage(bit)
        Dim pen1 As New Pen(color1, 3)
        Dim pen2 As New Pen(color2, 3)
        Dim buff(1023) As Single
        Dim X As Integer
        Dim Y As Integer
        BASS_ChannelGetData(handle, buff, datafft)
        If BASS_ChannelIsActive(handle) = 1 Then
            For X = 0 To pic.Width Step 4
                Y = CInt(buff(X + 10 - gain1) ^ 0.3 * pic.Height * gain2)
                If Y > pic.Height Then Y = pic.Height
                graph.DrawLine(pen1, X + 2, pic.Height, X + 2, pic.Height - Y)
                graph.DrawLine(pen2, X + 2, pic.Height - Y, X + 2, pic.Height - Y - 2)
            Next X
        End If
        pic.Image = bit
    End Sub

    Public Shared Sub SpectrumLineTwo(ByVal handle As Integer, ByVal pic As PictureBox, ByVal color1 As Color, ByVal color2 As Color, Optional ByVal gain1 As Integer = 2, Optional ByVal gain2 As Integer = 2, Optional ByVal datafft As Integer = -2147483645)
        Dim bit As Bitmap = New Bitmap(pic.Width, pic.Height)
        Dim graph As Graphics = Graphics.FromImage(bit)
        Dim pen1 As New Pen(color1, 3)
        Dim pen2 As New Pen(color2, 3)
        Dim buff(1023) As Single
        Dim X As Integer
        Dim Y As Integer
        BASS_ChannelGetData(handle, buff, datafft)
        If BASS_ChannelIsActive(handle) = 1 Then
            For X = 0 To pic.Width Step 4
                Y = CInt(buff(X + 10 - gain1) ^ 0.4 * pic.Height * gain2)
                If Y > pic.Height Then Y = pic.Height
                If Y < 0 Then Y = 0
                graph.DrawLine(pen1, X + 2, pic.Height \ 2, X + 2, pic.Height \ 2 - Y)
                graph.DrawLine(pen2, X + 2, pic.Height \ 2 + Y, X + 2, pic.Height \ 2)
            Next X
        End If
        pic.Image = bit
    End Sub
End Class

Public Delegate Sub PositionChangeEventHandler(ByVal sender As Object, ByVal e As PositionChangeEventArgs)

Public Class PositionChangeEventArgs
    Private Declare Auto Function BASS_ChannelBytes2Seconds Lib "bass.dll" (ByVal handle As Integer, ByVal pos As Long) As Double
    Private Declare Auto Function BASS_ChannelGetPosition Lib "bass.dll" (ByVal handle As Integer, ByVal mode As Integer) As Long
    Public Function CurrentPosition(ByVal handle As Integer) As Double
        Return BASS_ChannelBytes2Seconds(handle, BASS_ChannelGetPosition(handle, 0))
    End Function
End Class


« Last Edit: 20 Jun '17 - 12:11 by sak2005 »

sak2005

  • Posts: 1007
Learn more about using libZPlay.  ::)  Free new LibZPlayNet.dll  ;D Clickhere

 For direct codes in the libzplay:

Init Operate using.. zplay_CreateZPlay()
OpenFile using.. zplay_AddFile(ByVal objptr As System.UInt32, ByVal sFileName As String, ByVal nFormat As Integer) As Integer
Playing using..  zplay_Play(ByVal objptr As System.UInt32)

For nFormat. Using.. TStreamFormat Enum
Code: [Select]
Public Enum TStreamFormat
        #Region "TStreamFormat Fields"
        sfUnknown = 0
        sfMp3 = 1
        sfOgg = 2
        sfWav = 3
        sfPCM = 4
        sfFLAC = 5
        sfFLACOgg = 6
        sfAC3 = 7
        sfAacADTS = 8
        sfWaveIn = 9
        sfAutodetect = 1000
        #End Region
    End Enum

Example:
Code: [Select]
Public Class Form1
    Declare Auto Function zplay_CreateZPlay Lib "libzplay.dll" () As UInteger
    Declare Auto Function zplay_AddFile Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByVal sFileName As String, ByVal nFormat As Integer) As Integer
    Declare Auto Function zplay_Play Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_Close Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Public Const autodetect As Integer = 1000
    Private opf As New OpenFileDialog
    Private WithEvents btnplayonload As New Button
    Private objptr As UInteger
    Public Sub New()
        MyBase.New()
        InitializeComponent()
        btnplayonload.Text = "PlayOnLoad"
        Me.Controls.Add(btnplayonload)
        Me.objptr = 0
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objptr = zplay_CreateZPlay()
    End Sub
    Private Sub btnplayonload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplayonload.Click
        If opf.ShowDialog = Windows.Forms.DialogResult.OK Then
            If CBool(objptr) Then zplay_Close(objptr)
            zplay_AddFile(objptr, opf.FileName, autodetect)
            zplay_Play(objptr)
        End If
    End Sub
End Class
« Last Edit: 24 Jun '17 - 20:21 by sak2005 »

sak2005

  • Posts: 1007
About with Length, Position, Seek or SetPosition of sound file to open. ::)

Length using.. zplay_GetStreamInfoW(ByVal objptr As System.UInt32, ByRef pInfo As TStreamInfo_Internal) As Integer

The pInfo is Structure to used.

Code: [Select]
<StructLayout(LayoutKind.[Explicit])>  _
    Private Structure TStreamInfo_Internal
        #Region "TStreamInfo_Internal Fields"
        <FieldOffset(0)>  _
        Public SamplingRate As Integer
        <FieldOffset(4)>  _
        Public ChannelNumber As Integer
        <FieldOffset(8)>  _
        Public VBR As Boolean
        <FieldOffset(12)>  _
        Public Bitrate As Integer
        <FieldOffset(16)>  _
        Public Length As TStreamTime
        <FieldOffset(44)>  _
        Public Description As System.IntPtr
        #End Region
    End Structure

Code: [Select]
<StructLayout(LayoutKind.[Explicit])>  _
    Public Structure TStreamTime
        #Region "TStreamTime Fields"
        <FieldOffset(0)>  _
        Public sec As System.UInt32
        <FieldOffset(4)>  _
        Public ms As System.UInt32
        <FieldOffset(8)>  _
        Public samples As System.UInt32
        <FieldOffset(12)>  _
        Public hms As TStreamHMSTime
        #End Region
    End Structure

Code: [Select]
<StructLayout(LayoutKind.[Explicit])>  _
    Public Structure TStreamHMSTime
        #Region "TStreamHMSTime Fields"
        <FieldOffset(0)>  _
        Public hour As System.UInt32
        <FieldOffset(4)>  _
        Public minute As System.UInt32
        <FieldOffset(8)>  _
        Public second As System.UInt32
        <FieldOffset(12)>  _
        Public millisecond As System.UInt32
        #End Region
    End Structure

Merge get length in seconds and convert seconds to formatTime with GetStreamInfo function
Code: [Select]
Public Sub GetStreamInfo(ByRef info As TStreamInfo)
        Dim v_internal As TStreamInfo_Internal
        zplay_GetStreamInfoW(Me.objptr, v_internal)
        info.Length = v_internal.Length
        info.Description = System.Runtime.InteropServices.Marshal.PtrToStringUni(v_internal.Description)
    End Sub

If GetLength in Seconds. Return info.Length.second
If convert seconds to formatTime. Return  info.Length.hms.second.ToString("00")

Sample code for table time format 3 digi is.. 00:00:00
Code: [Select]
String.ConCat(info.Length.hms.hour.ToString("00"), ":", info.Length.hms.minute.ToString("00"), ":", info.Length.hms.second.ToString("00"))

« Last Edit: 25 Jun '17 - 04:44 by sak2005 »

sak2005

  • Posts: 1007
For GetCurrentPosition and SetPosition
Code: [Select]

Public Sub GetPosition(ByRef time As TStreamTime)
    zplay_GetPosition(objptr, time)
End Sub

 
Code: [Select]
 
Public Function Seek(ByVal TimeFormat As TTimeFormat, ByRef Position As TStreamTime, ByVal MoveMethod As TSeekMethod) As Boolean
    Return zplay_Seek(objptr, TimeFormat, Position, MoveMethod) = 1
End Function

Code: [Select]
Public Enum TSeekMethod As Integer
    smFromBeginning = 1
    smFromEnd = 2
    smFromCurrentForward = 4
    smFromCurrentBackward = 8
End Enum

Code: [Select]
Public Enum TTimeFormat As UInteger
    tfMillisecond = 1
    tfSecond = 2
    tfHMS = 4
    tfSamples = 8
End Enum
« Last Edit: 25 Jun '17 - 05:20 by sak2005 »

sak2005

  • Posts: 1007
Example: Can copy and paste to the editor.
Code: [Select]
Public Class Form1
    Declare Auto Function zplay_CreateZPlay Lib "libzplay.dll" () As UInteger
    Declare Auto Function zplay_AddFile Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByVal sFileName As String, ByVal nFormat As TStreamFormat) As Integer
    Declare Auto Function zplay_Play Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_Pause Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_Resume Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_Stop Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_Close Lib "libzplay.dll" (ByVal objptr As System.UInt32) As Integer
    Declare Auto Function zplay_GetStreamInfoW Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByRef pInfo As TStreamInfo_Internal) As Integer
    Declare Auto Sub zplay_GetPosition Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByRef pTime As TStreamTime)
    Declare Auto Function zplay_Seek Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByVal fFormat As TTimeFormat, ByRef pTime As TStreamTime, ByVal nMoveMethod As TSeekMethod) As Integer
    Declare Auto Sub zplay_GetStatus Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByRef pStatus As TStreamStatus)
    Declare Auto Sub zplay_GetVUData Lib "libzplay.dll" (ByVal objptr As System.UInt32, ByRef pnLeftChannel As Integer, ByRef pnRightChannel As Integer)
    Private opf As New OpenFileDialog
    Private WithEvents btnload, btnplay As New Button
    Private lblLen, lblPos As New Label
    Private WithEvents trackPos As New TrackBar
    Private WithEvents progPos As New ProgressBar
    Private progL, progR As New ProgressBar
    Private WithEvents timer1 As New Timer
    Private vuL, vuR As Integer
    Private v_str As String = String.Empty
    Private objptr As UInteger

    Public Sub New()
        MyBase.New()
        Me.StartPosition = FormStartPosition.CenterScreen
        InitializeComponent()
        Me.Height = 140
        Me.MaximizeBox = False
        Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
        btnload.Text = "Load"
        btnplay.Text = "Play"
        btnplay.Location = New Point(0, 25)
        lblLen.Text = "00:00"
        lblPos.Text = lblLen.Text
        lblLen.Location = New Point(100, 5)
        lblPos.Location = New Point(250, 5)
        trackPos.AutoSize = False
        progPos.Bounds = New Rectangle(108, 30, 171, 12)
        progL.Bounds = New Rectangle(0, 85, 145, 12)
        progL.RightToLeft = Windows.Forms.RightToLeft.Yes
        progL.RightToLeftLayout = True
        progR.Bounds = New Rectangle(145, 85, 145, 12)
        trackPos.Bounds = New Rectangle(100, 50, 185, 21)
        timer1.Interval = 50
        Me.Controls.AddRange(New Control() {btnload, btnplay, lblLen, lblPos, trackPos, progPos, progL, progR})
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        objptr = zplay_CreateZPlay()
    End Sub

    Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click
        Select Case btnload.Text
            Case "Load"
                If opf.ShowDialog = Windows.Forms.DialogResult.OK Then
                    If CBool(objptr) Then zplay_Close(objptr)
                    zplay_AddFile(objptr, opf.FileName, TStreamFormat.sfAutodetect)
                    Dim v_internal As TStreamInfo_Internal
                    Dim info As TStreamInfo
                    zplay_GetStreamInfoW(Me.objptr, v_internal)
                    info.Length = v_internal.Length
                    lblLen.Text = String.Concat(info.Length.hms.minute.ToString("00"), ":", info.Length.hms.second.ToString("00"))
                    trackPos.Maximum = CInt(info.Length.sec)
                    progPos.Maximum = trackPos.Maximum
                    btnplay_Click(sender, e)
                    timer1.Enabled = True
                End If
            Case "Pause"
                zplay_Pause(objptr)
                btnload.Text = "Resume"
            Case Else
                zplay_Play(objptr)
                btnload.Text = "Pause"
        End Select
    End Sub

    Private Sub btnplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplay.Click
        If opf.FileName = Nothing Then Return
        Select Case btnplay.Text
            Case "Play"
                zplay_Play(objptr)
                btnplay.Text = "Stop"
                btnload.Text = "Pause"
            Case Else
                zplay_Stop(objptr)
                btnplay.Text = "Play"
                btnload.Text = "Load"
        End Select
    End Sub

    Private Sub timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick
        Dim pos As TStreamTime
        zplay_GetPosition(objptr, pos)
        trackPos.Value = CInt(pos.sec)
        progPos.Value = trackPos.Value
        lblPos.Text = String.Concat(pos.hms.minute.ToString("00"), ":", pos.hms.second.ToString("00"))
        If Status = "Stopped" Then
            btnload.Text = "Load"
            btnplay.Text = "Play"
        End If
        Me.Text = String.Concat(opf.SafeFileName, " - ", Status)
        zplay_GetVUData(objptr, vuL, vuR)
        If Status = "Playing" Then
            progL.Value = vuL
            progR.Value = vuR
        Else
            progL.Value = 0
            progR.Value = progL.Value
        End If
    End Sub

    Private Sub trackPos_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackPos.Scroll
        If opf.FileName = Nothing Then Return
        Dim pos As New TStreamTime
        pos.sec = trackPos.Value
        zplay_Seek(objptr, TTimeFormat.tfSecond, pos, TSeekMethod.smFromBeginning)
        If Status = "Paused" Then
            zplay_Pause(objptr)
        End If
    End Sub

    Private Sub progPos_Click(ByVal sender As Object, ByVal e As EventArgs) Handles progPos.Click
        SetProgressBarPosition(sender, e)
        If Status = "Paused" Then
            zplay_Pause(objptr)
        End If
    End Sub

    Public Function SetProgressBarPosition(ByVal sender As Object, ByVal e As MouseEventArgs) As Integer
        Dim newpos As New TStreamTime()
        Dim v_internal As TStreamInfo_Internal
        Dim v_info As TStreamInfo
        zplay_GetStreamInfoW(objptr, v_internal)
        v_info.Length = v_internal.Length
        newpos.sec = CUInt(e.X * v_info.Length.sec / CDbl((CType(sender, ProgressBar)).Size.Width))
        Return zplay_Seek(objptr, TTimeFormat.tfSecond, newpos, TSeekMethod.smFromBeginning)
    End Function

    Public Property Status() As String
        Get
            Dim pStatus As TStreamStatus
            zplay_GetStatus(objptr, pStatus)
            If pStatus.fPlay Then
                v_str = "Playing"
            ElseIf pStatus.fPause Then
                v_str = "Paused"
            Else
                v_str = "Stopped"
            End If
            Return v_str
        End Get
        Set(ByVal value As String)
            v_str = value
        End Set
    End Property
End Class

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.[Explicit])> _
  Public Structure TStreamTime
#Region "TStreamTime Fields"
    <Runtime.InteropServices.FieldOffset(0)> _
    Public sec As System.UInt32
    <Runtime.InteropServices.FieldOffset(4)> _
    Public ms As System.UInt32
    <Runtime.InteropServices.FieldOffset(8)> _
    Public samples As System.UInt32
    <Runtime.InteropServices.FieldOffset(12)> _
    Public hms As TStreamHMSTime
#End Region
End Structure

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.[Explicit])> _
Public Structure TStreamInfo_Internal
#Region "TStreamInfo_Internal Fields"
    <Runtime.InteropServices.FieldOffset(0)> _
    Public SamplingRate As Integer
    <Runtime.InteropServices.FieldOffset(4)> _
    Public ChannelNumber As Integer
    <Runtime.InteropServices.FieldOffset(8)> _
    Public VBR As Boolean
    <Runtime.InteropServices.FieldOffset(12)> _
    Public Bitrate As Integer
    <Runtime.InteropServices.FieldOffset(16)> _
    Public Length As TStreamTime
    <Runtime.InteropServices.FieldOffset(44)> _
    Public Description As System.IntPtr
#End Region
End Structure

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.[Explicit])> _
   Public Structure TStreamInfo
#Region "TStreamInfo Fields"
    <Runtime.InteropServices.FieldOffset(0)> _
    Public SamplingRate As Integer
    <Runtime.InteropServices.FieldOffset(4)> _
    Public ChannelNumber As Integer
    <Runtime.InteropServices.FieldOffset(8)> _
    Public VBR As Boolean
    <Runtime.InteropServices.FieldOffset(12)> _
    Public Bitrate As Integer
    <Runtime.InteropServices.FieldOffset(16)> _
    Public Length As TStreamTime
    <Runtime.InteropServices.FieldOffset(44)> _
    Public Description As String
#End Region
End Structure

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.[Explicit])> _
   Public Structure TStreamHMSTime
#Region "TStreamHMSTime Fields"
    <Runtime.InteropServices.FieldOffset(0)> _
    Public hour As System.UInt32
    <Runtime.InteropServices.FieldOffset(4)> _
    Public minute As System.UInt32
    <Runtime.InteropServices.FieldOffset(8)> _
    Public second As System.UInt32
    <Runtime.InteropServices.FieldOffset(12)> _
    Public millisecond As System.UInt32
#End Region
End Structure

<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.[Explicit])> _
   Public Structure TStreamStatus
#Region "TStreamStatus Fields"
    <Runtime.InteropServices.FieldOffset(0)> _
    Public fPlay As Boolean
    <Runtime.InteropServices.FieldOffset(4)> _
    Public fPause As Boolean
    <Runtime.InteropServices.FieldOffset(8)> _
    Public fEcho As Boolean
    <Runtime.InteropServices.FieldOffset(12)> _
    Public fEqualizer As Boolean
    <Runtime.InteropServices.FieldOffset(16)> _
    Public fVocalCut As Boolean
    <Runtime.InteropServices.FieldOffset(20)> _
    Public fSideCut As Boolean
    <Runtime.InteropServices.FieldOffset(24)> _
    Public fChannelMix As Boolean
    <Runtime.InteropServices.FieldOffset(28)> _
    Public fSlideVolume As Boolean
    <Runtime.InteropServices.FieldOffset(32)> _
    Public nLoop As Integer
    <Runtime.InteropServices.FieldOffset(36)> _
    Public fReverse As Boolean
    <Runtime.InteropServices.FieldOffset(40)> _
    Public nSongIndex As Integer
    <Runtime.InteropServices.FieldOffset(44)> _
    Public nSongsInQueue As Integer
#End Region
End Structure

<Flags()> _
Public Enum TTimeFormat
#Region "TTimeFormat Fields"
    tfMillisecond = 1
    tfSecond = 2
    tfHMS = 4
    tfSamples = 8
#End Region
End Enum

<Flags()> _
Public Enum TSeekMethod
#Region "TSeekMethod Fields"
    smFromBeginning = 1
    smFromEnd = 2
    smFromCurrentForward = 4
    smFromCurrentBackward = 8
#End Region
End Enum

<Flags()> _
Public Enum TStreamFormat
#Region "TStreamFormat Fields"
    sfUnknown = 0
    sfMp3 = 1
    sfOgg = 2
    sfWav = 3
    sfPCM = 4
    sfFLAC = 5
    sfFLACOgg = 6
    sfAC3 = 7
    sfAacADTS = 8
    sfWaveIn = 9
    sfAutodetect = 1000
#End Region
End Enum

sak2005

  • Posts: 1007
Learn more with ZPlay EQualizer ::)

If wanted new creatting band frequncy using..
Code: [Select]
'For using with eq 10 bands.
Dim freq As Integer() = New Integer(9) {47, 63, 120, 250, 500, 1000, 2000, 4000, 8000, 12000}
        player.SetEqualizerPoints(freq, 9)

New code modify for SetEqualizerParameters, using range TrackbarEQ min and max is -100, 0, 100
Code: [Select]
Public Function SetEqualizerParameters(ByVal BandIndex As Integer, ByRef [value] As Integer) As Boolean
        Return SetEqualizerBandGain(BandIndex, CInt(20000 / 100 * [value]))
    End Function

sak2005

  • Posts: 1007
Modify code SetEqualizerPoints to SetFreqsOfBands
Code: [Select]
Public Function SetFreqsOfBands(ByRef FreqPointArray() As Integer, ByVal NumberOfPoints As Integer) As Boolean
    For i As Integer = 0 To NumberOfPoints
        Return SetEqualizerPoints(FreqPointArray, NumberOfPoints)
    Next i
End Function   

Example:
Code: [Select]
Dim arr As Integer() = New Integer(9) {47, 63, 120, 250, 500, 1000, 2000, 4000, 8000, 12000}
SetFreqsOfBands(arr, 9)

For VB6 get now ZPlayActiveX.ocx : Clickhere
« Last Edit: 29 Jun '17 - 08:02 by sak2005 »

sak2005

  • Posts: 1007
Tip: ;D
If the activeX.dll file is used on another computer. The activeX.dll file must be registered before using the program as an example.

Added ActiveX.dll to.. Debug folder (for register)
Added this code to.. Application.Designer.vb
Example:
Code: [Select]
'Application.Designer.vb

'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.3053
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On

Namespace My

    'NOTE: This file is auto-generated; do not modify it directly.  To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
        Public Sub New()
            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
            Shell("regsvr32 ZPlayMFCActiveX.ocx /s") 'register command.
            Me.IsSingleInstance = False
            Me.EnableVisualStyles = True
            Me.SaveMySettingsOnExit = True
            Me.ShutdownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
        End Sub

        <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.WindowsApplication1.Form1
        End Sub
    End Class
End Namespace


« Last Edit: 30 Jun '17 - 02:46 by sak2005 »

sak2005

  • Posts: 1007
Tip: Set Attribute Balance Volume in the mciSendString ::)

You can modify using for other program.

Example:
Code: [Select]
public int SetBalanceVolume(int bal)
{   
    if (bal > 0)
    {
        sCommand = "setaudio sound left volume to " + (1000 - bal).ToString();
        mciSendString(sCommand, null, 0, IntPtr.Zero);
    } 
    if (bal < 0)
    {
        sCommand = "setaudio sound right volume to " + (1000 + bal).ToString();
        mciSendString(sCommand, null, 0, IntPtr.Zero);
    }
    return bal;
}

sak2005

  • Posts: 1007
Tip: Get sound length , sound position and setposition in seconds in the mciSendString ::)

Convert miliseconds to seconds.

Example:
Code: [Select]
public double Duration
        {
            get
            {
                sCommand = "status sound length";
                mciSendString(sCommand, buffer, buffer.Capacity, IntPtr.Zero);
                return (double)(int.Parse(buffer.ToString())/1000);
            }
        }

Code: [Select]
public double CurrentPosition
        {
            get
            {
                sCommand = "status sound position";
                mciSendString(sCommand, buffer, buffer.Capacity, IntPtr.Zero);
                return (double)(int.Parse(buffer.ToString()) / 1000);
            }
        }

Code: [Select]
public int SetPosition(double pos)
        {
            sCommand = "status sound mode";
            mciSendString(sCommand, buffer, buffer.Capacity, IntPtr.Zero);
            if (buffer.ToString() == "playing")
            {
                sCommand = "play sound from " + (pos * 1000).ToString();
                return mciSendString(sCommand, null, 0, IntPtr.Zero);
            }
            else
            {
                 if (buffer.ToString()=="paused")
                {
                    sCommand = "seek sound to " + (pos * 1000).ToString();
                    mciSendString(sCommand, null, 0, IntPtr.Zero);
                    sCommand = "pause sound";
                    return mciSendString(sCommand, null, 0, IntPtr.Zero);
                }
                else
                {
                    sCommand = "seek sound to " + (pos * 1000).ToString();
                    return mciSendString(sCommand, null, 0, IntPtr.Zero);
                }
            }
       }

sak2005

  • Posts: 1007
Tip: Sound Level in the mciSendString ::)

If created mciSound.dll, Using.. mciSendString
If created WaveAudio Recording capture Level, Using.. mciSendStringA

If create new function VuMeter in vb.net Dlls, but using in VC++, will not work.
Becouse, function parameters is using ByRef Val.

Example: VuMeter functton in the VB.net Dlls
Code: [Select]
Public NotInheritable Class Level
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal strReturn As System.Text.StringBuilder, ByVal BufferLength As Integer, ByVal hwndCallback As IntPtr) As Integer
    Private Shared strReturn As System.Text.StringBuilder
    Private Shared hr As Integer
    Shared Sub New()
        strReturn = New System.Text.StringBuilder(128)
    End Sub
    Public Shared Function Init(ByVal bitspersample As Integer, ByVal samplespersec As Integer, ByVal channels As Integer) As Boolean
        hr = mciSendString("open new type waveaudio alias capture", Nothing, 0, IntPtr.Zero)
        hr = mciSendString("set capture bitspersample " & bitspersample.ToString(), Nothing, 0, IntPtr.Zero)
        hr = mciSendString("set capture samplespersec " & samplespersec.ToString(), Nothing, 0, IntPtr.Zero)
        hr = mciSendString("set capture channels " & channels.ToString(), Nothing, 0, IntPtr.Zero)
        If hr <> 0 Then Return False
    End Function
    Public Shared Function Peak() As Integer
        hr = mciSendString("status capture level", strReturn, strReturn.Capacity, IntPtr.Zero)
        If hr = 0 Then Return Integer.Parse(strReturn.ToString())
    End Function
    Public Shared Function LowWord(ByVal peak As Integer) As Integer
        Return peak And 65535
    End Function
    Public Shared Function HiWord(ByVal peak As Integer) As Integer
        Return (peak >> 16) And 65535
    End Function
End Class

Status and State code functions:
Code: [Select]
Public ReadOnly Property Status() As String
        Get
            Command = "status sound mode"
            Dim result As String = String.Empty
            hr = mciSendString(Command, strBuffer, strBuffer.Capacity, IntPtr.Zero)
            If hr = 0 Then
                result = strBuffer.ToString()
            Else
                result = "installed"
            End If
            Return result
        End Get
    End Property
    Public Overridable Function State() As Integer
        Dim v_state As Integer
        Select Case Status()
            Case "playing"
                v_state = 1
            Case "paused"
                v_state = 2
            Case Else
                v_state = 0
        End Select
        Return v_state
    End Function

Example : VB.net VuMeter functions
Code: [Select]
Public Overridable Function VuInit(ByVal samplespersec As Integer, ByVal bitspersample As Integer, ByVal channels As Integer) As Boolean
        Return Level.Init(bitspersample, samplespersec, channels)
    End Function

 Public Function VuMeter(ByRef LeftChannel As Integer, ByRef RightChannel As Integer) As Boolean
        If State() = 1 Then
            LeftChannel = Level.LowWord(Level.Peak)
            RightChannel = Level.HiWord(Level.Peak)
        Else
            LeftChannel = 0
            RightChannel = 0
        End If
    End Function

Example : Using  VuMeter functions in VB.net Dlls in the VC++ Form application.
Code: [Select]
public ref class Form1 : public System::Windows::Forms::Form
{
    public:
    Form1(void)
   {
                InitializeComponent();
                player->VuInit(22050, 16, 2);  //freqs = 44100, 22050, 11025
   }

private: System::Void mciSound_PositionChanged(System::Object^  sender, mciSoundCom::PositionChangeEventArgs^  e)
    {
         int LeftChannel = 0;
int RightChannel = 0;
player->VuMeter(LeftChannel, RightChannel);
progressBar1->Value = LeftChannel;
         progressBar2->Value = RightChannel;
    }
« Last Edit: 4 Jul '17 - 21:40 by sak2005 »

sak2005

  • Posts: 1007
Tip: ffmpeg convert and lame encode ::)

If short song convert on long song or from file to record , length time and position time is not match, must encode before using.

If wanted  stopping convert then push button is Q, that after will auto encode and next is delete file at not used.

Example: convert and encode and file delete on the file.bat command line.
Code: [Select]
@echo off
start/wait ffmpeg -i video.mp4 -vn -r 44100 -b 128k audio.mp3
start/wait lame audio.mp3 sound.mp3
start/wait del audio.mp3
exit
« Last Edit: 11 Jul '17 - 10:15 by sak2005 »

firstname

  • Posts: 10
sak2005, thanks man for all your kind and genteel work! It's a really very interesting and helpful to make use of all code you are providing.

sak2005

  • Posts: 1007
sak2005, thanks man for all your kind and genteel work! It's a really very interesting and helpful to make use of all code you are providing.

Thank you for follow We will continue to offer good things to continue. ;D