From 963d0b4be91e1050ba947a9bbddd511f78321c54 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 25 Aug 2013 12:03:11 +0000 Subject: source/av: handle multiple audio streams w/ proper sample rate We need to tell sox to use and resample to the _player_ format instead of the source format. Otherwise 48000 Hz audio (common for video?) sounds very slow when attempting to play back on the default 44100 Hz. It is also likely preferable to choose the audio stream which matches the player channel count instead of letting sox automatically invoke the remix effect. Before this change, playing 6-channel, 48000 Hz source into a sink expecting stereo, 44100 Hz is rather disturbing... While we're at it, clarify the spawn code for the sox source, too. We can drop the test_format_from_file test now, since it's probably overkill at this point. --- test/test_source_av.rb | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'test/test_source_av.rb') diff --git a/test/test_source_av.rb b/test/test_source_av.rb index 2104b7e..4dba559 100644 --- a/test/test_source_av.rb +++ b/test/test_source_av.rb @@ -98,17 +98,4 @@ class TestSourceAv < Minitest::Unit::TestCase source = DTAS::Source::Av.new(tmp.path, '1') assert_equal 1000000.0, source.offset_us end - - def test_format_from_file - Tempfile.open(%w(tmp .wav)) do |tmp| - # generate an empty file with 1s of audio - cmd = %W(sox -r 96000 -b 24 -c 2 -n #{tmp.path} trim 0 1) - system(*cmd) - assert $?.success?, "#{cmd.inspect} failed: #$?" - fmt = DTAS::Source::Av.new(tmp.path).format - assert_equal 96000, fmt.rate - assert_equal 2, fmt.channels - tmp.unlink - end - end end -- cgit v1.2.3-24-ge0c7