I had this problem with VLC where all output going S/PDIF was stuttering with Windows Vista, and now that I got myself Windows 7 X64, I had to re-fix this problem.
Now I finally found the fix, so I decided to save it to here for future reference:
Preferences -> Advanced settings -> Audio -> Output modules -> Win32 waveOut extension output.
Now the AC3/DTS passthrough works without stuttering.
Saturday, February 6, 2010
Saturday, January 2, 2010
Python snippets, find all occurences of string
>>> def find_all(string, occurrence):
... found = 0
...
... while True:
... found = string.find(occurrence, found)
... if found != -1:
... yield found
... else:
... break
...
... found += 1
...
>>>
>>> print list(find_all("awpropeoaspwtoapwroawpeoaweo", "p"))
[2, 5, 10, 15, 21]
>>>
>>> print list(find_all("Overllllapping", "ll"))
[4, 5, 6]
Note: Finds all overlapping matches.
Friday, January 1, 2010
Add your program to "Default Programs" in Windows 7
I wanted to have chromium in "Default Programs", so I can associate HTTP protocol to it, here is how I did that. If you want to do same just change
For your own program just change the chromium/path etc. to something suitable for your project.
ChromiumToSetDefaults.reg:
C:\\Program Copies\\Chromium\\chrome.exe to point your chrome.exe, note that is in two places!For your own program just change the chromium/path etc. to something suitable for your project.
ChromiumToSetDefaults.reg:
Windows Registry Editor Version 5.00
; Infamous capabilities:
[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities]
"ApplicationDescription"="Chromium - Beta Google Chrome"
"ApplicationIcon"="C:\\Program Copies\\Chromium\\chrome.exe,0"
"ApplicationName"="Chromium"
[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities\FileAssociations]
".htm"="ChromiumURL"
".html"="ChromiumURL"
".shtml"="ChromiumURL"
".xht"="ChromiumURL"
".xhtml"="ChromiumURL"
[HKEY_LOCAL_MACHINE\SOFTWARE\Chromium\Capabilities\URLAssociations]
"ftp"="ChromiumURL"
"http"="ChromiumURL"
"https"="ChromiumURL"
; Register to Default Programs
[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]
"Chromium"="Software\\Chromium\\Capabilities"
; ChromiumURL HANDLER:
[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL]
@="Chromium Document"
"FriendlyTypeName"="Chromium Document"
[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell]
[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell\open]
[HKEY_LOCAL_MACHINE\Software\Classes\ChromiumURL\shell\open\command]
@="\"C:\\Program Copies\\Chromium\\chrome.exe\" -- \"%1\""Monday, October 5, 2009
WPF Command line arguments.
App.xaml
<Application ...
Startup="App_Startup">
...
App.xaml.cs;
...
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
// Storing your arguments in your type you wish:
public static string Input = "";
void App_Startup(object sender, StartupEventArgs e)
{
// Store the arguments to static public you declared:
Input = String.Join(" ", e.Args);
}
}
...
Window1.xaml.cs
...
/// <summary>
/// Create window.
/// </summary>
public Window1()
{
Console.WriteLine(App.Input); // Woohoo! Got the input...
...
See, MSDN, you don't have to be so damn verbose always, when little codespeak would do.
Saturday, October 3, 2009
Glass *only* fallback, in Windows.Forms (when aero disabled / in XP)
Usage: Create windows.forms application and take stuff from here:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace GlassingJustFallbackInForms
{
public partial class FormGlassedFallback : Form
{
public FormGlassedFallback()
{
InitializeComponent();
}
#region WINAPI Crap:
private bool isActivated;
protected override void OnActivated(EventArgs e)
{
isActivated = true;
base.OnActivated(e);
this.Refresh(); // Causes flickering, any ideas?
}
protected override void OnDeactivate(EventArgs e)
{
isActivated = false;
base.OnDeactivate(e);
this.Refresh(); // Causes flickering, any ideas?
}
protected override void OnPaint(PaintEventArgs e)
{
IntPtr thmdata = OpenThemeData(this.Handle, "WINDOW");
IntPtr hdc = e.Graphics.GetHdc();
// Not very efficient, but doesn't flicker:
RECT rect = new RECT(-2, 0, this.Width, this.Height);
// RECT rect = new RECT(e.ClipRectangle.Left-3, e.ClipRectangle.Top, e.ClipRectangle.Right+3, e.ClipRectangle.Bottom);
base.OnPaint(e);
DrawThemeBackground(thmdata, hdc, WP_FRAMELEFT, isActivated ? FS_ACTIVE : FS_INACTIVE, ref rect, 0);
}
private const int FS_ACTIVE = 1;
private const int FS_INACTIVE = 2;
private const int WP_FRAMELEFT = 7;
[DllImport("uxtheme", ExactSpelling = true)]
private extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId,
int iStateId, ref RECT pRect, int test);
[DllImport("uxtheme", ExactSpelling = true)]
private extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId,
int iStateId, ref RECT pRect, IntPtr pClipRect);
[DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern IntPtr OpenThemeData(IntPtr hWnd, String classList);
private const int WM_PAINT = 15;
[Serializable, StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RECT(int left_, int top_, int right_, int bottom_)
{
Left = left_;
Top = top_;
Right = right_;
Bottom = bottom_;
}
}
#endregion
}
}
Friday, October 2, 2009
WPF Window with aero glass background. (C# .NET)
Usage, in your Window constructor do:
...
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
this.GlassBackground();
}
}
...Installation:
1.) Add reference "System.Drawing" to your Project (Right click on References folder on your project, and Add reference)
2.) Add to your project a class file (GlassExtensions.cs) replace the "YOURNAMESPACE" in with same namespace as in your Window1.xaml.cs, and paste this:
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Media;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace YOURNAMESPACE
{
public static class GlassingExtension
{
/// <summary>
/// Sets glass background to whole window.
/// </summary>
/// <remarks>Remember to set your WPF Window Background to "Transparent"!</remarks>
/// <param name="win"></param>
public static void GlassBackground(this Window win)
{
// Glass extend WINAPI thingie http://msdn.microsoft.com/en-us/library/aa969512%28VS.85%29.aspx form more details
// If any of the margins is "-1" the whole window is glass!
win.GlassBackground(-1, 0, 0, 0);
}
/// <summary>
/// Sets glass background to custom margins in the window.
/// </summary>
/// <param name="win"></param>
public static void GlassBackground(this Window win, int left, int right, int top, int bottom)
{
// Why would you read the inner workings? Why? If you need to know why...
// DwmExtendFrameIntoClientArea http://msdn.microsoft.com/en-us/library/aa969512%28VS.85%29.aspx is the magical WINAPI call
// rest is just crap to get its parameters populated.
win.Loaded += delegate(object sender, RoutedEventArgs e)
{
try
{
// Obtain the window handle for WPF application
IntPtr mainWindowPtr = new WindowInteropHelper(win).Handle;
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
// Transparent shall be glassed!
mainWindowSrc.CompositionTarget.BackgroundColor = System.Windows.Media.Colors.Transparent;
// Margin for the DwmExtendFrameIntoClientArea WINAPI call.
NonClientRegionAPI.MARGINS margins = new NonClientRegionAPI.MARGINS();
margins.cxLeftWidth = left;
margins.cxRightWidth = right;
margins.cyBottomHeight = bottom;
margins.cyTopHeight = top;
// Glass extend WINAPI thingie http://msdn.microsoft.com/en-us/library/aa969512%28VS.85%29.aspx form more details
int hr = NonClientRegionAPI.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
if (hr < 0)
{
//DwmExtendFrameIntoClientArea Failed
} else {
win.Background = System.Windows.Media.Brushes.Transparent;
}
}
// If not glassing capabilities (Windows XP...), paint background white.
catch (DllNotFoundException)
{
Application.Current.MainWindow.Background = System.Windows.Media.Brushes.White;
}
};
}
#region WINAPI Crap, none should handle this in 21st century
private class NonClientRegionAPI
{
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth; // width of left border that retains its size
public int cxRightWidth; // width of right border that retains its size
public int cyTopHeight; // height of top border that retains its size
public int cyBottomHeight; // height of bottom border that retains its size
};
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea(
IntPtr hwnd,
ref MARGINS pMarInset);
}
#endregion
}
}
Wednesday, June 10, 2009
semtech2009 conference coming up!
semtech2009 conference is coming up! Pointing the way for semantic web, I shall take an excerpt from their webpage HTML:
The glorious semantics of /dev/null I presume...
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
The glorious semantics of /dev/null I presume...
Subscribe to:
Posts (Atom)