Click here to Skip to main content
11,411,128 members (64,174 online)
Click here to Skip to main content
Add your own
alternative version

Low Latency Audio using ASIO Drivers in .NET

, 7 May 2008 CPOL
Demonstrates access to your sound hardware with ASIO drivers
//
// BlueWave.Interop.Asio by Rob Philpott. Please send all bugs/enhancements to
// rob@bigdevelopments.co.uk.  This file and the code contained within is freeware and may be
// distributed and edited without restriction. You may be bound by licencing restrictions
// imposed by Steinberg - check with them prior to distributing anything.
// 

#include "AsioRedirect.h"

#pragma once
#pragma managed

using namespace System;

namespace BlueWave
{
	namespace Interop
	{
		namespace Asio
		{
			// represents a single audio channel (input or output) on the soundcard
			public ref class Channel
			{
			internal:

				// pointer to owner
				IAsio* _pDriver;

				// true is this is an input channel
				bool _isInput;

				// the channel name
				String^ _name;

				// the number of samples in the buffer
				int _bufferSize;

				// the range for floats for bitperfect reproduction
				const static float __maxSampleValue = 8388607.0f / 8388608.0f;

				// sample format
				ASIOSampleType _sampleType;

				// pointer to their buffer
				DWORD* _pTheirBuffer0;
				DWORD* _pTheirBuffer1;

				// what buffer should be affected by our indexer
				DWORD* _pTheirCurrentBuffer;

				// internal construction only
				Channel(IAsio* pAsio, bool IsInput, int channelNumber, void* pTheirBuffer0, void* pTheirBuffer1, int bufferSize);

				// what buffer should be affected by our indexer
				void SetDoubleBufferIndex(long doubleBufferIndex);

			public:

				// the channel name
				property String^ Name { String^ get(); }

				// the buffer size in samples
				property int BufferSize { int get(); }

				// the sample type
				property double SampleType { double get(); }

				// indexer for setting the value of sample in the buffer
				property float default[int] { void set(int sample, float value); float get(int sample); }

			};
		};
	}
}

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

Rob Philpott
Architect
United Kingdom United Kingdom
I am a .NET architect/developer based in London working mostly on financial trading systems. My love of computers started at an early age with BASIC on a 3KB VIC20 and progressed onto a 32KB BBC Micro using BASIC and 6502 assembly language. From there I moved on to the blisteringly fast Acorn Archimedes using BASIC and ARM assembly.

I started developing with C++ since 1990, where it was introduced to me in my first year studying for a Computer Science degree at the University of Nottingham. I started professionally with Visual C++ version 1.51 in 1993.

I moved over to C# and .NET in early 2004 after a long period of denial that anything could improve upon C++.

Recently I did a bit of work in my old language of C++ and I now realise that frankly, it's a total pain in the arse.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.5 | Last Updated 7 May 2008
Article Copyright 2008 by Rob Philpott
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid