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

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #250 on: 22 Dec '14 - 16:29 »
I'm not a .Net user, so I can't try that code myself, but one suggestion I have is to use a single stream to play all of the data, and change it to a "push" stream too. Perhaps something like this...

Code: [Select]
     static void Main(string[] args)
      {
         Un4seen.Bass.BassNet.Registration("email", "key");
        
         if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            Console.Write("BASS_Init() failed");

         int channel = Bass.BASS_StreamCreate(44100, 2, BASSFlag.BASS_DEFAULT, BASSStreamProc.STREAMPROC_PUSH, IntPtr.Zero);
         Bass.BASS_ChannelPlay(channel, false);        

         while (true)
         {
            // Endless loop
            run(channel);
         }

         //Bass.BASS_Free();
      }
      
      static void run(int channel)
      {
         byte[] bytes;
         byte[] btSize = (byte[])Array.CreateInstance(typeof(byte), 4);
         int iCounter = 0;

         TcpClient tcpClient = new TcpClient();

         Console.WriteLine("run");

         // Get Audio Stream
         tcpClient.Connect("172.16.51.20", 64004);

         networkStream = tcpClient.GetStream();

         // First 4 bytes contain size of audio segment
         if (networkStream.Read(btSize, 0, 4) != 4)
         {
            Console.WriteLine("run - couldn't get audio size");
            return;
         }

         iAudioSize = BitConverter.ToInt32(btSize, 0);
         Console.WriteLine("Audio Size: " + iAudioSize.ToString());

         bytes = new byte[32000];

         while (iCounter < iAudioSize)
         {
            // read 32k chunk
            int z = networkStream.Read(bytes, 0, (int)32000);
            Bass.BASS_StreamPutData(channel, bytes, z); // pass the downloaded data to the stream

            iCounter += z;
         }

      }

If it's still not working properly, please also try this latest ARM Linux (hardfp) BASS build...

   www.un4seen.com/stuff/libbass.so

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #251 on: 23 Dec '14 - 15:06 »
The ARM Linux version of BASS 2.4.11 is now up in the 1st post.

Note that existing BASS_ChannelGetData calls that use the BASS_DATA_FLOAT or BASS_DATA_FFT flags will need to be modified slightly, because those options will now deliver floating-point data by default rather than fixed-point data, to match what happens on other (non fixed-point) platforms. Fixed-point data can still be requested via the new BASS_DATA_FIXED flag. This change affects the BASS_FX add-on, so if you're using that, you will need to upgrade to the latest version of that too.

mikem

  • Posts: 2
Re: BASS for ARM Linux
« Reply #252 on: 24 Dec '14 - 04:43 »
Hey Ian, thanks very much. The new release of the libraries fixed the problem without any changes of the code. I've put the code back to the push stream (which is how I started before trying to file option). Thanks again.

JoeK

  • Posts: 22
Re: BASS for ARM Linux
« Reply #253 on: 8 Feb '15 - 19:49 »
hello Mr Ian, im new to linux and i would like to develop app with bass for linux but i dont know from where to start,ive already installed virtual box on my win7 64bit and i downloaded the last version of ubuntu and successfully run it.now what? what IDE do i have to install to start programming. Thank you.

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #254 on: 9 Feb '15 - 16:17 »
I'm not sure what's best for ARM Linux specifically, but Code::Blocks is a nice option for Linux in general...

   www.codeblocks.org

Some other suggestions are given here...

   http://askubuntu.com/questions/48299/what-ides-are-available-for-ubuntu

ken

  • Posts: 749
Re: BASS for ARM Linux
« Reply #255 on: 13 Feb '15 - 11:27 »
Hi,

On the new "Raspberry Pi 2" I get a noise when starting the mixer (like a pink noise) it's there all the time, also noticeable when adding streams to the mixer and playing some audiofiles. 

I use the latest Arm DLL's (hardfp) and I run "Raspbian Debian Wheezy" on the Pi 2

Could it be that Pi 2 is using a different CPU "ARM Cortex-A7" ?


I init bass like this:
Code: [Select]

 if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{

        _mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_MIXER_RESUME | BASSFlag.BASS_MIXER_NONSTOP);
        if (_mixer == 0)
        {
           Console.WriteLine("ERROR, Could not create mixer!");
         }
         else
         {
            Bass.BASS_ChannelPlay(_mixer, true);
         }

    Console.WriteLine("Init Audio OK!");
}



Any ideas?

/Ken

ken

  • Posts: 749
Re: BASS for ARM Linux
« Reply #256 on: 13 Feb '15 - 12:49 »
I did some more test on the noise issue on "Raspberry Pi". I get the same on the old model "B" and the newer "B+" and the "Pi 2".

But If I use an external sound card "MAYA USB+" then I hear no noise, all is as it should be. 

Is the sound card on the Pi that bad or is it a BASS issu? I have used Pi and BASS before with the build in sound card, I can't remember that it was noisy.

/Ken
« Last Edit: 13 Feb '15 - 12:56 by ken »

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #257 on: 13 Feb '15 - 13:58 »
To confirm whether the noise is something specific to what BASS is doing, please check whether you get it when playing stuff with other (non-BASS) software. If it's not affecting the other software, then also try building and running the CONTEST example (taken from the standard Linux BASS package) and see whether that's affected.

ken

  • Posts: 749
Re: BASS for ARM Linux
« Reply #258 on: 13 Feb '15 - 16:38 »
To confirm whether the noise is something specific to what BASS is doing, please check whether you get it when playing stuff with other (non-BASS) software. If it's not affecting the other software, then also try building and running the CONTEST example (taken from the standard Linux BASS package) and see whether that's affected.

Hi,

I's not BASS, I get the same "noise" with the command line player "mpg321". So I guess the build in sound card is pretty bad.  But hey a quad-core 900Mhz computer for $35 dollar ;)

Sorry for not testing this before I post on the forum.

/Ken

AndroidMediaPlayer

  • Posts: 25
Re: BASS for ARM Linux
« Reply #259 on: 24 Mar '15 - 17:28 »
Hi Ian,

i have som problems with the Tags addon reading ID3V2 Tags. My Code is:
Code: [Select]
printf("A\n");
TAGS_Read(stream, '%UTF8(%TITL)');
// TAGS_ReadEx(stream, '%UTF8(%TITL)', BASS_TAG_ID3V2);
printf("B\n");

The Output is:
Code: [Select]
A

I have tried different mp3 files, it's always the same. Any idea? The stream is valid cause ID3V1 (BASS_ChannelGetTags) tags works fine.

Thank you ;)
« Last Edit: 24 Mar '15 - 17:41 by AndroidMediaPlayer »

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #260 on: 24 Mar '15 - 17:49 »
If you're not seeing "B", then I guess it's crashing in the TAGS_Read call? It looks like you're using single quotes (') in that call. Is that just a typo? If not, it should be double quotes (") :)

AndroidMediaPlayer

  • Posts: 25
Re: BASS for ARM Linux
« Reply #261 on: 24 Mar '15 - 18:11 »
Oh, lol, i see. You're right, the problem were the quotes... *doh*

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #262 on: 27 Mar '15 - 17:36 »
The ARM Linux version of the BASSmix 2.4.8 release is now up in the 1st post.

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #263 on: 4 Apr '15 - 15:48 »
Hi there,

I'm trying to get surround sound to work on a RPi 2 with Raspbian and Mono/Bass.NET and ALSA with a 7.1 USB sound card. I'm somewhat puzzled on how to get the surround to work.

The sound card works, speaker-test can play to all 8 channels. In my code I doubled checked the right device (the usb sound card) is selected with BASS_Init, which I also set as main device for ALSA.

After BASS_Init(deviceNo, 44100, initFlags, IntPtr.Zero) and querying BASS_GetInfo() it reports 2 speakers, even when I pass the BASS_DEVICE_SPEAKERS flag. (Which I find strange since doing this in a Windows Desktop environment does report 8 speakers.)

I must admit my knowledge to Linux is moderate, and knowledge of ALSA poor, and this problem probably might not be related to Bass at all, I still hope someone can point me in the right direction!

Kind regards, nibbo

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #264 on: 6 Apr '15 - 14:25 »
The ARM Linux BASS version does currently limit the output to stereo (to save CPU). The "hardfp" version of the ARM Linux stuff is currently in the middle of being updated to use floating-point rather than fixed-point, and that limit should get lifted at the same time. The updated stuff should be available within a few weeks.

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #265 on: 9 Apr '15 - 10:49 »
Thanks for the heads-up. I'll be a good boy and wait for that release then :-)

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #266 on: 22 Apr '15 - 18:11 »
Updated "hardfp" libraries that include floating-point support (eg. the BASS_SAMPLE_FLOAT flag) are now up in 1st post. The "softfp" libraries have also been updated to the latest stuff. An ARM Linux version of the BASSDSD add-on has also been added.

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #267 on: 23 Apr '15 - 20:31 »
Ian, you're me hero matey! ;D

I can confirm BASS (HF) reports 8 channels back correctly on a 7.1 usb soundcard, and playback on independent channels works like a charm.

Thanks!
(note to self: make a little film of everything I've done so far with RPi and BASS)

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #268 on: 25 Apr '15 - 14:17 »
...But unfortunately I stumbled upon a problem. However I'm not sure if it is BASS or the BASS.NET wrapper. The channel mappings get mixed up during runtime: when I repeatedly play a sound on e.g. channel "Center", after a couple of times it starts playing on another channel. Not sure if random, but also got the feeling it switched to one of the Front channels, like falling back to stereo.

A speaker-test test confirms the problem must lay with Bass, for that doesn't mix the channels up.

Any ideas?

gigi0ne

  • Posts: 40
Re: BASS for ARM Linux
« Reply #269 on: 25 Apr '15 - 14:20 »
Hi Ian..

On Raspberry 2 work all like a charme....
bass, bassmix, bassopus, bassenc
without change....

Thank's

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #270 on: 27 Apr '15 - 17:06 »
...But unfortunately I stumbled upon a problem. However I'm not sure if it is BASS or the BASS.NET wrapper. The channel mappings get mixed up during runtime: when I repeatedly play a sound on e.g. channel "Center", after a couple of times it starts playing on another channel. Not sure if random, but also got the feeling it switched to one of the Front channels, like falling back to stereo.

A speaker-test test confirms the problem must lay with Bass, for that doesn't mix the channels up.

That's strange. Are you repeatedly playing the same stream (ie. using the same handle in the BASS_ChannelPlay call), or are you creating a new stream each time? If you check the stream's flags via BASS_ChannelFlags each time, does that also change when the sound moves?

Code: [Select]
DWORD flags=BASS_ChannelFlags(handle, 0, 0);

On Raspberry 2 work all like a charme....
bass, bassmix, bassopus, bassenc
without change....

Good to hear!

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #271 on: 28 Apr '15 - 19:38 »
Here's my code:
Code: [Select]
if (Bass.BASS_Init(deviceNo, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{
string cmd = "";
while (cmd != "q")
{
Console.WriteLine("Playing...");
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_SPEAKER_CENTER | BASSFlag.BASS_MUSIC_MONO);
Bass.BASS_ChannelPlay(stream, false);
Console.Write(Bass.BASS_ChannelFlags(stream, 0, 0));
cmd = Console.ReadLine();
Bass.BASS_StreamFree(stream);
Thread.Sleep(1000);
}
}
Bass.BASS_Free();

Always keeps saying:
Code: [Select]
BASS_SAMPLE_SOFTWARE, BASS_SPEAKER_CENTER
-
Some other findings:
  • Without the sleep, it does work.
  • The number of plays it takes before it switches is usually between 2 and 15.
  • Forcefully closing the application resets it, taking a few plays before it happens again; gracefully ending it with BassFree will and then restarting the application shows the behavior immediately

Switching appears not to be random(!):
  • Playing to Center will eventually revert to FrontLeft
  • Rear2Left reverts to RearLeft
  • RearLeft reverts to Center
  • RearRight reverts to FrontRight
  • Rear2Right reverts to RearRight

My mono version info, if its the culprit here?
Code: [Select]
mono --version
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4+rpi1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       normal
        Notifications: epoll
        Architecture:  armel,vfp+hard
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

Ian @ un4seen

  • Administrator
  • Posts: 24941
Re: BASS for ARM Linux
« Reply #272 on: 29 Apr '15 - 11:40 »
Very strange. I doubt it's a Mono issue. If the problem only happens when you have a pause between playbacks, then perhaps the driver doesn't like having gaps in the data, so one thing you could try is enabling the BASS_CONFIG_DEV_NONSTOP option, like this:

Code: [Select]
BASS_SetConfig(BASS_CONFIG_DEV_NONSTOP, 1);

Btw, what soundcard are you having the problem with? If you happen to have another soundcard that you can try, please check whether the same thing happens with that.

nibbo

  • Posts: 7
Re: BASS for ARM Linux
« Reply #273 on: 29 Apr '15 - 15:29 »
Thanks, that does do the trick!

The stated flag is not available in the BASSConfig enum in the linux .NET wrapper, so perhaps if the radio42 team is reading along ;-)

Code: [Select]
Bass.BASS_SetConfig((BASSConfig)50, 1); //50 = BASS_CONFIG_DEV_NONSTOP

I have the GWCtech AA1570 in Conrad livery:
http://www.gwctech.com/product3.asp?listid=3&id=4&subid=10&pid=788&typeid=96

Unfortunately I have no other soundcard at hand. My original plan of using the RPi HDMI port didn't work out, so thats why I obtained this one.

radio42

  • Posts: 4785
Re: BASS for ARM Linux
« Reply #274 on: 29 Apr '15 - 15:47 »
That flag is only included in the Linux, Android, and Windows CE version!
As such it is only present in: Bass.Net.Linux.dll,Bass.Net.Android.dll and Bass.Net.compact.dll
Not sure which version of Bass.Net you are actually using?