BASS for Win64 (x64)

Started by Ian @ un4seen, 7 Oct '08 - 15:04

Ian @ un4seen



64-bit Windows versions of BASS and the add-ons can be found in the Win32 packages on the BASS webpage.


bertas

This is great ;D.
I've just set up an x64 system running Windows Server 2008.
Did a quick try on it and it worked fine.

Thanks a lot!

BertaS

bertas

Hi!

In my first try was using C++ (VS2005). This worked, but now I'm struggling with C#. :(

If I use the x86 libs and compile the C# app for x86 everything works just fine.
But if I try compile using the "Any CPU" or "x64" option and your x64 bass.dll I get a DllNotFoundException.

The dll and the executable are in the same directory. Even copying the dll to system folders didn't work.
How can that happen? ???

BTW: I#m not using the original Bass.NET. I'm just using Interop on the functions I need. :P
Example:
[DllImport("bass.dll")]
public static extern bool BASS_Init(int device, uint freq, uint flags, int win, int clsid);

Thanks in advance for all answers.

BertaS

Ian @ un4seen

I'm not a .Net user myself, so I'm afraid I can't really help very much with that, but one possibility comes to mind... perhaps you're putting the BASS.DLL in your app's x86 build directory, while the x64 build is in another directory? :)

bertas

Ok, thank you Ian.
I will try to make it work this weekend.

bertas

Couldn't stop thinking about this problem and finally I got it.  ;D
I don't want to explain it all in detail, but it has to do with WinSxS and a missing manifest.
You can read about this problem in detail at http://www.davidlenihan.com/2007/07/winsxs.html.
This article is really enlightening.

In short:
The applcation manifest was missing in the C# application, telling windows which version of msvcr80.dll the application
needs. The C++ compiler generates this automatically.
What I had to do was to copy the manifest resource (RT_MANIFEST) from the C++ exe to the C# exe.
After that it worked like a charm.

I hope this helps other developers. I had to google for a few hours.

BertaS

radio42

Can you maybe post your C# manifest file here, so that others can use it as well?

Jason Reskin

Quote from: Ian @ un4seen on  7 Oct '08 - 15:04Only the DLL and LIB files are included; the APIs and examples can be taken from the Win32 packages. The rest of the add-ons should also eventually be available in x64 flavour. If there is a particular add-on that you require now, let me know, and I'll see what I can do.

Please report any problems that you encounter!

As far as redistributability goes, we currently release the 32-bit and 64-bit versions of our application in the same directory (we just tack on 64, e.g. Client.exe and Client64.exe) but I don't see a way to distinguish which bass.dll we want to use since they have the same name.  Any change compiling the library to look for a bass64.dll?

Ian @ un4seen

I'm not sure about renaming the x64 DLLs (including add-ons), it'll need some thought.

Perhaps one solution in your case would be to load BASS dynamically? If you are using any add-ons, note that you should not rename the BASS.DLL file as the add-ons expect/require it to be "BASS.DLL". So, if you want to include both the x86 and x64 versions in the same installation, you would probably have to put the DLLs in separate sub-directories. If you go one step further and also put the executables in the sub-directories, you shouldn't need to bother with any changes like dynamic loading :)

radio42

I would also recommend NOT to rename the x64 dlls.
The best solution is definitly to provide two sub-directories (one containing x86 and one containing the x64 dlls) and then loads them dynamically depending on your OS resp. target application.

bertas

#10
Because of some people still struggling with BASS x64 and C#, here is a step by step "tutorial".
I use Visual Studio 2005 for this. Because I'm using a german version of Visual Studio i translated the labels of buttons etc on the fly to english, so don't assume the phrases to be 100% correct. I did my best ;).

1. Compile your application using the target "Any CPU"
2. Open the compiled .exe file with Visual Studio via File > Open > File...
 -> The resources of the file will be shown
3. Right-Click somewhere in the resource view to open the context menu and select "Add Resource..."
4. In the following dialog click on the "User Defined" button
5. For the resource type enter RT_MANIFEST
 -> Now the new resource is opened for editing
6. THIS IS IMPROTANT: Use the property editor to assign an ID of 1 to the RT_MANIFEST resource.
7. Select the following manifest and press Ctrl + C to copy it to your clipboard.  :P
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.1434" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>
8. Go to visual studio and paste the manifest into the new resource.
9. Save the executable and your done.

If it still doesn't work you have to check wich version of the Visual C++ Runtime you have installed. To do that go to C:\Windows\winsxs\. There should be a directory named something like "amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.1434_none_88de292b2fb06019" that contains the vc++ runtime. You may have noticed the "8.0.50727.1434". That is the version that has to be specified in the manifests "version" property.
If you don't have such a directory you don't have the vc++ runtime. Google for "Visual C++ Runtime" and you'll find it.

I hope this helps everyone. If not, feel free to PM me

kelarmin

The process here works for me, "User Defined" is "Custom" for English VS 2008.

My question is if there is any possibilty to make this as a build script, so debugging can be done on the program.

Ian @ un4seen

Updated builds are now up (see 1st post), which don't require MSVCR80.DLL, so the manifest entry for that should no longer be needed. Let me know if it still gives any grief.

kelarmin

Hey Ian, I am getting a BASS_ERROR_DRIVER when tring to initalize the system. I am using Vista x64, the program works on normal vista and xp. Any thoughts?

Ian @ un4seen

From the mention of things working on "normal vista and xp", does that mean you're using the x86 (32-bit) version of BASS on Vista x64 too, rather than the x64 version of BASS posted here? If you are using the x64 version, did the problem just begin with the latest update, or did it happen previously too?

kelarmin

#15
I am using the x64 version of bass on the x64 machines.

I built a simple console app to test the basic init + play functionality of bass. so when i init i send IntPtr.Zero into the init for window handle and it is able to play on both the new dll(2.4.2.5) and the old dll(2.4.2.1).

The application I'm building will send the window that owns the bass instance into the init function and it will not work using either dlls.

I also built a simple window app that runs the same code as the console but sends the handle to the window, and it does play so there may just be something with my main app. I'll look into this and post if I come across any other issues.

Ian @ un4seen

The BASS_ERROR_DRIVER error occurs when BASS can't initialize DirectSound for the device. Perhaps another app (or even your app) is already using the device in exclusive mode or via ASIO?

Do you have identical (in source) x86 (32-bit) and x64 (64-bit) versions of your app? If so, does the problem happen if you run the x86 version on the Vista x64 system?

kelarmin

Identical code for all systems. It works on the x86 vista and XP my code doesn't work on the x64 vista only.

I made a test app that kinda mirrors how i initialize the BASS and it works. One big difference is that In my app I run a FreeBASS() function that will make sure that BASS is not initialized before I begin.
        private void FreeBASS()
        {
            try
            {
                BASS_DEVICEINFO info = new BASS_DEVICEINFO();
                for (int i = 1; Bass.BASS_GetDeviceInfo(i,info); ++i)
                {
                    Console.WriteLine("Closing: " + info.ToString());
                    Console.WriteLine(info.ToString() + " IsInitialized = " + info.IsInitialized.ToString());
                    if (info.IsInitialized)
                    {
                        Bass.BASS_SetDevice(i);
                        Bass.BASS_PluginFree(0);
                        Bass.BASS_Free();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Application Error Shutting down please start again.\r\n" + ex.Message);
                this.Close();
            }
        }

The test app will play the sound file. Any other thoughts??

    public partial class SecondWindow : Window
    {
        string m_id;
        public SecondWindow(string id)
        {
            InitializeComponent();
            m_id = id;
            this.Show();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                BASS_DEVICEINFO info = new BASS_DEVICEINFO();
                for (int i = 1; Bass.BASS_GetDeviceInfo(i, info); ++i)
                {
                    Console.WriteLine(info.name);
                    if (!Bass.BASS_Init(i, 44100, BASSInit.BASS_DEVICE_SPEAKERS, new System.Windows.Interop.WindowInteropHelper(this).Handle, null))
                        throw new Exception("Failed to initialize: " + Bass.BASS_ErrorGetCode().ToString() + " SecondaryWindow (" + m_id + ")");
                    if (!Bass.BASS_SetDevice(i))
                        throw new Exception("Set Device Failed: " + Bass.BASS_ErrorGetCode().ToString());
                    int stream = Bass.BASS_StreamCreateFile("C:\\Users\\Public\\Music\\Sample Music\\wave.mp3", 0, 0, BASSFlag.BASS_DEFAULT);
                    Bass.BASS_ChannelPlay(stream, false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }

    public partial class Window1 : Window
    {
        List<SecondWindow> m_secondarywindows = new List<SecondWindow>();
        public Window1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 2; ++i)
            {
                m_secondarywindows.Add(new SecondWindow("Window" + (i + 1).ToString()));
            }
        }
    }

Ian @ un4seen

Quote from: kelarmin on 17 Dec '08 - 20:24Identical code for all systems. It works on the x86 vista and XP my code doesn't work on the x64 vista only.

Is the x86 version of your app working on x64 Vista?

Quote from: kelarmin on 17 Dec '08 - 20:24I made a test app that kinda mirrors how i initialize the BASS and it works. One big difference is that In my app I run a FreeBASS() function that will make sure that BASS is not initialized before I begin.

What happens if you add that FreeBASS stuff to your test app? That should confirm whether it is the problem :)

Btw, plugins are not tied to a particular device, so you only really need to call BASS_PluginFree(0) once (in total, not per-device) to free all plugins.

stevenmmm

what is your policy regarding distributing this beta? My application is in beta (http://www.getmusicbee.com if you are interested) and i've had a surprising number of requests for a 64 bit version so was wondering it was OK to release this?
If it is OK, would it be possible to also include basscd.dll and bassflac.dll to your upgraded files? And will bass.net just run on x64 without modification?
Lastly which of the other addons will be upgraded or will that be up to the individual developers whether they decide to or not?

radio42

Regarding BASS.NET.
Yes, BASS.NET should run without modifications.
But note, that if your App is compiled using the 'For Any CPU' setting, that it will automatically run in x64 mode on a Win64 OS and such will require the x64 bass.dll

Ian @ un4seen

Quote from: stevenmmm on 19 Jan '09 - 08:44what is your policy regarding distributing this beta? My application is in beta (http://www.getmusicbee.com if you are interested) and i've had a surprising number of requests for a 64 bit version so was wondering it was OK to release this?

Yes, that'll be fine. Please report how you/they get on with it :)

Quote from: stevenmmm on 19 Jan '09 - 08:44If it is OK, would it be possible to also include basscd.dll and bassflac.dll to your upgraded files? And will bass.net just run on x64 without modification?
Lastly which of the other addons will be upgraded or will that be up to the individual developers whether they decide to or not?

I'll look into x64 builds of BASSCD and BASSFLAC later today or tomorrow. For the 3rd-party add-ons, it will be up to the developers whether they provide x64 versions, but I think it should be possible in most cases.

Ian @ un4seen

BASSCD and BASSFLAC builds are now included in the x64 beta package (see 1st post).

quickmic

#23
Hi

I tested the 64bit version in WinXP64 but get an Error. But this test was only 10Sec or so. Just changed the 32bit versions to the 64bit.
So before I try again...
Is it possible to mix 32bit-Bass-Plugins with 64bit stuff?
Is there anything I have to change in the APIs?
Has anybody successfully tested on a VB6 programm?

Ian @ un4seen

No, it isn't possible to mix 32-bit and 64-bit code, ie. the EXE and DLLs all have to be the same. Separate processes can be different though, eg. 32-bit command-line encoders can still be used with the 64-bit BASSenc.

I don't think it's possible to create 64-bit apps with VB6.