abc2svg icon indicating copy to clipboard operation
abc2svg copied to clipboard

Playing audio in node-js

Open GitterHubber opened this issue 5 years ago • 4 comments

I see that the audio playing has 2 interfaces

Audio5 - uses Web Audio Midi5 - uses Web MIDI

I don't think these interfaces would work outside a browser environment eg. when running via node-js, or would they?

Is there a way to get audio playing to work when running abc2svg via node-js in a console?

GitterHubber avatar Oct 14 '19 14:10 GitterHubber

The audio playing engine has just been changed today (as you may know, the source is in chisel under fossil). The new engine generates the play data directly in the tree representation of the music after SVG generation. The new scripts 'sndaud.js' and 'sndmid.js' could be reworked for running via nodejs or quickjs, and output either MIDI or sound (wav?) files, or directly play sound samples or MIDI events via the system interface.

moinejf avatar Oct 14 '19 15:10 moinejf

The audio playing engine has just been changed today (as you may know, the source is in chisel under fossil).

This is amazing! Wasn't aware that you are still actively extending and updating this repository. Many thanks for this wonderful piece of software!

GitterHubber avatar Oct 14 '19 17:10 GitterHubber

I see that in

play-1.js you have exposed a function ToAudio for nodejs

// nodejs
if (typeof module == 'object' && typeof exports == 'object')
	exports.ToAudio = ToAudio

however I don't see a similar line in snd-1.js is this by design?

Infact I'm unable to access even AbcPlay() function via the snd-1.js file in nodejs. Is there any other way to access these functions or are these functions kept hidden by choice?

GitterHubber avatar Oct 17 '19 19:10 GitterHubber

Sorry: with the new play engine, I was in the browser and I forgot the CLI. I added the module exports in play.js and sndgen.js. Anyway, you will have to write a play-1/snd-1 like script to output the sound to file/system.

moinejf avatar Oct 18 '19 14:10 moinejf