Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Added standard noteon noteoff MIDI message handling #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

McOmghall
Copy link

Documented and added a little example. Working on adding an HTML example.

@danigb
Copy link
Owner

danigb commented May 24, 2016

Hi Pedro,

thanks a lot for all the pull requests. The example was very helpful to understand the value of the code. Anyway, I'm not still sure if this functionality should be in sample-player, or not. I'm thinking about move some features (like this one and schedule) to it's own files and make them optional until we decided if they should be on core or not.

I'm thinking in something like this:

var player = require('soundfont-player')
var midiPlayer = require('soundfont-player/ext/midi')(player)

requestMIDIAccess().then(function(midi) {
  midiPlayer.connect(midi.inputs)
}

This allows also to evolve the functionality without pollute the core. For example, I think it should be convenient to have various players attached to different midi channels. The midiPlayer instance could take care of this...

What do you think?

Saludos
Dani

@McOmghall
Copy link
Author

As long as this is activated manually, like setting an option on Soundfont or executing a function I think it can work. Btw, I need this to deploy one of my projects so if you could just publish it on npm it'd be great.

MIDI parsing should be where it can modify both instrument benches (0-127, instrument picker) and sound volume and pitch bend, to at least fullfill the standard.

Lastly I ask you if you ever write something like var midiPlayer = require('soundfont-player/ext/midi')(player) please write it like this:

var midi = require('soundfont-player/ext/midi')
var midiPlayer = midi(player)

Because browserify only includes requires like that, so if you want to use node modules in the browser you need it like that.

@danigb
Copy link
Owner

danigb commented May 24, 2016

Hi Pedro,

I don't think I'll have time today to include the changes and publish them.
Also, I don't want to publish code that I'm not sure yet how to integrate,
so I'll recommend move your code to your side until it's ready in the
package. Something like:

function addMidiSupport(player) {
   player.processMidiMessage = function (...) {
     ...
  }
  return player
}

Un saludo

On Tue, May 24, 2016 at 12:14 PM, Pedro Montoto García <
notifications@github.com> wrote:

As long as this is activated manually, like setting an option on Soundfont
or executing a function I think it can work. Btw, I need this to deploy one
of my projects so if you could just publish it on npm it'd be great.

MIDI parsing should be where it can modify both instrument benches (0-127,
instrument picker) and sound volume and pitch bend, to at least fullfill
the standard.

Lastly I ask you if you ever write something like var midiPlayer =
require('soundfont-player/ext/midi')(player) please write it like this:

var midi = require('soundfont-player/ext/midi')
var midiPlayer = midi(player)

Because browserify only includes requires like that, so if you want to
use node modules in the browser you need it like that.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#1 (comment)

@McOmghall
Copy link
Author

McOmghall commented May 24, 2016

Ok, let me know when you've decided on an architecture, I'd like to contribute to this codebase further. Thanks.

@danigb
Copy link
Owner

danigb commented May 24, 2016

Great, it will be soon. Meanwhile I'll happily accept a PR to fix the typo
on "schedule" event ;-)

Cheers,
Dani

On Tue, May 24, 2016 at 3:34 PM, Pedro Montoto García <
notifications@github.com> wrote:

Ok let me know when you've decided on an architecture, I'd like to
contribute to this codebase further.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#1 (comment)

@danigb
Copy link
Owner

danigb commented May 25, 2016

Hi Pedro,

I've added initial support for midi (mostly by copy and paste your code). I'm quite unsure yet of how to integrate this with sample-player, and even I'm thinking in a different npm module. Meanwhile you can take a look at examples/midi or run the midi example with: npm i -g beefy && beefy examples/midi.js

The good part is that finally I've listen the browser playing my external keyboard! Thanks!

Suggestions and additions welcomed!

@danigb
Copy link
Owner

danigb commented May 26, 2016

Hi Pedro,

Finally I decided to incorprate your changes to the core. Midi support is enabled by default in 0.4.0. I hope you like it. Suggestions welcomed.

El 24/05/2016, a las 15:34, Pedro Montoto García notifications@github.com escribió:

Ok let me know when you've decided on an architecture, I'd like to contribute to this codebase further.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

@McOmghall
Copy link
Author

McOmghall commented May 26, 2016

By core you mean the soundfont-player lib right?

What's next would be

  • configuring sample-player so that the decay phase of envelopes activates only on noteoff messages (i'm not sure how to do this).
  • adding parsing for pitchbend messages would be the priority, other messages are not as widely supported and semantics vary from vendor to vendor.

@danigb
Copy link
Owner

danigb commented May 26, 2016

Hi, the decay phase of envelope starts when you stop a sample, so it's working right now. Pitchbend is more tricky...

El 26/05/2016, a las 13:30, Pedro Montoto García notifications@github.com escribió:

By core you mean the soundfont-player lib right? What's next would be configuring sample-player so that the decay phase of envelopes activates only on noteoff messages (i'm not sure how to do this). Also adding parsing for pitchbend messages would be the priority, other messages are not as widely supported and semantics vary from vendor to vendor.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub

@McOmghall
Copy link
Author

Great, will investigate about pitchbend in the Web Audio API then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants