26 May '13 - 02:13 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2 3  All
  Reply  |  Print  
Author Topic: BASS_VIS in Visual Basic?  (Read 14591 times)
Chance
Guest
« on: 23 Apr '04 - 16:56 »
Reply with quoteQuote

Has the BASS_VIS.DLL ever been successfully tested in Visual Basic?

I have a VisChan (25954900), a RecChan and the Render function returns 25834753. So it seems to work, but nothing is rendered to the picturebox hdc.

The supplied vb bas file has some minor syntax errors (fixed them of course), so i guess noone ever tested it.

If someone got it to work, please tell me how Smiley
Logged
Irrational86
Posts: 960


« Reply #1 on: 24 Apr '04 - 11:31 »
Reply with quoteQuote

Hi, i am the programmer of BassVis...i have not tested it in VB because i dont have VB at this time, and could you please send me those minor bugs to fix? I will try to translate the delphi example to VB once i find the VB6 cd again
Logged
Patrice
Posts: 72


« Reply #2 on: 24 Apr '04 - 16:18 »
Reply with quoteQuote

Note: When I translated BASS_VIS to PB (PowerBASIC)
I was unable to have it running using implicit linking.
I had to use LoadLibrary and use DWORD pointers to make it works.

Quote
The supplied vb bas file has some minor syntax er
I am not a VB user, but here is how I would translate it to VB
' BASS_VIS include file

Global Const BASS_VIS_ERROR_OK      = 0     ' no error, all OK
Global Const BASS_VIS_ERROR_HANDLE  = 1     ' the "handle" provided is not valid
Global Const BASS_VIS_ERROR_LOAD    = 2     ' the plugin could not be loaded
Global Const BASS_VIS_ERROR_INIT    = 3     ' the plugin could/has not be initialized
Global Const BASS_VIS_ERROR_PARAM   = 4     ' invalid parameter given
Global Const BASS_VIS_ERROR_UNKNOWN = 256   ' unknown error

' BASS_SONIQUEVIS_CreateVis flags
Global Const BASS_VIS_NOINIT        = 1

' BASS_SONIQUEVIS_SetConfig flags
Global Const BASS_VIS_CONFIG_FFTAMP         = 1
Global Const BASS_VIS_CONFIG_FFT_SKIPCOUNT  = 2 ' Skip count range is from 0 to 3 (because of limited FFT request size)
Global Const BASS_VIS_CONFIG_WAVE_SKIPCOUNT = 3 ' Skip count range is from 0 to (...) try it out, whenever Bass crashes or does not return enough sample data

' Bass FFT Amplification values
Global Const BASS_VIS_FFTAMP_NORMAL  = 1
Global Const BASS_VIS_FFTAMP_HIGH    = 2
Global Const BASS_VIS_FFTAMP_HIGHER  = 3
Global Const BASS_VIS_FFTAMP_HIGHEST = 4

' BASS_VIS_FindPlugin flags
Global Const BASS_VIS_FIND_SONIQUE   = 1
' return value type
Global Const BASS_VIS_FIND_COMMALIST = 4
  ' Delphi's comma list style (item1,item2,"item 3",item4,"item with space")
  ' the list ends with single NULL character
Global Const BASS_VIS_FIND_NULLCHAR = 8
  ' C/C++ style list (item1#0item2#0item 3#0item4#0item with space#0#0)
  ' the list ends with double NULL character

DECLARE FUNCTION BASS_SONIQUEVIS_CreateVis LIB "bass_vis.dll" (BYVAL zFile AS STRING, BYVAL zVisConfig AS STRING, BYVAL flags AS LONG, BYVAL w AS LONG, BYVAL h AS LONG) AS LONG
     DECLARE SUB BASS_SONIQUEVIS_Free LIB "bass_vis.dll" (BYVAL hVis AS LONG)
DECLARE FUNCTION BASS_SONIQUEVIS_GetName LIB "bass_vis.dll" (BYVAL hVis AS LONG) AS LONG
DECLARE FUNCTION BASS_SONIQUEVIS_Clicked LIB "bass_vis.dll" (BYVAL hVis AS LONG, BYVAL x AS LONG, BYVAL y AS LONG) AS LONG
     DECLARE SUB BASS_SONIQUEVIS_Resize LIB "bass_vis.dll" (BYVAL hVis AS LONG, BYVAL nw AS LONG, BYVAL nh AS LONG)
DECLARE FUNCTION BASS_VIS_GetConfig LIB "bass_vis.dll" (BYVAL VISoption AS LONG) AS LONG
     DECLARE SUB BASS_VIS_SetConfig LIB "bass_vis.dll" (BYVAL VISoption AS LONG, BYVAL value AS LONG)
DECLARE FUNCTION BASS_VIS_FindPlugins LIB "bass_vis.dll" (BYVAL zPlugins AS STRING, BYVAL flags AS LONG) AS LONG
DECLARE FUNCTION BASS_VIS_GetInterval LIB "bass_vis.dll" (BYVAL hVis AS LONG) AS LONG
DECLARE FUNCTION BASS_VIS_ErrorGetCode LIB "bass_vis.dll" () AS LONG
DECLARE FUNCTION BASS_SONIQUEVIS_Render LIB "bass_vis.dll" (BYVAL VisChan AS LONG, BYVAL chan AS LONG, BYVAL hDC AS LONG) AS LONG
Logged
Chance
Guest
« Reply #3 on: 25 Apr '04 - 07:19 »
Reply with quoteQuote

Well, thx Patrice. I just fixed the syntax errors (the 'option' conflict and the leftover semicolons) but the line

Declare Function BASS_SONIQUEVIS_CreateVis Lib "bass_vis.dll" (ByVal f As Any, ByVal visconfig As Any, flags As Long, w As Integer, h As Integer) As Long

just references the last 3 values (ByRef by default), so using ByVal there fixed it. It worked all the time, but rendered a 0x0 sized viz. I didn't pay enough attention. Roll Eyes

Use Patrice's include file, seems to work so far.
Logged
Chance
Guest
« Reply #4 on: 25 Apr '04 - 10:11 »
Reply with quoteQuote

Quote
I will try to translate the delphi example to VB once i find the VB6 cd again.

I did so. Download it here:

http://home.tiscali.de/cryogen/download/vistest_vb.zip

Includes a compiled binary and Patrice's include (bas).
Maybe you can pack it into your next release.

Anyway, thanks for your help! Grin
Logged
Irrational86
Posts: 960


« Reply #5 on: 25 Apr '04 - 14:27 »
Reply with quoteQuote

Awesome, thanks a lot, now all i am missing is a C example, which i am hoping some nice person is going to help me make, since i dont know much C.

Chance, thanks for the fix up on the ByVal, i seem to have missed those param types...

Thanks a lot Chance, and Patrice for your examples and translations

Update is in the Bass page under "More Add-ons"
« Last Edit: 25 Apr '04 - 16:52 by XMinioNX » Logged
Irrational86
Posts: 960


« Reply #6 on: 26 Apr '04 - 00:09 »
Reply with quoteQuote

Chance, e-mail me at "e-mail hidden" please
« Last Edit: 21 Oct '11 - 15:59 by Irrational86 » Logged
strat59
Guest
« Reply #7 on: 28 Apr '04 - 00:25 »
Reply with quoteQuote

if ya'll are speaking of PicVis...i have it running in vb.net.
However; the timer is running behind causing a delay
in the visual. If i use the main timer the sound speeds up about
double speed. The pitch doesn't change....strange....

Any tips on how to hack the timers to sync, or use 2 timers
would be cool!

srvjayb@bsc.net
Logged
Irrational86
Posts: 960


« Reply #8 on: 28 Apr '04 - 02:59 »
Reply with quoteQuote

strat59, i dont understand what you mean? What is PicVis? And if you are talking BassVis, it does NOT touch the sound buffers, it simply requests data being played and uses the Sonique plugins to display them.
Logged
strat59
Guest
« Reply #9 on: 30 Apr '04 - 04:55 »
Reply with quoteQuote

The code i used for Vis.........

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
      Dim bit As Bitmap = New Bitmap(PicVis.Width, PicVis.Height)
      Dim graph As Graphics = Graphics.FromImage(bit)
      Dim RedPen As New Pen(Color.PaleVioletRed, 2)
      Dim BluePen As New Pen(Color.Blue, 2)

      Dim d(1023) As Single

      Dim playing
      Dim X As Integer

      graph.SmoothingMode = SmoothingMode.AntiAlias

      playing = Bass.BASS_ChannelIsActive(Strm)
      If playing = 0 Then Exit Sub

      Bass.BASS_ChannelGetData(Strm, d(0), Bass.BASS_DATA_FFT1024)

      For X = 0 To PicVis.Width Step 2

         Y = Sqrt(d(X + 1)) * 3 * PicVis.Height - 4
         If Y > PicVis.Height Then Y = PicVis.Height
         graph.DrawEllipse(RedPen, X, PicVis.Height - Y, X, PicVis.Height)
         graph.DrawEllipse(BluePen, X, PicVis.Height - Y, X + 5, PicVis.Height)

         'graph.DrawEllipse(RedPen, X, PicVis.Height - d(X) * 1000, X, PicVis.Height)
         'graph.DrawEllipse(BluePen, X, PicVis.Height - d(X) * 1000, X + 5, PicVis.Height)
      Next

      'draw the visual onto the picturebox
      PicVis.Image = bit
   End Sub

As u can see it uses PicVis and also timers 1 - 10.....Also strm Bass.BASS_ChannelGetData(Strm, d(0), ........
I have tried using strm, and also created new strm1 and used that.
The Visual runs but as i stated it is not in sync with the music.
R U using vb.net 2003 edition?
Is any one?HuhHuhHuhHuh?
I spend a great amount of time converting the code and as of now i have the player and some effects working......Cheers!
Strat59  srvjayb@bsc.net
Logged
Irrational86
Posts: 960


« Reply #10 on: 30 Apr '04 - 05:26 »
Reply with quoteQuote

This isnt directly related to BassVis, but I have no idea why the visuals on VB are out of sync. The BassVis example for VB runs out of sync and slow in my computer. Same as the code you showed above runs slow on VB.NET, I guess its a VB issue and not the code one.
Logged
strat59
Guest
« Reply #11 on: 13 May '04 - 06:50 »
Reply with quoteQuote

i am working in vb.net
The vis works with my BASS_CD
i have 2 other instances of the VIS on strm1 and srtm2
When i use strm1 the sound speeds up about double.....mmmmm
strm2 runs the VIS but the timing is off. Behind.

i am trying to tweak my app so that all timers are in sync....or
disabled if one is on......i have 8 instances of timer and haven't
solved the thing as of yet. If your'e in vb 6 i really never worked
in that enough to know or help you much. From what i hear it
is like apples to oranges.....

  ' Ya need all these at least
Public Sub PicVis5()
        Dim bit As Bitmap = New Bitmap(PicVis4.Width, PicVis4.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 playing
        Dim X As Int64
        'Dim Y As Int64

        graph.SmoothingMode = SmoothingMode.AntiAlias
        'Timer10.Enabled = True
        playing = Bass.BASS_ChannelIsActive(strm1)
        If playing = 0 Then Exit Sub

        Bass.BASS_ChannelGetData(strm1, d(0), Bass.BASS_DATA_FFT1024)
        ' strm1 = Bass.BASS_StreamCreateFile(BassLib2.Bass.BassBool.BassFalse, TextBox1.Text, 0, 0, BassLib2.Bass.StreamCreateFile.BASS_STREAM_DECODE)    'Bass.BASS_STREAM_AUTOFREE
        For X = 0 To PicVisD.Width    ' Step 4

            Y = Sqrt(d(X + 1)) * 3 * PicVisD.Height    ' - 4

            If Y > PicVisD.Height Then Y = PicVisD.Height
            If Y < 0 Then Y = 0
            graph.DrawLine(WhitePen, X + 2, PicVisD.Height \ 2, X + 2, PicVisD.Height \ 2 - Y)    ' \ 2)

            graph.DrawLine(PurplePen, X + 2, PicVisD.Height \ 2 + Y, X + 2, PicVisD.Height \ 2)     '- Y \ 2)
        Next

        'draw the visual onto the picturebox
        PicVisD.Image = bit
    End Sub
  Private Sub PicVis_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
      'Dim VisWindow As Graphics = PicVis.CreateGraphics
       ''''''''' 'Timer10.Enabled = True

End Sub

strat
Logged
strat59
Guest
« Reply #12 on: 13 May '04 - 06:54 »
Reply with quoteQuote

i just realized i already posted that.....opps.....tooo much coffee
sorry bout that. cant un-post not a member...
Back to work......

Strat
Logged
Irrational86
Posts: 960


« Reply #13 on: 13 May '04 - 23:03 »
Reply with quoteQuote

Well...this time you explained a bit more and clearer. What kind of channel are you passing to BassVis? Is it a decoding channel? If so, then thats why, you shouldnt give BassVis a decoding channel, give it the channel outputting the sound. If you are not using a decoding channel, then I have no idea why this happens (because BassVis doesnt touch anything on the channel, only the Bass_ChannelGetData function). Maybe you can post the piece of code you use with Bass and BassVis
Logged
Svante
Posts: 296


« Reply #14 on: 29 May '04 - 21:02 »
Reply with quoteQuote

VB:s built-in timer hasn't got a very high resolution, so you have to use a Windows API multimedia timer. I've changed Chance:s example to use multimedia timers, with some optimizions and vbAccelerators thread safe API call it works fine:

Edit: Is now in the BASSVIS package
« Last Edit: 13 Jun '04 - 12:37 by Svante » Logged
Irrational86
Posts: 960


« Reply #15 on: 29 May '04 - 21:54 »
Reply with quoteQuote

Svante, thanks for the update but while testing it, the GUI freezes and only the vis runs, so I have no way of stopping it. This is because of the resolution you have of "1" and this value should be a bit higher, otherwise it will be very CPU intensive.
« Last Edit: 29 May '04 - 22:00 by XMinioNX » Logged
Svante
Posts: 296


« Reply #16 on: 30 May '04 - 16:22 »
Reply with quoteQuote

You can try different intervals with the interval setting in the GUI, change the value to a higher one before starting the vis.
Logged
Irrational86
Posts: 960


« Reply #17 on: 31 May '04 - 12:49 »
Reply with quoteQuote

That is the timer delay (interval), and the second parameter is the resolution, which means how accurate the timer will be, and setting this value to "1" is very intensive on the CPU (at least on mine)
Logged
Svante
Posts: 296


« Reply #18 on: 9 Jun '04 - 11:32 »
Reply with quoteQuote

That is the timer delay (interval), and the second parameter is the resolution, which means how accurate the timer will be, and setting this value to "1" is very intensive on the CPU (at least on mine)

Now the resolution is set to the same value as the interval

Edit: Is now in the BASSVIS package
« Last Edit: 13 Jun '04 - 12:37 by Svante » Logged
Irrational86
Posts: 960


« Reply #19 on: 9 Jun '04 - 21:43 »
Reply with quoteQuote

Thanks for updating it, but I had already changed it to some higher value, it has been in the package for a while now, you can get it from the bass page ( http://www.un4seen.com/bass.html#addons )
Logged
Pages: [1] 2 3  All
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines