tambien / Piano

Multisampled Piano implementation using Salamander Grand Piano Sounds
https://tambien.github.io/Piano
MIT License
185 stars 49 forks source link

Cannot get samples to play correctly #26

Open enumjorge opened 4 years ago

enumjorge commented 4 years ago

I'm following the basic steps on the README, but when I play a tone I hear a low, rumbling sound instead of piano samples. I installed toneHere's my entire JS file:

import { Piano } from '@tonejs/piano';

document.getElementById('play-button').addEventListener('click', function() {
  const piano = new Piano({
    velocities : 5,
  }).toDestination();

  piano.load().then(() => {
    piano.keyDown('C4', '+1');
  });
});

Here's my package.json for reference:

{
  "name": "tonejs-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "parcel",
    "dev": "parcel index.html",
    "build": "parcel build index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@tonejs/piano": "^0.2.1",
    "tone": "^14.7.58",
    "webmidi": "^2.5.1"
  },
  "devDependencies": {
    "parcel-bundler": "^1.12.4"
  }
}

What am I doing wrong? I noticed that the code in the example folder passes the path to 'samples'. Not sure if I need to be passing that value as well. I looked in the @tonejs/piano folder inside node_modules/ and I didn't see any audio files. How are the samples being installed?

ianchow commented 4 years ago

I think the API has changed a bit- you have to supply a js object to piano.keyDown() with the proper keys. Eg. piano.keyDown({note: "F5"}) Samples are loaded from https://tambien.github.io/ unless you supply a url.