about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dtas/format.rb11
-rw-r--r--lib/dtas/splitfx.rb27
2 files changed, 37 insertions, 1 deletions
diff --git a/lib/dtas/format.rb b/lib/dtas/format.rb
index 690a21f..e9da16f 100644
--- a/lib/dtas/format.rb
+++ b/lib/dtas/format.rb
@@ -59,6 +59,16 @@ class DTAS::Format # :nodoc:
     end
   end
 
+  # returns 1 or 0 depending on endianess
+  def endian_opusenc
+    case e = @endian || NATIVE_ENDIAN
+    when "big" then "1"
+    when "little" then "0"
+    else
+      raise"unsupported endian=#{e}"
+    end
+  end
+
   def to_eca_arg
     %W(-f #{@type}_#{endian2},#@channels,#@rate)
   end
@@ -92,6 +102,7 @@ class DTAS::Format # :nodoc:
       "SOXFMT" => to_sox_arg.join(' '),
       "ECAFMT" => to_eca_arg.join(' '),
       "ENDIAN2" => endian2,
+      "ENDIAN_OPUSENC" => endian_opusenc,
     }
     begin # don't set these if we can't get them, SOX_FILETYPE may be enough
       rv["BITS_PER_SAMPLE"] = bits_per_sample.to_s
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index aa1665d..f7f8c39 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -42,7 +42,32 @@ class DTAS::SplitFX # :nodoc:
     @track_zpad = true
     @t2s = method(:t2s)
     @infile = nil
-    @targets = {}
+    @targets = {
+      "flac-cdda" => {
+        "command" => CMD,
+        "format" => {
+          "bits" => 16,
+          "rate" => 44100,
+          "type" => "flac",
+          "channels" => 2,
+        },
+      },
+      "opus" => {
+        "command" => 'sox "$INFILE" $COMMENTS $OUTFMT - ' \
+           '$TRIMFX $RATEFX $DITHERFX | opusenc --music ' \
+           '--raw-bits $BITS_PER_SAMPLE ' \
+           '$OPUSENC_BITRATE --raw-rate $RATE --raw-chan $CHANNELS ' \
+           '--raw-endianness $ENDIAN_OPUSENC ' \
+           '$OPUSENC_COMMENTS ' \
+           '- $TRACKNUMBER.opus',
+        "format" => {
+          "bits" => 16,
+          "rate" => 48000,
+          "type" => "s16",
+          "channels" => 2,
+        },
+      },
+    }
     @tracks = []
     @infmt = nil # wait until input is assigned
   end