Build 2015 and Audio Effects

We’re keeping the coding going with this third post in the series of technical articles following the Build 2015 conference. This post shows you how it is so much easier now to develop apps that have fantastic, responsive audio. The next one will focus on video.

Having great audio and video is a big deal to many developers who focus on have a cool, highly interactive user experience for their apps.

A great example of this is Muzik Official Bluetooth-connected drum sticks. This is a super cool app where you do some air drumming… those Bluetooth drum sticks, and the related C#/XAML app, were only possible because of the new Bluetooth and new low-latency audio APIs that were introduced in Windows 10.

The Build Drummer sample app that I showed uses this new AudioGraph API and its low-latency audio capabilities to show how a simple C#/XAML app can have great audio performance on Windows 10.  It is available on Github here – and we know it works with Win 10 build 10074 and Visual Studio 2015 RC.  Go grab it.

With a single line of code, we can instruct the audio stack to use the lowest audio latency possible for the devices in the graph.

 settings.QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency;

 

This sample also shows how simple it is to load samples into memory for playback using normal XAML event handlers.

 

 private async void BuildFileNodes() { // Init all the file input nodes 
  Uri[] uris = new Uri[numSamples]; 
  uris[(int)Samples.Steve] = new Uri
("ms-appx:///Assets/guggs_switch_gears.wav", UriKind.Absolute);
   … 
  uris[(int)Samples.OpenHighHat] = new Uri
("ms-appx:///Assets/Drum-Open-Hi-Hat.wav", UriKind.Absolute);
   // create a node for each uri 
  for (int i = 0; i < numSamples; i++) {
    StorageFile f = await StorageFile.GetFileFromApplicationUriAsync(uris[i]);
    var res = await _graph.CreateFileInputNodeAsync(f);
    if (res.Status != AudioFileNodeCreationStatus.Success) {
       // Give up on this one if the node didn't init properly continue;
    }
    _fileNodes[i] = res.FileInputNode;
    _fileNodes[i].FileCompleted += MainPage_FileCompleted;
    // By default, nodes are started. 
    // But we want to have the nodes start off in the stop state. 
    _fileNodes[i].Stop();
    _fileNodes[i].AddOutgoingConnection(_deviceOutput);
  } 
}

 

If you saw the keynote, I had a little fun with “Guggs”. He likes to say “Let’s switch gears” so we sampled his voice from last year’s keynote and included it here.

Try out the sample. Once you understand the code, swap in some of your own sound samples. If you want to give your coding skills a little stretch, add in some of the in-box effects like echo or reverb, or the ability to record your performance to a file.

 

For more information on AudioGraph: https://channel9.msdn.com/Events/Build/2015/3-634

And here’s another example of AudioGraph: https://github.com/Microsoft/Windows-universal-samples/tree/master/audiocreation

 

It’s the deep engineering work that the Windows team did that radically simplifies the creation of audio effects like this one.

In our next post, we’ll take a look at video processing and the significant work that went into simplifying it – we didn’t get a chance to show this in the Build keynote but I think you’ll find it pretty amazing.