<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,5 +12,14 @@ module DSP
     def stddev
       Math.sqrt(variance)
     end
+    def cmux(r)
+      smaller, larger = self.size &lt; r.size ? [self, r.dup] : [r.dup, self]
+      pad_amount = (larger.size - smaller.size) / 2
+      pad_amount.times do
+        smaller.unshift nil
+        smaller &lt;&lt; nil
+      end
+      larger.zip(smaller)
+    end
   end
 end</diff>
      <filename>lib/dsp/signal.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,4 +14,36 @@ class TestSignal &lt; Test::Unit::TestCase
       assert_in_delta 3.16227766016838, DSP::Signal.new([1, 2, 3, 4, 5]).stddev, 0.001
     end
   end
+
+  context &quot;cmuxing&quot; do
+    setup do
+      @left = DSP::Signal.new([1, 2, 3, 4, 5])
+      @right = DSP::Signal.new([2, 3, 4])
+    end
+
+    should &quot;not modify the signals&quot; do
+      @left.cmux(@right)
+      assert_equal [2, 3, 4], @right
+    end
+    
+    should &quot;mux signals of the same size&quot; do
+      assert_equal [[2, 2], [3, 3], [4, 4]], @right.cmux(@right)
+    end
+
+    should &quot;mux a smaller signal&quot; do
+      assert_equal [[1, nil], [2, 2], [3, 3], [4, 4], [5, nil]], @left.cmux(@right)
+    end
+
+    should &quot;mux a larger signal&quot; do
+      assert_equal [[1, nil], [2, 2], [3, 3], [4, 4], [5, nil]], @right.cmux(@left)
+    end
+
+    should &quot;mux a smaller signal with odd size&quot; do
+      assert_equal [[2, 1], [3, 2], [4, nil]], @right.cmux([1, 2])
+    end
+
+    should &quot;mux a larger signal with odd size&quot; do
+      assert_equal [[1, 2], [2, 3], [3, 4], [4, nil]], @right.cmux([1, 2, 3, 4])
+    end
+  end
 end</diff>
      <filename>test/test_signal.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>42ae2e328c0559e507335a108293783631799a92</id>
    </parent>
  </parents>
  <author>
    <name>Scott Barron</name>
    <email>scott@elitists.net</email>
  </author>
  <url>http://github.com/rubyist/dsp/commit/0857a0ed5245cef8d314a60ab62cf79d2e600883</url>
  <id>0857a0ed5245cef8d314a60ab62cf79d2e600883</id>
  <committed-date>2009-01-22T10:06:03-08:00</committed-date>
  <authored-date>2009-01-22T10:06:03-08:00</authored-date>
  <message>add Signal#cmux</message>
  <tree>47d4757a61e61b5e7b4a455b959d01ad34929fac</tree>
  <committer>
    <name>Scott Barron</name>
    <email>scott@elitists.net</email>
  </committer>
</commit>
