Giter Club home page Giter Club logo

purescript-polyphonic-soundfonts's Introduction

purescript-polyphonic-soundfonts

Deprecated in favour of purescript-soundfonts (which is a re-write in more-or-less pure PureScript and is a drop-in replacement).

This is a PureScript wrapper for danigb's soundfont project: soundfont-player. It differs from purescript-soundfonts in that it allows soundfonts for multiple instruments to reside in memory at the same time - i.e. it allows for polyphonic music. It also uses the latest version of danigb's soundfont-player. Eventually purescript-soundfonts will be deprecated in favour of this library.

It again loads soundfonts taken from Benjamin Gleitzman's package of pre-rendered sound fonts. You may either load a single piano soundfont from a local server or else a set of soundfonts from Benjamin Gleitzman's github server. It then provides functions which allow you to play either an individual note or a sequence of notes.

The description of a MidiNote now contains an indication of the channel (i.e. the polyphonic voice) :

 type MidiNote =
   { channel :: Int           -- the MIDI channel
   . id  :: Int               -- the MIDI pitch number
   , timeOffset :: Number     -- the time delay in seconds before the note is played
   , duration :: Number       -- the duration of the note
   , gain :: Number           -- the volume (between 0 and 1)
   }

We specify a duration for the note which will allow you to play staccato sequences. however, each note 'rings' for 10% more than its alloted time which allows the option of a legato feel whilst still letting each note to be started accurately at tempo. Purescript-aff now incorporates a delay function and this can be used to pace the notes correctly.

Build

Node and npm installed is required. Then run:

 npm install
 npm run build

Example

To build an example that runs in the browser:

npm run build-example

and then navigate to /example/dist/index.html

purescript-polyphonic-soundfonts's People

Contributors

danigb avatar newlandsvalley avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

danigb

purescript-polyphonic-soundfonts's Issues

Add a function to set the duration that a note rings

Currently, notes are interpreted by players in a fairly strict legato style, A note sounds for its allotted duration and then tends to be immediately followed by the next note in the sequence. This sounds OK for some instruments but tends to sound very stilted, for example, with the grand piano. Things improved a little when I allowed notes to overlap by a tenth of the original duration. This approach should now be extended by adding a function

   setNoteRing :: forall eff. Int -> Eff (au :: AUDIO | eff) Unit

where the parameter is constrained to be a percentage of the original note duration. This allows the note to last for longer, playing alongside the next note in sequence, where 0 represents no ring at all and 100 rings for an extra whole note duration.

Migrate to Aff 4.0.0

Presumably this will need to be done, but not before Pux itself migrates (because most projects use both). Although the new Aff is an improvement, unfortunately it makes things slightly worse for soundfonts. I had been subverting Aff 3 so that, when requesting the fonts to be loaded, I could execute the callback multiple times (once for each resource loaded which happens in parallel in the original javascript). This plays nicely with Pux so that users could see the fonts arrive individually. This no longer seems possible with Aff 4.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.