Author Topic: BASS.Net API, BASS_FX problem with Vista  (Read 8218 times)

a2tom

  • Posts: 9
BASS.Net API, BASS_FX problem with Vista
« on: 9 Aug '08 - 16:14 »

This problem was posted about on a different old thread, but the solution there didn't help me.  Was suggested to start a new thread, so here it is.

I'm working in Visual Basic.Net/Visual Studio using the BASS.Net API.  Developed under XP.  Testing on Vista gives the following:

Dim PlayStream As Integer = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_DEFAULT)

works fine on both XP and Vista - plays File.

HOWEVER,
Dim DecodeStream As Integer = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_STREAM_DECODE)
Dim PlayStream As Integer = BassFx.BASS_FX_TempoCreate(DecodeStream, BASSFlag.BASS_DEFAULT)

works fine on XP, but on Vista gives me:
PlayStream = 0
ErrorCode = BASS_OK

Very puzzling - if everything is OK, why don't I get a stream?

The other thread seemed to suggest that one needed to use the TempoCreate flag BASSFXFlag.BASS_DEFAULT instead of BASSFlag.BASS_DEFAULT (note the FX in the first flag).  However, I have searched the documentation and find no instance of BASSFXFlag.BASS_DEFAULT!  I would assume the defaults flags are all 0 anyway? 

So I'm stuck.  Why can't I get an FX Tempo stream on Vista?  Happy to provide more info...

Tom

radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #1 on: 10 Aug '08 - 11:00 »
Being honest, i have never discovered something like this and I am also developing under Vista.
And yes, there is definitly no BASSFXFlag. So your original code looks just fine!

Have you tried the provided VB or C# examples using the tempo stream? And did they also not work?

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #2 on: 10 Aug '08 - 15:29 »
Regarding the provided examples - I can run WaveFormExample from the Bass.net samples on Vista and it works.  But that isn't using BASS_FX_TempoCreate.  The vb samples that came with bass_fx.dll aren't vb.net - had no success trying to convert it and I'm not setup for VB6 etc.

Since my problem seems to be unique, I suspect it has to do with my Vista computer?  Don't know what.  I just installed DirectX 10 - should OK in that regard.

But so that I can be sure, I've created a simple app.  You can run it from here (ClickOnce, web run only, won't install anything on your computer - it brings my copies of bass.dll and bass_fx.dll with it, as well as a target MP3):

<deleted>

I'll paste the code into my next post if you'd rather that.

When I run it on my XP box, both Play buttons play Big Bill Broonzy's Shuffle Rag.  When I run it on my Vista box, only the simple playback works.  The decode stream plugged into BASS_FX_TempoCreate gives me a message box with error 0.  No stream, but BASS_OK.

If both buttons work onVista for you, then it must be my computer...

Tom

« Last Edit: 16 Aug '08 - 02:26 by a2tom »

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #3 on: 10 Aug '08 - 15:44 »

This is the complete code for my test app.  It requires Form1 with Button1, Button2, Button3.  You'd also have to fix File to something that worked for you.

I should clarify that the error I get on Vista is PlayStream - the DecodeStream always returns non-zero.


Code: [Select]
Imports Un4seen.Bass
Imports Un4seen.Bass.AddOn.Fx

Public Class Form1

    Private File As String = My.Application.Info.DirectoryPath & "\Shuffle Rag.mp3"
    Private PlayStream As Integer = 0
    Private DecodeStream As Integer = 0

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle, Nothing)
        Catch ex As Exception
            MsgBox("Could not load bass.dll")
            Me.Close()
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ResetStreams()
        PlayStream = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_DEFAULT)
        If PlayStream <> 0 Then
            Bass.BASS_ChannelPlay(PlayStream, False)
        Else
            MsgBox("PlayStream error: " & Bass.BASS_ErrorGetCode())
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ResetStreams()
        DecodeStream = Bass.BASS_StreamCreateFile(File, 0, 0, BASSFlag.BASS_STREAM_DECODE)
        If DecodeStream <> 0 Then
            PlayStream = BassFx.BASS_FX_TempoCreate(DecodeStream, BASSFlag.BASS_DEFAULT)
            If PlayStream <> 0 Then
                Bass.BASS_ChannelPlay(PlayStream, False)
            Else
                MsgBox("PlayStream error: " & Bass.BASS_ErrorGetCode())
            End If
        Else
            MsgBox("DecodeStream error: " & Bass.BASS_ErrorGetCode())
        End If
    End Sub

    Private Sub ResetStreams()
        If PlayStream <> 0 Then Bass.BASS_StreamFree(PlayStream)
        If DecodeStream <> 0 Then Bass.BASS_StreamFree(DecodeStream)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If PlayStream <> 0 Then Bass.BASS_ChannelStop(PlayStream)
    End Sub

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


radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #4 on: 10 Aug '08 - 15:49 »
Actually I get an error when I try to download you test app.
However, you might try to call "BASS_FX_GetVersion" in you Form1_Load method to ensure, that the BASS_FX add-on was loaded before you call BASS_FX_TempoCreate.

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #5 on: 10 Aug '08 - 16:46 »

This ClickOnce thing will drive me crazy, still trying to figure out what ones need to do to get those links to work all the time (it works when I click it...)  But forget the link, not trying to solve that problem right now!

I added the following to my code:

Code: [Select]
MsgBox("BASS_GetVersion = " & Bass.BASS_GetVersion() & Chr(13) & Chr(10) & _
               "BASS_FX_GetVersion = " & BassFx.BASS_FX_GetVersion())

And on BOTH XP and Vista get:
BASS_GetVersion = 33816833
BASS_FX_GetVersion = 33816578

This doesn't surprise me, since if it wasn't loading bass_fx.dll at all, it would throw an exception when I tried to call its functions, wouldn't it?

It seems to me that bass_fx tries to create the stream but for some reason fails on my Vista computer, but fails for a reason it doesn't have an error code for.

Tom

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #6 on: 10 Aug '08 - 21:21 »
alright, I'm about 90% sure I've got this ClickOnce web deployment working now.  This is the test app:

<deleted>

It would be nice to know that someone else can get both play buttons to work under Vista, since that would isolate the problem to my machine.

Tom
« Last Edit: 16 Aug '08 - 02:27 by a2tom »

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #7 on: 11 Aug '08 - 14:04 »
Are you able to reproduce the problem with BASS_FX's precompiled C\BIN\TEMPO.EXE example? That should help to narrow-down where the problem lies.

radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #8 on: 11 Aug '08 - 16:30 »
Now the app is launching.
Your app also returns "chan=0" on my Vista machine here.

However my demo apps are just running fine with alomost exactly the same code you provided here.
Except, that I am always explicitly calling BASS_FX_GetVersion() beforehand.
So it must be something else?! Which BASS and BASS_FX versions are you using?
Have you tried calling BASS_FX_GetVersion() in your app?

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #9 on: 12 Aug '08 - 03:13 »

First, sorry, I hadn't realized there were compiled samples.  As I suspected based on the last comment, tempo.exe works on all of my computers, including the problematic Vista.

Next, yes, the current version of my BASStest app (same link as below) is set to call several functions before TempoCreate on the FX button.  The output I get is as follows (functions called in the order shown):

Quote
On XP:
BASS_GetVersion = 2040101
BASS_FX_GetVersion = 2040100
BASS_FX_ReverseCreate = -1342177278
BASS_FX_BPM_DecodeGet = 46
BASS_FX_TempoCreate = -1342177277

On Vista:
BASS_GetVersion = 2040101
BASS_FX_GetVersion = 2040100
BASS_FX_ReverseCreate = 0
BASS_FX_BPM_DecodeGet = -1
BASS_FX_TempoCreate = 0

I should have included it in the output, but none of that would get reported if I hadn't already gotten a non-zero Decode channel, so Bass itself is working on XP and Vista.  I said it above, but Bass can even play the stream directly just fine so it's getting device, etc.

Thus, none of my FX calls work on Vista except FX_GetVersion, which seems to be fine and tells that the dll is loaded.  Now that I'm converting to hex, I can see that (I think) my bass and bass_fx are current versions.

Which all means that apparently the problem is related to - what?  I'm no expert here, but I'm pretty stumped. 

I guess is becomes pertinent to say that I'm developing under:
Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5
Installed Edition: VB Express
XP Professional
Version 2002
SP2

Tom

radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #10 on: 12 Aug '08 - 10:31 »
To get an idea what could cause your problem I guess the best thing to do is to create a complete new test application. A very simple one which does nothing else then:
- call BASS_Init
- call BASS_FX_GetVersion
- create a decoding stream via BASS_StreamCreateFile
- create a tempo stream via BASS_FX_TempoCreate
- play the tempo stream via BASS_ChannelPlay
nothing more!

Then debug your app and see what you get.

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #11 on: 12 Aug '08 - 13:09 »
OK, I've created just about the simplest test app I can at:
<deleted>

The complete code is:

Code: [Select]
Module Module1

    Sub Main()
        Try

            Console.WriteLine("Really simple console test of bass_fx.dll" & Chr(13) & Chr(10))

            Un4seen.Bass.Bass.BASS_Init(-1, 44100, Un4seen.Bass.BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Nothing)

            Dim BGV As Integer = Un4seen.Bass.Bass.BASS_GetVersion()
            Console.WriteLine("BASS_GetVersion = " & Hex(BGV) & Chr(13) & Chr(10))

            Dim BGFXV As Integer = Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_GetVersion()
            Console.WriteLine("BASS_FX_GetVersion = " & Hex(BGFXV) & Chr(13) & Chr(10))

            Dim DS As Integer = Un4seen.Bass.Bass.BASS_StreamCreate(44100, 2, Un4seen.Bass.BASSFlag.BASS_STREAM_DECODE, Nothing, Nothing)
            Console.WriteLine("BASS_StreamCreate = " & DS & Chr(13) & Chr(10))

            Dim PS As Integer = Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_TempoCreate(DS, Un4seen.Bass.BASSFlag.BASS_DEFAULT)
            Console.WriteLine("BASS_FX_TempoCreate = " & PS & Chr(13) & Chr(10))

            System.Threading.Thread.Sleep(15000)

            Un4seen.Bass.Bass.BASS_Free()

        Catch ex As Exception

            Console.WriteLine("Error" & Chr(13) & Chr(10))
            System.Threading.Thread.Sleep(15000)

        End Try


    End Sub

Here is what I get as returns on the console:

Quote
On XP:

Really simple console test of bass_fx.dll

**********************************************************
* BASS.NET API  by Bernd Niedergesaess - Version 2.4.1.0 *
*       Freeware version - For personal use only!        *
* c 2008 TEN53 GbR www.ten53.de  BASS by www.un4seen.com *
**********************************************************
BASS_GetVersion = 2040101

BASS_FX_GetVersion = 2040100

BASS_StreamCreate = -1342177279

BASS_FX_TempoCreate = -1342177278




On Vista:

Really simple console test of bass_fx.dll

BASS_GetVersion = 2040101

BASS_FX_GetVersion = 2040100

BASS_StreamCreate = -1342177279

BASS_FX_TempoCreate = 0

**********************************************************
* BASS.NET API  by Bernd Niedergesaess - Version 2.4.1.0 *
*       Freeware version - For personal use only!        *
* c 2008 TEN53 GbR www.ten53.de  BASS by www.un4seen.com *
**********************************************************


This is all as before - it all works on my XP machine (which is the machine on which I do the coding and building) but not on my Vista machine.  But note that I am running the published app on both (not just in debugging mode).

The obvious difference between XP and Vista seems to be when the BASS.NET splash information is being displayed.  Meaningful?  If you think it is, just remember that the form applications load bass.net right away (since I initialize Bass on form open).  I can let it sit for a long time, even play a song using bass alone, and it will still not use TempoCreate correctly.

Tom


« Last Edit: 16 Aug '08 - 02:28 by a2tom »

radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #12 on: 12 Aug '08 - 13:30 »
Hi Tom,

could it be, that you have any driver or whatever issue on your Vista machine.
As it looks like you are the only one having this problem.

Further tests here on my machine reveived, that I have no problem with all my test apps.

So I am not sure how this 'One-Click' installments work, as on my Vista machine I get the same result as you do when launching your application. So I guess it must have something to do with the web-installment stuff.
Have you tried to build a native .Net windows forms or console application which you do NOT run and execute via the web?

Maybe it is the web-deployment which prevents it from running correctly?

As said all runs fine when executing a normal console or windows forms application.

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #13 on: 13 Aug '08 - 14:36 »
Code: [Select]
            Un4seen.Bass.Bass.BASS_Init(-1, 44100, Un4seen.Bass.BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Nothing)

I suspect the problem may be the lack of a window handle (which is used by DirectSound) in the BASS_Init call. That won't be a problem when creating a decoding channel as DirectSound isn't used then, but it could be a problem with a normal playback channel. So I think BASS_FX is probably a bit of a red herring; you could confirm that by trying to create a normal BASS stream, ie. don't use the BASS_STREAM_DECODE flag.

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #14 on: 14 Aug '08 - 03:25 »
no, it's not the handle, since the forms applications use Me.Handle, and I could always play a stream directly with Bass (i.e. not a decode).  It really was only bass_fx that was failing. 

But I'm being pedantic since I have SOLVED THE PROBLEM.  For those keeping score at home, see if you can figure this one out! (and maybe this will help someone else someday)

I arrived at the solution by:
1) installing Visual Studio and Bass.net on my Vista machine, then running the same test program in debug mode.  And it worked fine, problem did not occur.
2) then building and publishing the test program from the Vista machine.  Now it had the same problem as above - bass_fx worked on XP, not on Vista. 

What that told me is that the Vista was only having the problem once it was published, not when debugging.  (this was true even for a locally installed program, not just the web publish) 

The only thing left was the way I was transferring the dlls with my published app.  Indeed, if I forced it to use dlls I copied by hand into the app directory, then it was fine on Vista.

Soooo..... I was transferring the dlls with the app as resource files that got copied at installation.  This obviously works to some large degree - bass.dll and even bass_fx.dll were copied and accessible and fully functional on XP.  However, bass_fx.dll wasn't completely functional on Vista (but was there and being loaded). 

Confused yet?  What I next did was instead of transferring the dll directly into the app directory, I transferred it into app directory\Resources.  Then I added Form Load code that checks for the dll in the app directory, and if it isn't present, it executes a file copy from \Resources.  And now bass_fx.dll works even on Vista!

Someone smarter than me will have to explain why the act of copying the dll from one directory into the app directory is different than simply putting it into the app directory in the first place, and why this is only necessary on Vista, and only with bass_fx.dll.

I love Microsoft.

Tom


radio42

  • Posts: 4576
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #15 on: 14 Aug '08 - 07:21 »
Hi Tom,

this is really a great finding! I suspected, that it must have something to do with the 'installation' process...but I also would have never come to such an idea!
And yes, I also would be curious to know the background of all this.

BASS exposes an add-on API which is being used by BASS_FX. So when the BASS_FX dll is being loaded it calls some internal BASS methods to register itself as an add-on. To me it looks, like this 'registration' fails. That would explain, why you don't get any errors when calling a BASS_FX function, but in effect these FX function can not really run well, as the add-on registration never worked.

Anyhow, that doesn't explain, why copying the dll's from a resource dir to the app dir works and directly extracting them to the app dir doesn't.

Sounds like a 'we-will-never-know' issue due to whatever Vista internal things?!

gretar

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #16 on: 1 Apr '09 - 09:40 »
Hi!

I have the same problem!

Could you please explain in more detail how you do the copying of the bass_fx from the form_load method?

I'm little bit confused about the Resources folder, because when the app has been published/built there isn't any Resources folder available, all the resources are included in one dll i.e. in NameOfTheApp.resources.dll

I would be thrilled if someone can point me to the right direction here!

a2tom

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #17 on: 2 Apr '09 - 01:50 »

Happy to provide what info I can, but it has been quite a while since I've looked at this project, or worked in Visual Studio.  Don't sue me if I say something wrong... 

Below is the relevant VB code called on form load.  On first run of the program, it copies from the folder Resources, which contains the dlls carried with app, into the app directory:

Code: [Select]
    Private Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitializeBass()
    End Sub

    Private Sub InitializeBass()
        LoadBASSFile("bass.dll")
        LoadBASSFile("bass_fx.dll")
        LoadBASSFile("basswma.dll")
        LoadBASSFile("tags.dll")
        Try
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle, Nothing)
        Catch ex As Exception
            MsgBox("Could not initialize BASS")
            Me.Close()
        End Try
    End Sub

    Private Sub LoadBASSFile(ByVal File As String)
        Dim p As String = My.Application.Info.DirectoryPath & "\"
        Dim pr As String = p & "Resources\"
        Try
            If Not My.Computer.FileSystem.FileExists(p & File) Then
                My.Computer.FileSystem.CopyFile(pr & File, p & File)
            End If
        Catch ex As Exception
            MsgBox(ex.Message.ToString)
            MsgBox("Could not load required file " & File)
            Me.Close()
        End Try
    End Sub

But I think the part you are asking about is how to get them into this Resources folder to begin with.  I probably shouldn't have used the name "Resources" since that is a special name. 

Bottom line, within Visual Studio, create a folder under the project.  Put the dlls into that folder (I called the folder Resources, but you could call it anything...).  Set the properties for each dll file to:

Build Action = Content
Copy To Output Directory = Copy Always

Those settings cause the dlls to be copied into the folder (e.g. Resources) under wherever the app gets installed by the user.  They are then ready to be copied by the form load action.

Rereading this thread after the intervening time, I still have no clue at all why you can't just put bass_fx.dll into the program folder to begin with!

Happy pitch shifting!  (or whatever fx you're after...)

tom


gretar

  • Posts: 9
Re: BASS.Net API, BASS_FX problem with Vista
« Reply #18 on: 3 Apr '09 - 09:50 »
Hi Tom!

Thanx for the prompt and detailed reply!

Now I understand this much better and I will try to implement this in C#.... hopefully this will work *fingers crossed* ;)

/Gretar.

P.s. It is the Pitch shifting effect I'm after :D