Sunday, 6 November 2016

Creating Tracks for Flute Practice


In order to create backing tracks on Audio CDROM, for flute practice and learning, I download MIDI files (and sheet music) from one of he following sources:


I use Ubuntu Studio (16.04, Xenial Xerus) and a suite of jackd compatible applications. This gives me the flexibility to process and mix anything I want, however, it can be confusing to get going.

Applications I use are (and there are many to choose from):
  1. QJackCtl: A front end to the jackd server (which switches and routes all of the MIDI and music messages between applications).
  2. QSynth: A MIDI synthesizer.
  3. QTractor: A MIDI editor and player.
  4. Ardour: A multi-track audio recorder / editor.
  5. MeterBridge: Level monitor.


Launch QJackCtl - This will put an application in the systray.  Double clicking on the application will show the control window.  It should already be running.

QJackCtl and QSynth Running

Launch QSynth, QTractor and Ardour, and in Ardour, Create a Stereo Audio track (we will use this for the recording).

Ardour and QTractor

Now the Applications have been Launched, you need to patch them together: In QJackCtl Patch Panel, connect the Midi Out from QTractor to QSynth.

Patching MIDI in QJackCtl

Connect the output of QSynth to the Stereo Audio Track in Ardour, and Connect the Stereo Audio Track in Ardour and QSynth to the Speakers.

Patching Audio in QJackCtl

Load a Midi File into QTractor with Edit/Track/Import/Midi, and you can now adjust the volume of one of the tracks to (say) 25% to quieten it down.  Also, you can push the balance (say) 70% to the left and 70% to the right for the two tracks.

Push the Midi tracks to the right if you wish a metronome lead-on and enable the metronome.  And adjust the tempo of the midi file if required.

Setting Volume Levels and Balance in QTractor

Press the Red Record Select/Enable in Ardour on the Audio track

Play the Midi file, and check the levels in Ardour (the Input Level Monitor on the Audio track should 'bounce')

Preparing Ardour and Checking Levels

Press Record/Play in Ardour to start recording in Ardour.

Enable the metronome in QTractor, and then press Play in QTractor, and stop the metronome manually at any point if you wish.

Capturing Synthesized Audio

Let it play to the end.

You should then adjust the Start and End Markers to select the part of the audio track you wish to export, then use the Ardour Session/Export export to save to a wav file.

You can now delete the audio recording in Ardour (click and delete), and rewind, adjust the volume balance for the other Flute voice, and record again.  Note that the 'end' marker moves to the right with  the recording, so you need to keep an eye of where this ends up before any export. 

If you want to pull in other programs, such as monitoring the levels with the Meter Bridge, simply launch the program, and patch it in:

MeterBridge, Level Monitoring


And that's it - you will have a number of WAV files that you can burn to CDROM with an application such as Brasero.

Burning to Audio CDROM with Brasero

Wednesday, 14 September 2016

XYZ Davinci Pro Network Problems

I've got a Davinci Pro 3D printer, and have identified an obscure network connection issue that I believe is associated with the printer firmware.

I use the Windows application to submit a job when connected to the home wifi network, then go out.
I then connect to the home network via VPN, and I can view the printing status ... no problem !
I return home, and reconnect using the home network and get a Timeout error when trying to look at the printing status.
I re-connect via VPN, and everything is fine.
Back to connecting via the home network, and no luck (Timeout again). 
I then wait and reboot the printer, and the home network works fine, until the next time I connect via VPN, of course.

I've managed to eliminate the XYZ software (and Windows) from the equation by using 'telnet printer 9100' - it either connects or times out.

This is the first problem report I've raised with XYZ, so here's hoping.

Monday, 12 September 2016

Braille Bow Ties

After having a taste of a shandy made with beer and cola, I decided it was time to make some labels so that different bottles in the fridge can be differentiated from each other, when the user cannot see.

These Braille Bow Ties clip onto the top of a standard 2L PET bottle neck, and contain a short one or two letter summary of the contents, e.g. DL for Diet Lemonade, SW for Sparkling Water etc.

These were designed using Freecad, saved as STL files, and shared with the world through thingiverse.

Sunday, 14 February 2016

QT 5.6 Development for Windows, from Linux

There are several ways that Windows QT applications can be developed / produced from a Linix machine.  This blog explores a few of them.

It is important to note that with QT5.6, the QWebView support has been dropped in favour of the Chromium-based QWebEngine.  The two offer similar functionality, although there are some differences (asynchronicity of responses being a major one).

QWebEngine's use of Chromium means that the development tools for Windows must use Visual Studio - 2013 or 2015 (at the time of writing).

This means that the QT development using MinGW is incompatible - if you try to build an application with QWebEngineWidgets, you are simply told it does not exist.

Building Options

Option 1: Virtual Machine

This option requires you to install windows (version 7 or greater) in a virtual machine, on which is installed: Visual Studio Community 2013.5 and QT 5.6 for visual studio.

Any time you wish ot build a Windows application, you need to launch the virtual machine.

You can build from the command line with qmake and nmake.  You can also build from the QTCreator environement with correctly configured kits, and I also believe, from the visual studio environment.

Installation of the resulting executable is achieved by:

Copying the .exe file to a chosen folder
Running windeployqt.exe to also  transfer the required DLLs and support files
Installing the copied files on the target machine
Installing the Visual Studio 2013.5 runtime on the target machine

Option 2: Wine - MinGW

This has not been tried - yet.

Option 3: Wine - Visual Studio 2013.5

This fails pretty quickly, as it is not possible to install even the visual studio 2013.5 runtime on Wine.

There is an attempt to create a tool distribution on Wine, but this requires you to go much of the way through Option 1, above, so has little advantage.

Option 4: Crossover - MinGW

This works fine - you can install QT Creator and associated MinGW libraries, buid and execute applications.  However, MinGW is not supported by the Chromium project, so you can't produce applications using QWebEngine.

Option 5: Crossover - Visual Studio 2013.5

Crossover has better support - you can install the runtime on crossover in a bottle, and applications you have compiled (in option 1) actually run applications, although I have found that QWebEngine applications crash when you invoke the web-engine (i.e. populate / display a web page).

However, although the QT development tools install OK, the Visual Studio tools refuse to install, so whilst you can run applications with the Visual Studio runtime, you can't compile them!


Virtual Machine: [build-ok] [buildwebengine-ok] [run-ok] [runwebengine-ok]
Wine - MinGW: [build-?] [buildwebengine-fail] [run-?] [runwebengine-fail]
Wine - Visual Studio: [build-fail] [buildwebengine-fail] [run-fail] [runwebengine-fail]
Crossover - MinGW: [build-ok] [buildwebengine-fail] [run-ok] [runwebengine-fail]
Crossover - Visual Studio: [build-fail] [buildwebengine-fail] [run-ok] [runwebengine-fail]

build - Applications can be built using QTCreator or command line (with appropriate visual studio or MinGW compiler)
buildwebengine - WebEngine Applications can be built using QTCreator or command line
run - Applications run OK on the platform
runwebengine - WebEngine Applications run OK on the platform

So, if you are looking to produce applications which use WebEngine, a virtual machine is currently the only real way to go.

If you are looking to produce non WebEngine applications, using MinGW may be right - this does work with Crossover, and may work with Wine.

Caveat: Note that I have used WebEngine as an example of how Visual Studio and MinGW produced applications differ.  In the past (QT4) I have found that they also differ in the way they support accessibility, and there may well be other differences.

Monday, 25 January 2016

QT QTextCodec and the Euro Character

The Problem

This is, in the end, a simple one to understand, but started with a QT application that when it imported a text file produced on a Windows machine with Notepad, and exporting the same data as in a UTF-8 file, turned the Euro character (0x80) into (0xC280).

Now this displays as a € sign in a QT application on Linux, but not on Windows.  It also does not show in gedit in Linux, but does work in Libre Office.


It turns out that the correct UTF-8 character sequence for the Euro is actually 0xE382AC, not 0xC280 - in fact, if you look at the definition on the unicode website, unicode character 0080 is actually undefined:

Whereas character 20AC is defined as the Euro.

The cause of the problem is the use of the incorrect Codec used to load the file in the first place.

A common mistake is to assume that ISO8859-1 includes the Euro sign, however, ISO8859-1 Does not actually define the Euro character (€) at all, but because this mistake has been made many times over, a lot of applications (including QT and Libre Office) display the character as a Euro.

A down-side of this helpfulness is that it is perfectly possible to have a text file with two characters that look like the €, however one could be unicode character 0080, and the other could be character 20AC - if you searched for a Euro, you would only find one of them!

The Solution

Codecs that do correctly include the Euro character include: Windows-1250, Windows-1252, and ISO8859-15.  QT has the special Codec called 'System', which is whatever the system is using (this should be the same as 'Notepad' - it can be referred to by codecForName("System") or codecForLocale().

In QT applications, when loading text files, it is possible to assume that the file is UTF-8, and failing that, fall back to the preferred alternative, or the default system codec.
QString text ;
QFile file(QString("file.txt")) ;

if ( | QIODevice::Text)) {
  QByteArray filedata = file.readAll() ;
  file.close() ;
  QTextCodec *codec = QTextCodec::codecForName("UTF-8");
  text = codec->toUnicode(byteArray.constData(), byteArray.size(), &state);
  if (state.invalidChars > 0) {
    codec = QTextCodec::codecForLocale() ;
    text=codec->toUnicode(byteArray.constData(), byteArray.size(), &state) ;
    if (state.invalidChars > 0) {
      qDebug() << "Invalid File Format\n" ;