const OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT=2 const OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH=3 var ChiptuneAudioContext=window.AudioContext||window.webkitAudioContext;var ChiptuneJsConfig=function(repeatCount,stereoSeparation,interpolationFilter,context){this.repeatCount=repeatCount;this.stereoSeparation=stereoSeparation;this.interpolationFilter=interpolationFilter;this.context=context} ChiptuneJsConfig.prototype.constructor=ChiptuneJsConfig;var ChiptuneJsPlayer=function(config){this.config=config;this.context=config.context||new ChiptuneAudioContext();this.currentPlayingNode=null;this.handlers=[];this.touchLocked=!0} ChiptuneJsPlayer.prototype.constructor=ChiptuneJsPlayer;ChiptuneJsPlayer.prototype.fireEvent=function(eventName,response){var handlers=this.handlers;if(handlers.length){handlers.forEach(function(handler){if(handler.eventName===eventName){handler.handler(response)}})}} ChiptuneJsPlayer.prototype.addHandler=function(eventName,handler){this.handlers.push({eventName:eventName,handler:handler})} ChiptuneJsPlayer.prototype.onEnded=function(handler){this.addHandler('onEnded',handler)} ChiptuneJsPlayer.prototype.onError=function(handler){this.addHandler('onError',handler)} ChiptuneJsPlayer.prototype.duration=function(){return libopenmpt._openmpt_module_get_duration_seconds(this.currentPlayingNode.modulePtr)} ChiptuneJsPlayer.prototype.seek=function(position){libopenmpt._openmpt_module_set_position_seconds(this.currentPlayingNode.modulePtr,position)} ChiptuneJsPlayer.prototype.getPosition=function(){return libopenmpt._openmpt_module_get_position_seconds(this.currentPlayingNode.modulePtr)} ChiptuneJsPlayer.prototype.getCurrentRow=function(){return libopenmpt._openmpt_module_get_current_row(this.currentPlayingNode.modulePtr)} ChiptuneJsPlayer.prototype.getCurrentPattern=function(){return libopenmpt._openmpt_module_get_current_pattern(this.currentPlayingNode.modulePtr)} ChiptuneJsPlayer.prototype.getCurrentOrder=function(){return libopenmpt._openmpt_module_get_current_order(this.currentPlayingNode.modulePtr)} ChiptuneJsPlayer.prototype.getCurrentTime=function(){return libopenmpt._openmpt_module_get_position_seconds(this.currentPlayingNode.modulePtr)};ChiptuneJsPlayer.prototype.getTotalOrder=function(){return libopenmpt._openmpt_module_get_num_orders(this.currentPlayingNode.modulePtr)};ChiptuneJsPlayer.prototype.getTotalPatterns=function(){return libopenmpt._openmpt_module_get_num_patterns(this.currentPlayingNode.modulePtr)};ChiptuneJsPlayer.prototype.getNumChannels=function(){return libopenmpt._openmpt_module_get_num_channels(this.currentPlayingNode.modulePtr)};ChiptuneJsPlayer.prototype.getCurrentPlayingChannels=function(){return libopenmpt._openmpt_module_get_current_playing_channels(this.currentPlayingNode.modulePtr)};ChiptuneJsPlayer.prototype.getVu=function(chan){return libopenmpt._openmpt_module_get_current_channel_vu_mono(this.currentPlayingNode.modulePtr,chan)};ChiptuneJsPlayer.prototype.isPaused=function(){return this.currentPlayingNode.paused};ChiptuneJsPlayer.prototype.metadata=function(){var data={};var keys=UTF8ToString(libopenmpt._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';');var keyNameBuffer=0;for(var i=0;i0){var framesPerChunk=Math.min(framesToRender,maxFramesPerChunk);var actualFramesPerChunk=libopenmpt._openmpt_module_read_float_stereo(this.modulePtr,this.context.sampleRate,framesPerChunk,this.leftBufferPtr,this.rightBufferPtr);if(actualFramesPerChunk==0){ended=!0;error=!this.modulePtr} var rawAudioLeft=libopenmpt.HEAPF32.subarray(this.leftBufferPtr/4,this.leftBufferPtr/4+actualFramesPerChunk);var rawAudioRight=libopenmpt.HEAPF32.subarray(this.rightBufferPtr/4,this.rightBufferPtr/4+actualFramesPerChunk);for(var i=0;i