Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / Visual Basic

Windows Media Audio compressor

Rate me:
Please Sign up or sign in to vote.
4.76/5 (25 votes)
8 Apr 20045 min read 302.6K   5K   106  
Managed C++ Windows Media Audio (WMA) compressor.
//  This material has been supplied as part of the Adapt-X Engine Development
//  Kit. Under copyright laws, this material may not be duplicated in whole
//  or in part, except for personal use, without the express written consent
//  of the author. Refer to the license agreement contained with this SDK
//  before using any part of this material.
//
//  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.
//
//  Email:  adaptx@hotmail.com
//
//  Copyright (C) 1999-2002 Ianier Munoz. All Rights Reserved.

#pragma once

#define WAVE_FORMAT_IEEE_FLOAT 3

#define ReleaseComObject(x) if (x != NULL) { x->Release(); x = NULL; }


//#include "adaptx30.h"

using namespace System;
//using namespace System::IO;
//using namespace System::Collections;
using namespace System::Runtime::InteropServices;

/*
using namespace System::Drawing;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Windows::Forms;

namespace AdaptX
{

	#define errCantCreateEngine S"Can't create the Adapt-X engine."
	#define errBadEngineVersion S"Bad Adapt-X engine version."
	#define errCantCreateEnumerator S"Can't create the system enumerator."
	#define errCantCreateEditor S"Can't create the engine editor."

	public __gc class AdaptXException : public Exception
	{
	public:
		AdaptXException(String* Message) : Exception(Message)
		{
		}
	};
}
*/
template<__nogc class Derived, __nogc class I, __gc class W>
class ManWrapper : public I
{
public:
	static void Create(W* wrapped, I** result)
	{
		Derived* c = new Derived();
		c->Init(wrapped);
        c->QueryInterface(__uuidof(I), (void**)result);
	}
public:
	ManWrapper() : 
	  m_RefCount(0), m_IntfHandle(NULL)
	{
	}
	virtual ~ManWrapper()
	{
		Done();
	}
public:
	void Init(W* wrapped)
	{
		if (wrapped != GetIntf())
		{
			Done();
			IntPtr IntfHandle = (IntPtr)GCHandle::Alloc(wrapped);
			m_IntfHandle = IntfHandle.ToPointer();
		}
	}
	void Done()
	{
		if (m_IntfHandle != NULL)
		{
			GCHandle h = GCHandle::op_Explicit(IntPtr(m_IntfHandle));
			if (h.IsAllocated)
				h.Free();
			m_IntfHandle = NULL;
		}
	}
	W* GetIntf()
	{
		if (m_IntfHandle != NULL)
		{
			GCHandle h = GCHandle::op_Explicit(IntPtr(m_IntfHandle));
			return static_cast<W*>(h.Target);
		}
		else
			return NULL;
	}
protected:
	void* m_IntfHandle;
public: // IUnknown
	virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) 
	{ 
		if (riid == IID_IUnknown || riid == __uuidof(I)) 
		{ 
			(*ppvObject) = (I*)this; 
			AddRef(); 
			return S_OK; 
		} 
		else return E_NOINTERFACE; 
	} 
	virtual ULONG STDMETHODCALLTYPE AddRef(void) 
	{ 
		return ++m_RefCount; 
	} 
	virtual ULONG STDMETHODCALLTYPE Release(void) 
	{ 
		m_RefCount--; 
		if (m_RefCount > 0) 
			return m_RefCount; 
		else 
		{ 
			delete this; 
			return 0; 
		} 
	} 
private: 
	ULONG m_RefCount; 
};

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions