<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

  <!-- Fixed-point type used for tempo -->
  <Type Name="FPInt&lt;*,*&gt;">
    <DisplayString>{v / double($T1)}</DisplayString>
  </Type>

  <!-- Fixed-point type used for sample position and increment values -->
  <Type Name="SamplePosition">
    <DisplayString>{v / 4294967296.}</DisplayString>
  </Type>

  <!-- Show enum inside FlagSet -->
  <Type Name="FlagSet&lt;*,*&gt;">
    <DisplayString>{($T1)bits_}</DisplayString>
  </Type>

  <!-- Sample import/export formats -->
  <Type Name="SampleIO">
    <DisplayString>{(SampleIO::Bitdepth)(format &amp; 0xFF)} / {(SampleIO::Channels)((format >> 0x08) &amp; 0xFF)} / {(SampleIO::Endianness)((format >> 0x10) &amp; 0xFF)} / {(SampleIO::Encoding)((format >> 0x18) &amp; 0xFF)}</DisplayString>
  </Type>

  <!-- Pattern editor position -->
  <Type Name="PatternCursor">
    <DisplayString>Row {cursor >> 16}, Chn {(cursor &amp; 0xFFFF) >> 3}, {(PatternCursor::Columns)(cursor &amp; 0x07)}</DisplayString>
    <Expand>
      <Item Name="Row">cursor >> 16</Item>
      <Item Name="Channel">(cursor &amp; 0xFFFF) >> 3</Item>
      <Item Name="Column">(PatternCursor::Columns)(cursor &amp; 0x07)</Item>
    </Expand>
  </Type>
  
  <!-- GUI update hint -->
  <Type Name="UpdateHint">
    <DisplayString>{(HintCategory)category}, {(HintType)type}, {item}</DisplayString>
  </Type>

  <!-- Version number -->
  <Type Name="Version">
    <DisplayString>
      {(m_Version >> 24) &amp; 0xFF}.{(m_Version >> 20) &amp; 0xF}{(m_Version >> 16) &amp; 0xF}.{(m_Version >> 12) &amp; 0xF}{(m_Version >> 8) &amp; 0xF}.{(m_Version >> 4) &amp; 0xF}{(m_Version >> 0) &amp; 0xF}
    </DisplayString>
  </Type>

  <!-- Contents of memory-mapped files -->
  <Type Name="FileDataMemory">
    <Expand>
      <ArrayItems>
        <Size>streamLength</Size>
        <ValuePointer>streamData</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- Memory spans -->
  <Type Name="mpt::mptx::span&lt;*&gt;">
    <Expand>
      <ArrayItems>
        <Size>m_size</Size>
        <ValuePointer>m_data</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- Signed Little-Endian -->
  <Type Name="mpt::mptx::packed&lt;__int64,0,__int64&gt;">
    <DisplayString>{(int64)data[0] | ((int64)data[1] &lt;&lt; 0x08) | ((int64)data[2] &lt;&lt; 0x10) | ((int64)data[3] &lt;&lt; 0x18) | ((int64)data[4] &lt;&lt; 0x20) | ((int64)data[5] &lt;&lt; 0x28) | ((int64)data[6] &lt;&lt; 0x30) | ((int64)data[7] &lt;&lt; 0x38)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;int,0,int&gt;">
    <DisplayString>{(int32)data[0] | ((int32)data[1] &lt;&lt; 0x08) | ((int32)data[2] &lt;&lt; 0x10) | ((int32)data[3] &lt;&lt; 0x18)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;mpt::mptx::int24,0,int&gt;">
    <DisplayString>{(int32)data[0] | ((int32)data[1] &lt;&lt; 0x08) | ((int32)data[2] &lt;&lt; 0x10) | ((int8)(data[2] &amp; 0x80) &lt;&lt; 0x10)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;short,0,short&gt;">
    <DisplayString>{(int16)data[0] | ((int16)data[1] &lt;&lt; 0x08)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;signed char,0,signed char&gt;">
    <DisplayString>{(int8)data[0]}</DisplayString>
  </Type>

  <!--  Unsigned Little-Endian -->
  <Type Name="mpt::mptx::packed&lt;unsigned __int64,0,unsigned __int64&gt;">
    <DisplayString>{((uint64)data[0]) | (((uint64)data[1]) &lt;&lt; 0x08) | (((uint64)data[2]) &lt;&lt; 0x10) | (((uint64)data[3]) &lt;&lt; 0x18) | (((uint64)data[4]) &lt;&lt; 0x20) | (((uint64)data[5]) &lt;&lt; 0x28) | (((uint64)data[6]) &lt;&lt; 0x30) | (((uint64)data[7]) &lt;&lt; 0x38)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned int,0,unsigned int&gt;">
    <DisplayString>{((uint32)data[0]) | (((uint32)data[1]) &lt;&lt; 0x08) | (((uint32)data[2]) &lt;&lt; 0x10) | (((uint32)data[3]) &lt;&lt; 0x18)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;mpt::mptx::uint24,0,unsigned int&gt;">
    <DisplayString>{((uint32)data[0]) | (((uint32)data[1]) &lt;&lt; 0x08) | (((uint32)data[2]) &lt;&lt; 0x10)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned short,0,unsigned short&gt;">
    <DisplayString>{(uint16)data[0] | ((uint16)data[1] &lt;&lt; 0x08)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned char,0,unsigned char&gt;">
    <DisplayString>{(uint8)data[0]}</DisplayString>
  </Type>

  <!--  Signed Big-Endian -->
  <Type Name="mpt::mptx::packed&lt;__int64,1,__int64&gt;">
    <DisplayString>{(int64)data[7] | ((int64)data[6] &lt;&lt; 0x08) | ((int64)data[5] &lt;&lt; 0x10) | ((int64)data[4] &lt;&lt; 0x18) | ((int64)data[3] &lt;&lt; 0x20) | ((int64)data[2] &lt;&lt; 0x28) | ((int64)data[1] &lt;&lt; 0x30) | ((int64)data[0] &lt;&lt; 0x38)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;int,1,int&gt;">
    <DisplayString>{(int32)data[3] | ((int32)data[2] &lt;&lt; 0x08) | ((int32)data[1] &lt;&lt; 0x10) | ((int32)data[0] &lt;&lt; 0x18)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;mpt::mptx::int24,1,int&gt;">
    <DisplayString>{(int32)data[2] | ((int32)data[1] &lt;&lt; 0x08) | ((int32)data[0] &lt;&lt; 0x10) | ((int8)(data[0] &amp; 0x80) &lt;&lt; 0x10)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;short,1,short&gt;">
    <DisplayString>{(int16)data[1] | ((int16)data[0] &lt;&lt; 0x08)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;signed char,1,signed char&gt;">
    <DisplayString>{(int8)data[0]}</DisplayString>
  </Type>

  <!--  Unsigned Big-Endian -->
  <Type Name="mpt::mptx::packed&lt;unsigned __int64,1,unsigned __int64&gt;">
    <DisplayString>{(uint64)data[7] | ((uint64)data[6] &lt;&lt; 0x08) | ((uint64)data[5] &lt;&lt; 0x10) | ((uint64)data[4] &lt;&lt; 0x18) | ((uint64)data[3] &lt;&lt; 0x20) | ((uint64)data[2] &lt;&lt; 0x28) | ((uint64)data[1] &lt;&lt; 0x30) | ((uint64)data[0] &lt;&lt; 0x38)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned int,1,unsigned int&gt;">
    <DisplayString>{(uint32)data[3] | ((uint32)data[2] &lt;&lt; 0x08) | ((uint32)data[1] &lt;&lt; 0x10) | ((uint32)data[0] &lt;&lt; 0x18)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;mpt::mptx::uint24,1,unsigned int&gt;">
    <DisplayString>{((uint32)data[2] &lt;&lt; 0x08) | ((uint32)data[1] &lt;&lt; 0x10) | ((uint32)data[0] &lt;&lt; 0x18)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned short,1,unsigned short&gt;">
    <DisplayString>{(uint16)data[1] | ((uint16)data[0] &lt;&lt; 0x08)}</DisplayString>
  </Type>
  <Type Name="mpt::mptx::packed&lt;unsigned char,1,unsigned char&gt;">
    <DisplayString>{(uint8)data[0]}</DisplayString>
  </Type>
</AutoVisualizer>
