Click here to Skip to main content
15,880,427 members
Articles / Programming Languages / Visual Basic

Audio Library Part I - (Windows Mixer Control)

Rate me:
Please Sign up or sign in to vote.
4.52/5 (79 votes)
1 Oct 2006CPOL3 min read 606.2K   15.4K   163  
Library to control Windows Mixer from C#
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER 
//  REMAINS UNCHANGED.
//
//  Email:  gustavo_franco@hotmail.com
//
//  Copyright (C) 2005 Franco, Gustavo 
//
using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace WaveLib.AudioMixer
{
	[Author("Gustavo Franco")]
	public class CallbackWindow : NativeWindow, IDisposable
	{
		#region Constants Declaration
		private const int WS_CHILD = 0x40000000, WS_VISIBLE = 0x10000000, WM_ACTIVATEAPP = 0x001C;
		#endregion

		#region Variables Declaration
		private CallbackWindowControlChangeHandler	mPtrMixerControlChange;
		private CallbackWindowLineChangeHandler		mPtrMixerLineChange;
		#endregion

		#region Constructors
		internal CallbackWindow(CallbackWindowControlChangeHandler ptrMixerControlChange, CallbackWindowLineChangeHandler ptrMixerLineChange)
		{
			CreateParams cp = new CreateParams();

			mPtrMixerControlChange	= ptrMixerControlChange;
			mPtrMixerLineChange		= ptrMixerLineChange;

			this.CreateHandle(cp);
		}
		#endregion

		#region Overrides
		[DebuggerNonUserCode(), System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
		protected override void WndProc(ref Message m)
		{
			switch (m.Msg)
			{
				case MixerNative.MM_MIXM_LINE_CHANGE:
					mPtrMixerLineChange(m.WParam, (uint) m.LParam);
					break;

				case MixerNative.MM_MIXM_CONTROL_CHANGE:
					mPtrMixerControlChange(m.WParam, (uint) m.LParam);
					break;
				default:
					break;

			}
			base.WndProc (ref m);
		}
		#endregion

		#region IDisposable Members
		public void Dispose()
		{
			if (this.Handle != IntPtr.Zero)
			{
				this.DestroyHandle();
			}
		}
		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Microsoft
United States United States
I started with programming about 19 years ago as a teenager, from my old Commodore moving to PC/Server environment Windows/UNIX SQLServer/Oracle doing gwBasic, QBasic, Turbo Pascal, Assembler, Turbo C, BC, Summer87, Clipper, Fox, SQL, C/C++, Pro*C, VB3/5/6, Java, and today loving C#.

Currently working as SDE on Failover Clustering team for Microsoft.

Passion for most programming languages and my kids Aidan&Nadia.

Comments and Discussions