Skip to content

Javascript port of SoundtrackOptical Processing library for browsers and node.js

Notifications You must be signed in to change notification settings

sixteenmillimeter/SoundtrackOptical.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoundtrackOptical.js

Create optical soundtracks using Javascript in either node.js or the browser.

Usage - Browser

This example will draw all frames of the soundtrack into a canvas element on the page.

<html>
<body>
	<canvas id="canvas"></canvas>
	<script src="SoundtrackOptical.js"></script>
	<script>
			var soundFile = 'data/barking.wav'; //url of sound file to decode
			var canvas = document.getElementById('canvas');
			var soundtrack = new SoundtrackOptical(canvas, soundFile);
			soundtrack.decode().then(() => {
				for (var i = 0; i < soundtrack.FRAMES; i++) {
					soundtrack.draw()
				}
			}).catch(err => {
				console.error(err);
			})
	</script>
</body>
</html>

Usage - Node

This example will draw all frames of the soundtrack into .png files in the directory the file is executed.

const SoundtrackOptical = require('soundtrackoptical');
const soundFile = './data/barking.wav'; // Path 
const soundtrack = new SoundtrackOptical(soundFile);

async function demo () {
	await soundtrack.decode();

	for (let i = 0; i < soundtrack.FRAMES; i++) {
		await soundtrack.draw();
	}
}

demo();

About

Javascript port of SoundtrackOptical Processing library for browsers and node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published