deskjet / chiptune2.js Goto Github PK
View Code? Open in Web Editor NEWmuch like chiptune.js - but newer and neater
much like chiptune.js - but newer and neater
Hi! Nice work. :)
Would be nice too see looping as the one posted before, but i alos would like to load and entire directory into a simple playlist. Will there come an option for this?
Keep up the good work. :+1
Edit:
Never mind the looping. Got it figured. Just using the onEnded. :)
(This isn't an issue with chiptune.js, and I'm sorry for this form abuse.)
There are amazingly a lot of javascript tracker libraries out there already, but I have searched in vain for even a rudimentary chip emulator which could play Atari snd or sc68 formats, or even C64 sid's.
Though there are great programs out there on linux, sc68 (@sf) for Atari/Amiga and sidplayfp for C64, trying to make one of them work myself using emscripten failed horrendously.
Since you seem to have skill with emscripten's pipeline (and you called this project "chiptune.js", not tracker.js), maybe I could interest youd in giving these chiptune players a try?
Especially libsc68 would be very amazing. I'd be very grateful for even trying.
Tunes for testing could be found at http://sndh.atari.org/ (sndh) and http://www.hvsc.de/ (sid).
Hello, i am new to javascript and i want to make it so that when the webpage loads, it plays the mod file and loops it. However i have no idea how this works and i dont seem to find tutorials or guides anywhere.
Could anyone help me with this please?
Sorry if i posted this in the wrong place.
Hey, trying to just play audio using:
async function initializePlayer() {
try {
while (typeof libopenmpt === 'undefined') {
await new Promise(resolve => setTimeout(resolve, 100));
}
var player = new ChiptuneJsPlayer(new ChiptuneJsConfig());
player.load('mymodule.mod', function (buffer) {
player.play(buffer);
});
} catch (error) {
console.error('Error initializing audio player:', error);
}
}
document.addEventListener('DOMContentLoaded', initializePlayer, { once: true });
get this error:
index.html:1 Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
i think im including the correct files here:
<body>
<canvas id="gameCanvas" width="800" height="600"></canvas>
<script async src="./chiptune2.js/libopenmpt.js"></script>
<script src="./chiptune2.js/chiptune2.js"></script>
<script src="dist/bundle.js"></script>
</body>
Hello! So I'm not an expert on JS, and I'm trying to figure out how to get a visualization in pattern, just like the trackers, if possible.
(Preferentially with a code snippet, I usually understand those better D: )
The live demo for chiptune2.js, which comes from the gh-pages branch, uses RawGit to fetch the most recent version of both chiptune2.js and libopenmpt.js from the master branch
Lines 136 to 137 in aef26d6
I randomly went and browsed rawgit's website to see if anything is new with them, and discovered a surprising new development. They're tentatively shutting down operations this October. https://rawgit.com
A number of possible options are available:
More options may be available that I hadn't thought of.
Hi!
Would it possible to access the interactive extension to control playback tempo?
Can't seem to wrap my head around how this could be done.
Thanks,
Martin
Subject.
Why? E.g. I want to get a WAV file, convert it to mp3/m4a and set it as a ringtone on my phone.
Using part of the code of the demo-page I've been trying to get Chiptune2.js to play a song. But this error keeps coming up.
chiptune2.js:187 Uncaught TypeError: libopenmpt._malloc is not a function
at ChiptuneJsPlayer.createLibopenmptNode (chiptune2.js:187:30)
at ChiptuneJsPlayer.play (chiptune2.js:151:26)
This is the part of the demo-page that I'm using...
<script type="text/javascript">
window['libopenmpt'] = {};
libopenmpt.onRuntimeInitialized = function() {
var player;
function init() {
if (player == undefined) {
player = new ChiptuneJsPlayer(new ChiptuneJsConfig(-1));
} else {
player.stop();
}
}
function afterLoad(path, buffer) {
player.play(buffer);
}
function loadURL(path) {
init();
player.load(path, afterLoad.bind(this, path));
}
document.querySelectorAll('.song').forEach(function (e) {
e.addEventListener('click', function (evt) {
modurl = evt.target.getAttribute("data-modurl");
loadURL(modurl);
}, false);
});
};
</script>
<script type="text/javascript" src="js/libopenmpt.js"></script>
<script type="text/javascript" src="js/chiptune2.js"></script>
I can't figure out why this error is thrown.
Can anyone help me out?
Many people seem to take their libopenmpt.js copy right from this repository, which is a bit unfortunate since it's several versions behind the current release. Updating to the latest version (and maybe encouraging people in the readme to compile their own, up-to-date version) would be appreciated.
I don't know if it's me that missed something but now the js-lib tries to load libopenmpt.js.mem
from the root folder of the site (not where I have the rest of the scripts).
When I tested yesterday I didn't need that file at all?
It would be useful for any type of application with audio.
The perfect implementation would be a PCM audio stream as the output.
A simple usage of this module:
var fs = require('fs');
var Chiptune = require('?');
var Speaker = require('speaker');
fs.createReadStream('file.mod').pipe(new Chiptune()).pipe(new Speaker());
// file.mod will be played
I might implement this in a PR by myself, but I want your approval for this idea
Hi, Developers.
I tried your github demo and your website, and so far everything play nicely. The only thing I am missing is M03 Format support.
Based on your libopenmpt github version, it is the first version which has native support of M03 without relying on Closed Source UN4SEEN MO3 decoder. So it should be able to play MO3 files.
Thank you for your attention
Could be good to have.
The library does support these functions: get_duration_seconds
, get_position_seconds
, and set_position_seconds
, so we could probably use something along those lines to create a seekbar that automatically updates and is draggable (seeing how we call set_repeat_count
as an example of calling those functions).
I might have a look at this, see how it goes.
libopenmpt 0.4 was released this week, and our default builds are now done with WebAssembly. This changes some things (e.g. there is no mem file anymore, but a wasm file), and there is in particular one change that needs to be done on the JS side: Wait until the wasm code is ready to run. You can get some inspiration from the changes I did to my own modified chiptune2.js: sagamusix/s3m.it@b69bf73
Hello !
I'm not able to make chiptune2.js works with iOS 10 :(
Is the demo page working for someone on iOS ?
http://deskjet.github.io/chiptune2.js/
I know that AudioContext is working fine with iOS, because some other mod js projects are working fine.
Examples:
But I need chiptune2.js who have the best lib for mods replay !
If anyone know a fix, please share :)
It would be helpful to be able to change the volume of the music being played.
Hi there! Encountering this error – can be seen on the demo page.
chiptune2.js:85 Uncaught TypeError: libopenmpt.ccall is not a function
at ChiptuneJsPlayer.module_ctl_set (chiptune2.js:85)
I guess libopenmpt changed their API for this:
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;
}
Since today, ModArchive's online player is powered by libopenmpt + chiptune2.js! :) (see http://modarchive.org/ - player link can be found on any module page)
However, one problem I initially stumbled upon was that the server-side script serving the module files didn't send a Content-Length header. In Chrome (but not Firefox), this caused the e.total variable of the XMLHttpRequest onload event to be 0, even though the total file size was of course known at this point. So I patched the serving script to send the correct Content-Length along, but this is probably not always possible, so omitting the check for e.total not being 0 might be a good idea.
One thing that'd be nice is being able to loop a song seamlessly. If you reset the position to 0 at the end of the song it resets, but there is a noticable few-second pause before it starts up again.
Now that iOS player is working, I have one more question :)
Do you know if libopenmpt support zipped mod file ?
It's not a needed feature, but could be a nice option :)
I tried to use chiptune2.js in a web worker, to see if I could speed up the game I'm making, but I'm kind of lost trying to get it to work.
Can it be used inside a web worker?
Thanks.
A good example is "Yuzu - Yu-Lib", is in OpenMPT's example modules.
Hi Chiptune team,
I want to use your cool library for a game I'm building.
Since mod files are patterns played, it is the ideal format for interactive music to support gameplay.
I would like to create a song with multiple pattern loops in it.
Example:
01 pattern1
02 pattern2
03 Jump to pattern2 at end http://milkytracker.org/docs/MilkyTracker.html#fxBxx
04 pattern4
05 Jump to pattern 4 at end
During gameplay I would like to start the song, the song will loop automatically because of the effect at the end of pattern3. When certain enemies appear in the game, I want to change the music, by having the mod file jump to pattern 4 at the end of pattern 3 (and repeat 4 and 5).
Is constructions like this possible with chiptune2?
Could it be made possible? (and could I help? (i tried to get it running locally but have not succeeded yet)
A construction that could work would be a javascript event when the player enters a pattern, where you can override the next pattern when the current one ends.
like:
player.on('EnterPattern', function(pattern) {
if (pattern === 3) {
player.forceNextPattern(4);
}
});
Could this be easily supported? Any pointers where I should look in the code to create support for this?
Thanks!
Allow the user to pass his or her own audio context into chiptune2.js. This is useful when using multiple instances of chiptune2.js (e.g. for sound effects) and/or using chiptune2.js with other audio libraries, so each instance and library may share just one context.
Hello!
I am trying to make chiptune2.js work with Javascript and Adobe PhoneGap Build.
https://build.phonegap.com
Android apk is playing the sound fine, but iOS ipa won't.
The handers[] is empty so it seems there is no error...
It works on Chrome and Safari so the onclick action is working.
===
ChiptuneJsPlayer.prototype.load = function(input, callback) {
xhr.onload = function(e) {
if (xhr.status === 200) {
It doesn't reach here
return callback(xhr.response); // no error
} else {
It reaches here and the xhr value was like this...
xhr.readyState = 4
xhr.status = 0
xhr.statusText = blank
player.fireEvent('onError', {type: 'onxhr'});
}
Hello i'm having problems using the latest version of libopenmpt-0.2.4764-beta10
I've tried compiling the windows and linux version of src http://lib.openmpt.org/libopenmpt/#sec_download both of them gives me the same compiled files.
This is the log in firefox dev tools:
Successfully compiled asm.js code (total compilation time 3548ms; unable to cache asm.js in synchronous scripts; try loading asm.js via <script async> or createElement('script'); 1 functions compiled slowly: Pu:7:119032 (776ms)) libopenmpt.js
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied libopenmpt.js:1:0
26 libopenmpt.js:1:2439 <<<<< here is when i try to play a song.
26 libopenmpt.js:1:2518
TypeError: abortDecorators is undefined libopenmpt.js:24:39233
I hope you can help me :)
It would be great if it were possible to disable specific channels or instruments with this library (or libopenmpt), but there doesn't seem to be a way to do it. I've tried a lot of things (including reading up on some information here), but I've unfortunately been unable to get it to work.
Is there something I'm missing, or is this not doable here? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.