Giter VIP home page Giter VIP logo

chiptune2.js's People

Contributors

deskjet avatar gs11 avatar perlun avatar raurir avatar sagamusix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chiptune2.js's Issues

Node.js module

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

Update libopenmpt

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.

Don't check for e.total

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.

Javascript and PhoneGap Build

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'});
}

Accesssing interactive extensions

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

web workers

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.

Disabling channels/instruments

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!

libopenmpt-0.2.4764-beta10 doesn't play.

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 :)

Github Pages demo: RawGit is shutting down

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

chiptune2.js/index.html

Lines 136 to 137 in aef26d6

<script type="text/javascript" src="//cdn.rawgit.com/deskjet/chiptune2.js/master/libopenmpt.js"></script>
<script type="text/javascript" src="//cdn.rawgit.com/deskjet/chiptune2.js/master/chiptune2.js"></script>
Doing this helps by not requiring either of these to be kept up to date in the gh-pages branch, since the demo pulls from master.

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:

  • Maintain copies of libopenmpt.js and chiptune2.js in gh-pages
  • Find and switch to an alternative service to rawgit.
  • Do nothing until rawgit goes offline, then:
    • Revisit this issue
    • Do nothing and allow the demo to remain broken

More options may be available that I hadn't thought of.

Would love a real chiptune player

(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).

Upgrading libopenmpt breaks tempo/pitch sliders

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;
}

Volume support

It would be helpful to be able to change the volume of the music being played.

Autoplay music

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.

OPL support

A good example is "Yuzu - Yu-Lib", is in OpenMPT's example modules.

M03 Format Support

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

Allow user to pass in an audio context

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.

Could not load libopenmpt.js.mem

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?

Playlist?

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. :)

Export to WAV?

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.

Upgrade to libopenmpt 0.4

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

Get pattern

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: )

Seekbar support

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.

Uncaught TypeError: libopenmpt._malloc is not a function

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?

Looping songs

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.

Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.

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>

Zip support for mods ?

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 :)

Question about interactive playback

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.