[LAU] loop speeding in sample level accuracy

Jari Suominen jari.suominen at helsinki.fi
Thu Sep 18 16:17:57 EDT 2008


I'm working on a simple java applet that will allow you to play an organ 
on your keyboard (or mouse). As organ has many registers and on the 
other hand Java isn't that good on audio apps (but better than Flash) 
I'm building a simple automixer to web server side that is basically a 
short php script that uses SoX. This way I don't have forty samples 
playing (or givin hellish noise) when user is playing some random chord. 
For that I need bunch of looping audio samples for each key that SoX can 
mix together (by combination chosen by the user) and send to browser. 
And resulting sample should still loop without klitches.

If I could choose tools myself, I would simply use Fluidsynth as it 
works in these kinds of application right away, but it isn't my call. My 
client wants a app that somewhat works on any computer online without 
installing any software.

..j


Dan Richert kirjoitti:
> I'm curious as to what your end goal is for this.  If you're trying to 
> get all the samples to play back in loops of the same length, you might 
> want to consider using SuperCollider (or similar), create a bunch of 
> buffers, load your samples and then scale your playback speed so the 
> loops are all the same length.
> 
> Jari Suominen wrote:
>> Yep, assuming that calculation of the ratio makes sense from the 
>> algorithm point of view. Might or might not.
>>
>> ..j
>>
>> Dan Richert kirjoitti:
>>   
>>> I think you'd always end up with +/- a couple samples unless $size and 
>>> $new_size divide evenly.  But I don't know much about the guts of the 
>>> sample speeding/slowing algorithm either.
>>>
>>>   
>>> Jari Suominen wrote:
>>>     
>>>> Thanks Dan!
>>>>
>>>> I will give it a try. I actually really need the length of the resulting 
>>>> audio file to be exactly what desired but as I'm not doing that hazard 
>>>> shifts this might work. And perhaps running same file through the script 
>>>> more than once would give the result I'm aiming at.
>>>>
>>>> More theoretical question is, are speed shifting algoritms actually 
>>>> using the ratio given to them or converting them to some other value 
>>>> before doing the conversion. And is the sample accurate 'speeding' even 
>>>> possible in reality, or is it always +/- couple samples. I tried to look 
>>>> at the SoX source but it was a bit too C:ish for me to give me an answer 
>>>> straight away.
>>>>
>>>> ......j
>>>>
>>>>
>>>>
>>>> Dan Richert kirjoitti:
>>>>   
>>>>       
>>>>> SoX can do the job with some help.  Here's a little Perl script to 
>>>>> figure out the speed scaling ratio based on the desired new length in 
>>>>> samples:
>>>>>
>>>>> #!/usr/bin/perl
>>>>>
>>>>> if(@ARGV != 3){ die "Usage: resize-audio.pl <in_file> <new_size> 
>>>>> <out_file>\n"; }
>>>>> ($in_file,$new_size,$out_file) = @ARGV;
>>>>> $size = `sox $in_file -n stat 2>&1 |grep ^Samples |awk '{print \$3}'`;
>>>>> $ratio = $size / $new_size;
>>>>> print "$ratio\n";
>>>>> `sox $in_file $out_file speed $ratio`;
>>>>>
>>>>>
>>>>>
>>>>> In the couple tests I ran, it doesn't get to the *exact* new size 
>>>>> specified in samples, but pretty close -- I converted a file 12486 
>>>>> samples long  to 3000 samples and ended up with a file with 3002 samples.
>>>>>
>>>>>
>>>>>
>>>>> Jari Suominen wrote:
>>>>>     
>>>>>         
>>>>>> Tiago Tavares kirjoitti:
>>>>>>   
>>>>>>       
>>>>>>           
>>>>>>> Can SoX do the job?
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>> Nope. Speed shift takes in prosent or cents.
>>>>>>
>>>>>> ....j
>>>>>>
>>>>>>   
>>>>>>       
>>>>>>           
>>>>>>> On Thu, Sep 18, 2008 at 1:51 PM, Jari Suominen <jari.suominen at helsinki.fi>wrote:
>>>>>>>
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I'm trying to search a program (with no success) that could used for
>>>>>>>> speeding up an audio file to a certain length. I mean, I would have a
>>>>>>>> audio file that has 40000 samples, and I would need it to be 40010. And
>>>>>>>> the pitch of the file can/should change. All speed change stuff that I
>>>>>>>> have found will take semitones/cents/procents as a input parameter. I
>>>>>>>> would wan't to only input the exact length (in samples) that I need.
>>>>>>>>
>>>>>>>> My purpose is basically make bunch of files that are loopable and have
>>>>>>>> equal length with each other.
>>>>>>>>
>>>>>>>> Does this thing exist or do I have to make it myself?
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> ..j
>>>>>>>> _______________________________________________
>>>>>>>> Linux-audio-user mailing list
>>>>>>>> Linux-audio-user at lists.linuxaudio.org
>>>>>>>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>>>>>>>
>>>>>>>>       
>>>>>>>>           
>>>>>>>>               
>>>>>>>     
>>>>>>>         
>>>>>>>             
>>>>>> _______________________________________________
>>>>>> Linux-audio-user mailing list
>>>>>> Linux-audio-user at lists.linuxaudio.org
>>>>>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>>>>>   
>>>>>>       
>>>>>>           
>>>>> _______________________________________________
>>>>> Linux-audio-user mailing list
>>>>> Linux-audio-user at lists.linuxaudio.org
>>>>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>>>>
>>>>>     
>>>>>         
>>>> _______________________________________________
>>>> Linux-audio-user mailing list
>>>> Linux-audio-user at lists.linuxaudio.org
>>>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>>>   
>>>>       
>>> _______________________________________________
>>> Linux-audio-user mailing list
>>> Linux-audio-user at lists.linuxaudio.org
>>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>>
>>>     
>> _______________________________________________
>> Linux-audio-user mailing list
>> Linux-audio-user at lists.linuxaudio.org
>> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
>>   
> 
> _______________________________________________
> Linux-audio-user mailing list
> Linux-audio-user at lists.linuxaudio.org
> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user
> 




More information about the Linux-audio-user mailing list