private static void UpdateData(DepthPlugin3DViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data) { Debug.Assert(data != null); if ((pluginViewSettings != null) && (data.depthMap != null) && (data.depthTexture != null)) { if (pluginViewSettings.IsSupplyingSurface) { data.depthMap.SetMode(viz.DepthVertexMode.Surface, viz.DepthRampMode.None); } else { switch (pluginViewSettings.ViewType) { case DepthPlugin3DViewSettings.Depth3DViewType.Color: data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Color); break; case DepthPlugin3DViewSettings.Depth3DViewType.Grey: data.depthMap.SetMode(viz.DepthVertexMode.Point, viz.DepthRampMode.Grey); break; case DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal: data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None); break; default: Debug.Assert(false); break; } } } }
private viz.Texture GetTexture(EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; value = this.UpdateData(data); return(value); }
protected override void OnEndRender(viz.Context context, viz.Texture texture, float width, float height) { DebugHelper.AssertUIThread(); base.OnEndRender(context, texture, width, height); if ((this.overlay != null) && (texture != null)) { overlay.DrawTexture(texture, 0, 0, (int)width, height, 1.0f); } this.Do2DPropertyView(); }
public viz.Texture GetTexture(EventType eventType, IPluginViewSettings pluginViewSettings) { viz.Texture value = null; switch (eventType) { case EventType.Monitor: value = this.GetTexture(pluginViewSettings, this.monitorData); break; case EventType.Inspection: value = this.GetTexture(pluginViewSettings, this.inspectionData); break; } return(value); }
private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { IrPluginViewSettings irPluginViewSettings = pluginViewSettings as IrPluginViewSettings; if (irPluginViewSettings != null) { IrPlugin.UpdateData(irPluginViewSettings.RampTexture, data); value = data.irTexture; } } return(value); }
// object owning data should be locked private static void UpdateData(viz.Texture rampTexture, EventTypePluginData data) { Debug.Assert(data != null); if (rampTexture != null) { if ((data.sharedIrFrame != null) && (data.rawIrTexture != null)) { unsafe { data.rawIrTexture.UpdateData((byte *)data.sharedIrFrame.Buffer, data.sharedIrFrame.Size); } } if (data.irTexture != null) { data.irTexture.RampConversion(data.rawIrTexture, rampTexture); } } }
private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { BodyIndexPlugin.UpdateData(data); if (pluginViewSettings is BodyIndexPlugin2DViewSettings) { value = data.bodyIndexTexture2d; } else if (pluginViewSettings is BodyIndexPlugin3DViewSettings) { value = data.bodyIndexTexture3d; } } return(value); }
private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { if (data.sharedDepthFrame != null) { DepthPlugin2DViewSettings depth2DSettingsViewSettings = pluginViewSettings as DepthPlugin2DViewSettings; if (depth2DSettingsViewSettings != null) { DepthPlugin.UpdateData(depth2DSettingsViewSettings, data); value = data.depthTexture; } } } return(value); }
// object owning data should be locked private static void Render2D(IPluginViewSettings pluginViewSettings, viz.Texture texture, float left, float top, float width, float height, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); BodyPlugin2DViewSettings bodyPluginViewSettings = pluginViewSettings as BodyPlugin2DViewSettings; if ((bodyPluginViewSettings != null) && (registration != null) && (data.body != null) && data.bodiesValid) { if (bodyPluginViewSettings.RenderBodies || bodyPluginViewSettings.RenderHands) { viz.Body2DMode bodyMode = viz.Body2DMode.DepthIR; if ((texture != null) && (texture.GetWidth() == nui.Constants.STREAM_COLOR_WIDTH) && (texture.GetHeight() == nui.Constants.STREAM_COLOR_HEIGHT)) { bodyMode = viz.Body2DMode.Color; } data.body.Begin2D(left, top, width, height, bodyMode, registration.GetCalibrationData()); for (uint i = 0; i < BodyPlugin.bodyOptions.Length; ++i) { if (bodyPluginViewSettings.RenderBodies) { viz.Vector color = BodyPlugin.bodyOptions[i].ColorVector; color.A = 0.7f; data.body.RenderBones2D(i, color); } if (bodyPluginViewSettings.RenderHands) { data.body.RenderHandStates2D(i); } } data.body.End2D(); } } }
private viz.Texture GetTexture(IPluginViewSettings pluginViewSettings, EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; lock (this.lockObj) { RawIrPlugin2DViewSettings raw2DSettingsViewSettings = pluginViewSettings as RawIrPlugin2DViewSettings; if (raw2DSettingsViewSettings != null) { RawIrPlugin.UpdateData(raw2DSettingsViewSettings, data); if (raw2DSettingsViewSettings.ViewType == RawIrPlugin2DViewSettings.RawIr2DViewType.Ir) { value = data.irTexture; } else { value = data.depthTexture; } } else { RawIrPlugin3DViewSettings raw3DSettingsViewSettings = pluginViewSettings as RawIrPlugin3DViewSettings; if (raw3DSettingsViewSettings != null) { if (raw3DSettingsViewSettings.ViewType == RawIrPlugin3DViewSettings.RawIr3DViewType.Ir) { value = data.irTexture; } } } } return(value); }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { }
public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height) { }
protected override void OnGetLayout(viz.Context context, viz.Texture texture, ref float layoutWidth, ref float layoutHeight) { DebugHelper.AssertUIThread(); bool fixZoom = (this.imageWidth == 0) || (this.imageHeight == 0); if (texture == null) { this.imageWidth = Image2DVisualizationControl.defaultWidth; this.imageHeight = Image2DVisualizationControl.defaultHeight; } else { this.imageWidth = texture.GetWidth(); this.imageHeight = texture.GetHeight(); } double scale = 1.0; if (this.IsZoomToFit) { if (this.scrollViewer != null) { this.scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; this.scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; scale = CalcScaleOnZoomToFit(this.scrollViewer.ActualWidth, this.scrollViewer.ActualHeight); } int zoom = (int)(100.0 * scale); if (this.Zoom != zoom) { if (this.scaleTransform != null) { this.scaleTransform.ScaleX = scale; this.scaleTransform.ScaleY = scale; } fixZoom = true; this.ignoreZoom++; this.SetValue(Image2DVisualizationControl.ZoomProperty, zoom); this.ignoreZoom--; } } else { scale = this.Zoom / 100.0; if (this.scrollViewer != null) { this.scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; this.scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; } } if (fixZoom) { this.OnZoomChanged(); } layoutWidth = (float)(this.imageWidth * scale); layoutHeight = (float)(this.imageHeight * scale); }
private viz.Texture UpdateData(EventTypePluginData data) { Debug.Assert(data != null); viz.Texture value = null; bool doDataEvent = false; bool doVisibleEvent = false; lock (this.lockObj) { bool updated = false; value = data.colorTexture; bool isSelectedData = (this.selectedData == data); data.visibleChanged = false; if (data.needsUpdate && (data.sharedColorFrame != null) && (data.sharedColorFrame.Buffer != IntPtr.Zero) && (data.colorTexture != null)) { try { if (data.doDecompress) { DateTime now = DateTime.Now; if (now > this.nextDecompress) { data.timer.Stop(); doVisibleEvent = isSelectedData && (!data.hasValidData || data.visibleChanged); data.needsUpdate = false; data.hasValidData = true; updated = true; if ((data.decompressMemoryStreamBuffer == null) || (data.decompressMemoryStreamBuffer.Length < data.sharedColorFrame.Size)) { data.decompressMemoryStreamBuffer = new byte[data.sharedColorFrame.Size]; } uint convertBufferSize = data.imageWidth * data.imageHeight * 3; if ((data.convertColorBuffer == null) || (data.convertColorBuffer.Length < convertBufferSize)) { data.convertColorBuffer = new byte[convertBufferSize]; } byte[] rgbBuffer = data.convertColorBuffer; if (this.averageDecompressCount > 10) { this.averageDecompressCount = 1; this.stopwatch.Reset(); } else { this.averageDecompressCount++; } this.stopwatch.Start(); Marshal.Copy(data.sharedColorFrame.Buffer, data.decompressMemoryStreamBuffer, 0, (int)data.sharedColorFrame.Size); using (Stream imageStream = new MemoryStream(data.decompressMemoryStreamBuffer)) { // this has to run on the UI thread JpegBitmapDecoder decoder = new JpegBitmapDecoder(imageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapSource bitmapSource = decoder.Frames[0]; bitmapSource.CopyPixels(rgbBuffer, (int)(data.imageWidth * 3), 0); // expand bgr to rgba uint imageSize = data.imageWidth * data.imageHeight; for (uint index = 0; index < imageSize; ++index) { uint rgbaIndex = index * 4; uint bgrIndex = index * 3; data.rgbaFrame[rgbaIndex] = rgbBuffer[bgrIndex + 2]; data.rgbaFrame[rgbaIndex + 1] = rgbBuffer[bgrIndex + 1]; data.rgbaFrame[rgbaIndex + 2] = rgbBuffer[bgrIndex]; data.rgbaFrame[rgbaIndex + 3] = 0xFF; } } this.stopwatch.Stop(); // color decompression takes a LONG time (sometimes upwards of 1/10 of second), so throttle it double averageDecompressTime = ((double)this.stopwatch.ElapsedMilliseconds) / this.averageDecompressCount; double sinceLastDecompress = (now - this.lastDecompress).TotalMilliseconds; if (sinceLastDecompress > 1000) { this.nextDecompress = now + TimeSpan.FromMilliseconds(averageDecompressTime * 2); } else { double minTime = Math.Max(sinceLastDecompress, averageDecompressTime * 2); this.nextDecompress = now + TimeSpan.FromMilliseconds(minTime); } this.lastDecompress = now; } } else { data.timer.Stop(); doVisibleEvent = isSelectedData && (!data.hasValidData || data.visibleChanged); data.needsUpdate = false; data.hasValidData = true; updated = true; unsafe { fixed(byte *p = data.rgbaFrame) { GCHandle rgbaFrameHandle = GCHandle.Alloc(data.rgbaFrame, GCHandleType.Pinned); NativeMethods.ConvertYUYVToRGBA( data.sharedColorFrame.Buffer, data.sharedColorFrame.Size, rgbaFrameHandle.AddrOfPinnedObject(), (uint)data.rgbaFrame.Length); } } } } catch (Exception) { // TODO_LOG } } if (updated) { if (ColorPlugin.UpdateSelectedPixelValue(data)) { doDataEvent = isSelectedData; } if ((data.colorTexture != null) && (data.rgbaFrame != null)) { unsafe { fixed(byte *pFrame = data.rgbaFrame) { data.colorTexture.UpdateData(pFrame, (uint)data.rgbaFrame.Length); } } } } } if (doVisibleEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } if (doDataEvent) { this.RaisePropertyChanged("Selected2DPixelColor"); } return(value); }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { if (eventType == EventType.Monitor) { lock (this.lockObj) { if (pluginViewSettings is AudioPlugin3DViewSettings) { if (this.beamConfidence > 0.0f) { viz.Effect effectBeam = new viz.Effect() { EnableLighting = true, Ambient = new viz.Vector(0.0f, 1.0f, 0.0f, 0.5f), }; float[] matrixFloats = new float[16]; unsafe { fixed(float *pMatrix = &matrixFloats[0]) { MatrixHelper.CalculateBeamMatrix(this.beamAngle, pMatrix); } } viz.Matrix mat = new viz.Matrix(); mat.R0 = new viz.Vector(matrixFloats[0], matrixFloats[1], matrixFloats[2], matrixFloats[3]); mat.R1 = new viz.Vector(matrixFloats[4], matrixFloats[5], matrixFloats[6], matrixFloats[7]); mat.R2 = new viz.Vector(matrixFloats[8], matrixFloats[9], matrixFloats[10], matrixFloats[11]); mat.R3 = new viz.Vector(matrixFloats[12], matrixFloats[13], matrixFloats[14], matrixFloats[15]); this.beamMesh.Render(viz.MeshRenderMode.IndexedTriangleList, mat, effectBeam, null); } } } } }
protected virtual void OnEndRender(viz.Context context, viz.Texture texture, float width, float height) { }
// object owning data should be locked private static void Render3D(IPluginViewSettings pluginViewSettings, viz.Texture texture, EventTypePluginData data, nui.Registration registration) { Debug.Assert(data != null); DepthPlugin3DViewSettings depthPlugin3DViewSettings = pluginViewSettings as DepthPlugin3DViewSettings; if ((registration != null) && (depthPlugin3DViewSettings != null)) { DepthPlugin.UpdateData(depthPlugin3DViewSettings, texture, data); bool doColor = false; bool doBodyIndex = false; if (texture != null) { uint textureWidth = texture.GetWidth(); uint textureHeight = texture.GetHeight(); doColor = (textureWidth == nui.Constants.STREAM_COLOR_WIDTH) && (textureHeight == nui.Constants.STREAM_COLOR_HEIGHT); doBodyIndex = (texture.GetTextureFormat() == viz.TextureFormat.B8G8R8A8_UNORM) && (textureWidth == nui.Constants.STREAM_DEPTH_WIDTH) && (textureHeight == nui.Constants.STREAM_DEPTH_HEIGHT); } if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex) || (!depthPlugin3DViewSettings.IsSupplyingSurface && depthPlugin3DViewSettings.ViewType == DepthPlugin3DViewSettings.Depth3DViewType.SurfaceNormal)) { if (data.depthMap != null) { // special case for body index viz.Effect effect = new viz.Effect() { Direction = new viz.Vector(0.5f, 0.3f, 1.5f, 0), Ambient = new viz.Vector(0.0f, 0.0f, 0.0f, 1.0f), Diffuse = new viz.Vector(0.5f, 0.5f, 0.5f, 1.0f), Specular = new viz.Vector(1.0f, 1.0f, 1.0f, 1.0f), Power = 25.0f, EnableLighting = true, EnableTexture = false, }; if ((depthPlugin3DViewSettings.IsSupplyingSurface && doBodyIndex)) { if (data.depthMap != null) { data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithNormal, viz.DepthRampMode.None); effect.EnableTexture = true; } } if (!depthPlugin3DViewSettings.IsSupplyingSurface) { texture = null; } data.depthMap.Render(effect, texture); } } else { if (depthPlugin3DViewSettings.IsSupplyingSurface && doColor) { // special case for color if ((registration != null) && (data.depthMap != null) && (data.uvTable != null) && (data.sharedDepthFrame != null)) { data.depthMap.SetMode(viz.DepthVertexMode.SurfaceWithUV, viz.DepthRampMode.None); IntPtr ptr = data.sharedDepthFrame.Buffer; if (ptr != IntPtr.Zero) { registration.Process(ptr, data.uvTable.Buffer); } data.depthMap.UpdateUVTable(data.uvTable.Buffer, data.uvTable.Size); } } if (data.depthMap != null) { viz.Effect effect = new viz.Effect() { EnableTexture = texture != null, }; data.depthMap.Render(effect, texture); } } } }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { lock (this.lockObj) { EventTypePluginData data = null; nui.Registration registration = null; switch (eventType) { case EventType.Monitor: data = this.monitorData; break; case EventType.Inspection: data = this.inspectionData; break; } if (data != null) { if (this.pluginService != null) { registration = this.pluginService.GetRegistration(eventType); if (data.lastRegistration != registration) { data.lastRegistration = this.pluginService.GetRegistration(eventType); if ((data.lastRegistration != null) && (data.depthMap != null)) { uint xyTableSize; IntPtr xyTable = data.lastRegistration.GetXYTable(out xyTableSize); data.depthMap.UpdateXYTable(xyTable, xyTableSize); } } } DepthPlugin.Render3D(pluginViewSettings, texture, data, registration); } } }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { lock (this.lockObj) { switch (eventType) { case EventType.Monitor: AccessoryPlugin.Render3D(pluginViewSettings, this.monitorAccessory); break; case EventType.Inspection: AccessoryPlugin.Render3D(pluginViewSettings, this.inspectionAccessory); break; } } }
protected virtual void OnGetLayout(viz.Context context, viz.Texture texture, ref float layoutWidth, ref float layoutHeight) { }
public void Render3D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture) { lock (this.lockObj) { nui.Registration registration = null; if (this.pluginService != null) { registration = this.pluginService.GetRegistration(eventType); } switch (eventType) { case EventType.Monitor: BodyPlugin.Render3D(pluginViewSettings, this.monitorData, registration); break; case EventType.Inspection: BodyPlugin.Render3D(pluginViewSettings, this.inspectionData, registration); break; } } }
private bool DoRender() { DebugHelper.AssertUIThread(); bool result = false; { if ((this.image != null) && (this.Visibility == System.Windows.Visibility.Visible)) { result = true; viz.Context context = null; if (this.PluginService != null) { context = this.PluginService.GetContext(this.EventType); } if (this.image != null) { if (context != null) { if (!context.BeginRender()) { context = null; } } } if (context != null) { this.OnBeginRender(context); viz.Texture texture = null; foreach (PluginViewState pluginViewState in this.PluginViewStates) { if (pluginViewState.IsEnabled) { IImageVisualPlugin visualPlugin = pluginViewState.Plugin as IImageVisualPlugin; if (visualPlugin != null) { texture = visualPlugin.GetTexture(this.EventType, pluginViewState.PluginViewSettings); if (texture != null) { break; } } } } float scaledWidth = 0; float scaledHeight = 0; this.OnGetLayout(context, texture, ref scaledWidth, ref scaledHeight); if (this.imageHost is Canvas) { uint w = (uint)scaledWidth; uint h = (uint)scaledHeight; if (this.image != null) { this.image.Width = w; this.image.Height = h; } this.FixRenderTargetSize(w, h); } if (this.renderTarget != null) { if (this.renderTarget.BeginRender(this.ClearColor, 1)) { foreach (PluginViewState pluginViewState in this.PluginViewStates) { if (pluginViewState.IsEnabled) { IImageVisualPlugin visualPlugin = pluginViewState.Plugin as IImageVisualPlugin; if (visualPlugin != null) { I2DVisualPlugin visualPlugin2d = visualPlugin as I2DVisualPlugin; if (visualPlugin2d != null) { visualPlugin2d.Render2D(this.EventType, pluginViewState.PluginViewSettings, context, texture, 0, 0, scaledWidth, scaledHeight); } I3DVisualPlugin visualPlugin3d = visualPlugin as I3DVisualPlugin; if (visualPlugin3d != null) { visualPlugin3d.Render3D(this.EventType, pluginViewState.PluginViewSettings, context, texture); } } } } this.OnEndRender(context, texture, scaledWidth, scaledHeight); this.renderTarget.EndRender(); } } context.EndRender(); } } } return(result); }
public void Render2D(EventType eventType, IPluginViewSettings pluginViewSettings, viz.Context context, viz.Texture texture, float left, float top, float width, float height) { if (eventType == EventType.Monitor) { lock (this.lockObj) { if (this.frameTime == TimeSpan.MinValue) { return; } AudioPlugin2DViewSettings audioPluginViewSettings = pluginViewSettings as AudioPlugin2DViewSettings; if (audioPluginViewSettings != null) { float x = 10; // margin on left float chartX = x + 100; // offset to chart rendering float y = 10; // margin on top float deltaY = 24; // height of each row // chart window size float chartHeight = 20; float chartWidth = 600; // max value in chart, bigger ones got capped float chartValueCap = 0.02f; // special color for current frame in time line viz.Vector currentFrameColor = new viz::Vector(1, 0, 0, 1); viz.Vector?color = null; if ((audioPluginViewSettings.RenderBeam) && (this.font != null)) { string str; if (this.beamConfidence > 0.0f) { str = string.Format(CultureInfo.CurrentCulture, Strings.Audio_Beam_Label_Format, this.beamAngle); // TODO: option for other display? like degrees? } else { str = Strings.Audio_Beam_Invalid_Label; } this.font.DrawText(str, x, y, color); } y += deltaY; if (this.sharedAudioFrame != null) { if (this.sharedAudioFrame.Size >= cAudioFrameSizeMinimum) { IntPtr bufferPtr = this.sharedAudioFrame.Buffer; unsafe { nui.AUDIO_FRAME * pFrame = (nui.AUDIO_FRAME *)bufferPtr.ToPointer(); nui.AUDIO_SUBFRAME *pSubFrame = &(pFrame->FirstSubFrame); ulong currentFirstFrameTimeStamp = (ulong)this.frameTime.Ticks; ulong timeStampOffset = currentFirstFrameTimeStamp - pSubFrame->TimeCounter; ulong currentLastFrameTimeStamp = pSubFrame[pFrame->SubFrameCount - 1].TimeCounter + timeStampOffset; #if TODO_LOCAL_PLAYBACK if ((this.timelineBegin != 0) || (this.timelineEnd != 0)) { // timeline rendering if (this.timelineDirty) { this.timelineData->Sort(new System.Comparison <TimelineEntry>(TimelineEntry.Compare)); timelineDirty = false; } if (audioPluginViewSettings.RenderOutput) { if (this.font != null) { this.font.DrawText(this.outString, x, y, color); for (int i = 0; i < this.timelineData.Count; i++) { ulong timeStamp = this.timelineData[i]->TimeStamp; if (timeStamp < this.timelineBegin) { continue; } if (timeStamp > this.timelineEnd) { break; } float normalizedValue = (float)(Math.Min(chartValueCap, Math.Abs(this.timelineData[i].Output)) / chartValueCap); float topLeftX = chartX + (timeStamp - this.timelineBegin) * chartWidth / (this.timelineEnd - this.timelineBegin); float topLeftY = y + (1 - normalizedValue) * chartHeight / 2; float chartBarHeight = Math.Max(normalizedValue * chartHeight, 1.0f); bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp); float barZ = isCurrentFrame ? 0 : 0.01f; // put current frame at a smaller z so it's always visible float barWidth = isCurrentFrame ? 2.0f : 1.0f; // make current frame tick bold viz::Vector?barColor = isCurrentFrame ? currentFrameColor : null; if (this.overlay != null) { this.overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor); } } } y += deltaY; } for (int iMIC = 0; iMIC < NUIP_AUDIO_NUM_MIC; iMIC++) { if ((int)renderOptionType == (int)RenderOptionType::MIC0 + iMIC) { _font->DrawText(renderOptionName, x, y, color); for (int iSample = 0; iSample < _timelineData->Count; iSample++) { UInt64 timeStamp = _timelineData[iSample]->TimeStamp; if (timeStamp < _timelineBegin) { continue; } if (timeStamp > _timelineEnd) { break; } float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->MIC[iMIC])) / chartValueCap; float topLeftX = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin); float topLeftY = y + (1 - normalizedValue) * chartHeight / 2; float chartBarHeight = max(normalizedValue * chartHeight, 1.0f); bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp); float barZ = isCurrentFrame ? 0 : 0.01f; float barWidth = isCurrentFrame ? 2.0f : 1.0f; Nullable <Xbox::Kinect::Viz::Vector> barColor; if (isCurrentFrame) { barColor = currentFrameColor; } _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor); } } y += deltaY; } for (int iSPK = 0; iSPK < NUIP_AUDIO_NUM_SPK; iSPK++) { if ((int)renderOptionType == (int)RenderOptionType::SPK0 + iSPK) { _font->DrawText(renderOptionName, x, y, color); for (int iSample = 0; iSample < _timelineData->Count; iSample++) { UInt64 timeStamp = _timelineData[iSample]->TimeStamp; if (timeStamp < _timelineBegin) { continue; } if (timeStamp > _timelineEnd) { break; } float normalizedValue = min(chartValueCap, fabs(_timelineData[iSample]->SPK[iSPK])) / chartValueCap; float topLeftX = chartX + (timeStamp - _timelineBegin) * chartWidth / (_timelineEnd - _timelineBegin); float topLeftY = y + (1 - normalizedValue) * chartHeight / 2; float chartBarHeight = max(normalizedValue * chartHeight, 1.0f); bool isCurrentFrame = (timeStamp >= currentFirstFrameTimeStamp && timeStamp <= currentLastFrameTimeStamp); float barZ = isCurrentFrame ? 0 : 0.01f; float barWidth = isCurrentFrame ? 2.0f : 1.0f; Nullable <Xbox::Kinect::Viz::Vector> barColor; if (isCurrentFrame) { barColor = currentFrameColor; } _overlay->DrawColor(topLeftX, topLeftY, barWidth, chartBarHeight, barZ, barColor); } } y += deltaY; } } else #endif // TODO_LOCAL_PLAYBACK { // live rendering float barWidth = 1; UInt64 timeSpan = 2 * 10 * 1000 * 1000; // in 100ns unit if (audioPluginViewSettings.RenderOutput) { if (this.font != null) { this.font.DrawText(this.outString, x, y, color); } if (this.outChart != null) { this.outChart.RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap); } y += deltaY; } if (this.micCharts != null) { for (int i = 0; i < this.micCharts.Length; ++i) { if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.Mic0 + i))) { if (this.font != null) { this.font.DrawText(this.micStrings[i], x, y, color); } this.micCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap); y += deltaY; } } } if (this.speakerCharts != null) { for (int i = 0; i < this.speakerCharts.Length; ++i) { if (audioPluginViewSettings.GetTrackOption((AudioTrack)(AudioTrack.SpeakerL + i))) { if (this.font != null) { this.font.DrawText(this.speakerStrings[i], x, y, color); } this.speakerCharts[i].RenderBar(chartX, y, chartWidth, chartHeight, 0, barWidth, color, currentLastFrameTimeStamp, timeSpan, 0, chartValueCap); y += deltaY; } } } } } } } } } } }