(export! content opts)
Takes edna content and exports it, returning the value of :out. The opts map can contain:
:type - :midi, :wav, or :mp3 (required)
:out - A java.io.OutputStream or java.io.File object
(optional, defaults to a ByteArrayOutputStream)
:soundbank - A javax.sound.midi.Soundbank object, or nil to use the JVM's built-in one
(optional, defaults to a soundbank included in this library)
:format - A javax.sound.sampled.AudioFormat object
(optional, defaults to one with 44100 Hz)
Note: If you want to use the sound font installed on your system, rather than the one
built into edna, include `:soundbank nil` in your opts map.
Source
(defn export!
"Takes edna content and exports it, returning the value of :out. The opts map can contain:
:type - :midi, :wav, or :mp3 (required)
:out - A java.io.OutputStream or java.io.File object
(optional, defaults to a ByteArrayOutputStream)
:soundbank - A javax.sound.midi.Soundbank object, or nil to use the JVM's built-in one
(optional, defaults to a soundbank included in this library)
:format - A javax.sound.sampled.AudioFormat object
(optional, defaults to one with 44100 Hz)
Note: If you want to use the sound font installed on your system, rather than the one
built into edna, include `:soundbank nil` in your opts map."
[content opts]
(binding [midi/*midi-synth* (midi/new-midi-synth false)
sound/*use-midi-sequencer* true
sound/*play-opts* {:async? false
:one-off? true}]
(export!* content
(-> opts
(update :out #(or % (java.io.ByteArrayOutputStream.)))
(update :soundbank #(if (contains? opts :soundbank) % @default-soundbank))
(update :format #(or % (AudioFormat. 44100 16 2 true false)))))))