spessasynth_core documentation
    Preparing search index...

    Class BasicSample

    A basic sample represents a single audio sample with associated parameters.

    Hierarchy (View Summary)

    Index
    • Creates a new BasicSample.

      Parameters

      • sampleName: string

        The sample's name.

      • sampleRate: number

        The sample's rate in Hz.

      • originalKey: number

        The sample's pitch as a MIDI note number.

      • pitchCorrection: number

        The sample's pitch correction in cents.

      • sampleType: SampleType

        The sample's type, an enum that defines the sample type/compression.

      • loopStart: number

        The sample's loop start relative to the sample start in sample points.

      • loopEnd: number

        The sample's loop end relative to the sample start in sample points. Exclusive.

      Returns BasicSample

    audioData?: Float32Array<ArrayBufferLike>

    The sample's audio data.

    compressedData?: Uint8Array<ArrayBufferLike>

    The compressed sample data if the sample has been compressed.

    dataOverridden: boolean = true

    Indicates if the data was overridden, so it cannot be copied back unchanged.

    linkedSample?: BasicSample

    The other linked sample of the stereo pair. undefined if the sample has no link.

    linkedTo: BasicInstrument[] = []

    Sample's linked instruments (the instruments that use it).

    loopEnd: number

    The sample's loop end index, exclusive. In sample data points, relative to the start of the sample.

    Maximum allowed value is the sample data length.

    loopStart: number

    The sample's loop start index, inclusive. In sample data points, relative to the start of the sample.

    Minimum allowed value is 0.

    name: string

    The sample's name.

    originalKey: number

    The MIDI note number of the recorded pitch for this sample.

    pitchCorrection: number

    The pitch correction to apply in cents. It can be negative.

    sampleRate: number

    The sample rate of the sample, in Hertz.

    sampleType: SampleType

    The type of the sample, as defined per SF2 specification:

    The value in sfSampleType is an enumeration with eight defined values: monoSample = 1, rightSample = 2, leftSample = 4, linkedSample = 8, RomMonoSample = 32769, RomRightSample = 32770, RomLeftSample = 32772, and RomLinkedSample = 32776. It can be seen that this is encoded such that bit 15 of the 16 bit value is set if the sample is in ROM, and reset if it is included in the SoundFont compatible bank. The four LS bits of the word are then exclusively set indicating mono, left, right, or linked.

    • Get the PCM Float32 audio data of this sample. This either decodes the compressed data or passes the ready sampleData.

      Returns Float32Array

      The raw audio data.

    • Get raw data for writing the file, either a compressed bit stream or signed 16-bit little endian PCM data.

      Parameters

      • allowVorbis: boolean

        if vorbis file data is allowed.

      Returns Uint8Array

      either s16le or vorbis data.

    • Replaces the audio data in-place.

      Parameters

      • audioData: Float32Array

        The new audio data as Float32.

      • sampleRate: number

        The new sample rate, in Hertz.

      Returns void

    • Replaces the audio with a compressed data sample and flags the sample as compressed.

      Parameters

      • data: Uint8Array

        The new compressed data.

      Returns void