Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Audio Library Part I - (Windows Mixer Control)

, 1 Oct 2006 CPOL
Library to control Windows Mixer from C#
audiolib_demo.zip
WaveLibMixer.dll
MixerTest.exe
audiolib_src.zip
MixerTest
WaveLibMixer
AudioMixer
WaveServices
WaveLibMixer.suo
App.ico
MixerTest.csproj.user
WaveLibMixer.csproj.user
//
//  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 MixerLines : System.Collections.CollectionBase
	{
		#region Constructors
		public MixerLines()
		{
		}
		#endregion

		#region Methods
		public bool	Contains(MixerLine line)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				if (mixerLine == line)
					return true;

			return false;
		}

		public MixerLine GetMixerLineByIndex(int index)
		{
			return this[index];
		}

		public MixerLine GetMixerFirstLineByComponentType(MIXERLINE_COMPONENTTYPE componentType)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				if (mixerLine.ComponentType == componentType)
					return mixerLine;

			return null;
		}

		public MixerLine GetMixerLineByControlId(uint controlId)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				foreach(MixerControl mixerControl in mixerLine.Controls)
					if(mixerControl.Id == controlId)
						return mixerLine;

			return null;
		}

		public MixerLine GetMixerLineByLineId(uint lineId)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				if(mixerLine.Id == lineId)
					return mixerLine;

			return null;
		}

		public MixerLine GetMixerLineByLineSource(uint lineSource)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				if (mixerLine.Source == lineSource)
					return mixerLine;

			return null;
		}

		public MixerLine GetMixerFirstLineByLineDestination(uint lineDestination)
		{
			foreach(MixerLine mixerLine in this.InnerList)
				if (mixerLine.Destination == lineDestination)
					return mixerLine;

			return null;
		}

		public void Add(MixerLine line)
		{
			this.InnerList.Add(line);
		}

		public void Remove(MixerLine mixerLine)
		{
			if (this.InnerList.Contains(mixerLine))
			{
				this.InnerList.Remove(mixerLine);
				return;
			}

			MixerLine mixerLineToRemove = null;
			foreach(MixerLine mixerLineLoop in this.InnerList)
			{
				if (mixerLineLoop.ComponentType	== mixerLine.ComponentType &&
					mixerLineLoop.Destination	== mixerLine.Destination &&
					mixerLineLoop.Id			== mixerLine.Id &&
					mixerLineLoop.Source		== mixerLine.Source &&
					mixerLineLoop.Name			== mixerLine.Name)
				{
					mixerLineToRemove = mixerLineLoop;
					break;
				}
			}
			
			if (mixerLineToRemove != null)
				this.InnerList.Remove(mixerLineToRemove);
		}
		#endregion

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

				return (MixerLine) 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)

Share

About the Author

CastorTiu
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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 1 Oct 2006
Article Copyright 2005 by CastorTiu
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid