Advertisement
Guest User

foobar2000 waveform seekerbar configuration

a guest
Oct 18th, 2011
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. Texture1D tex : WAVEFORMDATA;
  2.  
  3. SamplerState sTex
  4. {
  5. Filter = MIN_MAG_MIP_LINEAR;
  6. AddressU = Clamp;
  7. };
  8.  
  9. struct VS_IN
  10. {
  11. float2 pos : POSITION;
  12. float2 tc : TEXCOORD0;
  13. };
  14.  
  15. struct PS_IN
  16. {
  17. float4 pos : SV_POSITION;
  18. float2 tc : TEXCOORD0;
  19. };
  20.  
  21.  
  22. float4 backgroundColor : BACKGROUNDCOLOR;
  23. float4 highlightColor : HIGHLIGHTCOLOR;
  24. float4 selectionColor : SELECTIONCOLOR;
  25. float4 textColor : TEXTCOLOR;
  26. float cursorPos : CURSORPOSITION;
  27. bool cursorVisible : CURSORVISIBLE;
  28. float seekPos : SEEKPOSITION;
  29. bool seeking : SEEKING;
  30. float4 replayGain : REPLAYGAIN; // album gain, track gain, album peak, track peak
  31. float2 viewportSize : VIEWPORTSIZE;
  32. bool horizontal : ORIENTATION;
  33. bool shade_played : SHADEPLAYED;
  34.  
  35. PS_IN VS( VS_IN input )
  36. {
  37. PS_IN output = (PS_IN)0;
  38.  
  39. float2 half_pixel = float2(1,-1) / viewportSize;
  40. output.pos = float4(input.pos - half_pixel, 0, 1);
  41. if (horizontal)
  42. output.tc = float2((input.tc.x + 1.0) / 2.0, input.tc.y);
  43. else
  44. output.tc = float2((-input.tc.y + 1.0) / 2.0, input.tc.x);
  45.  
  46. return output;
  47. }
  48.  
  49. float4 bar( float pos, float2 tc, float4 fg, float4 bg, float width, bool show )
  50. {
  51. float dist = abs(pos - tc.x);
  52. float4 c = (show && dist < width)
  53. ? lerp(fg, bg, smoothstep(0, width, dist))
  54. : bg;
  55. return c;
  56. }
  57.  
  58. float4 evaluate(float4 bg, float4 fg, float factor)
  59. {
  60. return saturate(lerp(bg, fg, factor));
  61. }
  62.  
  63. float4 played( float pos, float2 tc, float4 bg, float factor)
  64. {
  65. float4 c = bg;
  66. if (pos > tc.x)
  67. {
  68. c = evaluate(backgroundColor, highlightColor, factor);
  69. }
  70. return c;
  71. }
  72.  
  73. float RMSfactor( float2 tc, float border )
  74. {
  75. // alpha 1 indicates biased texture
  76. float4 minmaxrms = tex.Sample(sTex, tc.x);
  77. minmaxrms.rgb -= 0.5 * minmaxrms.a;
  78. minmaxrms.rgb *= 1.0 + minmaxrms.a;
  79.  
  80. float belowWave = tc.y + border - minmaxrms.r;
  81. float aboveWave = tc.y - border - minmaxrms.g;
  82. float factorWave = min(abs(belowWave), abs(aboveWave));
  83. bool insideWave = (belowWave > 0 && aboveWave < 0);
  84.  
  85. float diffRms = abs(tc.y) - border - minmaxrms.b;
  86. float factorRms = abs(diffRms);
  87. bool insideRms = diffRms < 0;
  88.  
  89. float factor = insideRms ? (1.0 - 0.5 * saturate(factorRms / border / 2)): 1.0;
  90. factor = insideWave ? (factor * saturate(factorWave / border / 2)) : 0.0;
  91.  
  92. return factor;
  93. }
  94.  
  95. float4 PS( PS_IN input ) : SV_Target
  96. {
  97. float dx, dy;
  98. if (horizontal)
  99. {
  100. dx = 1/viewportSize.x;
  101. dy = 0/viewportSize.y;
  102. }
  103. else
  104. {
  105. dx = 1/viewportSize.y;
  106. dy = 1/viewportSize.x;
  107. }
  108. float seekWidth = 2.5 * dx;
  109. float positionWidth = 2.5 * dx;
  110.  
  111. float factor = RMSfactor(input.tc, 2.5 * dy);
  112.  
  113. float4 c0 = evaluate(backgroundColor, textColor, factor);
  114. if (shade_played)
  115. c0 = played(cursorPos, input.tc, c0, factor);
  116. c0 = bar(cursorPos, input.tc, selectionColor, c0, positionWidth, cursorVisible);
  117. c0 = bar(seekPos, input.tc, selectionColor, c0, seekWidth, seeking );
  118. return c0;
  119. }
  120.  
  121. technique10 Render10
  122. {
  123. pass P0
  124. {
  125. SetGeometryShader( 0 );
  126. SetVertexShader( CompileShader( vs_4_0, VS() ) );
  127. SetPixelShader( CompileShader( ps_4_0, PS() ) );
  128. }
  129. }
  130.  
  131. technique Render9
  132. {
  133. pass
  134. {
  135. VertexShader = compile vs_2_0 VS();
  136. PixelShader = compile ps_2_0 PS();
  137. }
  138. }
  139.  
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement