cobookman / html5.micio Goto Github PK
View Code? Open in Web Editor NEWWORK IN PROGRESS: HTML5 powered Hardware Communication Bus using a microphone and headphone port.
WORK IN PROGRESS: HTML5 powered Hardware Communication Bus using a microphone and headphone port.
Hi,
setInterval is usually pretty poor for timing things.
You should get better performance by using requestAnimationFrame(). This will run at a maximum of 60fps, depending on how "busy" the rest of the system is. The latter qualification is also true of setInterval of course since javascript is single threaded.
In general you would do something like this:
function requestInterval(fn, ms) {
var handle = {value: null};
var timeStart = new Date().getTime();
var rafFn = function() {
var timeNow = new Date().getTime();
if ( timeNow >= timeStart + ms ) {
fn();
timeStart = timeNow; // or maybe timeStart += ms?
}
handle.value = requestAnimationFrame(rafFn);
};
handle.value = requestAnimationFrame(rafFn);
return handle;
}
// use it:
var handle = requestInterval(function() {console.log(Date.now());}, 1000);
// cancel it:
cancelAnimationFrame(handle.value);
I haven't tested that code, and I also assume that requestAnimationFrame is unprefixed. There are decent shims out there you could look at to, such as:
I stumbled on this project through a โญ from @zemirco...
I'm curious if it is possible to port http://www.whence.com/minimodem/ (http://github.com/kamalmostafa/minimodem) from C to JavaScript (or some subset of functionality) to allow communication between a browser and a device connected to the browser's host system's hardware audio port.
Do you have any thoughts on this @kamalmostafa?
I'm happy to see this, I think adding this kind of functionality to JavaScript is important. When I first saw the project, I thought of the HiJack (http://web.eecs.umich.edu/~prabal/projects/hijack/) project which is building open-hardware and native libraries for the same purpose. Pooling resources with them might help.
Can you write out your milestones for completing this? I'd like to contribute. If you lay out what steps you want to complete, I can start contributing appropriately.
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.