deskjet / chiptune2.js

much like chiptune.js - but newer and neater
375 stars 52 forks source link

Question about interactive playback #15

Closed matthijsgroen closed 8 years ago

matthijsgroen commented 8 years ago

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!

onikienko commented 8 years ago

Take a look on this lib https://github.com/DhrBaksteen/ScripTracker I think it will a better solution for your needs.

Or you can try to implement this features for chiptune2.js with libopenmpt API http://lib.openmpt.org/doc/index.html

matthijsgroen commented 8 years ago

Wow thanks! I will experiment with it!