[linux-audio-user] Pulling off old 2-track reels and trying to slow them down

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 24 Apr 2005, Alan Taylor wrote:

> On Sun, 2005-04-24 at 19:16 +0200, Wolfgang Woehl wrote:
> > Alsaplayer sounds crap in varispeed. I'd use Ardour for slowing things 
> > down as it uses libsamplerate for that purpose. In the Mixer strip, 
> 
> You are correct.  While the results are still not ideal (due to the
> original sample rate of 48KHz), the overall quality surpasses what I got
> out of alsaplayer.  Thanks.

Actually, for the real-time varispeed, ardour does *not* use
libsamplerate, but a handcrafted linear interpolation from Steve
Harris.  This is also unsuitable for high quality archival work.

If you can use ardour or alsaplayer to estimate the exact amount
of resampling you need, you can then use:

     sndfile-resample -by <amount_ratio> infile.wav  outfile.wav

to do a high quality resampling.  You'll want to use the inverse
of the varispeed you find to get the correct resampling.  The
resulting file will have a weird sample rate, but if played back
at the original sample rate of your capture will sound correct.

You can replace the samplerate field in the output wav file with
the attached python script.  Run it as follows (example assumes
a 48000 original capture):

   python wavsrmod.py 48000 outfile.wav

As mentioned by others, the higher capture rate you can achieve
the better quality you'll get, but depending on the source, 48k
might be good enough.  Hope this helps.

jlc
-------------- next part --------------
#!/usr/bin/env python

# overwrites the samplerate in a WAV file with a new value

import sys
from struct import *


def replace_samplerate(fname, samprate):
    n = open(fname, 'r+')
    head = n.read(44)

    e = unpack('<22shiihh8s', head)
    f = []
    f.extend(e)
    
    f[2] = samprate
    # ByteRate = SampleRate * NumChannels * BitsPerSample/8

    f[3] = f[2] * f[1] * f[5]/8
    head2 = pack('<22shiihh8s', f[0],f[1],f[2],f[3],f[4],f[5],f[6])

    n.seek(0)
    n.write(head2)
    n.close()


if len(sys.argv) > 1:
    # first arg is new samplerate
    newrate = int(sys.argv[1])

    # remaining args are filenames
    for fname in sys.argv[2:]:
        try:
            replace_samplerate(fname, newrate)
            print 'converted %s to %d' % (fname, newrate)
        except Exception,ex:
            print "Error converting %s: %s" % (fname, str(ex))




        
        

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux