Author Topic: Error when playing DSD file in Ubuntu 20.04  (Read 211 times)

pzs7602

  • Posts: 76
Error when playing DSD file in Ubuntu 20.04
« on: 23 Sep '22 - 03:42 »
When using BASS_DSD_StreamCreateFile to create a dsd file stream in Ubuntu 20.04, error occurs:
libbassdsd.so: undefined symbol: BASS_GetVersion

My code:

Code: [Select]
namespace MusicFans.Linux.Models{

    public class Bass
    {
        public const string BassAssembly = "./libbass.so";
 
        [DllImport(Bass.BassAssembly)]
        public static extern  uint BASS_StreamCreateFileUser (uint system, uint flags, BASS_FILEPROCS proc, uint user);   
        // HSTREAM BASSDEF(BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user);   


        //HSTREAM BASSDEF(BASS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
        [DllImport(Bass.BassAssembly)]
        public static extern  uint BASS_StreamCreateFile(bool mem, IntPtr file,uint offset,uint length,uint flags);

        [DllImport(Bass.BassAssembly)]
        public static extern bool BASS_ChannelPlay(uint handle, bool restart);


        [DllImport(Bass.BassAssembly)]
        public static extern uint BASS_Init(int device, uint freq, uint flags, uint win, IntPtr dsguid);
        // BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, const void *dsguid);

        public delegate void BASS_FILEPROCS(int Handle, int Channel, int Data, IntPtr User);

        [DllImport(Bass.BassAssembly)]
        // int BASSDEF(BASS_ErrorGetCode)();
        public static extern int BASS_ErrorGetCode();
    }
    public class BassDsd
    {
        public const string BassAssembly = "./libbassdsd.so";
 
        [DllImport(BassDsd.BassAssembly)]
        public static extern  uint BASS_DSD_StreamCreateFileUser (uint system, uint flags, BASS_FILEPROCS proc, uint user);   
        // HSTREAM BASSDEF(BASS_APE_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user);   
       
        // HSTREAM BASSDSDDEF(BASS_DSD_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq);
        [DllImport(BassDsd.BassAssembly)]
        public static extern  uint BASS_DSD_StreamCreateFile(bool mem, IntPtr file,uint offset,uint length,uint flags, uint freq);

        [DllImport(BassDsd.BassAssembly)]
        public static extern bool BASS_ChannelPlay(uint handle, bool restart);

        [DllImport(Bass.BassAssembly)]
        public static extern uint BASS_Init(int device, uint freq, uint flags, uint win, IntPtr dsguid);
        // BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, const void *dsguid);

        public delegate void BASS_FILEPROCS(int Handle, int Channel, int Data, IntPtr User);

    }

......
    public class MainWindowViewModel : ViewModelBase
        public void OnClickCommand()
        {
            // play music
            uint code = Bass.BASS_Init(-1, 44100, BASS_DeviceInfo.BASS_DEVICE_DEFAULT, win: 0,IntPtr.Zero);
            if (code == 0)
            {
                Console.WriteLine("Error returned from BASS_INIT");
            }
            else
            {
                Console.WriteLine("BASS_INIT OK");
            }
            // Error here:
            uint stream = BassDsd.BASS_DSD_StreamCreateFile(false, System.Runtime.InteropServices.Marshal.StringToHGlobalAuto("test.dsf") , 0, 0, BASSSample.BASS_SAMPLE_FLOAT, 88200);
            if (stream == 0)
            {
                int err = Bass.BASS_ErrorGetCode();
                Console.WriteLine("StreamCreateFile error:"+ err);
            }
            /*
            try
            {
                GCHandle handle = GCHandle.Alloc(Player.current);
                ret = Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, _mySync, (IntPtr)handle);
                // ret = utilityImplement.BASS_ChannelSetSync2(stream,0,0,_mySync,IntPtr.Zero);
                Debug.WriteLine("setsync ret = " + ret);
            }
            catch
            {
                var error2 = Bass.BASS_ErrorGetCode();
                Debug.WriteLine("chanelsetsync error:" + ret);
            }
            */

            BassDsd.BASS_ChannelPlay(stream, false);

            string[] resNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
            Console.WriteLine("ManifestResourceNames:");
            foreach (string resName in resNames)
                Console.WriteLine(resName);
        }
    }
}

Error occurs at:
uint stream = BassDsd.BASS_DSD_StreamCreateFile(false, System.Runtime.InteropServices.Marshal.StringToHGlobalAuto("test.dsf") , 0, 0, BASSSample.BASS_SAMPLE_FLOAT, 88200);

How to deal with this?


Ian @ un4seen

  • Administrator
  • Posts: 24684
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #1 on: 23 Sep '22 - 15:14 »
I think the issue there is that the BASSDSD add-on is currently still using an old system on Linux that depends on the BASS library being loaded first with global scope (so it can be seen by the add-on), and .Net isn't loading the BASS library with global scope. The add-ons have been moving away from that system (explictly linking with the BASS library instead) in the last few years but BASSDSD hasn't had a new release in that time, so hadn't done so yet. I've put an updated BASSDSD build up on the BASS page now, so please redownload to get that. Let me know if you still have the problem with it.

pzs7602

  • Posts: 76
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #2 on: 24 Sep '22 - 04:55 »
Playing DSD is successful when using updated libbassdsd.so, so thanks!
But I found the same issue when using libbass_tta.so(also in Ubuntu 20.04, x64 version).
When using libbasswv.so in Ubuntu 20.04, although I've call BASS_Init, the method BASS_WV_StreamCreateFile still generate error info:
BASSWV: BASS must be loaded first

Ian @ un4seen

  • Administrator
  • Posts: 24684
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #3 on: 26 Sep '22 - 12:36 »
Good to hear that the BASSDSD update fixed the problem. You would indeed have the same issue with the BASSWV and BASS_TTA add-ons, as they haven't had new releases recently either. The same goes for the BASSWEBM and BASS_MPC add-ons. New Linux builds of those four add-ons are up on the BASS page now. I believe this means all add-ons are now using the updated system (mentioned in my last post).

pzs7602

  • Posts: 76
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #4 on: 28 Sep '22 - 04:15 »
At least tta updated version is tested OK.
But are you sure the x64 libbasswv.so is updated? Still the same error

Ian @ un4seen

  • Administrator
  • Posts: 24684
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #5 on: 28 Sep '22 - 13:59 »
I just checked, and the x64 libbasswv.so file was indeed updated. If you run "ldd libbasswv.so" on it, do you see libbass.so listed? If not, you're probably still using the old file. It should be dated 23/9/2022.

pzs7602

  • Posts: 76
Re: Error when playing DSD file in Ubuntu 20.04
« Reply #6 on: 28 Sep '22 - 15:27 »
My fault, sorry. The libbasswv.so is updated indeed :)
Thanks!