DrumMachines group different samples with same prefix under the same group. For example tom-1.ogg
and tom-2.ogg
forms the tom
group:
const drums = new DrumMachine(context, { instrument: "TR-808" });
drum.getSampleNames(); // => ['kick-1', 'kick-2', 'snare-1', 'snare-2', ...]
drum.getGroupNames(); // => ['kick', 'snare']
drum.getSampleNamesForGroup('kick') => // => ['kick-1', 'kick-2']
Deprecations:
drum.sampleNames
is deprecated in favour ofdrum.getSampleNames()
ordrum.getGroupNames()
drum.getVariations
is now calleddrum.getSampleNamesForGroup
Now you can pass a note name to stop
method of grand piano:
piano.start("C4");
piano.stop(60); // This worked previously
piano.stop("C4"); // This now works
By default the smplr player has a custom scheduler that helps when playing lot of notes at the same time. This scheduler can be disabled with disableScheduler
option:
const context = new AudioContext();
const piano = new SplendidGrandPiano(context, {
disableScheduler: true,
});
This is required to render things in an OfflineAudioContext.
Now is possible to load soundfont files directly thanks to soundfont2 package.
First you need to add the dependency to the project:
npm i soundfont2
Then, use the new Soundfont2Sampler class:
import { Soundfont2Sampler } from "smplr";
import { SoundFont2 } from "soundfont2";
const context = new AudioContext();
const sampler = Soundfont2Sampler(context, {
url: "https://smpldsnds.github.io/soundfonts/soundfonts/galaxy-electric-pianos.sf2",
createSoundfont: (data) => new SoundFont2(data),
});
sampler.load.then(() => {
// list all available instruments for the soundfont
console.log(sampler.instrumentNames);
// load the first available instrument
sampler.loadInstrument(sampler.instrumentNames[0]);
});
Support is still very limited. Lot of soundfont features are still not implemented, however looping seems to work quite well (read #78)
Previously you could use a instrument name or a instrument url to load a DrumMachine.
Now you can pass the DrumMachineInstrument object directly to the constructor:
const context = new AudioContext();
const drums = new DrumMachine(context, {
instrument: {
baseUrl: "https://smpldsnds.github.io/drum-machines/roland-cr-8000/",
name: "Roland-CR-8000",
samples: [
"hihat-closed",
"hihat-open",
"kick",
"snare",
"tom-high",
"tom-low",
],
formats: ["ogg", "m4a"],
},
});
- Fix: sample rate used to calculate soundfont loop data
- DrumMachine uses https://github.com/smpldsnds/drum-machines as source of samples
- Fix:
detune
param onstart
method
- 0.12.0 SplendidGrandPiano supports loading a subset of notes
- 0.12.1 Fix npm publish problem
- 0.12.2 Fix non-integer midi in 1 note length regions (#61)
- 0.11.3 Add support for standardized audio context
- 0.11.2 Resolved an issue in the sfz sampler that prevented any sound from being played when the velocity was not specified.
- 0.11.1 Fix onStart callback when using
start
on Soundfont - Add
onStart
sample event - Add
onStart
andonEnded
global events
- 0.10.3 - Fix output connection
- 0.10.2 - Remove console.log
- 0.10.1 - Fix onEnded not working
- Feature: Versilian VCSL instrument (not fully implemented)
- Feature: Support for SFZ file parsing
- Feature: New Smolken double bass instrument
- Fix: soundfont.loop returns this
- Improvement: Soundfont uses group abstraction. Simplify code
- Feature: New Mellotron instrument
- Deprecation: : use
load
property instead ofloaded()
function
- Feature: Soundfont can play looped instruments using new loadLoopData option
- Feature: New sample player accepts a very large number of notes
- Feature:
loop
,loopStart
andloopEnd
has been added as sample start options - Fix: Can't disconnect a player or channel twice
- Fix: error with HttpStorage fetch binding
- Feature: Add
CacheStorage
object for caching http requests
- Fix: Ensure
options
is optional when possible
- Feature: Add
onEnded
property to the start note object
- Fix: Rename
getSoundfontInstrumentNames
togetSoundfontNames
to keep naming consistency
- Fix: Ensure mp3 Soundfonts are loaded in Safari
- Fix: Accept note name in SplendidGrandPiano
- Fix: Show a console.warning if the buffer is not found
- Feature: Add DrumMachine instrument
Full rewrite. Samples stored at https://github.com/danigb/samples