Wednesday, 21 January 2015

Streaming your game with multiplayer audio using XSplit and two sound cards

Catchy title, no?

When streaming a game, XSplit Gamecaster allows me to take the sounds from that game and mix in a single vocal input, however I have two sound cards to allow me to use a mixing desk to manipulate the levels of a Skype call against the game sounds (I posted before about the details of my audio setup on my gaming machine). The XSplit options work for me when streaming or recording single player footage with commentary, however there are problems when it comes to capturing multiplayer gaming along with the group conversations as essentially there are two vocal sources (my voice and everyone else's voice). This leaves me having to choose two of the three audio sources and ending up with either the game sounds plus friends talking to a silent me or the game sounds plus me apparently chatting to nobody.

Why XSplit and Skype?

I am sure there are better capture programs than XSplit Gamecaster (the more-featured Broadcaster, for example) but they require more work to set up and at a quick glance do not offer the required additional options to solve this particular problem. Whatever its shortcomings, Gamecaster does a fantastic job of getting streaming and recording set up with minimum fuss.

The choice of Skype for communication is because that's how my regular group communicates. Again, there are probably better options but this works for us at the moment. For this problem, it shouldn't actually matter as it is basically conversation out of a secondary sound card, which can be done with any chat program.

Also it is worth noting that this is all done on Windows 7.

My requirements

I game a lot but at the moment I record rarely, so any solution needs to both be easy to fire up (to encourage me to do it) and non-intrusive (so my normal gaming doesn't get any worse).

  • low impact on my normal gaming once set up
  • easy to turn on when desired
  • records game sounds and both parts of the Skype call
  • I don't have my own voice echoed back to me through my headphones
  • allow me to keep my current hardware configuration

How to do it

First, we need to get at the output of the second sound card. For Creative Cards, this will be a device called "What You Hear". The RealTek equivalent is "Stereo Mix". Hit the start button and look for "Sound". On the dialogue that appears, select the "Recording" tab. If the device isn't there, right click and enable disconnected and disabled devices. It should appear. In XSplit, select this device as Microphone Input.

At this point, if you are playing a multiplayer game with a Skype call you'll record game sounds and your friends' voices but your own voice will be missing.

Next, go back to the Recording tab on the Sound dialogue. Find your microphone, right click, properties and select the "advanced" tab. Disable exclusive mode (both boxes). Finally, go to the "listen" tab. When you install XSplit it creates a device called XSplit Stream Audio Renderer. Select it from the drop-down and check "listen to this device".

Done! Now, when you record again you'll find your voice is included in the mix.

If you look at the audio options in your system tray you'll see that you can set the levels on the XSplit Stream Audio Renderer which will let you balance your recording.

What is going on?

XSplit seems to create a software audio device (i.e. it doesn't physically exist) and record the output of that. Behind the scenes it mixes the Default Audio output and whatever is specified as the mic input into this device. All we have done here is add an additional audio stream to that device using native Windows options. I added the microphone to the XSplit device by hand and let XSplit handle adding the rest of the Skype call, but I assume it would work just as well the other way around.


If you aren't using XSplit or you don't want to mess with one of its components you may want an alternative.

I am trying to mix three audio channels (game, mic and other vocals) when XSplit only allows me to specify two sources (default sound and mic input). In practice, XSplit lets me select any Windows audio input device as the "microphone input" and this gives me the option of creating a new (software) sound source and pre-mixing the microphone input and other vocal output. This requires additional software (such as AmaMix (free) or VAC) which is why I went with the above solution which only uses standard features of Windows.

Friday, 9 January 2015

Controlling your gaming audio through a hardware mixer

I play a lot of multiplayer games and getting the balance between communication and game sounds so both can be heard is very important. Alt-tabbing out of a game to fiddle with the Windows mixer is a pain and is potentially a one-way trip so I've been looking for a better solution.

My requirements

I have three different audio sources on my computer which need balancing:
  • game sounds
  • communication (my group uses Skype, I don't see why this won't work for TeamSpeak)
  • music (from time to time)
And I want to be able to change the levels without leaving my game.

The problems

There are two problems - both with fairly simple solutions: how to separate the audio streams, and how to re-combine them after the levels have been set.


First, I separated communication. A second sound card solved this problem - Skype can be configured to use any audio output device. Like most gamers, I have a PCIe sound card (Sound Blaster X-Fi for me) which means I have an unused sound card integrated into my motherboard. Re-enable that in the BIOS, point Skype at it and we're away.

For music, I cheated. A while ago I switched the music systems in my house to Sonos - I've written about moving music to a NAS and getting it tagged properly in the past - and this means that it is already a separate stream. The problem with the Sonos output was actually mixing back it into the others so I could listen to music while gaming with headphones.

This leaves my game sounds coming out of the primary sound card in my computer. Three separate audio streams - done.


To re-combine the audio, and also allow me to fiddle with the levels while in-game, I went for a mixing desk. I chose a Yamaha MG124C which is a bit over the top but I really wanted faders (the sliders) for volume control, not just pots (the twiddly knobs) and this was one of the smallest desks available with that feature. I've also used this desk in a radio station in the past so I know it makes a decent sound, is well made and isn't covered in useless features which are likely to break.

Setting up the desk was straightforward - the stereo output from the main sound card and Sonos go into the main stereo channels and the Skype soundcard goes into one of the secondary stereo channels. Some decent cables are also required; I'm using a variety of Adam Hall cables like this. The different channels are routed through the group fader so I can switch between output to the amp and output to the headphones with ease.


And that's it. Now when I'm gaming if I can't hear my team-mates I can simply reach over to the desk and turn up the Skype channel, or turn down the game channel. I can add in music as I choose, or mute it at the touch of a button if things are getting hectic. I can easily make ongoing adjustments to these settings without ever leaving the game.

Hopefully someone will find this useful. The biggest problem I've encountered so far with this setup is how to record game play along with the communication channel. I will cover the solution for that in the next post.

Saturday, 27 December 2014

The year that was

I often kick myself for not indulging my creative side enough, so in the interests of being positive once in a while and reminding myself that I do write more than I think I'm compiling a (likely incomplete) list of creative "things" done this year.

2015 is on the horizon. More next year.

Ubuntu 14.10, finally

I seem to have gotten into the habit of writing a post each time I do an upgrade, so here is the one for Ubuntu 14.10. It's really easy - by far the simplest upgrade I can remember. This, I'm sure, is partly because the changes behind the scenes this time are more about stability than new features but it's a welcome change. Nothing, and I mean nothing has broken for me either on my desktop install or this laptop.

I can't say I'm immediately noticing many improvements either, other than the latest packages. Not that I'm complaining - mostly, an obvious improvement means a change and frankly I like Ubuntu 14.04 enough as it was that it didn't need another overhaul to make me happy. Some minor bugs have been ironed out - the big one is that it no longer randomly forgets my keyboard language preferences.

So, don't fear this one. For me, this is the perfect upgrade - nothing broken and no major changes to learn.

Wednesday, 23 July 2014

Ubuntu 14.04 - here we go

Quick post about the upgrade from Ubuntu 13.10 to 14.04. It went ahead without any real problems. For the first time my decision to disable the utterly horrible "shopping" lens in Unity was honoured over an upgrade (well done - finally).

Bad things: the window close buttons have wandered over to the left AGAIN. This time apparently Canonical have removed the all of the options to move them back (well, someone is recommending recompiling the window manager but there is no way I'm doing that). Thanks guys, that's really helpful.

Further bad things: synaptiks is currently missing from the Ubuntu repositories so if you want a middle mouse click on your touchpad you're out of luck. Fortunately there is a way around that - you can install it from the debian repository:

sudo apt-get update
sudo apt-get install wget gdebi
sudo gdebi kde-config-touchpad_0.8.1-2_all.deb

That solution pulled from here.

Now to man up and do this on my work machine...

Friday, 25 April 2014

Tagging a music library for use with a Sonos system

I migrated my iTunes music library to a NAS built with a Raspberry Pi so it could be shared with my Sonos system. Before this the only thing reading any metadata on the files was iTunes which can sometimes do weird things. Coupled with that, I've previously used TuneUp to fix broken metadata within iTunes. It works very well in that context but it seems that the metadata it writes is non-standard in some way and other programs will not read it. All this manifests in some of my music only appearing in the track listing part of the Sonos interface, being listed by filename rather than track name and not being listed by album or artist at all.

What do I need?

Sonos reads standard id3 tags - apparently v1 or any of the v2 options. The files need to be tagged in one of these formats.

Fixing things up

My files are kept in a consistent directory structure looking like this:

blah/Music/Gun/Swagger/01 Stand in line.mp3

My first plan was to use a Linux command line utility for reading and writing id3 tags and pull the required information from the directory path using some clever scripting. I've been away from work for over a week so my brain isn't really up to the required "clever" scripting at the moment. Fortunately, when building the NAS as per my last post I made all my music available over a samba share so it was easy to mount that on my desktop machine and get access to the files that way.

There are dozens of GUI id3 editors. I chose to use mp3tag (my desktop is a Windows machine) and hoped I could somehow convert the tags produced by TuneUp and used in iTunes to something more standard. Unfortunely mp3tag lists the TuneUp tags as "Bad Tags". Drat. Well, at least that explains the problem.

So, armed with my new clicky it's back to plan 1. Having found the files which needed attention I used the "filename-tag" converter with this pattern:

%artist%\%album%\%track% %title%

Slashes reversed because we're in a Windows environment now.

This solved the vast majority of the problems. There were still a few albums tagged in a bizarre way - with no track numbers and a title of something like "01 Intro". I didn't want to completely nuke the existing tags for these as they included Album Art so it was time to break out the "tag-tag" converter which lets you use existing information in the tag to populate other fields.

We need two different filters here, applied in this order because the second removes information needed for the first.

Field: TRACK
Pattern: $left(%TITLE%,2)


Field: TITLE
Pattern: $cutLeft(%TITLE%,3)

These methods came from the scripting section of the mp3tag documentation. It turns out it's quite powerful, even if the methods don't always do exactly what the docs suggest they will do.

Job done.

Next steps

My album art is all extremely patchy. Sonos is now my primary playout system at home and it takes an age to load album art so I'm not too bothered about fixing it, however if I change my mind there are a couple of options. Firstly, mp3tag lets you paste album art into the box rather than having to use a presaved photo. I can look up album art in iTunes and copy from there for the occasional simple fix.

If I want to do a proper, automatic job I'll probably take a look at Album Art Downloader which is apparently very good and can be run as a tool within mp3tag. That's fun for another day though.

Monday, 21 April 2014

Using a Raspberry Pi as a headless media store on a Sonos network

This is to build a headless media centre and is also being built that way - that is, I'm not going to plug a screen or keyboard/mouse directly into the Pi. This means that I can install the version of Debian without the window manager which makes it far lighter on the processor.

It's not difficult, but I've compiled my notes and written some English to link them together as someone may find them useful. I'm going to assume some basic Linux and home networking knowledge.

You will need

Sourced from Amazon, total cost (at time of writing, without hunting around) is: £47.60

You'll also need some USB hard drives. The Pi (model B here) only has USB 2.0 ports so you can use older drives if you're not planning on plugging them in anywhere else. Also, the Pi runs on very low power so you really want powered drives or a powered USB hub to sit between them. If you want to back up your data, you're going to need two drives. If you don't, you can ignore all the stuff about rsync that comes up later.

Let's go

Up and running

  1. download Raspbian
    Sadly, the NOOBS install method requires the use of a screen so wont work for us.
  2. install Raspbian onto the SD card
    These are the instructions for prepping the card on a Windows machine.
  3. put the Pi in the case, plug in the ethernet cable and put in the SD card
  4. finally plug in the power cable and we're off

Connect and update

Find the IP address of your Pi, shell to it and log in (default username / password is pi / raspberry). You need to run:
sudo raspi-config
and select the option to expand the root filesystem to fill the SD card. It's important you do this before any of the other steps or you will be starting again.

Next update the operating system via:
sudo apt-get update
sudo apt-get upgrade
This will likely take a while.

Connect the drives

Plugging the drives in will auto-mount them, however if we are using one drive as a backup to the other we need to ensure they are always mounting the same way round on restart. To do this we will identify the drives via their UUID in /etc/fstab:
UUID=0AC4D607C4D5F543 /mount/location ntfs rw,defaults 0 0
To find the UUID of the drives:
blkid /dev/sda1
blkid /dev/sdb1
Remember that if you format a drive, the UUID will change.

Install the software

Time to install some useful software.

Samba shares specified parts of your filesystem on the network. It will allow you to mount the drive on another computer which will let you put files on your media server when it's ready. It is also the shared area that Sonos will be able to search for music files.

Minidlna shares an area of your filesystem via DLNA. This means a DLNA-ready device can locate the share and request any files in it. I use this for watching video on my iPad (my viewing program of choice being 8player).
# install samba
sudo apt-get install samba samba-common-bin

# install minidlna
sudo apt-get install minidlna
I also installed some extra tools to make other tasks easier. You don't need them for this build.
sudo apt-get install tree locate chkconfig

Configure samba

To configure samba you need to edit /etc/samba/smb.conf. You'll want something like this:
    netbios name = NETBIOS_NAME
    workgroup = WORKGROUP
    security = user
    encrypt passwords = yes
    smb passwd file = /etc/samba/smbpasswd

    comment = My media
    path = /PATH/TO/SHARE
    writeable = yes
    create mask = 0770
    force create mode = 0770
    locking = yes
Mixed to taste, of course.

Then add the user to the samba password file:
sudo smbpasswd -L -a USERNAME
Restart samba and you should then be able to mount the drive on other machines on the network.

Configure minidlna

The minidlna config file is found at /etc/minidlna.conf

Docs on configuring minidlna are available on the minidlna site. The important bits are:
media_dir=A,/home/user/Music      # Music directory
media_dir=P,/home/user/Pictures   # Pictures directory
media_dir=V,/home/user/Videos     # Video directory
friendly_name=Laptop              # Name of the share
db_dir=/var/cache/minidlna        # Index files (make sure location is writeable)
log_dir=/var/log                  # Log files (make sure location is writeable)
inotify=yes                       # Index new files as they are added
It's important to make sure the minidlna user can read and write to the index and log directories and read the media files. Alternately, if you're lazy like me you can make minidlna run as the main user by editing /etc/init.d/minidlna (around line 68). Obviously this is not recommended for any significant install of anything, but I'm assuming we're at home on a very limited access network.

When starting minidlna you may get an error message claiming to be exceeding the watch limit. To increase this limit, add to /etc/sysctl.d/90-inotify.conf
fs.inotify.max_user_watches = 100000
and restart.

Note that there is a new version of minidlna on the way called ReadyMedia possibly rendering this completely obsolete.

Back up the drives

I wanted to keep a backup of my media on the second drive. I could have used RAID 1 but reading around suggested that the amount of read/write information going across the USB bus would cause a bottleneck and therefore problems serving the files. To get around this, I use rsync to copy everything across on a nightly basis.

Something like this in the crontab will sync the drives each night at 3am:
0 3 * * * rsync /mountpoint/maindrive /mountpoint/backupdrive >> ~/rsync_log.txt 2>&1
And with this, the setup is complete.

Getting the media files in order

Sonos will read the ID3 tags on the music files so they need to correct. Due to the fun of an iTunes crash some time in the past mine are a mess so it's time for some scripting. More on this in a future post.