Click here to Skip to main content
15,883,883 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.7K   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.Collections;

namespace WaveLib.AudioMixer
{
	[Author("Gustavo Franco")]
	public class MixerControls : System.Collections.CollectionBase
	{
		#region Constructors
		public MixerControls()
		{
		}
		#endregion

		#region Properties
		#endregion

		#region Methods
		public MixerControl GetControlByType(MIXERCONTROL_CONTROLTYPE type)
		{
			foreach(MixerControl mixerControl in this.InnerList)
				if (mixerControl.Type == type)
					return mixerControl;
			
			return null;
		}

		public MixerControl GetControlByIndex(int index)
		{
			return this[index];
		}

		public void Add(MixerControl mixerControl)
		{
			this.InnerList.Add(mixerControl);
		}

		public void Remove(MixerControl mixerControl)
		{
			if (this.InnerList.Contains(mixerControl))
			{
				this.InnerList.Remove(mixerControl);
				return;
			}

			MixerControl mixerControlToRemove = null;
			foreach(MixerControl mixerControlLoop in this.InnerList)
			{
				if (mixerControlLoop.Id		== mixerControl.Id &&
					mixerControlLoop.Name	== mixerControl.Name &&
					mixerControlLoop.Line	== mixerControl.Line)
				{
					mixerControlToRemove = mixerControlLoop;
					break;
				}
			}
			
			if (mixerControlToRemove != null)
				this.InnerList.Remove(mixerControlToRemove);
		}
		#endregion

		#region Indexers
		public MixerControl this[int index]
		{
			get
			{
				if (index >= this.InnerList.Count || index < 0)
					return null;

				return (MixerControl) this.InnerList[index];
			}
		}
		#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