/*! Our V8 new operator */
v8::Handle<v8::Value> Audio::AudioEngine::New( const v8::Arguments& args ) {
	HandleScope scope;

	if (!args[0]->IsFunction()) {
		return ThrowException( Exception::TypeError(String::New("Callback function required")) );
	}

	Local<Function> callback = Local<Function>::Cast( args[0] );
	
	AudioEngine* engine = new AudioEngine( callback );
	engine->Wrap( args.This() );

	return scope.Close( args.This() );
} // end AudioEngine::New()
/*! Create a v8 object */
v8::Handle<v8::Value> Audio::AudioEngine::New( const v8::Arguments& args ) {
	HandleScope scope;

	Local<Object> options;

	if( args.Length() > 0 ) {
		if( !args[0]->IsObject() )
			return scope.Close( ThrowException(Exception::TypeError(String::New("First argument must be an object."))) );
		else
			options = Local<Object>::Cast( args[0] );
	} else {
		options = Object::New();
	}

	AudioEngine* pEngine = new AudioEngine( options );
	pEngine->Wrap( args.This() );

	return scope.Close( args.This() );
} // end AudioEngine::New()