Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Dec 2012 00:14:56 +1100 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        Polytropon <freebsd@edvax.de>
Cc:        Gary Aitken <ah@dreamchaser.org>, freebsd-questions@freebsd.org
Subject:   Re: audio playback with variable tempo
Message-ID:  <20121214233800.E52305@sola.nimnet.asn.au>
In-Reply-To: <mailman.65.1355486407.2798.freebsd-questions@freebsd.org>
References:  <mailman.65.1355486407.2798.freebsd-questions@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In freebsd-questions Digest, Vol 445, Issue 5, Message: 25
On Fri, 14 Dec 2012 09:52:53 +0100 Polytropon <freebsd@edvax.de> wrote:
 > On Thu, 13 Dec 2012 16:56:51 -0700, Gary Aitken wrote:
 > > On 12/12/12 23:51, Polytropon wrote:
 > > > On Wed, 12 Dec 2012 16:27:16 -0700, Gary Aitken wrote:
 > > >> Can anyone suggest an audio playback application that allows you to vary the
 > > >> tempo?  I've used audacity on win systems, but I don't see that in ports.
 > > > 
 > > > Except that audacity actually _is_ in ports, if you just
 > > > require "adjustable" speed (without editing / saving the
 > > > original file), you could use "mplayer -speed <n> <file>",
 > > > or use "mplayer <file>" and use the [ ] and { } keys to
 > > > adjust the speed (if you have OSD on, key 'o') you can
 > > > see the speed (if the file contains video; if not, the
 > > > output will be text only for information purposes).
 > > 
 > > Thanks.  
 > > Speed is not what I want to adjust, as it changes the pitch.
 > > The playback timing needs to be adjusted so everything has the same pitch,
 > > but just comes out faster or slower.
 > 
 > Oh, I see. No problem - Audacity can do that. (And as it has
 > been suggested, if you need to apply batch operation, you
 > can use sox, also in ports.)

sox(1) _can_ be daunting, but has this to say on the $subject:

      tempo [-q] factor [segment [search [overlap]]]
              Change the audio tempo  (but  not  its  pitch).   The  audio  is
              chopped  up  into  segments  which  are then shifted in the time
              domain and overlapped (cross-faded) at points where their  wave-
              forms  are  most similar (as determined by measurement of `least
              squares').

              By default, linear searches are used to find the  best  overlap-
              ping  points;  if  the  optional  -q  parameter  is  given, tree
              searches are used instead, giving a quicker, but possibly  lower
              quality, result.

              factor  gives  the  ratio of new tempo to the old tempo, so e.g.
              1.1 speeds up the tempo by 10%, and 0.9 slows it down by 10%.

              The optional segment parameter selects the  algorithm's  segment
              size  in milliseconds.  The default value is 82 and is typically
              suited to making small changes to the tempo of music; for larger
              changes  (e.g.  a  factor of 2), 50 ms may give a better result.
              When changing the tempo of speech,  a  segment  size  of  around
              30 ms often works well.

              The  optional  search  parameter  gives the audio length in mil-
              liseconds (default 14) over which the algorithm will search  for
              overlapping  points.  Larger values use more processing time and
              do not necessarily produce better results.

              The optional overlap parameter gives the segment overlap  length
              in milliseconds (default 12).

              See  also  speed  for  an  effect  that  changes tempo and pitch
              together, pitch for an  effect  that  changes  tempo  and  pitch
              together,  and  stretch for an effect that changes tempo using a
              different algorithm.

Works for me.  Audacity may do more, but explain less what it's doing?

 > > However, I'm a little confused on what all the devices are related to audio.
 > > 
 > > For the default device, which I've set to unit 3 (for pcm3), 
 > > I see the following in /dev:  dsp3.0 mixer3
 > > What are each of these associated with?
 > > The mixer itself shows the following devices:
 > >   vol, pcm, mix, rec, igain, ogain, monitor
 > > Can someone point me to documentation on what these are and how they interact?  
 > > It's not obvious to me what the difference between vol and ogain,
 > > or rec and igain, are, for example.  What is mix mixing, and what does 
 > > monitor do?  A schematic would be helpful...
 > 
 > If I remember correctly, monitor is a monitor channel for the
 > inputs, so this channel contains what will be recorded (even
 > though only one of its sources can be recorded at a time).
 > It lets you listen to the recording source.

Gary has a mix device too .. see below.

 > The manpage mentions several mixer devices:
 > 
 >      The list of mixer devices that may be modified are:
 > 
 >            vol, bass, treble, synth, pcm, speaker, line, mic, cd, mix, pcm2,
 >            rec, igain, ogain, line1, line2, line3, dig1, dig2, dig3, phin,
 >            phout, video, radio, and monitor.
 > 
 >      Not all mixer devices are available.
 > 
 > True, my sound card doesn't have all of them. :-)

:)  I was going to challenge you on your 'only one at a time', when I 
discovered the AC97 in my Thinkpad T23 doesn't let me record from 'mix' 
either, which surprised me as years earlier I'd sometimes record from 
mix, usually line + mic, on an ancient Compaq 1500c (Celeron 300MHz, 
made in '98, still running 24/7 as a solar-powered small-system mail, 
DNS and webserver plus firewall/NAT box - but I digress ..

smithi on sola% egrep 'pcm|sbc' /var/run/dmesg.boot
sbc0: <ESS ES1869 (Compaq OEM)> at port 0x330-0x331,0x388-0x38b,0x220-0x22f irq 5 drq 5,1 on isa0
pcm0: <ESS 18xx DSP> on sbc0

smithi on sola% mixer recsrc
Recording source: mic
smithi on sola% mixer =rec mix
Recording source: mix
smithi on sola% mixer -h
mixer: illegal option -- h
usage: mixer [-f device] [-s] [dev [+|-][voll[:[+|-]volr]] ...
       mixer [-f device] [-s] recsrc ...
       mixer [-f device] [-s] {^|+|-|=}rec rdev ...
 devices: vol, synth, pcm, speaker, line, mic, cd, line1
 rec devices: line, mic, cd, mix
smithi on sola% mixer -s
vol 100:100 synth 0:0 pcm 92:92 speaker 0:0 line 0:0 mic 0:0 cd 0:0 line1 0:0 =rec mix

 > > For device /dev/dsp4, there is a dsp4.0 and dsp4.1, 
 > > which I thought would be the separate left and right channels;
 > > but I only see a dsp3.0, not a dsp3.1, and there is definitely stereo sound.
 > > pcm3 is an analog device, and pcm4 is digital; 
 > > does that have anything to do with it?
 > 
 > That would probably be documented in the actual sound driver's
 > documentation, as pcm and mixer are interfaces to the driver
 > functionality (FreeBSD kernel mixer <-> hardware driver).
 > 
 > Because of use the source Luke, I found "use igain for the mic
 > 20dB boost" in /usr/src/sys/dev/sound/pcm/ac97.c. Maybe there
 > are more hints to what the mixer devices actually do in the
 > source tree. I also assume the functionality depends on what
 > the hardware implements in reality, which may differ from
 > device to device.

Thanks, I've always wondered what igain and ogain were about.

cheers, Ian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121214233800.E52305>