Get audio for your application, demo or tests.
It will create a component with every possible audio source for Web Audio API - an audio file, url, soundcloud, microphone or primitive signal. Also it tackles play/stop/reset controls, drag-n-drop, recent tracks, soundcloud tracklists, queuing multiple tracks, saving to session storage, progress bar, looping etc.
const createAudio = ;let audioSrc =;
Get app-audio constructor. It can also serve as a class.**`let appAudio = createAudio(options);`**
Create app-audio instance based off options:
//initial sourcesource: null//container to place UIcontainer: documentbody//audio context to usecontext://Enable file selectfile: true//Enable url inputurl: true//Enable soundcloud inputsoundcloud: true//Enable primitive signal inputsignal: true//Enable mic inputmic: true//Show play/payse buttonsplay: true//Start playing whenever source is selectedautoplay: true//Repeat track list after endloop: true//Show progress indicator at the top of containerprogress: true//Save/load tracks to sessionStoragesave: true//Show list of recent tracksrecent: true//Enable drag and drop filesdragAndDrop: true//Default colorcolor: 'black'
Bind event callback. Available events:
//called whenever new source is set and loaded, like mic, file, signal etc.//source audioNode is passed as a first argument, so do connection routine hereappAudio;//whenever play is pressed or calledappAudio;//whenever pause is pressed or calledappAudio;//whenever reset is calledappAudio;
Set source to play. Source can be whether
FileList, URL, soundcloud URL, list of URLs,
Play selected source. Other playback methods:
//pause current source, for mic - mute outputappAudio;//reset current source, stop playbackappAudio;//play next track, if there are multiple tracksappAudio;
Open menu. To hide menu, call
Update view or options, if required. Possible options are all the same as in the constructor.
Beautiful myself, who spent like a week on that, and another week before on start-app.