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

SteveS

  • Guest
Re: BASS for ARM Linux
« Reply #100 on: 23 May '13 - 09:58 »
This sounds suspiciously like the problem I had, where I was using a version of the libbass.so without 64 bit offset support against a file system which required it.

Are you using the latest version of the library (which has the support built in)?

If it was regular C/C++ I'd suggest executing a stat() call on the file and checking that you do get a zero return, and whereas in a Windows .NET environment that would be possible using Interop, I don't know if MONO supports such a thing.

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #101 on: 23 May '13 - 16:06 »
i am uploading the file now..
i tried 3-4 different mp3 file, all of them works on windows environment with the same code runs with mono..
all files i tried not worked in arm debian and arch linux.
also tried mp3-free and normal version. both have the same problem..

if you give me a test c++ app that will work on arm to test and debug..
just upload it and i will try and send you the output that it generates..

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #102 on: 24 May '13 - 13:55 »
Ian any update? :)

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #103 on: 24 May '13 - 15:35 »
There doesn't appear to be anything unusual about your uploaded MP3 files, so it's a bit puzzling. Are you having the problem only with them, or is it all MP3 files? What about other file formats, eg. WAV or OGG? For a C/C++ test to compare with, please try the CONTEST example from the standard Linux BASS package.

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #104 on: 27 May '13 - 08:25 »
hi ian,
tested with wav , i got this error while executing int _stream = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSFlag.BASS_DEFAULT);


[root@alarm music]# mono sevan.exe /root/music/deneme.wav
loading bass
registered bass33819143
init success
info success
info printed
Speakers=2, MinRate=0, MaxRate=0, DX=0, EAX=False
devices installed:
0-No sound
1-Default
2-MXS EVK:
filename:"/root/music/deneme.wav"

Unhandled Exception: System.ExecutionEngineException: SIGILL
  at Un4seen.Bass.Bass.BASS_StreamCreateFile (System.String file, Int64 offset,                                                     Int64 length, BASSFlag flags) [0x00000] in <filename unknown>:0
  at sevan.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>                                                    :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: SIGILL
  at Un4seen.Bass.Bass.BASS_StreamCreateFile (System.String file, Int64 offset,                                                     Int64 length, BASSFlag flags) [0x00000] in <filename unknown>:0
  at sevan.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>                                                    :0



then i tried an mp3 file:
int _stream = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSFlag.BASS_DEFAULT);
this loaded success but, _stream returned 0
here is the result:
[root@alarm music]# mono sevan.exe /root/music/love.mp3
loading bass
registered bass33819143
init success
info success
info printed
Speakers=2, MinRate=0, MaxRate=0, DX=0, EAX=False
devices installed:
0-No sound
1-Default
2-MXS EVK:
filename:"/root/music/love.mp3"
streamcreate file ok
file load problem :BASS_ERROR_FILEFORM
Hello SMG!
Press any key to exit

[root@alarm music]#




i can play both mp3 and wav file with ffmpeg and mplayer in same device..
all audio files failed after or while streamcreatefile

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #105 on: 27 May '13 - 08:47 »
by the way, i dont know how to compile the contest example project on arm..
can you help me how to do that?
i put makefile, makefile.in, bass.h, bass.lib in the same folder then
modified makefile and makefile.in

makefile:
include makefile.in

TARGET = test

all: $(TARGET)

clean:
   $(RM) $(OUTDIR)\$(TARGET)


makefile.in:
BASSPATH = ..
BASSLIB = bass.lib
OUTDIR = ..
FLAGS = -Os -I$(BASSPATH)

CC = gcc
RM = del
RES = windres

%.exe: %.c %.rc
   $(RES) -i $*.rc -o rsrc.obj
   $(CC) $(FLAGS) $*.c rsrc.obj $(BASSLIB) $(LIBS) -o $(OUTDIR)\$@
   $(RM) rsrc.obj

%.exe: %.c
   $(CC) $(FLAGS) $*.c $(BASSLIB) $(LIBS) -o $(OUTDIR)\$@

.PHONY: all clean



then i gcc contest.c
here is the result:

[root@alarm cexample]# gcc contest.c
/tmp/ccQWGB7S.o: In function `Error':
contest.c:(.text+0x114): undefined reference to `BASS_ErrorGetCode'
contest.c:(.text+0x12c): undefined reference to `BASS_Free'
/tmp/ccQWGB7S.o: In function `main':
contest.c:(.text+0x158): undefined reference to `BASS_GetVersion'
contest.c:(.text+0x1b0): undefined reference to `BASS_Init'
contest.c:(.text+0x1f4): undefined reference to `BASS_StreamCreateFile'
contest.c:(.text+0x22c): undefined reference to `BASS_StreamCreateURL'
contest.c:(.text+0x248): undefined reference to `BASS_ChannelGetLength'
contest.c:(.text+0x25c): undefined reference to `BASS_StreamGetFilePosition'
contest.c:(.text+0x300): undefined reference to `BASS_MusicLoad'
contest.c:(.text+0x350): undefined reference to `BASS_ChannelGetAttribute'
contest.c:(.text+0x368): undefined reference to `BASS_ChannelGetTags'
contest.c:(.text+0x378): undefined reference to `BASS_ChannelGetLength'
contest.c:(.text+0x3a0): undefined reference to `BASS_ChannelGetLength'
contest.c:(.text+0x3dc): undefined reference to `BASS_ChannelBytes2Seconds'
contest.c:(.text+0x450): undefined reference to `BASS_ChannelPlay'
contest.c:(.text+0x45c): undefined reference to `BASS_ChannelGetLevel'
contest.c:(.text+0x46c): undefined reference to `BASS_ChannelGetPosition'
contest.c:(.text+0x484): undefined reference to `BASS_ChannelBytes2Seconds'
contest.c:(.text+0x4c8): undefined reference to `BASS_ChannelGetPosition'
contest.c:(.text+0x564): undefined reference to `BASS_StreamGetFilePosition'
contest.c:(.text+0x660): undefined reference to `BASS_GetCPU'
contest.c:(.text+0x6ac): undefined reference to `BASS_ChannelIsActive'
contest.c:(.text+0x6d8): undefined reference to `BASS_ChannelSlideAttribute'
contest.c:(.text+0x6f4): undefined reference to `BASS_ChannelSlideAttribute'
contest.c:(.text+0x70c): undefined reference to `BASS_ChannelIsSliding'
contest.c:(.text+0x71c): undefined reference to `BASS_Free'
collect2: error: ld returned 1 exit status



i think it can not find bass.lib
but it is in the same folder..


can you provide a compiled arm version of contest example?

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #106 on: 28 May '13 - 14:25 »
ian any suggestion? :)

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #107 on: 28 May '13 - 15:21 »
by the way, i dont know how to compile the contest example project on arm..
can you help me how to do that?
i put makefile, makefile.in, bass.h, bass.lib in the same folder then
modified makefile and makefile.in
...

It looks like you downloaded the Win32 BASS package. You need to get the Linux package instead :) ... You can then replace the libbass.so file with the ARM Linux version, and go to the "contest" directory and type "make" to build the CONTEST example. Alternatively, if you place contest.c and libbass.so in the same directory, you can type this: "gcc contect.c ./libbass.so -o contest". In either case, you can then type "./contest <filename>" to run the example.

SteveS

  • Guest
Re: BASS for ARM Linux
« Reply #108 on: 29 May '13 - 08:44 »
I suspect that won't work either, and if not, you should make your gcc line different

gcc -D_FILE_OFFSET_BITS=64 contest.c ./libbass.so -o contest

and see if that gives you different results. I spent a little time looking at a similar problem myself, where I was getting problems with files on specific file systems, a local SD was fine, but a network file wasn't. It turned out that the support for large (>2TB) files was by default not switched on, and if you execute a stat/fstat call to determine file properties, it did not reliably fill in size fields. Using the pre-processor definition above resolved it, once Ian had also supplied a version of the BASS library compiled the same way (which is in the download at the top of the thread now, I believe). Since then, I've never looked back, and my web-hosted player is happily able to blast out all 1600+ ripped CDs on demand (although obviously, not all at once...)

Steve

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #109 on: 29 May '13 - 09:08 »
here is the compile result:
--

root@debian:~/music/contest# gcc contest.c ./libbass.so -o contest
root@debian:~/music/contest# chmod 755 contest
root@debian:~/music/contest# ./contest /root/music/lenka.mp3
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Error(41): Can't play the file
root@debian:~/music/contest# ./contest /root/music/love1.mp3
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Error(41): Can't play the file
root@debian:~/music/contest# ./contest /root/music/test.wav
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Illegal instruction
root@debian:~/music/contest# ./contest /root/music/billy.wma
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Error(41): Can't play the file
root@debian:~/music/contest#




tried also the steve's suggestion:
root@debian:~/music/contest#
root@debian:~/music/contest# gcc -D_FILE_OFFSET_BITS=64 contest.c ./libbass.so -o contest1
root@debian:~/music/contest# ./contest1 /root/music/love1.mp3
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Error(41): Can't play the file
root@debian:~/music/contest# ./contest1 /root/music/test.wav
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Illegal instruction
root@debian:~/music/contest# ./contest1 /root/music/billy.wma
Simple console mode BASS example : MOD/MPx/OGG/WAV player
---------------------------------------------------------
Error(41): Can't play the file
root@debian:~/music/contest#



SteveS

  • Guest
Re: BASS for ARM Linux
« Reply #110 on: 29 May '13 - 12:09 »
Are you definitely using the libbass.so from the first post? (i.e. it isn't dated before the "last changed" in the post)

As I remember, when I had the non 64 offset compiled version, the -D... made my app collapse with a fault as well. Unfortunately I don't have one of my ARM boxes here, so I can't post up a compiled app and library I know works for me.

Steve

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #111 on: 29 May '13 - 12:39 »
i definetely know i am using the lib in the first post.. dont worry..
i tried hardfp and mp3-free versions alsa..

if you try other versions, you can not compile the source contest.c
it is giving many many errors while compiling if used different versions..

 it is armv5 , imx233 board i am using.. maybe it is the problem?
today i will try it on another qemu virtual arm on ubuntu and see what will happen..
anyway, it is not working in my physical device..


Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #112 on: 29 May '13 - 13:55 »
it is armv5 , imx233 board i am using.. maybe it is the problem?

Ah! Yes, I think that is indeed the problem. The ARM Linux BASS version uses ARMv6 instructions, so that would explain the "Illegal instruction" errors.

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #113 on: 29 May '13 - 14:23 »
strange.. i can not send any reply here
i cant write long text here.. anyway.. i will then use arm9 chipset device.. will it be problem?

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #114 on: 29 May '13 - 14:53 »
Unfortunately, I think that will still be limited to the ARMv5 instruction set. ARM11 is where ARMv6 instructions were introduced. Here's a table of ARM architectures...

   www.wikipedia.org/wiki/ARM_architecture#ARM_cores

Regarding being unable to post long text, the current post length limit is 12000 characters. If you need to post a longer piece of text, you can split it into multiple posts or perhaps put it in an attachment.

serkan

  • Guest
Re: BASS for ARM Linux
« Reply #115 on: 29 May '13 - 17:24 »
i will be using aria g25 device.
it says it is arm9 but not saying cortex or etc.. http://www.acmesystems.it/aria

will you support armv5 ? :)

noanylove

  • Posts: 2
Re: BASS for ARM Linux
« Reply #116 on: 31 May '13 - 07:20 »
Hi,
I use python+ctypes to run the hardfp version of libbass.so on Raspbmc.  It shows some errors with the ALSA lib when I call BASS_Init. My test code is below:

Quote
#!/usr/bin/python
#coding:utf-8
from ctypes import *

BASSVERSION=0x204
BASS_ACTIVE_STOPPED=0

try:
    bass=cdll.LoadLibrary("libbass.so")
except:
    print("[ERROR] Load libbass.so FAIL")
    input()
    exit()

print("[INFO] Load libbass.so (Handle: %x)" % bass._handle)

if not bass.BASS_Init(-1, 44100, 0, 0, 0):
    print("[ERROR] Fail to init")
    exit()
print("[INFO] Init libbass")

The output is:
Quote
root@raspbmc:~# ./playxbmc2.py
[INFO] Load libbass.so (Handle: 6b2ef0)
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM default
[ERROR] Fail to init

What's wrong with it ?

serkan

  • Guest
Re: BASS for ARM Linux
« Reply #117 on: 31 May '13 - 07:35 »
hi,
which version of linux do you use?
if you use archlinux then you have to add alsa and sound driver and you have to configure auto settings
if you use original rasbian image debian wheeze you have to put hardfp so files to /usr/lib and make ldconfig

serkanp

  • Posts: 67
Re: BASS for ARM Linux
« Reply #118 on: 31 May '13 - 11:53 »
here is the solution of your problem:

(if you are using archlinux use pacman -S , if you use debian apt-get install )

#install alsa and utils
pacman -S alsa-firmware alsa-lib alsa-plugins alsa-utils

#probe sound card
modprobe snd-bcm2835

#auto load sound card driver at startup
echo "snd-bcm2835" >> /etc/modules-load.d/snd-bcm2835.conf

#test if soundcard exists
alsamixer

#auto set output
amixer cset numid=3 0

#or 3.5 mm jack
amixer cset numid=3 1

#or hdmi output
amixer cset numid=3 2

#get sound from output
speaker-test -c 2

#save settings
alsactl store

reboot


thats all..


in default raspbian debian (original from website) sets the output from speakers..
if you want to change it to hdmi, just make the adjustments i mentioned above..

noanylove

  • Posts: 2
Re: BASS for ARM Linux
« Reply #119 on: 4 Jun '13 - 14:11 »
Hi serkanp,
    It works. Thank you.

dlabella

  • Posts: 4
Re: BASS for ARM Linux
« Reply #120 on: 19 Jun '13 - 11:28 »
Hello I'm new on this community,

I'm trying to put an equalizer,compressor,spectrum analyzer and other stuff to a homemade sound amplifier with a Raspberry Pi, Bass, Bass.Net and one LCD

To do this I put an very cheap Usb sound card (only for testing purproses... ) for input and output data. The sound card is recognised by operating system ok (Raspbian soft-float).

I made a simple main for testing input and output sound, but sounds like loudspeaker is broken.

Here's my code:

Code: [Select]
using System;
using Un4seen.Bass;

namespace SimpleAudio
{
class MainClass
{
private static RECORDPROC _recordingCallback;
private static int _streamChannel;
//private static int _recordChannel;

private const int _inputDevice=-1;  //DISPOSITIVO DE ENTRADA -1 = POR DEFECTO
private const int _outputDevice=-1; //DISPOSITIVO DE SALIDA -1 = POR DEFECTO

public static void Main (string[] args)
{
BassNet.Registration ("XXXXXXXXX", "XXXXXXXXXX");
int version=Bass.BASS_GetVersion();
Console.WriteLine("BASS VERSION: "+version);

_recordingCallback = OnAudioData;

Bass.BASS_SetConfig (BASSConfig.BASS_CONFIG_UPDATEPERIOD, 10);

if (!Bass.BASS_Init (_outputDevice, 44100, BASSInit.BASS_DEVICE_LATENCY, IntPtr.Zero)) { //256
//SI NO SE HA PODIDO INICIALIZAR SALIMOS Y MOSTRAMOS MENSAJE
Console.WriteLine ("Can't initialize output device!!");
return;
}

var info = new BASS_INFO();
                if (!Bass.BASS_GetInfo(info))
        {
                System.Diagnostics.Debug.WriteLine("Can't get information!!");
                          return;
            }

Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER,10+info.minbuf);

            _streamChannel = Bass.BASS_StreamCreate(44100, 2,0, BASSStreamProc.STREAMPROC_PUSH);

            bool recordInitOk = Bass.BASS_RecordInit(_inputDevice);

            Bass.BASS_RecordStart(44100, 2, 0, _recordingCallback, IntPtr.Zero);

            if ((!recordInitOk))
            {
                Bass.BASS_RecordFree();
             Bass.BASS_Free();
                System.Diagnostics.Debug.WriteLine("Can't initialize recording device");
                return;
            }

Bass.BASS_ChannelPlay(_streamChannel, false);
Console.WriteLine("Press any key to stop...");
Console.ReadKey();

Bass.BASS_Stop();
Bass.BASS_RecordFree();
            Bass.BASS_Free();

return;
}

private static bool OnAudioData(int handle, IntPtr buffer, int length, IntPtr user)
        {
//COGEMOS EL BUFFER DE ENTRADA Y LO PONEMOS EN EL STREAM DE AUDIO DE SALIDA
            Bass.BASS_StreamPutData(_streamChannel, buffer, length);
            return true;
        }
}
}


What I'm doing wrong??

I've read other entries on this thread relative to sound problems but I can't find libbass.so in the post link

Thanks in advance!!!!

P.D: Sorry by my poor english!!!

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #121 on: 19 Jun '13 - 17:04 »
It looks like you want to forward the input to the output? There are a few changes that I would suggest. Firstly, you can remove the low BASS_CONFIG_UPDATEPERIOD and BASS_CONFIG_BUFFER settings, as there is no benefit in setting them low when using a "push" stream. Secondly, to reduce latency in the recording, you can specify an update period in the BASS_RecordStart call (HIWORD of "flags" parameter). Thirdly, you should pre-buffer some data before starting the output, otherwise the output could be stuttering due to a lack of data to play. You can use the "info.minbuf" value to decide how much to pre-buffer. The modified code could look something like this...

Code: [Select]
using System;
using Un4seen.Bass;

namespace SimpleAudio
{
class MainClass
{
private static RECORDPROC _recordingCallback;
private static int _streamChannel;
//private static int _recordChannel;
private static int _prebuf;

private const int _inputDevice=-1;  //DISPOSITIVO DE ENTRADA -1 = POR DEFECTO
private const int _outputDevice=-1; //DISPOSITIVO DE SALIDA -1 = POR DEFECTO

public static void Main (string[] args)
{
BassNet.Registration ("XXXXXXXXX", "XXXXXXXXXX");
int version=Bass.BASS_GetVersion();
Console.WriteLine("BASS VERSION: "+version);

_recordingCallback = OnAudioData;

if (!Bass.BASS_Init (_outputDevice, 44100, BASSInit.BASS_DEVICE_LATENCY, IntPtr.Zero)) { //256
//SI NO SE HA PODIDO INICIALIZAR SALIMOS Y MOSTRAMOS MENSAJE
Console.WriteLine ("Can't initialize output device!!");
return;
}

var info = new BASS_INFO();
                if (!Bass.BASS_GetInfo(info))
        {
                System.Diagnostics.Debug.WriteLine("Can't get information!!");
                          return;
            }

            _streamChannel = Bass.BASS_StreamCreate(44100, 2,0, BASSStreamProc.STREAMPROC_PUSH);
            _prebuf = BASS_ChannelSeconds2Bytes(_streamChannel, info.minbuf/1000.f); // amount of data to pre-buffer

            bool recordInitOk = Bass.BASS_RecordInit(_inputDevice);

            Bass.BASS_RecordStart(44100, 2, MAKELONG(0, 10), _recordingCallback, IntPtr.Zero); // start recording with 10ms period

            if ((!recordInitOk))
            {
                Bass.BASS_RecordFree();
             Bass.BASS_Free();
                System.Diagnostics.Debug.WriteLine("Can't initialize recording device");
                return;
            }

Console.WriteLine("Press any key to stop...");
Console.ReadKey();

Bass.BASS_Stop();
Bass.BASS_RecordFree();
            Bass.BASS_Free();

return;
}

private static bool OnAudioData(int handle, IntPtr buffer, int length, IntPtr user)
        {
//COGEMOS EL BUFFER DE ENTRADA Y LO PONEMOS EN EL STREAM DE AUDIO DE SALIDA
            Bass.BASS_StreamPutData(_streamChannel, buffer, length);
            if (_prebuf && Bass.BASS_ChannelGetData(_streamChannel, 0, BASS_DATA_AVAILABLE)>=_prebuf) { // pre-buffered the wanted amount of data
Bass.BASS_ChannelPlay(_streamChannel, false); // start playing
_prebuf = 0; // done pre-buffering
}
            return true;
        }
}
}

If you still get problems (eg. stuttering output), you can try increasing the pre-buffer amount.

dlabella

  • Posts: 4
Re: BASS for ARM Linux
« Reply #122 on: 19 Jun '13 - 23:10 »
Thanks for the reply!!!

Now is working but only for a few seconds... I tried to increase the _prebuf, but the only I get is a few miliseconds more....

The cpu usage is about 10%, and I don't know why "the buffer is filling fastest than consuming data..." (I don't know how to explain it in english...sorry)

There's something more that I can do?? or I have to forget to do it in Mono and C# and do it in C ??

Thanks again!

Ian @ un4seen

  • Administrator
  • Posts: 20427
Re: BASS for ARM Linux
« Reply #123 on: 20 Jun '13 - 13:02 »
When you say it's only working for a few seconds, do you mean the output totally stops after a few seconds, or does the sound just go bad, eg. it's stuttering or distorted?

You could try monitoring the level of the stream's playback buffer to see if it's running out of data. You can use BASS_ChannelGetData (with BASS_DATA_AVAILABLE) to do that, like this...

Code: [Select]
buflevel=Bass.BASS_ChannelGetData(_streamChannel, 0, BASSData.BASS_DATA_AVAILABLE);

dlabella

  • Posts: 4
Re: BASS for ARM Linux
« Reply #124 on: 20 Jun '13 - 13:47 »
Is working correctly for a few secods, after that, sound goes bad...but still playing audio

I'll try to post the buffer level as soon as I arrive to home!

Thanks Again!