tones = {
let tonesObj = {};
Object.keys(spritePositions).map(async name => {
const file = {
fish: await FileAttachment("fish.wav"),
coin: await FileAttachment("coin@1.wav"),
flower: await FileAttachment("flower.wav"),
egg: await FileAttachment("egg.wav"),
feather: await FileAttachment("feather.wav"),
star: await FileAttachment("star.wav"),
question: await FileAttachment("question.wav"),
mushroom: await FileAttachment("mushroom.wav"),
ghost: await FileAttachment("ghost.wav"),
}[name]
const pitchAdjust = {
fish: -3,
coin: -1,
flower: -4,
egg: 4,
feather: 3,
star: 4,
question: 3,
mushroom: 4,
ghost: -4
}[name];
const tone = new Tone.Player(await file.url());
const shift = new Tone.PitchShift().toDestination();
tone.connect(shift);
tonesObj[name] = { play: y => {
const pitch = range(boundry.top, boundry.bottom, 6, -6, y);
shift.pitch = pitch + pitchAdjust;
tone.start();
} };
})
return tonesObj;
}