/node-libopenmpt

Convert tracker music to PCM streams in Node.js

Primary LanguageJavaScriptGNU Lesser General Public License v2.1LGPL-2.1

node-libopenmpt

A JS wrapper for libopenmpt, to enable decoding and playing tracker modules using node.

A fork from Guichaguri's node-chiptune.

If you are looking for a HTML5 player to play tracker music, check out Chiptune2.js

Example

var chiptune = require('node-chiptune');
var speaker = require('speaker');

fs.readFile('file.mod', function(err, data) {
    if(err != null) {
        console.log(err);
    } else {
        // Create a chiptune readable stream
        var chiptuneStream = chiptune(data, {
            channels: 2, // 2 channels (stereo)
            sampleRate: 48000 // 48,000 Hz sample rate
        });
        
        // We should be able to pipe the the chiptune stream to the speaker
        chiptuneStream.pipe(new Speaker());
    }
});

fs.readFile('file.mod', function(err, data) {
    if(err != null) {
        console.log(err);
    } else {
        var module = new OpenMTP_Module(data);
        var chiptuneStream = module.openAsStream();
		
		chiptuneStream.pipe(new Speaker());
    }
});

Supported formats

All sound tracker module formats (meaning not MIDI or ABC) supported by libOpenMTP should work.