Skip to content

Commit

Permalink
attempting to add new samples
Browse files Browse the repository at this point in the history
  • Loading branch information
choptop84 committed Apr 11, 2024
1 parent 5da113a commit 28bac79
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 15 deletions.
17 changes: 17 additions & 0 deletions editor/AddSamplesPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ export class AddSamplesPrompt {
let useLegacySamples: boolean = false;
let useNintariboxSamples: boolean = false;
let useMarioPaintboxSamples: boolean = false;
let useSecretSamples: boolean = false;
const parsedEntries: SampleEntry[] = [];
for (const url of urls) {
if (url === "") continue;
Expand Down Expand Up @@ -488,6 +489,21 @@ export class AddSamplesPrompt {
});
}
useMarioPaintboxSamples = true;
} else if (url.toLowerCase() === "secretsamples") {
if (!useSecretSamples) {
parsedEntries.push({
url: "secretSamples",
sampleRate: 44100,
rootKey: 60,
percussion: false,
chipWaveLoopStart: null,
chipWaveLoopEnd: null,
chipWaveStartOffset: null,
chipWaveLoopMode: null,
chipWavePlayBackwards: false,
});
}
useSecretSamples = true;
} else {
let urlSliced: string = url;
let sampleRate: number = 44100;
Expand Down Expand Up @@ -593,6 +609,7 @@ export class AddSamplesPrompt {
urlInLowerCase === "legacysamples"
|| urlInLowerCase === "nintariboxsamples"
|| urlInLowerCase === "mariopaintboxsamples"
|| urlInLowerCase === "secretsamples"
);
const options: string[] = [];
if (sampleRate !== 44100) options.push("s" + sampleRate);
Expand Down
50 changes: 50 additions & 0 deletions synth/SynthConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ declare global {
const oinkpaintbox: number[];
const swanpaintboxsample: number[];
const facepaintboxsample: number[];
const secretsample1: number[];
}

function loadScript(url: string): Promise<void> {
Expand Down Expand Up @@ -817,6 +818,55 @@ export function loadBuiltInSamples(set: number): void {
chipWaveIndexOffset++;
}
});
} else if (set == 3) {
// Create chip waves with the wrong sound.
const chipWaves = [
{ name: "choptop84s announcement", expression: 4.0, isSampled: true, isPercussion: false, extraSampleDetune: 0 },
];

sampleLoadingState.totalSamples += chipWaves.length;

// This assumes that Config.rawRawChipWaves and Config.chipWaves have
// the same number of elements.
const startIndex: number = Config.rawRawChipWaves.length;
for (const chipWave of chipWaves) {
const chipWaveIndex: number = Config.rawRawChipWaves.length;
const rawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const rawRawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const integratedChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultIntegratedSamples };
Config.rawRawChipWaves[chipWaveIndex] = rawRawChipWave;
Config.rawRawChipWaves.dictionary[chipWave.name] = rawRawChipWave;
Config.rawChipWaves[chipWaveIndex] = rawChipWave;
Config.rawChipWaves.dictionary[chipWave.name] = rawChipWave;
Config.chipWaves[chipWaveIndex] = integratedChipWave;
Config.chipWaves.dictionary[chipWave.name] = rawChipWave;
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loading;
sampleLoadingState.urlTable[chipWaveIndex] = "secretSamples";
}

loadScript("secretsamples.js")
.then(() => {
// Now put the right sounds in there after everything
// got loaded.
const chipWaveSamples: Float32Array[] = [
centerWave(secretsample1),
];
let chipWaveIndexOffset: number = 0;
for (const chipWaveSample of chipWaveSamples) {
const chipWaveIndex: number = startIndex + chipWaveIndexOffset;
Config.rawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.rawRawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.chipWaves[chipWaveIndex].samples = performIntegral(chipWaveSample);
sampleLoadingState.statusTable[chipWaveIndex] = SampleLoadingStatus.loaded;
sampleLoadingState.samplesLoaded++;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(
sampleLoadingState.totalSamples,
sampleLoadingState.samplesLoaded
));
chipWaveIndexOffset++;
}
});

}
else {
console.log("invalid set of built-in samples");
Expand Down
18 changes: 17 additions & 1 deletion synth/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3693,6 +3693,7 @@ export class Song {
let willLoadLegacySamples = false;
let willLoadNintariboxSamples = false;
let willLoadMarioPaintboxSamples = false;
let willLoadSecretSamples = false;
const customSampleUrls = [];
const customSamplePresets: Preset[] = [];
sampleLoadingState.statusTable = {};
Expand Down Expand Up @@ -3725,6 +3726,13 @@ export class Song {
loadBuiltInSamples(2);
}
}
else if (url.toLowerCase() === "secretsamples") {
if (!willLoadSecretSamples) {
willLoadSecretSamples = true;
customSampleUrls.push(url);
loadBuiltInSamples(3);
}
}

else {
// UB version 2 URLs and below will be using the old syntax, so we do need to parse it in that case.
Expand Down Expand Up @@ -6037,6 +6045,7 @@ export class Song {
let willLoadLegacySamples: boolean = false;
let willLoadNintariboxSamples: boolean = false;
let willLoadMarioPaintboxSamples: boolean = false;
let willLoadSecretSamples: boolean = false;
const customSampleUrls: string[] = [];
const customSamplePresets: Preset[] = [];
for (const url of customSamples) {
Expand All @@ -6061,7 +6070,14 @@ export class Song {
loadBuiltInSamples(2);
}
}

else if (url.toLowerCase() === "secretsamples") {
if (!willLoadSecretSamples) {
willLoadSecretSamples = true;
customSampleUrls.push(url);
loadBuiltInSamples(3);
}
}

else {
// When EditorConfig.customSamples is saved in the json
// export, it should be using the new syntax, unless
Expand Down
74 changes: 73 additions & 1 deletion website/beepbox_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,44 @@ var beepbox = (function (exports) {
}
});
}
else if (set == 3) {
const chipWaves = [
{ name: "choptop84s announcement", expression: 4.0, isSampled: true, isPercussion: false, extraSampleDetune: 0 },
];
sampleLoadingState.totalSamples += chipWaves.length;
const startIndex = Config.rawRawChipWaves.length;
for (const chipWave of chipWaves) {
const chipWaveIndex = Config.rawRawChipWaves.length;
const rawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const rawRawChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultSamples };
const integratedChipWave = { index: chipWaveIndex, name: chipWave.name, expression: chipWave.expression, isSampled: chipWave.isSampled, isPercussion: chipWave.isPercussion, extraSampleDetune: chipWave.extraSampleDetune, samples: defaultIntegratedSamples };
Config.rawRawChipWaves[chipWaveIndex] = rawRawChipWave;
Config.rawRawChipWaves.dictionary[chipWave.name] = rawRawChipWave;
Config.rawChipWaves[chipWaveIndex] = rawChipWave;
Config.rawChipWaves.dictionary[chipWave.name] = rawChipWave;
Config.chipWaves[chipWaveIndex] = integratedChipWave;
Config.chipWaves.dictionary[chipWave.name] = rawChipWave;
sampleLoadingState.statusTable[chipWaveIndex] = 0;
sampleLoadingState.urlTable[chipWaveIndex] = "secretSamples";
}
loadScript("secretsamples.js")
.then(() => {
const chipWaveSamples = [
centerWave(secretsample1),
];
let chipWaveIndexOffset = 0;
for (const chipWaveSample of chipWaveSamples) {
const chipWaveIndex = startIndex + chipWaveIndexOffset;
Config.rawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.rawRawChipWaves[chipWaveIndex].samples = chipWaveSample;
Config.chipWaves[chipWaveIndex].samples = performIntegral(chipWaveSample);
sampleLoadingState.statusTable[chipWaveIndex] = 1;
sampleLoadingState.samplesLoaded++;
sampleLoadEvents.dispatchEvent(new SampleLoadedEvent(sampleLoadingState.totalSamples, sampleLoadingState.samplesLoaded));
chipWaveIndexOffset++;
}
});
}
else {
console.log("invalid set of built-in samples");
}
Expand Down Expand Up @@ -20822,6 +20860,7 @@ li.select2-results__option[role=group] > strong:hover {
let willLoadLegacySamples = false;
let willLoadNintariboxSamples = false;
let willLoadMarioPaintboxSamples = false;
let willLoadSecretSamples = false;
const customSampleUrls = [];
const customSamplePresets = [];
sampleLoadingState.statusTable = {};
Expand Down Expand Up @@ -20851,6 +20890,13 @@ li.select2-results__option[role=group] > strong:hover {
loadBuiltInSamples(2);
}
}
else if (url.toLowerCase() === "secretsamples") {
if (!willLoadSecretSamples) {
willLoadSecretSamples = true;
customSampleUrls.push(url);
loadBuiltInSamples(2);
}
}
else {
const parseOldSyntax = beforeThree;
const ok = Song._parseAndConfigureCustomSample(url, customSampleUrls, customSamplePresets, sampleLoadingState, parseOldSyntax);
Expand Down Expand Up @@ -23045,6 +23091,7 @@ li.select2-results__option[role=group] > strong:hover {
let willLoadLegacySamples = false;
let willLoadNintariboxSamples = false;
let willLoadMarioPaintboxSamples = false;
let willLoadSecretSamples = false;
const customSampleUrls = [];
const customSamplePresets = [];
for (const url of customSamples) {
Expand All @@ -23069,6 +23116,13 @@ li.select2-results__option[role=group] > strong:hover {
loadBuiltInSamples(2);
}
}
else if (url.toLowerCase() === "secretsamples") {
if (!willLoadSecretSamples) {
willLoadSecretSamples = true;
customSampleUrls.push(url);
loadBuiltInSamples(2);
}
}
else {
const parseOldSyntax = false;
Song._parseAndConfigureCustomSample(url, customSampleUrls, customSamplePresets, sampleLoadingState, parseOldSyntax);
Expand Down Expand Up @@ -46441,6 +46495,7 @@ You should be redirected to the song at:<br /><br />
let useLegacySamples = false;
let useNintariboxSamples = false;
let useMarioPaintboxSamples = false;
let useSecretSamples = false;
const parsedEntries = [];
for (const url of urls) {
if (url === "")
Expand Down Expand Up @@ -46493,6 +46548,22 @@ You should be redirected to the song at:<br /><br />
}
useMarioPaintboxSamples = true;
}
else if (url.toLowerCase() === "secretsamples") {
if (!useSecretSamples) {
parsedEntries.push({
url: "secretSamples",
sampleRate: 44100,
rootKey: 60,
percussion: false,
chipWaveLoopStart: null,
chipWaveLoopEnd: null,
chipWaveStartOffset: null,
chipWaveLoopMode: null,
chipWavePlayBackwards: false,
});
}
useSecretSamples = true;
}
else {
let urlSliced = url;
let sampleRate = 44100;
Expand Down Expand Up @@ -46599,7 +46670,8 @@ You should be redirected to the song at:<br /><br />
const urlInLowerCase = url.toLowerCase();
const isBundledSamplePack = (urlInLowerCase === "legacysamples"
|| urlInLowerCase === "nintariboxsamples"
|| urlInLowerCase === "mariopaintboxsamples");
|| urlInLowerCase === "mariopaintboxsamples"
|| urlInLowerCase === "secretsamples");
const options = [];
if (sampleRate !== 44100)
options.push("s" + sampleRate);
Expand Down
2 changes: 1 addition & 1 deletion website/beepbox_editor.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 28bac79

Please sign in to comment.