#include <hxcpp.h>

#ifndef INCLUDED_c5728fd05c542abe
#define INCLUDED_c5728fd05c542abe
#include "cpp_float32array.h"
#endif
#ifndef INCLUDED_kha_Resource
#include <hxinc/kha/Resource.h>
#endif
#ifndef INCLUDED_kha_Sound
#include <hxinc/kha/Sound.h>
#endif
#ifndef INCLUDED_kha_arrays_Float32ArrayPrivate
#include <hxinc/kha/arrays/Float32ArrayPrivate.h>
#endif
#ifndef INCLUDED_kha_audio1_AudioChannel
#include <hxinc/kha/audio1/AudioChannel.h>
#endif
#ifndef INCLUDED_kha_audio2_Audio
#include <hxinc/kha/audio2/Audio.h>
#endif
#ifndef INCLUDED_kha_audio2_Buffer
#include <hxinc/kha/audio2/Buffer.h>
#endif

HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_10__init,"kha.audio2.Audio","_init",0xded2726f,"kha.audio2.Audio._init","kha/audio2/Audio.hx",10,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_16__callCallback,"kha.audio2.Audio","_callCallback",0xe4856ae2,"kha.audio2.Audio._callCallback","kha/audio2/Audio.hx",16,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_33__readSample,"kha.audio2.Audio","_readSample",0xa617ccbf,"kha.audio2.Audio._readSample","kha/audio2/Audio.hx",33,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_46_stream,"kha.audio2.Audio","stream",0x707f0900,"kha.audio2.Audio.stream","kha/audio2/Audio.hx",46,0xd33fa1b0)
namespace kha{
namespace audio2{

void Audio_obj::__construct() { }

Dynamic Audio_obj::__CreateEmpty() { return new Audio_obj; }

void *Audio_obj::_hx_vtable = 0;

Dynamic Audio_obj::__Create(hx::DynamicArray inArgs)
{
	hx::ObjectPtr< Audio_obj > _hx_result = new Audio_obj();
	_hx_result->__construct();
	return _hx_result;
}

bool Audio_obj::_hx_isInstanceOf(int inClassId) {
	return inClassId==(int)0x00000001 || inClassId==(int)0x7a99c552;
}

 ::kha::audio2::Buffer Audio_obj::buffer;

void Audio_obj::_init(){
            	HX_GC_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_10__init)
HXLINE(  11)		int bufferSize = 2048;
HXLINE(  12)		::kha::audio2::Audio_obj::buffer =  ::kha::audio2::Buffer_obj::__alloc( HX_CTX ,(bufferSize * 4),2,44100);
            	}

STATIC_HX_DEFINE_DYNAMIC_FUNC0(Audio_obj,_init,(void))

void Audio_obj::_callCallback(int samples){
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_16__callCallback)
HXLINE(  17)		if (hx::IsNull( ::kha::audio2::Audio_obj::buffer )) {
HXLINE(  17)			return;
            		}
HXLINE(  18)		if (hx::IsNotNull( ::kha::audio2::Audio_obj::audioCallback )) {
HXLINE(  19)			::kha::audio2::Audio_obj::audioCallback(samples,::kha::audio2::Audio_obj::buffer);
            		}
            		else {
HXLINE(  22)			int _g = 0;
HXDLIN(  22)			int _g1 = samples;
HXDLIN(  22)			while((_g < _g1)){
HXLINE(  22)				_g = (_g + 1);
HXDLIN(  22)				int i = (_g - 1);
HXLINE(  23)				::kha::audio2::Audio_obj::buffer->data->self.set(::kha::audio2::Audio_obj::buffer->writeLocation,( (float)(0) ));
HXLINE(  24)				 ::kha::audio2::Buffer _hx_tmp = ::kha::audio2::Audio_obj::buffer;
HXDLIN(  24)				_hx_tmp->writeLocation = (_hx_tmp->writeLocation + 1);
HXLINE(  25)				if ((::kha::audio2::Audio_obj::buffer->writeLocation >= ::kha::audio2::Audio_obj::buffer->size)) {
HXLINE(  26)					::kha::audio2::Audio_obj::buffer->writeLocation = 0;
            				}
            			}
            		}
            	}

STATIC_HX_DEFINE_DYNAMIC_FUNC1(Audio_obj,_callCallback,(void))

Float Audio_obj::_readSample(){
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_33__readSample)
HXLINE(  34)		if (hx::IsNull( ::kha::audio2::Audio_obj::buffer )) {
HXLINE(  34)			return ( (Float)(0) );
            		}
HXLINE(  35)		float value = ::kha::audio2::Audio_obj::buffer->data->self.get(::kha::audio2::Audio_obj::buffer->readLocation);
HXLINE(  36)		++::kha::audio2::Audio_obj::buffer->readLocation;
HXLINE(  37)		if ((::kha::audio2::Audio_obj::buffer->readLocation >= ::kha::audio2::Audio_obj::buffer->size)) {
HXLINE(  38)			::kha::audio2::Audio_obj::buffer->readLocation = 0;
            		}
HXLINE(  40)		return ( (Float)(value) );
            	}

STATIC_HX_DEFINE_DYNAMIC_FUNC0(Audio_obj,_readSample,return )

 ::Dynamic Audio_obj::audioCallback;

::Dynamic Audio_obj::stream( ::kha::Sound sound,hx::Null< bool >  __o_loop){
            		bool loop = __o_loop.Default(false);
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_46_stream)
HXDLIN(  46)		return null();
            	}

STATIC_HX_DEFINE_DYNAMIC_FUNC2(Audio_obj,stream,return )

Audio_obj::Audio_obj()
{
}

bool Audio_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp)
{
	switch(inName.length) {
	case 5:
		if (HX_FIELD_EQ(inName,"_init") ) { outValue = _init_dyn(); return true; }
		break;
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { outValue = ( buffer ); return true; }
		if (HX_FIELD_EQ(inName,"stream") ) { outValue = stream_dyn(); return true; }
		break;
	case 11:
		if (HX_FIELD_EQ(inName,"_readSample") ) { outValue = _readSample_dyn(); return true; }
		break;
	case 13:
		if (HX_FIELD_EQ(inName,"_callCallback") ) { outValue = _callCallback_dyn(); return true; }
		if (HX_FIELD_EQ(inName,"audioCallback") ) { outValue = ( audioCallback ); return true; }
	}
	return false;
}

bool Audio_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp)
{
	switch(inName.length) {
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { buffer=ioValue.Cast<  ::kha::audio2::Buffer >(); return true; }
		break;
	case 13:
		if (HX_FIELD_EQ(inName,"audioCallback") ) { audioCallback=ioValue.Cast<  ::Dynamic >(); return true; }
	}
	return false;
}

#ifdef HXCPP_SCRIPTABLE
static hx::StorageInfo *Audio_obj_sMemberStorageInfo = 0;
static hx::StaticInfo Audio_obj_sStaticStorageInfo[] = {
	{hx::fsObject  ,(void *) &Audio_obj::buffer,HX_("buffer",00,bd,94,d0)},
	{hx::fsObject  ,(void *) &Audio_obj::audioCallback,HX_("audioCallback",bb,94,3e,7f)},
	{ hx::fsUnknown, 0, null()}
};
#endif

static void Audio_obj_sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(Audio_obj::buffer,"buffer");
	HX_MARK_MEMBER_NAME(Audio_obj::audioCallback,"audioCallback");
};

#ifdef HXCPP_VISIT_ALLOCS
static void Audio_obj_sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(Audio_obj::buffer,"buffer");
	HX_VISIT_MEMBER_NAME(Audio_obj::audioCallback,"audioCallback");
};

#endif

hx::Class Audio_obj::__mClass;

static ::String Audio_obj_sStaticFields[] = {
	HX_("buffer",00,bd,94,d0),
	HX_("_init",ef,56,cc,f8),
	HX_("_callCallback",62,cf,b7,99),
	HX_("_readSample",3f,11,50,e9),
	HX_("audioCallback",bb,94,3e,7f),
	HX_("stream",80,14,2d,11),
	::String(null())
};

void Audio_obj::__register()
{
	Audio_obj _hx_dummy;
	Audio_obj::_hx_vtable = *(void **)&_hx_dummy;
	hx::Static(__mClass) = new hx::Class_obj();
	__mClass->mName = HX_("kha.audio2.Audio",ee,db,10,90);
	__mClass->mSuper = &super::__SGetClass();
	__mClass->mConstructEmpty = &__CreateEmpty;
	__mClass->mConstructArgs = &__Create;
	__mClass->mGetStaticField = &Audio_obj::__GetStatic;
	__mClass->mSetStaticField = &Audio_obj::__SetStatic;
	__mClass->mMarkFunc = Audio_obj_sMarkStatics;
	__mClass->mStatics = hx::Class_obj::dupFunctions(Audio_obj_sStaticFields);
	__mClass->mMembers = hx::Class_obj::dupFunctions(0 );
	__mClass->mCanCast = hx::TCanCast< Audio_obj >;
#ifdef HXCPP_VISIT_ALLOCS
	__mClass->mVisitFunc = Audio_obj_sVisitStatics;
#endif
#ifdef HXCPP_SCRIPTABLE
	__mClass->mMemberStorageInfo = Audio_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
	__mClass->mStaticStorageInfo = Audio_obj_sStaticStorageInfo;
#endif
	hx::_hx_RegisterClass(__mClass->mName, __mClass);
}

} 
}
// Generated by Haxe 4.0.0-preview.5
#include <hxcpp.h>

#ifndef INCLUDED_c5728fd05c542abe
#define INCLUDED_c5728fd05c542abe
#include "cpp_float32array.h"
#endif
#ifndef INCLUDED_kha_Resource
#include <hxinc/kha/Resource.h>
#endif
#ifndef INCLUDED_kha_Sound
#include <hxinc/kha/Sound.h>
#endif
#ifndef INCLUDED_kha_arrays_Float32ArrayPrivate
#include <hxinc/kha/arrays/Float32ArrayPrivate.h>
#endif
#ifndef INCLUDED_kha_audio1_AudioChannel
#include <hxinc/kha/audio1/AudioChannel.h>
#endif
#ifndef INCLUDED_kha_audio2_Audio
#include <hxinc/kha/audio2/Audio.h>
#endif
#ifndef INCLUDED_kha_audio2_Buffer
#include <hxinc/kha/audio2/Buffer.h>
#endif

HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_10__init,"kha.audio2.Audio","_init",0xded2726f,"kha.audio2.Audio._init","kha/audio2/Audio.hx",10,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_16__callCallback,"kha.audio2.Audio","_callCallback",0xe4856ae2,"kha.audio2.Audio._callCallback","kha/audio2/Audio.hx",16,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_33__readSample,"kha.audio2.Audio","_readSample",0xa617ccbf,"kha.audio2.Audio._readSample","kha/audio2/Audio.hx",33,0xd33fa1b0)
HX_LOCAL_STACK_FRAME(_hx_pos_4c284ccaa8c50f8e_46_stream,"kha.audio2.Audio","stream",0x707f0900,"kha.audio2.Audio.stream","kha/audio2/Audio.hx",46,0xd33fa1b0)
namespace kha{
namespace audio2{

void Audio_obj::__construct() { }

Dynamic Audio_obj::__CreateEmpty() { return new Audio_obj; }

void *Audio_obj::_hx_vtable = 0;

Dynamic Audio_obj::__Create(hx::DynamicArray inArgs)
{
	hx::ObjectPtr< Audio_obj > _hx_result = new Audio_obj();
	_hx_result->__construct();
	return _hx_result;
}

bool Audio_obj::_hx_isInstanceOf(int inClassId) {
	return inClassId==(int)0x00000001 || inClassId==(int)0x7a99c552;
}

 ::kha::audio2::Buffer Audio_obj::buffer;

void Audio_obj::_init(){
            	HX_GC_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_10__init)
HXLINE(  11)		int bufferSize = 2048;
HXLINE(  12)		::kha::audio2::Audio_obj::buffer =  ::kha::audio2::Buffer_obj::__alloc( HX_CTX ,(bufferSize * 4),2,44100);
            	}


STATIC_HX_DEFINE_DYNAMIC_FUNC0(Audio_obj,_init,(void))

void Audio_obj::_callCallback(int samples){
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_16__callCallback)
HXLINE(  17)		if (hx::IsNull( ::kha::audio2::Audio_obj::buffer )) {
HXLINE(  17)			return;
            		}
HXLINE(  18)		if (hx::IsNotNull( ::kha::audio2::Audio_obj::audioCallback )) {
HXLINE(  19)			::kha::audio2::Audio_obj::audioCallback(samples,::kha::audio2::Audio_obj::buffer);
            		}
            		else {
HXLINE(  22)			int _g = 0;
HXDLIN(  22)			int _g1 = samples;
HXDLIN(  22)			while((_g < _g1)){
HXLINE(  22)				_g = (_g + 1);
HXDLIN(  22)				int i = (_g - 1);
HXLINE(  23)				::kha::audio2::Audio_obj::buffer->data->self.set(::kha::audio2::Audio_obj::buffer->writeLocation,( (float)(0) ));
HXLINE(  24)				 ::kha::audio2::Buffer _hx_tmp = ::kha::audio2::Audio_obj::buffer;
HXDLIN(  24)				_hx_tmp->writeLocation = (_hx_tmp->writeLocation + 1);
HXLINE(  25)				if ((::kha::audio2::Audio_obj::buffer->writeLocation >= ::kha::audio2::Audio_obj::buffer->size)) {
HXLINE(  26)					::kha::audio2::Audio_obj::buffer->writeLocation = 0;
            				}
            			}
            		}
            	}


STATIC_HX_DEFINE_DYNAMIC_FUNC1(Audio_obj,_callCallback,(void))

Float Audio_obj::_readSample(){
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_33__readSample)
HXLINE(  34)		if (hx::IsNull( ::kha::audio2::Audio_obj::buffer )) {
HXLINE(  34)			return ( (Float)(0) );
            		}
HXLINE(  35)		float value = ::kha::audio2::Audio_obj::buffer->data->self.get(::kha::audio2::Audio_obj::buffer->readLocation);
HXLINE(  36)		++::kha::audio2::Audio_obj::buffer->readLocation;
HXLINE(  37)		if ((::kha::audio2::Audio_obj::buffer->readLocation >= ::kha::audio2::Audio_obj::buffer->size)) {
HXLINE(  38)			::kha::audio2::Audio_obj::buffer->readLocation = 0;
            		}
HXLINE(  40)		return ( (Float)(value) );
            	}


STATIC_HX_DEFINE_DYNAMIC_FUNC0(Audio_obj,_readSample,return )

 ::Dynamic Audio_obj::audioCallback;

::Dynamic Audio_obj::stream( ::kha::Sound sound,hx::Null< bool >  __o_loop){
            		bool loop = __o_loop.Default(false);
            	HX_STACKFRAME(&_hx_pos_4c284ccaa8c50f8e_46_stream)
HXDLIN(  46)		return null();
            	}


STATIC_HX_DEFINE_DYNAMIC_FUNC2(Audio_obj,stream,return )


Audio_obj::Audio_obj()
{
}

bool Audio_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp)
{
	switch(inName.length) {
	case 5:
		if (HX_FIELD_EQ(inName,"_init") ) { outValue = _init_dyn(); return true; }
		break;
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { outValue = ( buffer ); return true; }
		if (HX_FIELD_EQ(inName,"stream") ) { outValue = stream_dyn(); return true; }
		break;
	case 11:
		if (HX_FIELD_EQ(inName,"_readSample") ) { outValue = _readSample_dyn(); return true; }
		break;
	case 13:
		if (HX_FIELD_EQ(inName,"_callCallback") ) { outValue = _callCallback_dyn(); return true; }
		if (HX_FIELD_EQ(inName,"audioCallback") ) { outValue = ( audioCallback ); return true; }
	}
	return false;
}

bool Audio_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp)
{
	switch(inName.length) {
	case 6:
		if (HX_FIELD_EQ(inName,"buffer") ) { buffer=ioValue.Cast<  ::kha::audio2::Buffer >(); return true; }
		break;
	case 13:
		if (HX_FIELD_EQ(inName,"audioCallback") ) { audioCallback=ioValue.Cast<  ::Dynamic >(); return true; }
	}
	return false;
}

#ifdef HXCPP_SCRIPTABLE
static hx::StorageInfo *Audio_obj_sMemberStorageInfo = 0;
static hx::StaticInfo Audio_obj_sStaticStorageInfo[] = {
	{hx::fsObject /*  ::kha::audio2::Buffer */ ,(void *) &Audio_obj::buffer,HX_("buffer",00,bd,94,d0)},
	{hx::fsObject /*  ::Dynamic */ ,(void *) &Audio_obj::audioCallback,HX_("audioCallback",bb,94,3e,7f)},
	{ hx::fsUnknown, 0, null()}
};
#endif

static void Audio_obj_sMarkStatics(HX_MARK_PARAMS) {
	HX_MARK_MEMBER_NAME(Audio_obj::buffer,"buffer");
	HX_MARK_MEMBER_NAME(Audio_obj::audioCallback,"audioCallback");
};

#ifdef HXCPP_VISIT_ALLOCS
static void Audio_obj_sVisitStatics(HX_VISIT_PARAMS) {
	HX_VISIT_MEMBER_NAME(Audio_obj::buffer,"buffer");
	HX_VISIT_MEMBER_NAME(Audio_obj::audioCallback,"audioCallback");
};

#endif

hx::Class Audio_obj::__mClass;

static ::String Audio_obj_sStaticFields[] = {
	HX_("buffer",00,bd,94,d0),
	HX_("_init",ef,56,cc,f8),
	HX_("_callCallback",62,cf,b7,99),
	HX_("_readSample",3f,11,50,e9),
	HX_("audioCallback",bb,94,3e,7f),
	HX_("stream",80,14,2d,11),
	::String(null())
};

void Audio_obj::__register()
{
	Audio_obj _hx_dummy;
	Audio_obj::_hx_vtable = *(void **)&_hx_dummy;
	hx::Static(__mClass) = new hx::Class_obj();
	__mClass->mName = HX_("kha.audio2.Audio",ee,db,10,90);
	__mClass->mSuper = &super::__SGetClass();
	__mClass->mConstructEmpty = &__CreateEmpty;
	__mClass->mConstructArgs = &__Create;
	__mClass->mGetStaticField = &Audio_obj::__GetStatic;
	__mClass->mSetStaticField = &Audio_obj::__SetStatic;
	__mClass->mMarkFunc = Audio_obj_sMarkStatics;
	__mClass->mStatics = hx::Class_obj::dupFunctions(Audio_obj_sStaticFields);
	__mClass->mMembers = hx::Class_obj::dupFunctions(0 /* sMemberFields */);
	__mClass->mCanCast = hx::TCanCast< Audio_obj >;
#ifdef HXCPP_VISIT_ALLOCS
	__mClass->mVisitFunc = Audio_obj_sVisitStatics;
#endif
#ifdef HXCPP_SCRIPTABLE
	__mClass->mMemberStorageInfo = Audio_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
	__mClass->mStaticStorageInfo = Audio_obj_sStaticStorageInfo;
#endif
	hx::_hx_RegisterClass(__mClass->mName, __mClass);
}

} // end namespace kha
} // end namespace audio2
