-
Notifications
You must be signed in to change notification settings - Fork 12
Sample Class
Represents a single SoundFont2 sample.
The class should not be initialized on its own as it's used internally by the SoundFont2
class.
Gets the PCM Float32Array
audio data and stores it internally for reuse. Decodes compressed samples if necessary.
const data = sample.getAudioData();
The returned value is a Float32Array
containing the PCM audio data for the sample.
All other methods are internal.
The sample's name.
console.log(sample.sampleName); // "Standard SnareL"
The sample's loop start index. In sample data points, relative to start of the sample.
console.log(sample.sampleLoopStartIndex); // 5834
The sample's loop end index. In sample data points, relative to start of the sample.
console.log(sample.sampleLoopEndIndex); // 8968
The sample type. Note that for compressed samples bit 4 is 1.
console.log(sample.sampleType); // 2 -> this means "right sample"
Indicates if the sample is compressed.
console.log(sample.isCompressed); // true
The sample rate of the sample, in hertz.
console.log(sample.sampleRate); // 44100
The MIDI key number of the recorded pitch of the sample.
console.log(sample.samplePitch); // 60 (Middle C)
The pitch correction to apply, in cents. can be negative.
console.log(sample.samplePitchCorrection); // -4 (4 cents down)
All other properties are internal.
Tip
If you encounter any errors in this documentation, please open an issue!
Warning
Make sure you always update worklet_processor.min.js
along with the npm package!