Mercurial > web
changeset 58:e6c574c6f8e0
music: reupload music to the music folder, fix links
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 19 Dec 2022 18:31:02 -0500 |
parents | ac1900c0e376 |
children | d1e77bf4b37f |
files | js/chiptune2.js music.html music/gerudo_valley.s3m music/paper_-_3005.it music/paper_-_bestending.it music/paper_-_bob-omb_battlefield_remix.it music/paper_-_chippygolucky.xm music/paper_-_dance_in_the_universe_cover.mod music/paper_-_drip.xm music/paper_-_hip_shop.it music/paper_-_huxchx.it music/paper_-_infinity.it music/paper_-_nerou.it music/paper_-_old_desk_tribute.xm music/paper_-_point_of_no_hi-score.it music/paper_-_reaching_the_world_border.it music/paper_-_sarta.mptm music/paper_-_shartlover.s3m music/paper_-_tintin_on_the_moon.mod music/paper_-_visitors.xm music/paper_-_vrc6n001.it music/paper_-_vrc6n001_remake.it music/paper_-_whistling_meadows.it music/usa_keyboard_final.it projects.html |
diffstat | 25 files changed, 295 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/chiptune2.js Mon Dec 19 18:31:02 2022 -0500 @@ -0,0 +1,271 @@ +// constants +const OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT = 2 +const OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH = 3 + +// audio context +var ChiptuneAudioContext = window['AudioContext'] || window['webkitAudioContext']; + +// config +var ChiptuneJsConfig = function (repeatCount, stereoSeparation, interpolationFilter, context) +{ + this.repeatCount = repeatCount; + this.stereoSeparation = stereoSeparation; + this.interpolationFilter = interpolationFilter; + this.context = context; +} + +ChiptuneJsConfig.prototype.constructor = ChiptuneJsConfig; + +// player +var ChiptuneJsPlayer = function (config) { + this.config = config; + this.context = config.context || new ChiptuneAudioContext(); + this.currentPlayingNode = null; + this.handlers = []; + this.touchLocked = true; +} + +ChiptuneJsPlayer.prototype.constructor = ChiptuneJsPlayer; + +// event handlers section +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); +} + +// metadata +ChiptuneJsPlayer.prototype.duration = function() { + return libopenmpt._openmpt_module_get_duration_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.metadata = function() { + var data = {}; + var keys = UTF8ToString(libopenmpt._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';'); + var keyNameBuffer = 0; + for (var i = 0; i < keys.length; i++) { + keyNameBuffer = libopenmpt._malloc(keys[i].length + 1); + writeAsciiToMemory(keys[i], keyNameBuffer); + data[keys[i]] = UTF8ToString(libopenmpt._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr, keyNameBuffer)); + libopenmpt._free(keyNameBuffer); + } + return data; +} + +ChiptuneJsPlayer.prototype.module_ctl_set = function(ctl, value) { + return libopenmpt.ccall('openmpt_module_ctl_set', 'number', ['number', 'string', 'string'], [this.currentPlayingNode.modulePtr, ctl, value]) === 1; +} + +// playing, etc +ChiptuneJsPlayer.prototype.unlock = function() { + + var context = this.context; + var buffer = context.createBuffer(1, 1, 22050); + var unlockSource = context.createBufferSource(); + + unlockSource.buffer = buffer; + unlockSource.connect(context.destination); + unlockSource.start(0); + + this.touchLocked = false; +} + +ChiptuneJsPlayer.prototype.load = function(input, callback) { + + if (this.touchLocked) { + this.unlock(); + } + + var player = this; + + if (input instanceof File) { + var reader = new FileReader(); + reader.onload = function() { + return callback(reader.result); // no error + }.bind(this); + reader.readAsArrayBuffer(input); + } else { + var xhr = new XMLHttpRequest(); + xhr.open('GET', input, true); + xhr.responseType = 'arraybuffer'; + xhr.onload = function(e) { + if (xhr.status === 200) { + return callback(xhr.response); // no error + } else { + player.fireEvent('onError', {type: 'onxhr'}); + } + }.bind(this); + xhr.onerror = function() { + player.fireEvent('onError', {type: 'onxhr'}); + }; + xhr.onabort = function() { + player.fireEvent('onError', {type: 'onxhr'}); + }; + xhr.send(); + } +} + +ChiptuneJsPlayer.prototype.play = function(buffer) { + this.stop(); + var processNode = this.createLibopenmptNode(buffer, this.config); + if (processNode == null) { + return; + } + + // set config options on module + libopenmpt._openmpt_module_set_repeat_count(processNode.modulePtr, this.config.repeatCount); + libopenmpt._openmpt_module_set_render_param(processNode.modulePtr, OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT, this.config.stereoSeparation); + libopenmpt._openmpt_module_set_render_param(processNode.modulePtr, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, this.config.interpolationFilter); + + this.currentPlayingNode = processNode; + processNode.connect(this.context.destination); +} + +ChiptuneJsPlayer.prototype.stop = function() { + if (this.currentPlayingNode != null) { + this.currentPlayingNode.disconnect(); + this.currentPlayingNode.cleanup(); + this.currentPlayingNode = null; + } +} + +ChiptuneJsPlayer.prototype.togglePause = function() { + if (this.currentPlayingNode != null) { + this.currentPlayingNode.togglePause(); + } +} + +ChiptuneJsPlayer.prototype.createLibopenmptNode = function(buffer, config) { + // TODO error checking in this whole function + + var maxFramesPerChunk = 4096; + var processNode = this.context.createScriptProcessor(2048, 0, 2); + processNode.config = config; + processNode.player = this; + var byteArray = new Int8Array(buffer); + var ptrToFile = libopenmpt._malloc(byteArray.byteLength); + libopenmpt.HEAPU8.set(byteArray, ptrToFile); + processNode.modulePtr = libopenmpt._openmpt_module_create_from_memory(ptrToFile, byteArray.byteLength, 0, 0, 0); + processNode.paused = false; + processNode.leftBufferPtr = libopenmpt._malloc(4 * maxFramesPerChunk); + processNode.rightBufferPtr = libopenmpt._malloc(4 * maxFramesPerChunk); + processNode.cleanup = function() { + if (this.modulePtr != 0) { + libopenmpt._openmpt_module_destroy(this.modulePtr); + this.modulePtr = 0; + } + if (this.leftBufferPtr != 0) { + libopenmpt._free(this.leftBufferPtr); + this.leftBufferPtr = 0; + } + if (this.rightBufferPtr != 0) { + libopenmpt._free(this.rightBufferPtr); + this.rightBufferPtr = 0; + } + } + processNode.stop = function() { + this.disconnect(); + this.cleanup(); + } + processNode.pause = function() { + this.paused = true; + } + processNode.unpause = function() { + this.paused = false; + } + processNode.togglePause = function() { + this.paused = !this.paused; + } + processNode.onaudioprocess = function(e) { + var outputL = e.outputBuffer.getChannelData(0); + var outputR = e.outputBuffer.getChannelData(1); + var framesToRender = outputL.length; + if (this.ModulePtr == 0) { + for (var i = 0; i < framesToRender; ++i) { + outputL[i] = 0; + outputR[i] = 0; + } + this.disconnect(); + this.cleanup(); + return; + } + if (this.paused) { + for (var i = 0; i < framesToRender; ++i) { + outputL[i] = 0; + outputR[i] = 0; + } + return; + } + var framesRendered = 0; + var ended = false; + var error = false; + while (framesToRender > 0) { + 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 = true; + // modulePtr will be 0 on openmpt: error: openmpt_module_read_float_stereo: ERROR: module * not valid or other openmpt error + 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 < actualFramesPerChunk; ++i) { + outputL[framesRendered + i] = rawAudioLeft[i]; + outputR[framesRendered + i] = rawAudioRight[i]; + } + for (var i = actualFramesPerChunk; i < framesPerChunk; ++i) { + outputL[framesRendered + i] = 0; + outputR[framesRendered + i] = 0; + } + framesToRender -= framesPerChunk; + framesRendered += framesPerChunk; + } + if (ended) { + this.disconnect(); + this.cleanup(); + error ? processNode.player.fireEvent('onError', {type: 'openmpt'}) : processNode.player.fireEvent('onEnded'); + } + } + return processNode; +}
--- a/music.html Mon Dec 19 18:18:57 2022 -0500 +++ b/music.html Mon Dec 19 18:31:02 2022 -0500 @@ -38,7 +38,7 @@ color: #ff6600; } </style> - <script type="application/javascript" src="https://cdn.jsdelivr.net/gh/deskjet/chiptune2.js@a97e04cc7e98924f6ad17980d6eeca3f764378b5/chiptune2.js"></script> + <script type="application/javascript" src="./js/chiptune2.js"></script> <script type="application/javascript" src="./js/libopenmpt.js"></script> <script nonce="paper-web-inline"> window['libopenmpt'] = {}; @@ -111,33 +111,33 @@ </div> <div class="box"> <h2>Originals</h2> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194229">Old Desk Tribute [.XM]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194229#paper_-_old_desk_tribute.xm">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194228">Chippy-Go-Lucky [.XM]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194228#paper_-_chippygolucky.xm">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194154">Whistling Meadows [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194154#paper_-_whistling_meadows.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=193897">xX ShartLover1337 Xx [.S3M]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=193897#paper_-_shartlover.s3m">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=193607">Reaching the World Border [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=193607#paper_-_reaching_the_world_border.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=192651">THIS IS SARTA [.MPTM]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=192651#paper_-_sarta.mptm">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_old_desk_tribute.xm">Old Desk Tribute [.XM]</a> <a href="./music/paper_-_old_desk_tribute.xm">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_chippygolucky.xm">Chippy-Go-Lucky [.XM]</a> <a href="./music/paper_-_chippygolucky.xm">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_whistling_meadows.it">Whistling Meadows [.IT]</a> <a href="./music/paper_-_whistling_meadows.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_shartlover.s3m">xX ShartLover1337 Xx [.S3M]</a> <a href="./music/paper_-_shartlover.s3m">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_reaching_the_world_border.it">Reaching the World Border [.IT]</a> <a href="./music/paper_-_reaching_the_world_border.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_sarta.mptm">THIS IS SARTA [.MPTM]</a> <a href="./music/paper_-_sarta.mptm">(Download)</a></p> </div> <div class="box"> <h2>Collabs</h2> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=198747">USA Keyboard (co-op with ishineee, rainbow, and quyu) [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=198747#usa_keyboard_final.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/usa_keyboard_final.it">USA Keyboard (co-op with ishineee, rainbow, and quyu) [.IT]</a> <a href="./music/usa_keyboard_final.it">(Download)</a></p> </div> <div class="box"> <h2>Covers</h2> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=199486">Razerek - huxchx [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=199486#paper_-_huxchx.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=196945">Gerudo Valley (OPL2) [.S3M]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=196945#gerudo_valley.s3m">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194255">Jeroen Tel - TinTin on the Moon [.MOD]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194255#paper_-_tintin_on_the_moon.mod">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194152">Adeq - Dance in the universe [.MOD]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194152#paper_-_dance_in_the_universe_cover.mod">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=194058">Super Mario 64 - Bob-omb Battlefield Remix [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=194058#paper_-_bob-omb_battlefield_remix.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=192921">(mashup) Drax - Tiger Mission Hi-score + ESCHATOS OST - Point of No Return [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=192921#paper_-_point_of_no_hi-score.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=192722">(remake) Naruto - VRC6N001 [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=192722#paper_-_vrc6n001_remake.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=192494">Deltarune - Hip Shop [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=192494#paper_-_hip_shop.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=191811">ziner - Flatwoods Monster [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=191811#paper_-_nerou.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=191735">Leonz - Among Us Drip Theme [.XM]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=191735#paper_-_drip.xm">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=191381">Childish Gambino - 3005 [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=191381#paper_-_3005.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=191287">Cho Ren Sha 68k - Infinity [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=191287#paper_-_infinity.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=191006">Aphex Twin - Avril 14th [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=191006#paper_-_bestending.it">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=190865">KOTO - Visitors [.XM]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=190865#paper_-_visitors.xm">(Download)</a></p> - <p><a href="#" class="song" data-modurl="https://api.modarchive.org/downloads.php?moduleid=190803">Naruto - VRC6N001 [.IT]</a> <a href="https://api.modarchive.org/downloads.php?moduleid=190803#paper_-_vrc6n001.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_huxchx.it">Razerek - huxchx [.IT]</a> <a href="./music/paper_-_huxchx.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/gerudo_valley.s3m">Gerudo Valley (OPL2) [.S3M]</a> <a href="./music/gerudo_valley.s3m">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_tintin_on_the_moon.mod">TinTin on the Moon [.MOD]</a> <a href="./music/paper_-_tintin_on_the_moon.mod">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_dance_in_the_universe_cover.mod">Dance in the universe cover [.MOD]</a> <a href="music/paper_-_dance_in_the_universe_cover.mod">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_bob-omb_battlefield_remix.it">Super Mario 64 - Bob-omb Battlefield Remix [.IT]</a> <a href="./music/paper_-_bob-omb_battlefield_remix.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_point_of_no_hi-score.it">(mashup) Drax - Tiger Mission Hi-score + ESCHATOS OST - Point of No Return [.IT]</a> <a href="./music/paper_-_point_of_no_hi-score.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_vrc6n001_remake.it">(remake) Naruto - VRC6N001 [.IT]</a> <a href="./music/paper_-_vrc6n001_remake.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_hip_shop.it">Deltarune - Hip Shop [.IT]</a> <a href="./music/paper_-_hip_shop.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_nerou.it">ziner - Flatwoods Monster [.IT]</a> <a href="./music/paper_-_nerou.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_drip.xm">Leonz - Among Us Drip Theme [.XM]</a> <a href="./music/paper_-_drip.xm">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_3005.it">Childish Gambino - 3005 [.IT]</a> <a href="./music/paper_-_3005.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_infinity.it">Cho Ren Sha 68k - Infinity [.IT]</a> <a href="./music/paper_-_infinity.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_bestending.it">Aphex Twin - Avril 14th [.IT]</a> <a href="./music/paper_-_bestending.it">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_visitors.xm">KOTO - Visitors [.XM]</a> <a href="./music/paper_-_visitors.xm">(Download)</a></p> + <p><a href="#" class="song" data-modurl="./music/paper_-_vrc6n001.it">Naruto - VRC6N001 [.IT]</a> <a href="./music/paper_-_vrc6n001.it">(Download)</a></p> </div> </body>
--- a/projects.html Mon Dec 19 18:18:57 2022 -0500 +++ b/projects.html Mon Dec 19 18:31:02 2022 -0500 @@ -3,11 +3,10 @@ <title>Projects - Paper's website</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> - <link href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet" media="screen"> + <link href="./css/bootstrap.min.css" rel="stylesheet" media="screen"> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico?"> <style nonce="paper-web-inline"> .navbar { - /* font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; */ text-align: left; /* Override body text align */ box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5); }