Forums

Looping ~50ms portion of an audio

Started by p_robi86 November 11, 2015
Hello,

I am writing an application in which I need to be able to move trough an
audio file based on where the user places the cursor, and if the user
holds the cursor on a given position, I need to  "freeze" the sound. 

In order to achieve this, I am looping 50ms of the audio from the position
of the cursor. However this generates some noise in the audio, because the
beginning and the end of the loop don't match.

1. An example of a "frozen sound" from the application:
https://clyp.it/a4q44hvw
2. The desired frozen sound: https://clyp.it/ic5bee2d
3. An example of going trough the song with variable speed:
https://clyp.it/gmpvmzgk

You can hear that audio 1 is quite annoying, and I would like to make the
sound smoother, change it to something similar to audio 2.

Audio 3 is how going trough the song currently works. There's quite a lot
of noise, etc. in the audio.

Are there any spectral filtering combinations I could use to make the
audio sound "better"?

Let me know if there are any more details that I can/should provide.

Thank you in advance!



---------------------------------------
Posted through http://www.DSPRelated.com
p_robi86 <110135@dsprelated> wrote:
 
> I am writing an application in which I need to be able to move trough an > audio file based on where the user places the cursor, and if the user > holds the cursor on a given position, I need to "freeze" the sound.
> In order to achieve this, I am looping 50ms of the audio from the position > of the cursor. However this generates some noise in the audio, because the > beginning and the end of the loop don't match.
For data input to FFT, it is usual to window the data such that there is no sharp transition from the end to the beginning. That transition for FFT has the same effect as for audio, large and unnatural frequency components. The usual window gradually brings each end to zero, where the actual window is chosen for each case. Seems to me that you could also smoothly transition each end toward a value half way between the first and last samples. If the exact number of samples in the loop is variable, choose points with similar values and slopes. That is, choose an end point where the next value is close to the first value, and the point before the first is close to the last value. -- glen
On Wednesday, November 11, 2015 at 8:41:15 AM UTC-5, p_robi86 wrote:
> Hello, > > I am writing an application in which I need to be able to move trough an > audio file based on where the user places the cursor, and if the user > holds the cursor on a given position, I need to "freeze" the sound. > > In order to achieve this, I am looping 50ms of the audio from the position > of the cursor. However this generates some noise in the audio, because the > beginning and the end of the loop don't match. > > 1. An example of a "frozen sound" from the application: > https://clyp.it/a4q44hvw > 2. The desired frozen sound: https://clyp.it/ic5bee2d > 3. An example of going trough the song with variable speed: > https://clyp.it/gmpvmzgk > > You can hear that audio 1 is quite annoying, and I would like to make the > sound smoother, change it to something similar to audio 2. > > Audio 3 is how going trough the song currently works. There's quite a lot > of noise, etc. in the audio. > > Are there any spectral filtering combinations I could use to make the > audio sound "better"? > > Let me know if there are any more details that I can/should provide. > > Thank you in advance! > > > > --------------------------------------- > Posted through http://www.DSPRelated.com
What is the purpose of looping on the 50 msec of audio? Dirk
This is a pretty standard thing to do, and most people use some combination of the following ;

1) search for a best-fit looping point where the amplitude and first derivative match within a certain tolerance. If you match higher derivatives, even better. 

2) apply a cross-fade window between the loop end and the loop start. 

If you have a strong low-frequency component you may need to use a longer time frame to find a good splice point. 

Most of these algorithms need some strategy for the case where you can't find a good splice point. Usually you just need to do the cross-fade at that point. 

I have also seen papers where people take advantage of the fact that the artifacts are periodic (if you don't adjust the loop size to find a good splice point) so you can use a sinc filter where the response nulls are aligned with 1/splice period. But I think those would sound pretty bad. 

If you want to get fancier there are frequency-domain techniques but I don't know them very well. 
Bob
bellda2005@gmail.com writes:

> On Wednesday, November 11, 2015 at 8:41:15 AM UTC-5, p_robi86 wrote: >> Hello, >> >> I am writing an application in which I need to be able to move trough an >> audio file based on where the user places the cursor, and if the user >> holds the cursor on a given position, I need to "freeze" the sound. >> >> In order to achieve this, I am looping 50ms of the audio from the position >> of the cursor. However this generates some noise in the audio, because the >> beginning and the end of the loop don't match. >> >> 1. An example of a "frozen sound" from the application: >> https://clyp.it/a4q44hvw >> 2. The desired frozen sound: https://clyp.it/ic5bee2d >> 3. An example of going trough the song with variable speed: >> https://clyp.it/gmpvmzgk >> >> You can hear that audio 1 is quite annoying, and I would like to make the >> sound smoother, change it to something similar to audio 2. >> >> Audio 3 is how going trough the song currently works. There's quite a lot >> of noise, etc. in the audio. >> >> Are there any spectral filtering combinations I could use to make the >> audio sound "better"? >> >> Let me know if there are any more details that I can/should provide. >> >> Thank you in advance! >> >> >> >> --------------------------------------- >> Posted through http://www.DSPRelated.com > > What is the purpose of looping on the 50 msec of audio?
Good question. 50 ms is awfully short for human review of audio. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On Wed, 11 Nov 2015 07:41:13 -0600, "p_robi86" <110135@DSPRelated>
wrote:

>Hello, > >I am writing an application in which I need to be able to move trough an >audio file based on where the user places the cursor, and if the user >holds the cursor on a given position, I need to "freeze" the sound. > >In order to achieve this, I am looping 50ms of the audio from the position >of the cursor. However this generates some noise in the audio, because the >beginning and the end of the loop don't match. > >1. An example of a "frozen sound" from the application: >https://clyp.it/a4q44hvw >2. The desired frozen sound: https://clyp.it/ic5bee2d >3. An example of going trough the song with variable speed: >https://clyp.it/gmpvmzgk > >You can hear that audio 1 is quite annoying, and I would like to make the >sound smoother, change it to something similar to audio 2. > >Audio 3 is how going trough the song currently works. There's quite a lot >of noise, etc. in the audio. > >Are there any spectral filtering combinations I could use to make the >audio sound "better"? > >Let me know if there are any more details that I can/should provide. > >Thank you in advance!
If you're still listening: It sounds like you're trying to slow playback of an audio stream. If so, search for "phase vocoder." They are used in musical instrument apps that do similar things. Musicians use a program called "Transcribe!" (written with the !) from SeventhString Systems. Easy to find. There's another called Amazing SlowDowner. If you only need to loop a short segment, the looping thing has been pursued forever by companies that make "Harmonizers." There are various ways of finding the splice points. But perhaps, given the short duration, you could just try a Short-Time Fourier Transform (STFT) at that point, get the output frequencies, and play those as individually looped sines. Not sure how well that would work, but it should at least avoid the abrasive glitches. Why not check back to let the group know how it's going.