SoloGig v1.0 for Windows And Win 8.1 Tablets (not WinRT) - CodeProject

:

Introduction

I would like to begin this article by saying that my father encouraged me to help other people. So, dad, in my own humble way, in honor of the start of Spring 2015 and what would've been your 88th birthday, this is for you! You have taught me well, may you rest in peace!

The article is a quick introduction to using SoloGig and how it came to exist. Source code with Visual Studio 2013 solution is available from the download link above.

I had spent many hours searching for a "simple media playback tool with lyrics" type of program for any mobile device. While I had certainly found a few that were acceptable none of the acceptable lot were free or behaved in the manner I so desired for "live" use. So, I decided to write my own and give the program away instead of continuing my search online.

My hope is that those who use the application find it useful in "live playing" situations as I have. Those who like to tinker with code can certainly do so. Feel free to either add or suggest more features if necessary. I would like to state that I am by no means an NAudio expert or even C# guru so there may be better ways of dealing with end-of-media events, custom controls, etc. For this application however, to allow the custom list box control to be able to highlight the selected item as well as the currently playing item, I had to "bandage" a "creative" event triggering system together. In other words, the code may be ugly by professional standards!

Background

SoloGig is a small Windows program that I wrote to solve the issue of keeping all related files for playing smaller "solo" type gigs (a la coffee houses, bar duets, backyard parties, etc.) in one conveniently accessible user interface. Given the recent price reductions in tablets capable of running a full version of Windows 8.1, my goal was to write my first "mobile" application such that I can bring SoloGig with me and not require a separate backing track playback system or printed lead sheets and / or lyrics in a folder, etc.

I have tested the application on my Windows 7 x64 development server, a Dell Venue 8" tablet, and an Acer Aspire Switch 10" with excellent results. The tablets in question both run a full version of Windows 8.1. Tablets which use Windows RT will not run this application.

What began as a trivial exercise in C# quickly led me discovering the inadequacies of certain built-in .NET controls. Rather than go on some length diatribe about owner-drawn versus compound controls I will leave it up to the reader to decide whether they simply want to use the program or what features of it they wish to explore if, like me, you consider "playing" with Visual Studio a relaxing endeavor. Nothing too fancy here. A custom round button with three paint modes, a drag and drop list box with custom painting, and a custom slider control for media volume and media playback position. Even though the application is a "plain old WinForms" .NET application I didn't want it to look like one, at least, not the main interface.

While I love .NET it is lacking in decent support for "useful" media techonologies including different formats of compressed audio playback, near realtime (low latency) audio devices, MIDI, etc. etc. Enter NAudio. The NAudio  libraries (links below) solve every problem I faced for this application. Given that NAudio is excellent and free I would like the personally thank Mark Heath for all of his efforts.

Using the Application

Please refer to the screenshot at the top of this article for the following description or simply run the application on your desktop.

SoloGig is designed to be intuitive and touch-screen friendly. You begin by adding media files to a set list by clicking on the round (+) button. Clicking on this add item button opens the following dialog.

Provide a song title, then just browse for the files you wish to use for the current song.

If you would like to remove an entry from the set list, just click on the item in the listview to highlight it, then click the (-) button.

NOTE: You can rearrange the set list order via drag and drop although it can become difficult on touchscreens when the set list becomes quite long.

Once you have several media files collected into a set list, you may want to save the set list for future use. You do this by clicking on the "old floppy disk" icon with the red arrows pointing towards the disk. Provide a filename and click Save. This icon is greyed-out in the screenshot because there is a song playing. You are not allowed to modify or save the setlist, or change the audio device configuration while a media item is playing.

Loading a saved set list is done via the other floppy disk button (with the green arrows pointing away from the disk, also greyed-out in the screenshot).

The button directly below the add item button is for configuration. This allows you to select an audio device for playback. BE WARNED! I have seen several issues using various ASIO devices!

Don't wait until the night of a gig to test if your ASIO device works correctly! Some devices may cause a crash. Some devices have issues being reset (per the existing codebase). The next version of this application will address as many flaws as possible. My best advice to you is to do a trial run of your entire set list before "going live".

The button which looks like a little tablet changes the main window display orientation and maximizes or normalizes the main window as well. I purposefully chose to ignore automatic orientation as there are benefits to being able to select which mode you are comfortable with rather than forcing you to use the one selected based on your devices physical orientation. Simply click this button a few times to step through the four different modes.

The button with the piece of paper simply toggles the display of the chord sheet or the lyrics sheet. Some people prefer to have them separate. I like to have them all in one place (like the screenshot). Chords and lyrics are just text files. I prefer to use RTF (rich text formatted) files to allow more control over display formatting.

You can change the zoom factor of the text display by tapping / clicking on the text area. On a Windows 8.1 tablet, you can actually change the zoom by pinching! Built right into the control! Go .NET! Setting the default zoom when building your set list in the add item dialog can help accommodate files that may be too difficult to read and the normal zoom level.

Simply click on a song in the set list, then click on the play button (|>) near the transport controls.

The green highlight in the listview shows what is currently playing. The purple highlight in the listview shows what is displayed in the text windows. You may want to jump ahead depending on what type of media is currently playing (instrumental, etc.). having two highlights plus the drag reordering is helpful, hence, the custom control.

That's basically it to SoloGig! I hope you find this useful!

ENJOY!

I highly encourage you to open Visual Studio and start digging through the project source code. I'm sure you can think of ways to enhance the application! After digging around a bit you will see it's quite easy!

Using or Augmenting the Code

The code consists of two classes to handle the set list management, SetList.cs and SetListEntry.cs. Start here if you wish to add additional information for every song such as bitmap artwork or whatever you can imagine. The class SetList is just a collection of SetListEntry objects. The class SetList is used to populate the SetList List View at runtime. Remember to edit the SetListEntryEditor form to handle all the plumbing to and from the data storage classes.

The only thing you may want or even need to change (or even add to the config UI) is related to the default audio device buffer size and latency. It exists in the NAudioPlayer.cs helper functions as shown below:

#region Local Private helper Functions

private void CreateWaveOut()
{
    CloseWaveOut();

    // set default latency quite high to avoid glitches on tablets, slow systems, etc.
    int latency = 300;              

    m_WavePlayer = SelectedOutputDevicePlugin.CreateDevice(latency);
    m_WavePlayer.PlaybackStopped += OnPlaybackStopped;
    m_AudioDeviceReady = true;

}
.
.
.

The value of 300 for latency works for all of my devices. It shouldn't really matter because there is no time sensitive synchronization going on here with anything except your ears. That said, if your audio device tends to hiccup, you may want to increase this at the expense of additional lag in the application relative to position tracking, volume changes, etc.

Features I Would Like To Add

There are a few bluetooth devices on the market that are designed to allow media playback control via foot switches. There are additional devices designed to allow "turning pages" much as you would with actual printed sheet music. I would like to add this capability to the next version of Solo Gig. I presume these appear as some type of USB input device but I'm really not sure. I don't have any of them yet.

Additionally I would like the ability to have a media item loop seemlessly and also segue seemlessly into the next media item in the Set List. Currently there are significant audio gaps while attempting each. This may require more low level control over the audio stream. If anyone can offer some good advice on how to implement this I would love to learn!

Points of Interest

NAudio is an excellent library for media manipulation under .NET.

I am only using a very small portion of functionality from this wonderful free library. I have included some of the NAudio form control source code in this project solution so that I could customize the graphical aspects of the audio device selection dialog. Lightly modified versions of the original NAudio source are all located in the NAudioHelperClasses folder within the Visual Studio solution.

I encourage you to explore the entire NAudio project if you would like to write .NET audio applications.

http://naudio.codeplex.com/

Known Issues

Changing the audio device within NAudio while audio is playing is generally a VERY bad thing! The SoloGig user interface prevents you from doing so. If you feel inclined to hack the code, just keep this in mind and be prepared for a blue-screen or two depending on your ASIO device type.

I'm sure there are other bugs lurking in here somewhere. If you find one that is related to the actual application logic and not a specific audio device or some different version of .NET, then please report it and I will do my best to address the issue.

Lastly, take it easy on me! :-) This is my first CodeProject submission!

History

  • SoloGig v1.0 - Initial release