This commit is contained in:
parent
05c8a39bd8
commit
c40c5d97db
74 changed files with 863 additions and 669 deletions
|
|
@ -13,8 +13,6 @@ const DEFAULT_PROGRESSION: ReadonlyArray<GardenAudioChord> = [
|
|||
const DEFAULT_ROOT_MIDI = 57;
|
||||
const DEFAULT_SCALE: ReadonlyArray<number> = [0, 2, 4, 7, 9];
|
||||
|
||||
const profileCache = new WeakMap<VibePreset, GardenAudioVibeProfile>();
|
||||
|
||||
const getProfileScale = (vibe: VibePreset): Array<number> => {
|
||||
const scale = vibe.audio.scale?.length ? vibe.audio.scale : DEFAULT_SCALE;
|
||||
return [...scale];
|
||||
|
|
@ -26,21 +24,10 @@ const getProfileProgression = (vibe: VibePreset): Array<GardenAudioChord> =>
|
|||
);
|
||||
|
||||
export const getVibeProfile = (vibe: VibePreset): GardenAudioVibeProfile => {
|
||||
let profile = profileCache.get(vibe);
|
||||
if (!profile) {
|
||||
profile = {
|
||||
...vibe.audio,
|
||||
rootMidi: DEFAULT_ROOT_MIDI + vibe.audio.notePitchOffset,
|
||||
scale: getProfileScale(vibe),
|
||||
progression: getProfileProgression(vibe),
|
||||
};
|
||||
profileCache.set(vibe, profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
Object.assign(profile, vibe.audio);
|
||||
profile.rootMidi = DEFAULT_ROOT_MIDI + vibe.audio.notePitchOffset;
|
||||
profile.scale = getProfileScale(vibe);
|
||||
profile.progression = getProfileProgression(vibe);
|
||||
return profile;
|
||||
return {
|
||||
...vibe.audio,
|
||||
rootMidi: DEFAULT_ROOT_MIDI + vibe.audio.notePitchOffset,
|
||||
scale: getProfileScale(vibe),
|
||||
progression: getProfileProgression(vibe),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue