Author Topic: BASS for ARM Linux  (Read 153968 times)

DJAGABx

  • Guest
Re: BASS for ARM Linux
« Reply #350 on: 26 Jul '17 - 10:24 »
Thanks Ian for the quick reply.
I did a quick test and the add-ons appear to work fine on the 64bit environment. Would it be possible to create a 64bit version of the libbasscd.so as well?

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #351 on: 26 Jul '17 - 17:05 »
The BASSCD add-on has now been added, as has the BASSMIDI add-on.

   www.un4seen.com/stuff/bass24-linux-aarch64.zip

DJAGABx

  • Guest
Re: BASS for ARM Linux
« Reply #352 on: 27 Jul '17 - 14:02 »
Thanks again Ian for the quick response. I may have found a possible issue concerning BASS_ChannelSetSync. I use a mono environment version 4.2.1.201 together with the latest Bass.net version and the bass version from the arm64 package. Perhaps you or Radio 42 could look into this. To me it feels like accessing dereferenced pointers on the unmanaged side from a managed side.
This happens on all places in my code where channelsetsync is used. The same code has worked before on an ARM32 environment using mono version 3.10 armhf.

Here is the stack trace:

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.__icall_wrapper_mono_delegate_to_ftnptr (object) <0xffffffff>
  at (wrapper managed-to-native) Un4seen.Bass.Bass.BASS_ChannelSetSync (int,Un4seen.Bass.BASSSync,long,Un4seen.Bass.SYNCPROC,intptr) <0xffffffff>
  at AudioBitsApp.Radio.Connect () <0x001b7>
  at AudioBitsApp.AudioBits.TestInternetRadio (string) <0x00073>

And here's an excerpt from the code reponsible:
Code: [Select]
_Stream=Bass.BASS_StreamCreateURL(url,0,BASSFlag.BASS_STREAM_STATUS|BASSFlag.BASS_STREAM_DECODE|BASSFlag.BASS_STREAM_PRESCAN,null,IntPtr.Zero);

//check for _Stream being zero left out.

BASS_CHANNELINFO info=Bass.BASS_ChannelGetInfo(_Stream);
mySync+=new SYNCPROC(MetaSync);
Bass.BASS_ChannelSetSync(_Stream, BASSSync.BASS_SYNC_META, 0,mySync,IntPtr.Zero);
}

This is just a small piece I took from the part of my program that tests Radio station stream validity. It happens on other places, too where I use channelsetsync for other purposes.

Thanks in advance for the effort.

djagab

  • Posts: 35
Re: BASS for ARM Linux
« Reply #353 on: 28 Jul '17 - 10:40 »
I have read Radio42's very comprehensive help section Interoperating with Unmanaged Code and made some changes to the code listed above.
mySync+=new SYNCPROC(MetaSync); changed to mySync=new SYNCPROC(MetaSync);
This time it is working fine, again! This leads me to the question: Why does mono 4.2.1.102 require this modification while mono 3.10 armhf does not?
In respect to Garbage Collection compared to unmanaged code, how does '+=' act differently compared to using '='?
@Radio42: Your thoughts please..... ;)

 

radio42

  • Posts: 4612
Re: BASS for ARM Linux
« Reply #354 on: 28 Jul '17 - 11:37 »
I cannot really follow, since the += operator is noemally used for event handlers; while the = sign is a simple assign operator.
SoI cannot follow, why += should have have worked once. "+=" and "=" are two different things.
The only main difference with Mono once was (afair), that it only allowed static callbacks - but I am not sure, as I am not too much into Mono development.

djagab

  • Posts: 35
Re: BASS for ARM Linux
« Reply #355 on: 30 Jul '17 - 09:40 »
Thanks for your reply. It didn't make sense to me either. I changed the error (possible type-o) and now it is working fine on an Allwinner H5 ARM64 SBC from China :). I expected some performance improvements over the ARM32 version, though. The performance is slightly worse, but this might be mono version related.
Anyway bass(.net) is running on an ARM64 architecture. Good work!!

DJAGABx

  • Guest
Re: BASS for ARM Linux
« Reply #356 on: 31 Jul '17 - 10:50 »
One more thing. I connected the DSD DAC based on the ESS Sabre 9018K2M to this SBC with the ARM64 setup. In my DAC this chip is combined with a SA9227 USB receiver. This combination requires a valid DOP marker right at the beginning of the playback. In order to achieve this, Ian advised to disable all ramp-in and introduced an attribute to channelplay for preventing ramp-in. This attribute had number 11. @Ian: Could it be this option is not available in the 64bit build version for ARM? When I try to play the file it is not recognised as a valid Dop file and the setattribute line in my code
Code: [Select]
Bass.BASS_ChannelSetAttribute(!useRaW ? mixerHandle : stream, (BASSAttribute)11, 1); returns false for this version of libbass.so 

DJAGABx

  • Guest
Re: BASS for ARM Linux
« Reply #357 on: 31 Jul '17 - 11:58 »
Hi Ian. My bad. It turned out the alsamixer set the master volume back to 25% of this device which is not bit perfect enough ;) for playing DoP this way.
The setattribute return value being false was a result of an error occuring in a piece of code prior to this setattribute.  :'( So, nothing wrong with BASS but with me, needing a holiday ;)



ken

  • Posts: 739
Re: BASS for ARM Linux
« Reply #358 on: 14 Aug '17 - 12:12 »
Hi Ian,

Do you have an 64-bit version of the Bass ARM?

I'm trying to run it on a Allwinner H5 64-bit processor, but it just say "threw an exception".

This is the board: http://www.friendlyarm.com/index.php?route=product/product&path=69&product_id=180

Running Ubuntu core 16.04 LTS (4.11.2) aarch64

Thanks!

/Ken


-- EDIT --

Just found the post with "linux-aarch64" seam to work just fine!  Is it possible to make "libbassalac" and "libbassopus" as 64-bit to?

/Ken



« Last Edit: 14 Aug '17 - 12:19 by ken »

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #359 on: 15 Aug '17 - 18:02 »
The BASSALAC and BASSOPUS add-ons have been added:

   www.un4seen.com/stuff/bass24-linux-aarch64.zip

Let me know if you hear any problems with BASSOPUS. It's using the latest libOpus version (1.2.1), which seems to have introduced sound quality issues on iOS at least. I haven't got to the bottom of that yet, which is why none of the ARM-based platforms have been updated to BASSOPUS 2.4.1.10 yet, in case it affects all of them.

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #360 on: 8 Sep '17 - 14:48 »
The ARM Linux versions of the recent BASSFLAC and BASSmix releases are up now in the 1st post. The aarch64 architecture files have also now been added to the main package, instead of being separate downloads.

laheller

  • Guest
Re: BASS for ARM Linux
« Reply #361 on: 7 Oct '17 - 22:28 »
Just did a quick test and I can tell that BASS works fine on Raspberry PI running "Raspbian wheezy". I run C# code using Mono 2.10 with BASS.Net (C# 4.0)

/Ken
How to set up the whole stuff? I mean for example where to put the libbass.so ? Which Bass.Net nuget package is required?
I just created a simple console app in Monodevelop + Bass.Net and my code fails at BASS_Init:

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Un4seen.Bass.Bass' threw an exception. ---> System.DllNotFoundException: bass
  at (wrapper managed-to-native) Un4seen.Bass.Bass:BASS_SetConfig (Un4seen.Bass.BASSConfig,int)
  at Un4seen.Bass.Bass.InitBass () [0x0000c] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
  at Un4seen.Bass.Bass..cctor () [0x00069] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
   --- End of inner exception stack trace ---
  at Second.MainClass.Main (System.String[] args) [0x0009f] in /home/pi/Test/Second/Program.cs:19
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Un4seen.Bass.Bass' threw an exception. ---> System.DllNotFoundException: bass
  at (wrapper managed-to-native) Un4seen.Bass.Bass:BASS_SetConfig (Un4seen.Bass.BASSConfig,int)
  at Un4seen.Bass.Bass.InitBass () [0x0000c] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
  at Un4seen.Bass.Bass..cctor () [0x00069] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
   --- End of inner exception stack trace ---
  at Second.MainClass.Main (System.String[] args) [0x0009f] in /home/pi/Test/Second/Program.cs:19


laheller

  • Guest
Re: BASS for ARM Linux
« Reply #362 on: 9 Oct '17 - 10:31 »
Just did a quick test and I can tell that BASS works fine on Raspberry PI running "Raspbian wheezy". I run C# code using Mono 2.10 with BASS.Net (C# 4.0)

/Ken
How to set up the whole stuff? I mean for example where to put the libbass.so ? Which Bass.Net nuget package is required?
I just created a simple console app in Monodevelop + Bass.Net and my code fails at BASS_Init:

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Un4seen.Bass.Bass' threw an exception. ---> System.DllNotFoundException: bass
  at (wrapper managed-to-native) Un4seen.Bass.Bass:BASS_SetConfig (Un4seen.Bass.BASSConfig,int)
  at Un4seen.Bass.Bass.InitBass () [0x0000c] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
  at Un4seen.Bass.Bass..cctor () [0x00069] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
   --- End of inner exception stack trace ---
  at Second.MainClass.Main (System.String[] args) [0x0009f] in /home/pi/Test/Second/Program.cs:19
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Un4seen.Bass.Bass' threw an exception. ---> System.DllNotFoundException: bass
  at (wrapper managed-to-native) Un4seen.Bass.Bass:BASS_SetConfig (Un4seen.Bass.BASSConfig,int)
  at Un4seen.Bass.Bass.InitBass () [0x0000c] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
  at Un4seen.Bass.Bass..cctor () [0x00069] in <1603c3a5c01b47259b0e7edff8fa7eb0>:0
   --- End of inner exception stack trace ---
  at Second.MainClass.Main (System.String[] args) [0x0009f] in /home/pi/Test/Second/Program.cs:19

Nevermind, I already solved it.
Problem was the I forgot to reference Bass.Net.Linux.dll and also used wrong version of libbass.so.
Now it works!

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #363 on: 10 Oct '17 - 17:57 »
An ARM Linux version of the BASSHLS add-on has been added to the package in the 1st post.

Alias

  • Guest
Re: BASS for ARM Linux
« Reply #364 on: 9 Nov '17 - 05:29 »
Is recording working on Raspberry PI? Playback/encoding works fine, but when i call BASS_RecordStart(44100, 2, BASS_RECORD_PAUSE, 0, 0);, I get BASS_ERROR_DRIVER. BASS_RecordInit gives me BASS_OK. So what's wrong here?

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #365 on: 9 Nov '17 - 16:28 »
A BASS_ERROR_DRIVER error from BASS_RecordStart indicates that an ALSA snd_pcm_open call on the device failed, and not because it was busy (EBUSY). For comparison, are you able to successfully record using ALSA's "arecord" utility?

Alias

  • Guest
Re: BASS for ARM Linux
« Reply #366 on: 11 Nov '17 - 11:53 »
Nope. It's not able to open any device (File or directory not found, wrong number for device, ...).

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #367 on: 23 Dec '17 - 13:52 »
The ARM Linux version of the new BASS 2.4.13 release is up in the 1st post.

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #368 on: 12 Feb '18 - 16:41 »
The ARM Linux versions of the BASS 2.4.13.8 and BASSHLS 2.4.1.1 releases are now up in the 1st post.

SteveS

  • Posts: 6
Re: BASS for ARM Linux
« Reply #369 on: 27 Feb '18 - 14:07 »
Hi Ian

With the release of Raspbian Stretch, a pi can now use bluealsa as a device. So, for example, if my .asoundrc contains

defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "A0:E9:DB:11:32:50"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

then I can use "aplay -D bluealsa  filename.wav " to play the appropriate file.
Now, I don't want to do that, I want an appropriate device to appear in the list used by BASS.
I assume I would need to add some sort of device definition into asoundrc as well.
Any clues as to what that needs to say, in order for BASS to be able to understand it?

Thanks in advance,
/Steve

drugoimir

  • Posts: 19
Re: BASS for ARM Linux
« Reply #370 on: 27 Feb '18 - 15:45 »
Hello,
i'm resampling a channel from 48Kto 192K, but the output (resampled) signal
still contains spectral replicas of the low rate input.
The replicas are only -10 to -20dB down in respect to the 24KHz bandwidth input
spectrum, and their level barely changes for any BASS_SetConfig(BASS_CONFIG_SRC,  X).
I tried every setting from 0 to 6, and, though the 24KHz passband cutoff become sharper,
the replicas are always present, just like a linear interpolator is always used.
The only way to get rid of them is to filter the 192KHz stream, but it is no solution.

I'm using the last 2.4.13.8 version for arm-linux in hard-fp.
Here's the startup code:

Code: [Select]
BASS_Init(-1,192000,0,0,NULL);
BASS_SetConfig(BASS_CONFIG_FLOATDSP,TRUE);
BASS_SetConfig( BASS_CONFIG_SRC, 3 );

handlemixer48 = BASS_Mixer_StreamCreate(48000,2,BASS_MIXER_NONSTOP | BASS_STREAM_DECODE | BASS_SAMPLE_FLOAT);
handlepush = BASS_StreamCreate(48000,2,BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE,STREAMPROC_PUSH,NULL);
BASS_Mixer_StreamAddChannel(handlemixer48,handlepush,0); //put the udp - data stream into the 48K mixer

HDSP48 = BASS_ChannelSetDSP(handlemixer48,AudioDsp48,NULL,1);//dsp on 48K audio

handlemixer192 = BASS_Mixer_StreamCreate(192000,2,BASS_MIXER_NONSTOP | BASS_SAMPLE_FLOAT);
BASS_Mixer_StreamAddChannel(handlemixer192,handlemixer48,0);//plug 48K channel into 192K mixer

lpf24k = BASS_ChannelSetDSP(handlemixer192,lpf_192k,NULL,1);//24K lpf filter to clean out replicas at 192KHz
dsp192k = BASS_ChannelSetDSP(handlemixer192,AudioDsp192,NULL,1);//192K DSP

Other 2 question on the same argument:
1-  assuming that the resampler was working fine,  is it possible to perform multi rate processing such as, into a DSP callback running at 48K, upsample to X, process, then downsample to 48K ?
If so, what the latency of upsampling/downsampling process would be, in order to match the resampled data to the non-resampled ones ?
I'm asking this because, for some special effects, i've to upsample some 48K data to avoid aliasing, process them then downsample, but i have then to combine the resampled data with non resampled
ones with exact time alignment.
2- may i write my own resampler ? In such case, i 'll have my 48K stream, then i can upsample it, and how then i send it to the 192K stream ?
Have i to setup a STREAMPROC_PUSH channel ?

Thanks in advance for any support.

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #371 on: 27 Feb '18 - 17:28 »
With the release of Raspbian Stretch, a pi can now use bluealsa as a device. So, for example, if my .asoundrc contains

defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "A0:E9:DB:11:32:50"
defaults.bluealsa.profile "a2dp"
defaults.bluealsa.delay 10000

then I can use "aplay -D bluealsa  filename.wav " to play the appropriate file.
Now, I don't want to do that, I want an appropriate device to appear in the list used by BASS.
I assume I would need to add some sort of device definition into asoundrc as well.
Any clues as to what that needs to say, in order for BASS to be able to understand it?

I haven't tried that myself, so I'm not sure, but have you already checked the BASS device list (eg. using the LIST example) and found that it's missing? If so, does "aplay -l" or "aplay -L" show it?

If all else fails, perhaps you can just set it as the default device in the ALSA config? It should then get used by the BASS "Default" device.

i'm resampling a channel from 48Kto 192K, but the output (resampled) signal
still contains spectral replicas of the low rate input.
The replicas are only -10 to -20dB down in respect to the 24KHz bandwidth input
spectrum, and their level barely changes for any BASS_SetConfig(BASS_CONFIG_SRC,  X).
I tried every setting from 0 to 6, and, though the 24KHz passband cutoff become sharper,
the replicas are always present, just like a linear interpolator is always used.

I don't seem to be able to reproduce that, at least not on Windows just now. The result should be the same on ARM, but can you try on another platform to confirm what you're seeing? If not, I'll check on ARM later this week. My test involved plugging a 0-24KHz sweep WAV file into a 192KHz mixer with BASS_CONFIG_SRC set to 6, and writing the floating-point output to another WAV file, and checking the spectrum in Cool Edit. If you're using some other input signal that better shows the problem then please upload it here:

   ftp.un4seen.com/incoming/

drugoimir

  • Posts: 19
Re: BASS for ARM Linux
« Reply #372 on: 27 Feb '18 - 18:08 »
Hello Ian,
thanks for reply.

Audio output is sent to real audio device and i grabbed the spectrum using an analyzer,
audio input is a pseudorandom noise (using the C rand function) generated into the
48KHz channel DSP.

I'll make the same test on windows tomorrow and i'll let you know.

Regards.
Drugo

drugoimir

  • Posts: 19
Re: BASS for ARM Linux -resampler-
« Reply #373 on: 28 Feb '18 - 09:53 »
Hello Ian,
i can confirm that, on MS Windows, the resampler is working fine, while on ARM-Linux seems not.

I used the same ARM-Linux initialization, the test signal is a white noise generated into the
48KHz dsp routine, then it is resampled to 192K.
Audio is routed out the PC and sent to a spectrum analyzer.

Code: [Select]
procedure dsp48 (handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: Pointer); stdcall;
var
n:integer;
chans:^TTWofloat;
begin

 chans :=buffer;
  for n := 0 to length div (sizeof(single)*2)  -1  do
    begin
        chans^.left:= 0.04 * (random(100) - 50); //generate white noise
        chans^.right:=chans^.left;
        inc(chans);
    end;
end;

var
sptr:single;
procedure dsp192 (handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: Pointer); stdcall;
var
n:integer;
chans:^TTWofloat;
begin

 chans :=buffer;
  for n := 0 to length div (sizeof(single)*2)  -1  do
    begin
        chans^.left:= chans^.left + sin(sptr) * 0.5;   //just to be sure it's running at 192KHz
        chans^.right:=chans^.left;
        sptr:=sptr + (6.28 / 192000) * 80000;
        if sptr>=6.28 then sptr:=sptr-6.28;
        inc(chans);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  BASS_Init(-1,192000,0,0,nil);

  BASS_SetConfig(    BASS_CONFIG_SRC, 3 );
  BASS_SetConfig (BASS_CONFIG_FLOATDSP,1);
  hmixer48 := BASS_Mixer_StreamCreate(48000,2,BASS_MIXER_NONSTOP or BASS_STREAM_DECODE or BASS_SAMPLE_FLOAT);
  hdsp48 := BASS_ChannelSetDSP(hmixer48,dsp48,nil,1);
  hmix192 := BASS_Mixer_StreamCreate(192000,2,BASS_MIXER_NONSTOP or BASS_SAMPLE_FLOAT);
  BASS_Mixer_StreamAddChannel(hmix192,hmixer48,0);
  hdsp192 := BASS_ChannelSetDSP(hmix192,dsp192,nil,1);
 
 BASS_ChannelPlay(hmix192,FALSE);
end;

Regards
D.

Update:
Initializing bass with 192K samplerate, then creating a "stand alone" mixer running at 48K,
there are no replicas in output spectrum, though the output card is driven at 192K.

So i'm guessing that bass opens the audio device at the specified frequency and
takes care of the sample rate of the sources playing, resampling them if necessary.
This is working, but the "inter-channel" mixer resampler seems not.

Code: [Select]
...
BASS_Init(-1,192000,0,0,NULL);
handlemixer48 = BASS_Mixer_StreamCreate(48000,2, BASS_MIXER_NONSTOP  | BASS_SAMPLE_FLOAT);
dsp48= BASS_ChannelSetDSP(handlemixer48,dsp48_callback,NULL,1); //test signal (noise) generator
BASS_ChannelPlay(handlemixer48,FALSE);

« Last Edit: 28 Feb '18 - 16:18 by drugoimir »

Ian @ un4seen

  • Administrator
  • Posts: 21012
Re: BASS for ARM Linux
« Reply #374 on: 28 Feb '18 - 16:03 »
Oh yes, I see there is indeed a resampling bug in the ARM Linux version of BASSmix, specifically a config mismatch between the BASSmix core and the NEON optimized code. An update to fix that is now up in the 1st post. Let me know if you still have any trouble with it.