alemangui / pizzicato

Library to simplify the way you create and manipulate sounds with the Web Audio API.
https://alemangui.github.io/pizzicato/
MIT License
1.67k stars 132 forks source link

Piano samples sound as Harmonika #173

Open JanVeb opened 1 year ago

JanVeb commented 1 year ago

Hi there, reply interesting library, using Howler at the moment and decided to try Pizzicato because of reverb function.

I was sucesfull in making Pizzicato playing midi file with piano samples, which in Howler sound normal, but in Pizzicato they sound as though its harmonica playing. How can I control this>

Also when adding reverb effect, sound gets really deformed and it stoped playing altogether after few seconds.

How I implemented Pizzicato:


import Pizzicato from 'pizzicato';

const m21 = new Pizzicato.Sound({
  source: 'file',
  options: { path: 'assets/Yamahac3/mcg_mf_021.mp3' },
});
const m22 = new Pizzicato.Sound({
  source: 'file',
  options: { path: 'assets/Yamahac3/mcg_mf_022.mp3' },
});
const m23 = new Pizzicato.Sound({
  source: 'file',
  options: { path: 'assets/Yamahac3/mcg_mf_023.mp3' },
});
...
let midiToHowl = {
  21: m21,
  22: m22,
  23: m23,
...
}

var reverb = new Pizzicato.Effects.Reverb({
  time: 1,
  decay: 0.8,
  reverse: true,
  mix: 0.5,
});

function OsmdNoteOn() {
  let noteName = midi.tracks[0].notes[noteIndex];

  noteName = midiToHowl[midi.tracks[0].notes[noteIndex]['midi']];

  noteName.stop();
  //   noteName.addEffect(reverb);
  noteName.play();

  setTimeout(
    () => noteName.stop(),
    midi.tracks[0].notes[noteIndex]['durationTicks'] * 4
  );

  setTimeout(
    () => OsmdNoteOn(),

    (midi.tracks[0].notes[noteIndex + 1]['ticks'] -
      midi.tracks[0].notes[noteIndex]['ticks']) *
      2
  );
  if (noteIndex + 2 <= midi.tracks[0].notes.length) {
    noteIndex++;
  } else {
    noteIndex = 0;
    console.log(
      '🚀 ~ file: howlerPlay.js ~ line 222 ~ OsmdNoteOn ~ noteIndex',
      noteIndex
    );
  }

}

How could I implement reverb and to make piano samples sound like Piano?

Thank