📜 ⬆️ ⬇️

Interactive Browser Music

Recently, there have been many examples of using the Web Audio API for synthesizing sound in a browser. You can get acquainted with the most interesting projects in this area on the Audiocrawl.co website:

image

What libraries / frameworks can I use to create audio applications? There is MIDI.js , a search on Github can still find several different degrees of abandonment.
')
But I would like something more:

And there is such a library!

This is SSSynthesiser.js . Examples of use can be found on the project page.

image

General ideology




Example use with WebGL


image

Distinctive characteristics





Code examples


Library connection:

<script src="SSSynthesiser.js"></script> 

Initialization and loading:

 var sssynthesiser = null; var xmlHttpRequest = new XMLHttpRequest(); xmlHttpRequest.open('GET', "http://site/x/sviridovtimeforward.molgav", true); xmlHttpRequest.onload = function () { var o = JSON.parse(xmlHttpRequest.response); sssynthesiser = new SSSynthesiser(o); }; xmlHttpRequest.send(); 

Of course, the site must be configured CORS .

Reproduction:

 sssynthesiser.startPlaySong(); 

One note:

 sssynthesiser.playKey(sssynthesiser.findSampleBySubPath(s),1000,45); 

where 45 is the note height on the MIDI scale, in this case it is A3, i.e. La third octave.

One chord:

 sssynthesiser.playChord(sssynthesiser.findSampleBySubPath(s),2000,[48,52,55,60,64]); 

where 48,52,55,60,64 is the height of the notes on the MIDI scale.

JSON file format


An example can be found here . Ideologically, it is close to the tracker files and contains sampled instruments in addition to notes.

Performance


In SSSynthesis.js , samples are mixed directly during the production. Nevertheless, the sound is seamlessly synthesized even on very weak phone models.

Compatible with Chrome / Safari / Firefox / Opera / MSEdge on the desktop and mobile platforms, Godless IE of course in the span.

Source: https://habr.com/ru/post/266145/


All Articles