Git Product home page Git Product logo

purescript-soundfonts's Introduction

purescript-soundfonts

Build Status

Latest release

This library allows you to play music directly in the browser using a variety of instruments. These are provided, courtesy of Benjamin Gleitzman's package of pre-rendered sound fonts. You can either load them remotely from the Gleitzman GitHub account or else host then locally on your own server. They load as dictionaries of AudioBuffers - one for each note on each selected instrument. Once loaded. you can play individual notes or groups of notes on your instruments of choice.

Also included is conversion to a Melody type which is suitable for use in a soundfont player widget.

The conversion of a Gleitzman note name (e.g. Ab4) to a MIDI pitch uses middle C = C4.

For more information, see the guide.

Acknowledgements

The design in very heavily influenced by danigb's JavaScript soundfont project: soundfont-player and in fact initial versions of this library simply wrapped his. However, this version minimises the amount of native JavaScript which is still necessary in order to wrap Web-Audio functions.

Installation

 bower install purescript-soundfonts

To build the example

 bower install
 npm run example  

Module documentation

Module documentation is published on Pursuit.

purescript-soundfonts's People

Contributors

i-am-the-slime avatar newlandsvalley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

i-am-the-slime

purescript-soundfonts's Issues

toMelody should allow the MIDI phrase length to be set

Audio.SoundFont.Melody.Maker toMelody has the signature:

   toMelody :: Midi.Recording -> Melody

with a preset phrase length for the Melody of 0.6s.

we should instead use

   toMelody :: Number -> Midi.Recording -> Melody

to allow the user to specify the phrase length. This influences the responsiveness of 'play' buttons in audio players, which can only interrupt the melody after each phrase has played.

Update to purs 0.13

And when we do this, resolve the conflict over which version of purescript-typelevel-prelude to use. It seems to me that this conflict is brought in by references to purescript-quickcheck from purescript-test-unit but I don't understand why this causes the problems it does at the moment.

Use midicube npm published module?

Hi @newlandsvalley,

I tried deploying chord-editor to jgart.whereis.xn--q9jyb4c for testing but the audio does not work because of the following errors:

Content Security Policy: The page’s settings blocked the loading of a resource at https://gleitz.github.io/midi-js-soundfonts/MusyngKite/acoustic_guitar_steel-ogg.js (“default-src”)

SourceHut Pages is blocking the downloading of external resources like the one specified on this line:

gleitzBaseUrl = "https://gleitz.github.io/midi-js-soundfonts/"

I found an issue regarding publishing midijs as an npm module. It sounds like midijs is abandonware but mscuthbert published a module on the npm registry.

What do you think of using mscuthbert's published module on npm instead of downloading the fonts off the internet?

or else host then locally on your own server.

The README mentions two possibilities for loading the soundfonts but a third possibility would be to be able to load them in the context of a service that does not grant you access to the server. If that service restricts downloading external resources then the user of purescript-soundfonts will not be able to use the library in that deployment environment as demonstrated with jgart.whereis.xn--q9jyb4c. I think that using npm to install the soundfonts would resolve this issue.

What do you think?

Implicitly support rests

You obviously can't play a rest, only a note. However, some clients would benefit by having the option to 'play' a rest as a no-op. This would allow them to emit both notes and rests that are generated from a score and have the final group of notes/rests paced properly.

This is easily achieved by using a MIDI pitch (note id) of less than or equal to zero to represent a rest. In which case, the playNote effect would simply return the duration of the unplayed note (instead of returning zero as an error indication as happens at present). In particular, this would benefit purescript-abc-melody.

Add playPhrase and playMelody to the MIDI module

playPhrase will be identical to playNotes except that it also invokes delay for the duration of the phrase. This allows an array of phrases to be paced properly. playMelody will thus simply traverse the array of phrases.

Decide which pitch to use for middle C

At the moment I use middle C = C5. However this seems to produce melodies an octave higher than I would expect. I think danigb used middle C = C4 - I should change to this to ensure compatibility. This is what danigb's JavaScript player used.

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.