Skip to content

Commit

Permalink
Windows 10 Anniversary Update - August 2016 Update 4
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed Aug 18, 2016
2 parents 6623695 + d9f8c36 commit 4ea76f7
Show file tree
Hide file tree
Showing 19 changed files with 526 additions and 458 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=619979
--->

# Universal Windows app samples
# Universal Windows Platform (UWP) app samples

This repo contains the samples that demonstrate the API usage patterns for the Universal Windows Platform (UWP) in the Windows Software Development Kit (SDK) for Windows 10. These code samples were created with the Universal Windows templates available in Visual Studio, and are designed to run on desktop, mobile, and future devices that support the Universal Windows Platform.
This repo contains the samples that demonstrate the API usage patterns for the Universal Windows Platform (UWP) in the Windows Software Development Kit (SDK) for Windows 10. These code samples were created with the Universal Windows Platform templates available in Visual Studio, and are designed to run on desktop, mobile, and future devices that support the Universal Windows Platform.

## Universal Windows Platform development

These samples require Visual Studio 2015 and the Windows Software Development Kit (SDK) for Windows 10 to build, test, and deploy your Universal Windows apps.
These samples require Visual Studio 2015 and the Windows Software Development Kit (SDK) for Windows 10 to build, test, and deploy your Universal Windows Platform apps.

[Get a free copy of Visual Studio 2015 Community Edition with support for building Universal Windows apps](http://go.microsoft.com/fwlink/?LinkID=280676)
[Get a free copy of Visual Studio 2015 Community Edition with support for building Universal Windows Platform apps](http://go.microsoft.com/fwlink/p/?LinkID=280676)

Additionally, to stay on top of the latest updates to Windows and the development tools, become a Windows Insider by joining the Windows Insider Program.

[Become a Windows Insider](https://insider.windows.com/)

## Using the samples

The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in Visual Studio 2015.
The easiest way to use these samples without using Git is to download the zip file containing the current version (using the following link or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in Visual Studio 2015.

[Download the samples ZIP](../../archive/master.zip)

**Notes:**
* Before you unzip the archive, right-click it, select Properties, and then select Unblock.
* Before you unzip the archive, right-click it, select **Properties**, and then select **Unblock**.
* Be sure to unzip the entire archive, and not just individual samples. The samples all depend on the SharedContent folder in the archive.
* In Visual Studio 2015, the platform target defaults to ARM, so be sure to change that to x64 or x86 if you want to test on a non-ARM device.

The samples use Linked files in Visual Studio to reduce duplication of common files, including sample template files and image assets. These common files are stored in the SharedContent folder at the root of the repository and referred to in the project files using links.
The samples use Linked files in Visual Studio to reduce duplication of common files, including sample template files and image assets. These common files are stored in the SharedContent folder at the root of the repository, and are referred to in the project files using links.

**Reminder:** If you unzip individual samples, they will not build due to references to other portions of the ZIP file that were not unzipped. You must unzip the entire archive if you intend to build the samples.

For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance, tutorials, and reference topics provided in the Windows 10 documentation available in the [Windows Developer Center](http://go.microsoft.com/fwlink/?LinkID=532421). These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for Windows.
For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance, tutorials, and reference topics provided in the Windows 10 documentation available in the [Windows Developer Center](http://go.microsoft.com/fwlink/p/?LinkID=532421). These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for Windows.

## Contributions

These samples are direct from the feature teams and we welcome your input on issues and suggestions for new samples. At this time we are not accepting new samples from the public, but check back here as we evolve our contribution model.
These samples are direct from the feature teams and we welcome your input on issues and suggestions for new samples. At this time we are not accepting new samples from the public, but check back here as we evolve our contribution model.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## See also
Expand Down
18 changes: 9 additions & 9 deletions Samples/AudioCreation/cs/AudioCreation/Scenario4_Submix.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<Setter Target="audioPipe1.(RelativePanel.AlignVerticalCenterWith)" Value="fileButton1" />
<Setter Target="audioPipe2.(RelativePanel.RightOf)" Value="fileButton2" />
<Setter Target="audioPipe2.(RelativePanel.AlignVerticalCenterWith)" Value="fileButton2" />
<Setter Target="subMixNode.(RelativePanel.RightOf)" Value="audioPipe1" />
<Setter Target="subMixNode.(RelativePanel.AlignTopWith)" Value="fileButton1" />
<Setter Target="submixNodeContainer.(RelativePanel.RightOf)" Value="audioPipe1" />
<Setter Target="submixNodeContainer.(RelativePanel.AlignTopWith)" Value="fileButton1" />
<!--Output device is to the right of submix node-->
<Setter Target="audioPipe3.Height" Value="10" />
<Setter Target="audioPipe3.Width" Value="80" />
<Setter Target="audioPipe3.Margin" Value="0,20,0,0" />
<Setter Target="audioPipe3.(RelativePanel.RightOf)" Value="subMixNode" />
<Setter Target="audioPipe3.(RelativePanel.AlignVerticalCenterWith)" Value="subMixNode" />
<Setter Target="audioPipe3.(RelativePanel.RightOf)" Value="submixNodeContainer" />
<Setter Target="audioPipe3.(RelativePanel.AlignVerticalCenterWith)" Value="submixNodeContainer" />
<Setter Target="speakerContainer.Margin" Value="0,20,0,0" />
<Setter Target="speakerContainer.(RelativePanel.RightOf)" Value="audioPipe3" />
<Setter Target="speakerContainer.(RelativePanel.AlignVerticalCenterWith)" Value="audioPipe3" />
Expand All @@ -60,14 +60,14 @@
<Setter Target="audioPipe1.(RelativePanel.AlignVerticalCenterWith)" Value="fileButton1" />
<Setter Target="audioPipe2.(RelativePanel.RightOf)" Value="fileButton2" />
<Setter Target="audioPipe2.(RelativePanel.AlignVerticalCenterWith)" Value="fileButton2" />
<Setter Target="subMixNode.(RelativePanel.RightOf)" Value="audioPipe1" />
<Setter Target="subMixNode.(RelativePanel.AlignTopWith)" Value="fileButton1" />
<Setter Target="submixNodeContainer.(RelativePanel.RightOf)" Value="audioPipe1" />
<Setter Target="submixNodeContainer.(RelativePanel.AlignTopWith)" Value="fileButton1" />
<!--Output device is below submix node-->
<Setter Target="audioPipe3.Height" Value="80" />
<Setter Target="audioPipe3.Width" Value="10" />
<Setter Target="audioPipe3.Margin" Value="0,0,0,0" />
<Setter Target="audioPipe3.(RelativePanel.Below)" Value="subMixNode" />
<Setter Target="audioPipe3.(RelativePanel.AlignHorizontalCenterWith)" Value="subMixNode" />
<Setter Target="audioPipe3.(RelativePanel.Below)" Value="submixNodeContainer" />
<Setter Target="audioPipe3.(RelativePanel.AlignHorizontalCenterWith)" Value="submixNodeContainer" />
<Setter Target="speakerContainer.Margin" Value="0,0,0,0" />
<Setter Target="speakerContainer.(RelativePanel.Below)" Value="audioPipe3" />
<Setter Target="speakerContainer.(RelativePanel.AlignHorizontalCenterWith)" Value="audioPipe3" />
Expand Down Expand Up @@ -110,7 +110,7 @@
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Border x:Name="subMixNode" Background="#313131" Width="160" Height="130" Margin="-10,20,0,0">
<Border x:Name="submixNodeContainer" Background="#313131" Width="160" Height="130" Margin="-10,20,0,0">
<StackPanel Orientation="Vertical">
<TextBlock x:Name="submixLabel" Text="SubMix Node" HorizontalAlignment="Center" Margin="0,20,0,0"/>
<ToggleSwitch x:Name="echoEffectToggle" Header="Echo" IsOn="False" Toggled="EchoEffectToggle_Toggled" IsEnabled="False" Margin="40,15,0,0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private async Task CreateAudioGraph()
speakerContainer.Background = new SolidColorBrush(Colors.Green);

submixNode = graph.CreateSubmixNode();
subMixNode.Background = new SolidColorBrush(Colors.Green);
submixNodeContainer.Background = new SolidColorBrush(Colors.Green);
submixNode.AddOutgoingConnection(deviceOutputNode);

echoEffect = new EchoEffectDefinition(graph);
Expand Down
14 changes: 10 additions & 4 deletions Samples/AudioCreation/cs/CustomEffect/CustomEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ public sealed class AudioEchoEffect : IBasicAudioEffect
// Mix does not have a set - all updates should be done through the property set.
private float Mix
{
get { return (float)propertySet["Mix"]; }
get
{
object val;
if (propertySet != null && propertySet.TryGetValue("Mix", out val))
{
return (float)val;
}
return .5f;
}
}

public bool UseInputFrameForOutput { get { return false; } }
public bool TimeIndependent { get { return true; } }
public bool IsReadyOnly { get { return true; } }

// Set up constant members in the constructor
public AudioEchoEffect()
Expand Down Expand Up @@ -100,7 +106,7 @@ unsafe public void ProcessFrame(ProcessAudioFrameContext context)
inputData = inputDataInFloat[i] * (1.0f - this.Mix);
echoData = echoBuffer[currentActiveSampleIndex] * this.Mix;
outputDataInFloat[i] = inputData + echoData;
echoBuffer[currentActiveSampleIndex] = inputData;
echoBuffer[currentActiveSampleIndex] = inputDataInFloat[i];
currentActiveSampleIndex++;

if (currentActiveSampleIndex == echoBuffer.Length)
Expand Down
38 changes: 22 additions & 16 deletions Samples/CameraFrames/cpp/FrameRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ struct ColorBGRA

// Colors to map values to based on intensity.
static constexpr std::array<ColorBGRA, 9> colorRamp = {
ColorBGRA{0xFF, 0x7F, 0x00, 0x00},
ColorBGRA{0xFF, 0xFF, 0x00, 0x00},
ColorBGRA{0xFF, 0xFF, 0x7F, 0x00},
ColorBGRA{0xFF, 0xFF, 0xFF, 0x00},
ColorBGRA{0xFF, 0x7F, 0xFF, 0x7F},
ColorBGRA{0xFF, 0x00, 0xFF, 0xFF},
ColorBGRA{0xFF, 0x00, 0x7F, 0xFF},
ColorBGRA{0xFF, 0x00, 0x00, 0xFF},
ColorBGRA{0xFF, 0x00, 0x00, 0x7F}
ColorBGRA{ 0xFF, 0x7F, 0x00, 0x00 },
ColorBGRA{ 0xFF, 0xFF, 0x00, 0x00 },
ColorBGRA{ 0xFF, 0xFF, 0x7F, 0x00 },
ColorBGRA{ 0xFF, 0xFF, 0xFF, 0x00 },
ColorBGRA{ 0xFF, 0x7F, 0xFF, 0x7F },
ColorBGRA{ 0xFF, 0x00, 0xFF, 0xFF },
ColorBGRA{ 0xFF, 0x00, 0x7F, 0xFF },
ColorBGRA{ 0xFF, 0x00, 0x00, 0xFF },
ColorBGRA{ 0xFF, 0x00, 0x00, 0x7F }
};

static ColorBGRA ColorRampInterpolation(float value)
Expand Down Expand Up @@ -122,29 +122,29 @@ static ColorBGRA InfraredColor(float value)
}

// Maps each pixel in a scanline from a 16 bit depth value to a pseudo-color pixel.
static void PseudoColorForDepth(int pixelWidth, byte* inputRowBytes, byte* outputRowBytes)
static void PseudoColorForDepth(int pixelWidth, byte* inputRowBytes, byte* outputRowBytes, float depthScale)
{
// Visualize space in front of your desktop, in meters.
constexpr float min = 500; // 0.5 meters
constexpr float max = 4000; // 4 meters
constexpr float min = 0.5f; // 0.5 meters
constexpr float max = 4.0f; // 4 meters
constexpr float one_min = 1.0f / min;
constexpr float range = 1.0f / max - one_min;

UINT16* inputRow = reinterpret_cast<UINT16*>(inputRowBytes);
ColorBGRA* outputRow = reinterpret_cast<ColorBGRA*>(outputRowBytes);
for (int x = 0; x < pixelWidth; x++)
{
UINT16 value = inputRow[x];
float depth = static_cast<float>(inputRow[x]) * depthScale;

// Map invalid depth values to transparent pixels.
// This happens when depth information cannot be calculated, e.g. when objects are too close.
if (value == 0)
if (depth == 0)
{
outputRow[x] = { 0 };
}
else
{
float alpha = (1.0f / value - one_min) / range;
float alpha = (1.0f / depth - one_min) / range;
outputRow[x] = PseudoColor(alpha * alpha);
}
}
Expand Down Expand Up @@ -252,8 +252,14 @@ SoftwareBitmap^ FrameRenderer::ConvertToDisplayableImage(VideoMediaFrame^ inputF
}
else if ((inputBitmap->BitmapPixelFormat == BitmapPixelFormat::Gray16) && (inputFrame->FrameReference->SourceKind == MediaFrameSourceKind::Depth))
{
using namespace std::placeholders;

// Use a special pseudo color to render 16 bits depth frame.
return TransformBitmap(inputBitmap, PseudoColorForDepth);
// Since we must scale the output appropriately we use std::bind to
// create a function that takes the depth scale as input but also matches
// the required signature.
double depthScale = inputFrame->DepthMediaFrame->DepthFormat->DepthScaleInMeters;
return TransformBitmap(inputBitmap, std::bind(&PseudoColorForDepth, _1, _2, _3, static_cast<float>(depthScale)));
}
else if (inputBitmap->BitmapPixelFormat == BitmapPixelFormat::Gray16)
{
Expand Down
2 changes: 1 addition & 1 deletion Samples/CameraFrames/cpp/FrameRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace SDKTemplate
private: // Private data.
Windows::UI::Xaml::Controls::Image^ m_imageElement;
Windows::Graphics::Imaging::SoftwareBitmap^ m_backBuffer;
bool m_taskRunning = false;
bool m_taskRunning = false;

};
} // SDKTemplate
5 changes: 0 additions & 5 deletions Samples/CameraFrames/cpp/Scenario1_DisplayDepthColorIR.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ namespace SDKTemplate
/// </summary>
concurrency::task<void> CleanupMediaCaptureAsync();

/// <summary>
/// Stop streaming from all readers.
/// </summary>
concurrency::task<void> StopCurrentStreamAsync();

/// <summary>
/// Creates a reader for the frame source described by the MediaFrameSourceInfo.
/// On frame arrived will render the output to the supplied software bitmap source.
Expand Down
17 changes: 9 additions & 8 deletions Samples/CameraFrames/cs/FrameRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//*********************************************************

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
Expand Down Expand Up @@ -106,7 +105,8 @@ public static unsafe SoftwareBitmap ConvertToDisplayableImage(VideoMediaFrame in
if (inputFrame.FrameReference.SourceKind == MediaFrameSourceKind.Depth)
{
// Use a special pseudo color to render 16 bits depth frame.
result = TransformBitmap(inputBitmap, PseudoColorHelper.PseudoColorForDepth);
var depthScale = (float)inputFrame.DepthMediaFrame.DepthFormat.DepthScaleInMeters;
result = TransformBitmap(inputBitmap, (w, i, o) => PseudoColorHelper.PseudoColorForDepth(w, i, o, depthScale));
}
else
{
Expand Down Expand Up @@ -300,29 +300,30 @@ private static uint PseudoColor(float value)
/// /// <param name="pixelWidth">Width of the input scanline, in pixels.</param>
/// /// <param name="inputRowBytes">Pointer to the start of the input scanline.</param>
/// /// <param name="outputRowBytes">Pointer to the start of the output scanline.</param>
public static unsafe void PseudoColorForDepth(int pixelWidth, byte* inputRowBytes, byte* outputRowBytes)
/// /// /// <param name="depthScale">Physical distance that corresponds to one unit in the input scanline.</param>
public static unsafe void PseudoColorForDepth(int pixelWidth, byte* inputRowBytes, byte* outputRowBytes, float depthScale)
{
// Visualize space in front of your desktop.
const ushort min = 500; // 0.5 meters
const ushort max = 4000; // 4 meters
const float min = 0.5f; // 0.5 meters
const float max = 4.0f; // 4 meters
const float one_min = 1.0f / min;
const float range = 1.0f / max - one_min;

ushort* inputRow = (ushort*)inputRowBytes;
uint* outputRow = (uint*)outputRowBytes;
for (int x = 0; x < pixelWidth; x++)
{
var value = inputRow[x];
var depth = inputRow[x] * depthScale;

if (value == 0)
if (depth == 0)
{
// Map invalid depth values to transparent pixels.
// This happens when depth information cannot be calculated, e.g. when objects are too close.
outputRow[x] = 0;
}
else
{
var alpha = (1.0f / value - one_min) / range;
var alpha = (1.0f / depth - one_min) / range;
outputRow[x] = PseudoColor(alpha * alpha);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Samples/HolographicSpatialMapping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ you will need to use a PIN to pair your PC with the Microsoft HoloLens.

- To debug the sample and then run it, follow the steps listed above to connect your
developer-unlocked Microsoft HoloLens, then press F5 or select **Debug** \> **Start Debugging**.
To run the sample without debugging, press Ctrl+F5 or select **Debug** \> **Start Without Debugging**.
To run the sample without debugging, press Ctrl+F5 or select **Debug** \> **Start Without Debugging**.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void RealtimeSurfaceMeshRenderer::Update(

// Update the surface mesh.
surfaceMesh.UpdateTransform(
m_deviceResources->GetD3DDevice(),
m_deviceResources->GetD3DDeviceContext(),
timer,
coordinateSystem
Expand Down
Loading

0 comments on commit 4ea76f7

Please sign in to comment.