| import { BasicInstrumentZone } from "../basic_soundfont/basic_zones.js"; |
| import { Generator, generatorTypes } from "../basic_soundfont/generator.js"; |
|
|
| export class DLSZone extends BasicInstrumentZone |
| { |
| |
| |
| |
| |
| constructor(keyRange, velRange) |
| { |
| super(); |
| this.keyRange = keyRange; |
| this.velRange = velRange; |
| this.isGlobal = true; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| setWavesample( |
| attenuationCb, |
| loopingMode, |
| loop, |
| sampleKey, |
| sample, |
| sampleID, |
| samplePitchCorrection |
| ) |
| { |
| if (loopingMode !== 0) |
| { |
| this.generators.push(new Generator(generatorTypes.sampleModes, loopingMode)); |
| } |
| this.generators.push(new Generator(generatorTypes.initialAttenuation, attenuationCb)); |
| this.isGlobal = false; |
| |
| |
| samplePitchCorrection -= sample.samplePitchCorrection; |
| const coarseTune = Math.trunc(samplePitchCorrection / 100); |
| if (coarseTune !== 0) |
| { |
| this.generators.push(new Generator(generatorTypes.coarseTune, coarseTune)); |
| } |
| const fineTune = samplePitchCorrection - (coarseTune * 100); |
| if (fineTune !== 0) |
| { |
| this.generators.push(new Generator(generatorTypes.fineTune, fineTune)); |
| } |
| |
| |
| if (loopingMode !== 0) |
| { |
| const diffStart = loop.start - sample.sampleLoopStartIndex; |
| const diffEnd = loop.end - sample.sampleLoopEndIndex; |
| if (diffStart !== 0) |
| { |
| const fine = diffStart % 32768; |
| this.generators.push(new Generator(generatorTypes.startloopAddrsOffset, fine)); |
| |
| const coarse = Math.trunc(diffStart / 32768); |
| if (coarse !== 0) |
| { |
| this.generators.push(new Generator(generatorTypes.startloopAddrsCoarseOffset, coarse)); |
| } |
| } |
| if (diffEnd !== 0) |
| { |
| const fine = diffEnd % 32768; |
| this.generators.push(new Generator(generatorTypes.endloopAddrsOffset, fine)); |
| |
| const coarse = Math.trunc(diffEnd / 32768); |
| if (coarse !== 0) |
| { |
| this.generators.push(new Generator(generatorTypes.endloopAddrsCoarseOffset, coarse)); |
| } |
| } |
| } |
| |
| if (sampleKey !== sample.samplePitch) |
| { |
| this.generators.push(new Generator(generatorTypes.overridingRootKey, sampleKey)); |
| } |
| |
| this.generators.push(new Generator(generatorTypes.sampleID, sampleID)); |
| this.sample = sample; |
| sample.useCount++; |
| } |
| } |