Class: AudioGlue::SoxAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- AudioGlue::SoxAdapter
- Defined in:
- lib/audio_glue/sox_adapter.rb
Overview
Pretty small adapter based on the ruby-sox
library. Handles only local files ( snippet type = :file ).
Instance Method Summary collapse
-
#build(snippet_packet) ⇒ String
Write output to a temporary file, read data from it, and remove it.
Instance Method Details
#build(snippet_packet) ⇒ String
Write output to a temporary file, read data from it, and remove it.
14 15 16 17 18 19 20 21 22 |
# File 'lib/audio_glue/sox_adapter.rb', line 14 def build(snippet_packet) tmp_file = gen_tmp_filename(snippet_packet.format) write(snippet_packet, tmp_file) File.binread(tmp_file) rescue ::Sox::Error => err raise(::AudioGlue::BuildError, err.) ensure FileUtils.rm tmp_file if File.exists?(tmp_file) end |