Translate

Sunday, 3 January 2016

Building the Polyphone soundfont editor on a Gentoo system

Polyphone is very useful soundfont editor. Version 1.7 compiled without any issues on my Gentoo system once I had edited the polyphone.pro file (one of the source files) and uncommented these lines (taking the initial hash out):

#DEFINES += USE_LOCAL_RTMIDI
#DEFINES += USE_LOCAL_STK
#DEFINES += USE_LOCAL_QCUSTOMPLOT

This stops qmake trying to find the relevant files in your main Gentoo library directories. As it says in the polyphone.pro file:

# Uncomment a line if your distribution doesn't come with some of the following libraries

It is possible to emerge rtmidi (one of the dependencies) from the Gentoo lorelei overlay but Polyphone's installation script still won't find it.

Using the process described here, you end up with a Polyphone binary which works fine.

The version of GCC used was i686-pc-linux-gnu-4.9.3.

Thursday, 15 October 2015

Brief review of linux mail clients for a lightweight desktop environment

Opera mail

I have found this an excellent mail client (v.12.16). It's fast and the integration with the Web browser is brilliant. It wasn't until I started investigating other Linux email clients that I realised how convenient it is for Web pages accessed through HTML emails to display on a new tab in the same browser. Other email clients with the exception of Claws-mail open  Web pages in a separate browser window. Same sentiment expressed this forum post.

Opera scrolls through my  inbox of over 12,000 emails very smoothly. This client is really the benchmark by which I measure others mail. Perhaps the main drawback of Opera mail in my version is the lack of filters i.e. processing emails into    

Disappointing to learn (a) that the email client is now standalone and even more that (b) there is currently no Linux version of Opera mail.    

Evolution

Seems sluggish in use especially when downloading HTML emails. So difficult to recommend for a lightweight desktop environment. However, integration with Google for mail, calendaring and contacts is excellent. Important to remember to set google account options in gnome-online-accounts not from within Evolution (which was the old way).

Claws mail

Superfast, outperforming Opera mail in terms of speed. This is the program I chose to use following the demise of Opera.

Powerful configuration options and processing tools. Ability to create emails in external editors like vi (if that floats your boat) is a nice feature.

Web pages can be viewed in the same pane as the message by selecting a link although I have not yet found a way to get this to work consistently, sometimes a right click seems to be required.       

Sunday, 4 January 2015

Installing the latest version of Compiz for tear-free Flash playback in Gentoo Linux

The aim here is video playback without screen tearing in Linux, a common issue with  Adobe Flash. If you have this issue with Flash videos embedded in browsers, the effect can be seen clearly in this Youtube video.

Ubuntu users have reported (e.g. in this forum post) that the issue can be resolved by running Compiz as your window manager with its Sync to VBlank  setting enabled. I tested this on Ubuntu and Gentoo and the results were markedly better in Ubuntu. The reason appears to be that Ubuntu is running the latest release of Compiz  (0.9.10.2) whereas the version available through portage is 0.8.8 (described as "the latest stable release" on compiz.org). There are more display setting options in the later version and, possibly because of this, it works better with Flash videos.

It's important to note that the procedure described here shouldn't be followed if it's critical you don't break your system. I use my Gentoo installation as a sandbox as well as a working tool, a way of keeping up to date with, and learning new, Linux skills. Hence it's not critical if something breaks. This being said, I have ended up with a useful and fully-functioning Compiz desktop under Gentoo.

To install the latest release of compiz you have to remove all Compiz components if they have been installed through Portage. In my case:

*  dev-python/compizconfig-python
*  x11-libs/compiz-bcop
*  x11-libs/compizconfig-backend-gconf
*  x11-libs/compizconfig-backend-kconfig4
*  x11-libs/libcompizconfig
*  x11-plugins/compiz-plugins-extra
*  x11-plugins/compiz-plugins-main
*  x11-plugins/compiz-plugins-unsupported
*  x11-wm/compiz
*  x11-wm/compiz-fusion
*  x11-apps/ccsm
*  x11-apps/simple-ccsm

Note that simple-ccsm (simple Compiz Configuration Settings Manager) is not currently available for the latest version of Compiz.

Fortunately,  all the sources for Compiz have now been merged into one repository, which makes configuration, compilation and installation much easier.

Obtaining the latest source code is straightforward as described here:

bzr branch lp:compiz

This creates a compiz directory in the location where you have entered this command. Now:

mkdir build

and

cd build

Next is the configuration stage. You need to run cmake with flags indicating the location of the installation and the options and plugins to install. Currently on Gentoo the 0.9.10.2 default compile configuration won't work  because of a missing header file kdecorationbridge.h. I worked around this by disabling the KDE window decorator option:

-DUSE_KDE4=false

You also have to nominate a location for the installation which by default will otherwise be /usr/local. I installed in the standard location to avoid having to set additional library paths:

-DCMAKE_INSTALL_PREFIX=/usr

Hence in the build directory the full configuration command was:

cmake -DUSE_KDE4=false -DCMAKE_INSTALL_PREFIX=/usr ..

I found with the subsequent make install command the code compiled without a hitch on Gentoo.

A useful initial way of testing if the compiz command is running is:

compiz --version

which should give the output:

compiz 0.9.12.0

Next you need a working desktop running Compiz. I decided to make this as lightweight as possible by running Compiz alongside the excellent fbpanel (which can be emerged through Portage for this purpose). In the directory /etc/X11/Sessions on Gentoo I have a compiz file containing:

#!/bin/sh
xsetbg /home/my_name/.fluxbox/backgrounds/sid_fluxbox.jpg
setxkbmap gb
fbpanel &
exec /usr/bin/compiz ccp 
 

This sets a background, the keyboard to British, runs the Fluxbox panel in the background and then calls compiz. Note that, contrary to the guidance in this Archlinux wiki the ccp switch is still necessary otherwise settings in  ccsm appear to have no effect.

Next, to create a user-selectable desktop option in a graphical login manager (I use lightdm) I have the following compiz-session.desktop file in /usr/share/xsessions:

[Desktop Entry]
Encoding=UTF-8
Name=Compiz 

Comment=dynamic window manager
Exec=/etc/X11/Sessions/compiz
TryExec=/usr/bin/compiz ccp
Icon=
Type=Application


I achieved good results in Adobe flash with the following configuration:

  • the nouveau video driver (the proprietary Nvidia driver still caused screen tearing)
  • the following options:
    • In cssm General => OpenGL => Sync to VBlank
    • In /etc/X11/xorg.conf:
      •  Option "GLXVBlank" "True" #as described here


This setup produced significantly better results in Flash videos (including the the test Youtube video) than the same videos run under a different window manager.

Tip: following recent development work on the nouveau driver, Nvidia cards can be re-clocked to some degree. Add nouveau.pstate=1 to your kernel line in Grub. In my case I then use the command:

cat /sys/class/drm/card0/device/pstate

which results in the output:

20: core 350 MHz shader 350 MHz memory 532 MHz
--: core 200 MHz shader 0 MHz memory 401 MHz *


To re-clock based on this output, in root:

echo 20 > /sys/class/drm/card0/device/pstate

resulting in:

20: core 350 MHz shader 350 MHz memory 532 MHz *
--: core 351 MHz shader 0 MHz memory 532 MHz
 

Tuesday, 25 February 2014

How to play audio from a smarthone through a PC running Linux

Last tested on bluez 5.15 

A few notes on how to setting up an audio connection between a smartphone and a PC running Linux. Skifta is useful just for mp3's but I need to run iReal jazz backing tracks through my PC's speaker system for keyboard improvisation practice for which bluetooth is required.

I am using Gentoo but these notes should be applicable to other distributions.

The key software to install is bluez version 5 and Pulseaudio (the latest at the time of writing is 4.99.4). Pavucontrol (Pulseaudio volume control should also be installed).  Kernel options to enable are described here.

Hardware I am using is the Atheros Communications AR3011 bluetooth dongle (badged as Trust and bought from Ebuyer). The phone is HTC One V.

Blueman currently doesn't work with bluez 5 so is no use for this purpose. Bluedevil (a KDE dongle) does work. I haven't tested Bluetooth using the Gnome control center.

In my experience it is much easier to use the bluetoothctl interactive command line utility than it is to use GUI programs like Blueman and Bluedevil. If the connection fails the GUI programs don't give very helpful output. Connection attempts may appear to "hang" and it's not clear why. The Arch wiki is a useful guide to bluetoothctl but there doesn't seem to be a great deal of documentation available apart from this.

The bluetooth daemon (service) has to be running either through /etc/init.d/bluetooth start or through systemd (where the command is systemctl start bluetooth).

There are some forum posts about configuration of /etc/bluetooth/audio.conf, for instance whether Disable=Socket is necessary. Unless specific bluetooth services are to be disabled, none of these service should be specifically enabled or disabled. Every service that is implemented on your system with then be available. 

There are two main stages to the bluetooth audio setup: pairing and connecting.

Bluetooth obviously must be enabled on the phone, discoverable to all nearby devices and within range of the dongle.

Enter bluetoothctl which will give you the bluetoothctl command line:

[bluetooth]#

Subsequent commands below are all within the bluetoothctl utility.

Power on the controller. if you don't do this, neither the controller (dongle) or the phone may be picked up:

[bluetooth]#power on

Make the dongle discoverable: 

[bluetooth]# discoverable on
 
Another useful command if the phone isn't showing (e.g. when you enter the devices command) is: 

[bluetooth]# scan on

Use the devices command to check what devices have been picked up. This should return  a MAC (hardware) address which looks like this: 

[bluetooth]# Device E6:48:C2:AB:91:32 my_smartphone

Use the info command to check what bluetooth services are available, e.g.

[bluetooth]# info E6:48:C2:AB:91:32 

Before trying to pair the dongle and the smartphone make sure you register the agent:

 [bluetooth]# agent on

There are other options for this command, but this is sufficient to ensure the dongle and smartphone are ready to be paired. If this command isn't used, a pairing  prompt appears on the phone but without a passkey. Although this prompt can be accepted, the phone and teh dongle won't be paired. 

Use show command  to check the controller is pairable and likewise the device command for the phone. If both are shown as pairable, enter the pair command with the phone's MAC address e.g.:

[bluetooth]# pair E6:48:C2:AB:91:32

You are returned to the bluetoothctl prompt. Wait until bluetoothctl confirms the pairing is successful. 

Now run up pavucontrol (pulseaudio volume control). Select the "Playback" tab and then  select "All streams" from the picklist at the bottom of the screen. pavucontrol helps you monitor whether a successful audio connection has been made using the A2DP protocol. 

Next try to connect the phone to the dongle, e.g.

[bluetooth]# connect E6:48:C2:AB:91:32

bluetoothctl should indicate if the connection is successful. If so you should also see the phone shown as a "loopback" device in pavucontrol.

At this point, I sometimes find that the phone appears to be connected as an audio source but there is no sound. The only workaround for this issue appears to be to using the bluetoothctl disconnect command followed by connect.

Saturday, 22 June 2013

Streaming mp4 videos from an Android device to gmediarender on a UPNP-enabled remote device

gmediarender is a resource efficient UPNP-compatible media renderer suitable for lower specification devices such as the Raspberry pi.

Skifta can be used as both media server and control point (i.e. the remote) but in my experience mp4 files can't be streamed from the Skifta server on the phone (HTC One V in this case) to gmediarender. This results is an error "media unable to perform play".

One solution is to use BubbleUPnP as the control point with the setting Mime-type check unchecked (this setting can be found under "UPNP tweaks"). Within BubbleUPnP on the Android device either Skifta or BubbleUPnP  can be used as the media server.  

Another app which works well with gmediarender is MediaHouse which plays back mp4s without any need to configure the app.   

The UPnP Play app seems to have the same issue with mp4's being streamed to gmediarender, it returns "unsupported format video/mp4"

Sunday, 16 June 2013

How to create create karaoke videos in Linux from midi files created in the nted score editor

The pykaraoke utility can be used to generate karaoke videos in Linux from original midi files created using the nted score editor. Other score editors in Linux that I have tested do not appear to work (Denemo, Musescore, Rosegarden) as they don't produce a midi file with lyrics in a form which can be  processed by pykaraoke. Another solution is to use Noteworthy composer under wine. Noteworthy is an excellent score editor with a very user-friendly interface although not open source. Noteworthy produces tidier output because hyphens used to separate syllables in the lyrics do not show in the final video. In Noteworthy, midi files must be created a type 0 (there is a pick list in the midi export dialog). nted is a good solution for Linux. It has more advanced functionality in some areas than Noteworthy.


First create a midi file with lyrics using nted as explained in the documentation. Make sure the midi score  doesn't start with rests as this causes music/video synchronisation issues. Export the nted score you have created in midi format.

Download and unpack this script into your folder which contains the pykaraoke scripts and make the script executable. Run the script with the first argument as the midi file and the second argument as the soundfont e.g.:

karaoke /midi_files/my_midi_file.mid /my_soundfonts/soundfont.SF2

The script produces a standard video in mp4 format. You can also run the nted midi file directly using a progam such as kmid but the music won't be synchronised accurately with the lyrics in my experience and the output is not so easily shared as an mp4 video.  

The script assumes:

  • python 2, mjpegtools, mplayer, ffmpeg and fluidsynth are installed
  • you are running the script from the same folder into which you have downloaded the pykaraoke scripts (pykaraoke also has its own dependencies)
  • a soundfont is available on your system (such as FluidR3_GM.sf2)  

Any further information needed, please leave a comment.
Alert icon

Wednesday, 13 February 2013

Using MMA to generate musical accompaniments under Linux

Musical Midi Accompaniment (MMA) provides an open source alternative to the proprietary Windows/Mac Band in a Box. It is a command line utility with an extensive reference manual.

There is also a GUI available called linuxband which is simple to use and provides some access to the functionality of MMA. Linuxband enables you to quickly create chord sequences for midi output and choose a "Groove" which is a musical style for the chords. Linux band requires the jack soundserver which is typically started up and configured using qjackctl. You may find, like me, that linuxband appears as an output port in qjackctl with nothing  to connect it to, like so...


...because your input ports are all under the ALSA tab...



If this is the case, you can use a2jmidid  to surface the ALSA input ports under the midi tab (for Gentoo and OpenSUSE users there are packages available). Once a2jmidid is running, the relevant connections can be made. Use the -e switch to make hardware ports available such as the emu10k1 ports (shown below):


a2jmidid will also make software synths such as fluidsynth and its GUI frontend qsynth available as a writable client for linuxband.  

There are a huge number of Band in a Box files available on the Internet so it's useful to have a utility that converts these files to MMA format. Alain Brenzikofer's Perl script no longer works with recent versions of Perl 5 (because of a deprecated function. I tried it on v5.16.1). Here is an amended version which will work. The download includes a gentoo ebuild which will pull in this version from my Web site. According to the documentation, the script can't convert all BIAB files but so far it has worked fine with everything I have tried.       

If you are learning to improvise, it's useful to have a backing track in all 12 keys. This script (usage: transpose [file].mma)  transposes an mma file into all the other keys of  he chromatic scale. It assumes the mma file contains a Groove command. 

The -T switch used with the mma command is very handy if you need to reduce the number of instruments in a backing track. I use this to create backing tracks containing only bass and drums. The -c switch displays which tracks are available in any given mma file.  

Here are some midi files with bass and drums generated from mma which I use for jazz practice: