Audio
Import audio subpath module.
import * as Audio from "web-music-score/audio";
Add Instrument
Following instruments/audio modules are available:
audio-synth- Default Synthesizeraudio-cg- Classical Guitar
Hope to add more instruments in the future! 🙏🏼
Import instrument.
import { Synthesizer } from "web-music-score/audio-synth";
import { ClassicalGuitar } from "web-music-score/audio-cg";
💡 Synthesizer is included by default and does not need to be imported/added.
Classical guitar bundle is also available for HTML <script>.
<!-- Use either one -->
<script src="https://unpkg.com/web-music-score@6.0.0-pre.3/dist/iife/audio-cg.js"></script>
<script src="https://cdn.jsdelivr.net/npm/web-music-score@6.0.0-pre.3/dist/iife/audio-cg.js"></script>
<script>
const { ClassicalGuitar } = window.Audio_CG;
</script>
Finally, add the instrument.
Audio.addInstrument(ClassicalGuitar);
💡 This will also set the instrument current for playback.
Manage Instruments
Audio.getInstrumentList(); // returns string[]
Audio.getCurrentInstrument();
Audio.useInstrument(instrument: string);
💡 Currently available instrument names are "Synthesizer" and "Classical Guitar".
Play Note
Audio.playNote(note, duration?, linearVolume?);
Audio.stop();
Mute
Audio.mute();
Audio.unmute();
Audio.isMuted();