Mod Archive Forums

Music Production => Players => PC Players => Topic started by: almos on November 05, 2011, 12:27:48

Title: libbass-based module player for Linux
Post by: almos on November 05, 2011, 12:27:48
Hello,

   Annoyed by the lack of the module players for Linux that would replicate the playback quality offered by the XMPlay, I decided to write my own player that uses Bass library. While I wrote the player primarily for myself, I decided to post it to the forum in case it might prove useful for other Linux users out there.

   Notes about the player:
  
    - the player is an interactive command-line application
    - it requires the Linux version of libbass (downloadable from the Un4Seen website (http://www.un4seen.com/))
    - for now it takes only one command-line parameter, namely the name of the module that is being played. The volume can be set  during playback.
  
   The key bindings for the player are:
  
   '[ ]' - decrease and increase the volume, respectively
   'p'  - pause or resume the playback
   'q'  - stop the playback

   Sample usage (provided that the bassplay is in path, eg. /usr/local/bin):

  
Code: [Select]
     cd ~/Music/modules
      bassplay mystery.xm
  

   While the application itself is quite unpolished, I might expand on the functionality in case of positive feedback.

   I put the player on Mediafire (http://www.mediafire.com/?9800q46dilh3b4d) for download

The download for the player is attached to this post.

*EDIT = not console, but command-line application
 EDIT2 = The upload on mediafire contains just the player binary
Title: Re: libbass-based module player for Linux
Post by: m0d on November 09, 2011, 16:54:51
Posted news :) Also added the file to your post as an attachment because Mediafire shares suck when they disappear/expire and don't look very trustworthy.
Title: Re: libbass-based module player for Linux
Post by: 68k on November 20, 2011, 03:28:43
This is nice, thanks for posting it!
Title: Re: libbass-based module player for Linux
Post by: almos on November 30, 2011, 19:17:01
As a matter of fact, I am working on a GTK version of the application. I'm trying to keep a steady progress, implementing one functionality after another - and typing in at least a few lines of code a day, which is not always easy given that my day work leaves me unsurprisingly drained by the evening.

On a positive note, working with the Linux libraries and programming tools is a breeze - I was able to implement all of the player's basic functions (such as loading the module and basic control over the playback) during the last weekend. Hopefully the next two weeks will see something I'll be able to post to the forums.
Title: Re: libbass-based module player for Linux
Post by: raina on December 01, 2011, 08:11:38
A BASS-based GUI player for Linux? I think the new computer just might get a Linux partition..
Title: Re: libbass-based module player for Linux
Post by: almos on December 03, 2011, 22:10:31
It doesn't have volume control as of yet - but it's playing modules!

Busy with rooting out some annoying bugs.

(http://img27.imageshack.us/img27/7607/zrzutekranu8vy.th.png) (http://imageshack.us/photo/my-images/27/zrzutekranu8vy.png/)

Uploaded with ImageShack.us (http://imageshack.us)
Title: Re: libbass-based module player for Linux
Post by: 68k on December 10, 2011, 17:16:29
Will the command-line player be updated still, or are you moving to GUI only? The GUI player looks nice but I'm a terminal nerd :P

Either way I'm glad you're posting updates.
Title: Re: libbass-based module player for Linux
Post by: almos on December 12, 2011, 09:17:19
At the moment I'm concentrating on the GUI player, as most users would probably find it the most convenient. On the other hand, in response to the popular demand, I might as well continue the bassplay along the bassplay-gtk!

Yesterday I've implemented the long-overdue volume control; right now the GTK player has: the ability to stop, start, pause and resume the playback, control the volume; the slider shows the position within the module - but is not yet able to control it. I'm already using the player to play the modules on my own computer.

My TODOS are: to be able to set the position within module and show the message, sample, and instrument list for the module. The player is usable enough for me to be able to use it - if anyone is interested I could release the binaries along with some BASH script to install them in the opt directory.

By the way, writing a GTK application in C with Anjuta and Gtk-Builder is like creating a RAD application with Delphi or Lazarus. If not for the lack of time and other concerns that detract me from the project I think it'd already be complete.
Title: Re: libbass-based module player for Linux
Post by: 68k on December 12, 2011, 10:12:55
At the moment I'm concentrating on the GUI player, as most users would probably find it the most convenient. On the other hand, in response to the popular demand, I might as well continue the bassplay along the bassplay-gtk!

Well I don't know that I'm that popular... ;) You're right that a GUI player would probably drum up more interest.

Oh, and just to get the elephant out of the room: no source release?
Title: Re: libbass-based module player for Linux
Post by: almos on December 12, 2011, 11:40:56
The source at the moment is a mess - since I lack experience with creating GNU software (to date I wrote Windows and - mostly - web applications) I let Anjuta manage the whole thing, including configuration, Makefiles et al. Couple that with the fact that most features are introduced impromptu, and that my own limited ability to keep the code organized forces me to reorganize it repeatedly to keep things in check, and you get functions that are inappropriately named, others completely empty, then you get structures that were declared when I thought they would serve a specific purpose, only to find that I don't need them, that linger still in the code - in other words, the code, at the moment, IS A MESS, AS I SADLY AND TRULY CONFESS.

However, I do plan on doing a cleanup and posting the code to Sourceforge - as soon as - well - I have basic things cleaned up.

The console version is in a slightly better condition (source-wise), perhaps because I didn't spend as much time working on it as I did working on a GUI version. When I make the code readable by commenting on it it might be eligible for Sourceforge.

EDIT: The screenshot of Bassplay-Gtk, newest version (with the volume control, that is), playing Nightbeat's "Miriel":

(http://img38.imageshack.us/img38/2373/bassplayscreenshot.th.png) (http://imageshack.us/photo/my-images/38/bassplayscreenshot.png/)

Uploaded with ImageShack.us (http://imageshack.us)
Title: Re: libbass-based module player for Linux
Post by: 68k on December 12, 2011, 19:54:48
The source at the moment is a mess

Totally understandable! I know some of my code is quite bad and I would probably die of humiliation if anyone saw it.
Title: Re: libbass-based module player for Linux
Post by: almos on December 17, 2011, 09:21:55
Last distribution turned out to be slightly screwed due to the bad macro; I'm working on making it work.

EDIT: Problem solved: the source installation of bassplay_gtk can be downloaded from Sourceforge (http://sourceforge.net/projects/almos666.u/files/bassplay_gtk-0.1.tar.gz/download). Enjoy!
Title: Re: libbass-based module player for Linux
Post by: Koli on January 01, 2012, 16:37:07
Unfortunately, I'm having trouble compiling the GTK source on Ubuntu 11.10 x64. I've installed build-essentials, intltool and libgtk2 (along with all the dependencies they bring in), extracted BASS for Linux into /bass within the source directory, configured bassplay, but I'm getting a lot of 'undefined reference' errors right on compile so it doesn't finish.

I guess I'm missing something, but I've no idea what...  :(
Title: Re: libbass-based module player for Linux
Post by: almos on January 05, 2012, 19:26:19
Koli: do the errors pop up during the compilation or during the configuration? Are the BASS headers unpacked into the /usr/local/include directory (the full path to extract the BASS headers to is /usr/local/headers/bass) and is libbass.so installed in the /usr/local/lib directory? If these conditions are met, please post the compiler output so I can figure what is wrong.

Sorry for the delay in response, the only thing I can offer as an excuse is - work!

Title: Re: libbass-based module player for Linux
Post by: Koli on January 05, 2012, 21:35:40
During compilation. I just extracted the headers into /usr/local/headers/bass and into /usr/local/include, while libbass.so is also in /usr/local/lib (tried both the x86 and x64 library), but it's still throwing the same 'undefined reference' errors. I rarely compile software, so I'm no doubt making a silly error somewhere.

Here's the output:

Code: [Select]
make  all-recursive
make[1]: Entering directory `/home/koli/Software/bassplay_gtk-0.1'
Making all in src
make[2]: Entering directory `/home/koli/Software/bassplay_gtk-0.1/src'
  CCLD   bassplay_gtk
main.o: In function `main':
/home/koli/Software/bassplay_gtk-0.1/src/main.c:90: undefined reference to `BASS_Init'
/home/koli/Software/bassplay_gtk-0.1/src/main.c:107: undefined reference to `BASS_Free'
callbacks.o: In function `on_play_button_click':
/home/koli/Software/bassplay_gtk-0.1/src/callbacks.c:75: undefined reference to `BASS_ChannelIsActive'
/home/koli/Software/bassplay_gtk-0.1/src/callbacks.c:77: undefined reference to `BASS_ChannelIsActive'
/home/koli/Software/bassplay_gtk-0.1/src/callbacks.c:78: undefined reference to `BASS_ChannelPlay'
callbacks.o: In function `on_volume_control_change':
/home/koli/Software/bassplay_gtk-0.1/src/callbacks.c:101: undefined reference to `BASS_ChannelSetAttribute'
helper_funcs.o: In function `handle_bass_error':
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:93: undefined reference to `BASS_ErrorGetCode'
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:95: undefined reference to `BASS_ErrorGetCode'
helper_funcs.o: In function `update_position_slider':
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:119: undefined reference to `BASS_ChannelGetPosition'
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:120: undefined reference to `BASS_ChannelBytes2Seconds'
helper_funcs.o: In function `update_label_text':
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:140: undefined reference to `BASS_ChannelGetTags'
helper_funcs.o: In function `setup_music_slider':
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:164: undefined reference to `BASS_ChannelGetLength'
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:165: undefined reference to `BASS_ChannelBytes2Seconds'
helper_funcs.o: In function `choose_and_begin_playback':
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:64: undefined reference to `BASS_ChannelSetAttribute'
/home/koli/Software/bassplay_gtk-0.1/src/helper_funcs.c:58: undefined reference to `BASS_MusicFree'
play.o: In function `start_playback':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:9: undefined reference to `BASS_MusicLoad'
/home/koli/Software/bassplay_gtk-0.1/src/play.c:17: undefined reference to `BASS_ChannelPlay'
play.o: In function `pause_playback':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:23: undefined reference to `BASS_ChannelIsActive'
play.o: In function `stop_playback':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:30: undefined reference to `BASS_ChannelStop'
play.o: In function `pause_playback':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:25: undefined reference to `BASS_ChannelPause'
/home/koli/Software/bassplay_gtk-0.1/src/play.c:24: undefined reference to `BASS_ChannelPlay'
play.o: In function `stop_playback':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:31: undefined reference to `BASS_ChannelSetPosition'
play.o: In function `adjust_volume':
/home/koli/Software/bassplay_gtk-0.1/src/play.c:49: undefined reference to `BASS_ChannelSetAttribute'
collect2: ld returned 1 exit status
make[2]: *** [bassplay_gtk] Error 1
make[2]: Leaving directory `/home/koli/Software/bassplay_gtk-0.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/koli/Software/bassplay_gtk-0.1'
make: *** [all] Error 2
Title: Re: libbass-based module player for Linux
Post by: almos on January 06, 2012, 11:09:08
Actually, Bassplay is my first ever Linux distribution, so it's equally probable I made some error while preparing it.
My mistake from the previous post - it should be /usr/local/include/bass instead of /usr/local/headers/bass! However, it seems from the code you posted that the problems occur at the linking stage. Check for the permissions for the libbas.so installed in the /usr/local/lib subdirectory - or try to change them by hand:

Code: [Select]
sudo chmod 644 /usr/local/lib/libbass.so
Then remove the directory unpacked from tarball and unpack the tarball again. Enter the directory and try to compile the source

I just got results similar to those you got by removing the reading permissions for libbass.so for all the users and groups, so I assume that if the library is in path and the linker still gives you unknown reference errors it might be the case of badly set permissions. Alternately, you can try to run both the configure script and the make commands with the as root  (or via sudo), but the method I gave you worked for me only after I removed the directory unpacked from the tarball and unpacked it again (alternately, you can clean the project via make clean).

I hope this helps!
Title: Re: libbass-based module player for Linux
Post by: Koli on January 06, 2012, 15:00:34
SUCCESS!  ;D

Had to copy the x64 library to /usr/lib after doing sudo make install, but it's working flawlessly, even with PulseAudio.  ;D

Le image: http://cosmic-dreams.net/images/ubuntu/11_10/bassplay_gtk.png

Strange why it connects to PulseAudio with 7.1 though (I only have stereo audio). No matter, it's working. :)
Title: Re: libbass-based module player for Linux
Post by: almos on January 06, 2012, 15:26:35
Congratulations then - and I hope you enjoy using it!
Title: Re: libbass-based module player for Linux
Post by: Koli on January 06, 2012, 15:30:28
I get a segmentation fault when I try to open up a second module, but I guess that will happen considering the player's very early nature.
Title: Re: libbass-based module player for Linux
Post by: almos on January 06, 2012, 16:06:28
That's strange - I play several modules in a row and don't get segmentation fault. There used to be an issue with this earlier on, when I figured out that I'm launching off new threads without terminating threads that don't need to go on (more specifically, the position of the slider is updated by a separate thread that I plan on using for keeping track of several playback parameters at once), but once I got it fixed the program ceased to crash - on my computer, at least. Do you get segmentation faults each and every time you're launching a new module?
Title: Re: libbass-based module player for Linux
Post by: Koli on January 06, 2012, 16:13:44
It only happens when the current module has finished playing. If I stop it before it reaches the end and open another one, it doesn't throw a segmentation fault.
Title: Re: libbass-based module player for Linux
Post by: almos on January 06, 2012, 17:28:51
All right - that's the first thing I'm going to look into when preparing an update. Strange that the problem didn't show up when I was testing the program.
Title: Re: libbass-based module player for Linux
Post by: almos on January 07, 2012, 16:08:57
Sorry for double posting - I decided to do away with my own threads and rely on the in-built BASS event system instead. The problem is that now the program likes to "hang" on my computer until I click on one of the buttons - I used to have same problem when using my own thread to update the slider position, with the difference that when I ordered my thread to sleep for a considerably long time (but short enough for the user to notice that the slider is not moving) the problem seemed to lessen to a considerable degree. On the other hand, the problem that Koli mentioned of should be now gone. The amended version can be downloaded from Sourceforge:

http://sourceforge.net/projects/almos666.u/files/bassplay_gtk-0.1.1.tar.gz/download

EDIT: I played two modules in a row using the updated player and the program didn't "hang", so maybe other users won't experience the issue. This way or another, I'd appreciate any feedback from the Linux users willing to test the program on their own machines.
Title: Re: libbass-based module player for Linux
Post by: almos on February 24, 2013, 08:56:56
After a long hiatus I'm posting another update to the GTK version of Bassplay. The player now saves the session data (such as the last song played and the last directory used) to the /tmp directory, so the user doesn't have to navigate back to his Mod directory each and every time he runs the application. Will update to saving to home directory. I should have added this functionality in the beginning, but job pressure and associated stuff prevented me.

The new version is available at https://sourceforge.net/projects/almos666.u/files/latest/download?source=files

EDIT: It was completely stupid for me to upload the previous version - the new version creates a hidden folder in user's home directory and that's where it stores the session data. The download link above still applies.
Title: Re: libbass-based module player for Linux
Post by: almos on October 07, 2014, 18:22:08
The project has moved to Github (https://github.com/AlekMosingiewicz/bassplay-gtk). I'll try to update it as frequently as I can. So far I fixed a couple of memory allocation errors that popped up under Linux Mint, and also made the distribution more Ubuntu-friendly.

Happy listening!