Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Usage question #3

Open
jtrunick opened this issue Nov 16, 2018 · 5 comments
Open

Usage question #3

jtrunick opened this issue Nov 16, 2018 · 5 comments

Comments

@jtrunick
Copy link

I'm thinking of converting RTTTL (ring tone) to midi, and then when playing midi reflect current note in RTTTL. It looks like this code could work if i understand the translation.

Any plan to update to Elm .19?

@newlandsvalley
Copy link
Owner

Yes, this would work, I think, if you are able to choose a soundfont that represents the ring tone sound you're looking for.

I'm afraid I have no plans whatsoever to update any of my Elm code to 0.19. Unfortunately, I came up against a set of insurmountable barriers in Elm and I chose instead to rewrite everything in PureScript.

@jtrunick
Copy link
Author

jtrunick commented Nov 17, 2018

Curious what your barriers were, but more important how do you get a .js file from a soundfont file?

@newlandsvalley
Copy link
Owner

I'm not sure exactly what you mean. The soundfont files are themselves .js files - see for example https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/gh-pages/FluidR3_GM/acoustic_grand_piano-mp3.js. But what they really consist of is base64 encoded MP3 or OGG data expressed as JSON.

So what the module does is to decode this data and reconstitute images of the sound files which can then be played through web-audio. Under the covers it uses danigb's JS soundfont player to do all the heavy lifting.

@jtrunick
Copy link
Author

Oh I see. I had found a .sf2 file that definitely isn't .js format. Are soundfonts strictly needed to play midi files? Possibly for my purposes I don't care exactly on the exact sound. I could likely still use your code to convert from Elm -> js midi format.

@newlandsvalley
Copy link
Owner

Well, MIDI is just a definition of a bunch of notes and in order to 'play' MIDI, you need to use some sort of synth to produce actual sounds. Soundfonts are just one option. You could, for example, synthesize the sounds yourself using web-audio oscillators and filters and so on.

You could, if you wanted, use a library like elm-comidi to generate MIDI, but by itself, it won't play anything.

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

No branches or pull requests

2 participants