Author Topic: BASS for Linux  (Read 270551 times)

Ian @ un4seen

  • Administrator
  • Posts: 26223
BASS for Linux
« on: 26 Jun '08 - 16:18 »
Linux (x86 and x64) versions of BASS and the BASSCD/FLAC/MIDI/WV/enc/mix add-ons are available here:

Now available on the BASS page.


ALSA is used for output, but the "no sound" device can still be used without it.

BASS will attempt to set the output threads to real-time priority, but Linux appears not to permit normal users to have control over the priority of their threads. So unless you're running as "root" (or you have "rtprio" enabled in limits.conf), it is possible for the BASS output threads to be starved of CPU, resulting in output underruns, ie. breaks in the sound. To get around that, there is a BASS_SetConfig option (BASS_CONFIG_DEV_BUFFER) to set the device buffer size. It defaults to 40ms, but the actual value used may be different if the device/driver requires it; BASS_GetInfo can be used to check the average latency. Note that the device buffer size affects the latency of things like playback starting and attribute changes, so you will probably want to avoid setting it unnecessarily high.

By default, BASS_Init will initialize a device in exclusive mode, but a shared mode is also available via the BASS_DEVICE_DMIX flag. If the device is busy, then BASS_Init will automatically try the shared mode. I say "exclusive mode", but it isn't necessarily exclusive if the device/driver supports hardware mixing, ie. each hardware mixing channel can be used in exclusive mode. When in exclusive mode, the "freq" parameter will determine the output rate (if possible) and all of the device's speakers will be available. When in shared mode, the ALSA config will determine the output rate and number of speakers (the default appears to be 48000hz stereo). Exclusive mode will also allow the use of smaller output buffers (BASS_CONFIG_DEV_BUFFER) and so lower latency; the minimum buffer size is again determined by the ALSA config in shared mode.

BASS also provides a "Default" device, which uses whatever output is set as the default in the ALSA config. That could map directly to one of the hardware devices, or it could use plugins. Note the latter could add latency, and it may be necessary to increase the device buffer size (BASS_CONFIG_DEV_BUFFER) to avoid breaks in the sound.

An "mp3-free" version is included, which makes use of the libmpg123 library for MP3 decoding. The libmpg123 library comes with mpg123 (a command-line player), but can also be installed separately (although that seems to be less common). Without it, the "mp3-free" BASS will still function, but MP3 stream creation will fail with a BASS_ERROR_CODEC error.
« Last Edit: 23 May '11 - 17:41 by Ian @ un4seen »

ken

  • Posts: 752
Re: BASS for Linux
« Reply #1 on: 26 Jun '08 - 16:23 »
Sweet, hopfully I can use it with Mono framework, so I can still develop in C#. Then I give it a try.

Bernd, does BASS.NET work with Mono on Linux (and maby on Mac) ?

http://www.mono-project.com/

Chris

  • Posts: 2221
Re: BASS for Linux
« Reply #2 on: 26 Jun '08 - 16:46 »
Hi Ian and I can translate the Delphi Demos to  Lazarus (Freepascal) (and can test them under Suse 10,1 / 11.0
Cheers Chris
« Last Edit: 26 Jun '08 - 20:03 by Chris »

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #3 on: 26 Jun '08 - 19:22 »
If Mono is fully .Net compatible I don't see any reason why it shouldn't work...but I haven't tried that, since I have no Linux PC and no Mono installed...and guess I will not buy one just to try it ;-)

ken

  • Posts: 752
Re: BASS for Linux
« Reply #4 on: 27 Jun '08 - 09:16 »
ok, nice. I know that specific windows functions like "DllImport" don't work in Mono.

I will get it a try when Ian post the linux version of Bass. 

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #5 on: 27 Jun '08 - 09:51 »
If "DllImport" isn't automatically converted/supported under Mono - then BASS.NET will definitly NOT work!
Since "DllImport" is used almost everywhere to import the native BASS functions :-)

ken

  • Posts: 752
Re: BASS for Linux
« Reply #6 on: 27 Jun '08 - 13:43 »
Bad by me, I belive I mention specific Win32 calls.

looks like "DllImport" works in mono: http://www.mono-project.com/Interop_with_Native_Libraries
 

rogier21

  • Posts: 33
Re: BASS for Linux
« Reply #7 on: 30 Jun '08 - 13:55 »
In Delphi Codegear you can easily make linux apps, I have a VM here and Delphi, so I can test if you want.

franck

  • Guest
Re: BASS for Linux
« Reply #8 on: 23 Jul '08 - 14:39 »
I really look for a linux version while all my application runs under mono expect bass features...


According monon documentation, it's possible to link to linux library files by adding information in the mono parameter file, like this:

 <configuration>
    <dllmap dll="bass.dll" target="bass.so" />
 </configuration>

and then no change has to be made in the .NET wrapper [ImportDll("bass.dll")].




I actually just need to generate a waveform (no playback, no recording...), is there already an early first alpha version of bass under linux which can do that?

Ian @ un4seen

  • Administrator
  • Posts: 26223
Re: BASS for Linux
« Reply #9 on: 23 Jul '08 - 16:02 »
There is actually a fully functional beta version available :)

I'm afraid I can't assist with "mono", but if you would like to try to get BASS working with it, please confirm your email address and I'll send the beta.

fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #10 on: 23 Jul '08 - 17:41 »
ok, I sent you an email directly, but I've registered a new time to answer here...
So, can you send me this linux version?
I'll send you my feedback if that can help.

fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #11 on: 24 Jul '08 - 09:01 »
Hi,
Thank you for your mail.
I've simply run my application under mono using the linux version of mono.
The configuration of mono is quite simple using dllmap mecanism.

The library is found by the API, the first call are OK (initialization etc...), audio device are correctly found (alsa) and initialized

but everything is not working probably (stream creation) because I use an obsolete version of the .NET API (2.3.1.8).
I'll try to update to last release of .NET API and will test this again.


fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #12 on: 24 Jul '08 - 10:17 »
Ok, after updating to 2.4.1 .NET API, things sounds better.
Except that I cannot open my OGG file?
BASS_ERROR_FILEOPEN error while creating a file stream on an OGG vorbis file while it can be opened under windows.

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #13 on: 24 Jul '08 - 10:57 »
If you can open 'other' files (e.g. wav or mp3) I guess this is something special inside BASS - as the interface for BASS.NET is the same.

fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #14 on: 24 Jul '08 - 11:06 »
I've already get this same error (opening file) when there was version mismatch between .NET API lib and native lib.

Here I use the 2.4.1.2 .NET API lib, maybe it should be a previous one?

fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #15 on: 24 Jul '08 - 12:55 »
ok, same issue with mp3 and wav

The BASS_GetVersion returns 2.4.1.5 while the .NET API version is 2.4.1.2 supports only BASS v2.4.1.1.
Probably the issue come from this mismatch.



fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #16 on: 24 Jul '08 - 13:00 »
Sorry for the multiple post, but I've tried the given binaries to test the .so file.

the writewav works well with the same OGG file.
the content can't initialize device (alsa 1.0.15) but it's not my target for this app.

so definilty, I think that the issue come from the .NET API...

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #17 on: 24 Jul '08 - 13:38 »
I guess I might not really help - as I don't have any linux PC - nor mono available.

Regarding the versions - I don't think that this is an issue.

So basically what you can try is to write your own little mono .Net wrapper and see if that really works out.

Ian @ un4seen

  • Administrator
  • Posts: 26223
Re: BASS for Linux
« Reply #18 on: 24 Jul '08 - 13:40 »
I think BASS.Net uses Unicode (UTF-16) strings whenever possible? If so, that's probably the problem as the Linux BASS version does not currently support the BASS_UNICODE flag. Does Mono use Unicode strings?

fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #19 on: 24 Jul '08 - 14:19 »
OK, investigating more...
it works opening the file using a buffer and creating the stream from memory.

I see the next bug in the WaveForm generation. So I also change this, by creating a waveform from a stream instead of a file (which bugged with the previous bug)
...
but here that freezes wher I start the rendering



fcasado

  • Posts: 8
Re: BASS for Linux
« Reply #20 on: 24 Jul '08 - 15:17 »
I can conclude.
I can now generate the weaveform starting from a stream and not from a filename.
So, thank you very much for this first version!

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #21 on: 24 Jul '08 - 15:24 »
Yes, that's correct BASS.NET always uses the BASS_UNICODE flag internally for any file calls!
So that's then probably the issue.

Ian @ un4seen

  • Administrator
  • Posts: 26223
Re: BASS for Linux
« Reply #22 on: 24 Jul '08 - 16:09 »
Is it possible for BASS.Net to detect whether it's running under Windows? If so, perhaps it could convert the filename to UTF-8 (and omit BASS_UNICODE) on other platforms?

radio42

  • Posts: 4841
Re: BASS for Linux
« Reply #23 on: 24 Jul '08 - 16:25 »
I'll take a look - otherwise a global BASS.NET config flag might help and solve it.

So what conventions do you have Ian:
Windows: with BASS_UNICODE = UTF-16, without = ANSI
Linux: with BASS_UNICODE = not supported?, without = UTF-8?
Mac: with BASS_UNICODE = UTF-16, without = not supported?


Ian @ un4seen

  • Administrator
  • Posts: 26223
Re: BASS for Linux
« Reply #24 on: 24 Jul '08 - 17:42 »
Filenames are UTF-8 on OSX, so BASS_UNICODE is not supported there either (no need for an additional Unicode option). I think Linux supports UTF-8 filenames too (it does here), but I'm not certain whether that depends on the kernel version or some other system config.

I think it'll be OK to just use UTF-8 (and omit BASS_UNICODE) on non-Windows. If it turns out not to be OK, it can be changed later :)