New P2 (?) "Reverse does not reverse clip boundaries"

33 messages Options
Embed this post
Permalink
1 2
Gale (Audacity Team)

New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink

I "assume" this to be a bug rather than a feature. You lose the
association between the clip boundaries and the original audio
when you  reverse it, and actually lose audio if the clips were
separated by white space.

To reproduce:

1 Generate 30 seconds chirp at 0.8 amplitude
2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
     drag to 20 seconds
3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
    visible
4  Click in Track Panel to select all the track and Effect > Reverse    
5  White space converted to silence at other end of track but original
      white space left in situ, which removes two five-second chunks of
      the original audio including the amplified part
6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
7  Double-click the first two silences in turn and generate DTMF in them
      to make them visible
8  Select whole track and Effect > Repeat  
9  Note you lost all your clip lines but now have them where you don't
     want them

Added to Checklist for now as P2.
 



Gale


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Martyn Shaw-2

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink


[hidden email] wrote:

> I "assume" this to be a bug rather than a feature. You lose the
> association between the clip boundaries and the original audio
> when you  reverse it, and actually lose audio if the clips were
> separated by white space.
>
> To reproduce:
>
> 1 Generate 30 seconds chirp at 0.8 amplitude
> 2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
>      drag to 20 seconds
> 3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
>     visible
> 4  Click in Track Panel to select all the track and Effect > Reverse    
> 5  White space converted to silence at other end of track but original
>       white space left in situ, which removes two five-second chunks of
>       the original audio including the amplified part

Stop there.  This is a bug report.  The rest is not needed.  Verified.

Presumably the re-insertion of silence that I think somebody put in
recently does not work the right way around.

Martyn

> 6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
> 7  Double-click the first two silences in turn and generate DTMF in them
>       to make them visible
> 8  Select whole track and Effect > Repeat  
> 9  Note you lost all your clip lines but now have them where you don't
>      want them
>
> Added to Checklist for now as P2.
>  
>
>
>
> Gale
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> audacity-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-devel
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Gale (Audacity Team)

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink

| From Martyn Shaw <[hidden email]>
| Sun, 06 Sep 2009 00:11:04 +0100
| Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip boundaries"

> [hidden email] wrote:
> > I "assume" this to be a bug rather than a feature. You lose the
> > association between the clip boundaries and the original audio
> > when you  reverse it, and actually lose audio if the clips were
> > separated by white space.
> >
> > To reproduce:
> >
> > 1 Generate 30 seconds chirp at 0.8 amplitude
> > 2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
> >      drag to 20 seconds
> > 3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
> >     visible
> > 4  Click in Track Panel to select all the track and Effect > Reverse    
> > 5  White space converted to silence at other end of track but original
> >       white space left in situ, which removes two five-second chunks of
> >       the original audio including the amplified part
>
> Stop there.  This is a bug report.  The rest is not needed.

Strongly disagree. It might be needed. We've had several instances
recently of bugs being only partially fixed, so we should make sure
the fix cures both problems, IMO. Of course I say that without
knowledge of the code, but I'd far rather be safe than sorry. That's
why I gave both scenarios. We're aiming for a "Stable" release.    


> Presumably the re-insertion of silence that I think somebody put in
> recently does not work the right way around.

Unlikely, I think, because both sets of symptoms can be found in
1.3.5.




Gale



> > 6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
> > 7  Double-click the first two silences in turn and generate DTMF in them
> >       to make them visible
> > 8  Select whole track and Effect > Repeat  
> > 9  Note you lost all your clip lines but now have them where you don't
> >      want them
>
>
> >
> > Added to Checklist for now as P2.
> >  
> >
> >
> >
> > Gale





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi
 
I am currently writing a patch for this. Most of the work is done. I wanted to discuss the patch in a bit of detail so that any mistakes can be corrected before finalizing and submitting the patch.
 
The overall approach is: reverse each clip individually and then rearrange them.
 
For this to work, all the clips to be reversed must completely be in the reverse selection region. However, there may be cases when a portion of the clip lies out of the selected region. In this case, I have split the clip at the appropriate time (the start and/or end of the selected region). Of course, they will have to be merged in the end.
 
Once all the clips to be reversed are in the selected region, I go through all the clips in the track one by one.
1) If the clip is before the selected region, nothing is done.
2) If the clip is after the selected region, it is temporarily detached from the track and moved to a WaveClipList (say the name of the list is otherClips).
3) If the clip is in the selected region, it is reversed. It is then detached from the track and the appropriate offset value is set. (The offset values cannot be applied in situ as the clips may overlap and cause loss of audio). The detached clip is then moved to another WaveClipList (say revClips).
 
Finally I move all the clips in revClips and otherClips back to the track.
 
For detaching and reinserting the clips, I have added two new functions to the WaveTrack class. I hope this is ok. (Currently, there is a longer way to insert a clip to the wave track. I can create a new clip in the track and copy one clip to the other. But I thought the amount of computation is unnecessary). If there is already a function which does these tasks that I have overlooked, please tell me.
 
I have a few more things to finalize like the progress dialog, merging at the end etc.

I have tested this on a few sample tracks including those described in the bug report. They are working fine. Of course, this amount of testing is definitely not enough. I will do it more thoroughly once I finalize the patch.

Any corrections or improvements...?

Thanks

Vidyashankar
 
On 9/6/09, Gale Andrews <[hidden email]> wrote:

| From Martyn Shaw <[hidden email]>
| Sun, 06 Sep 2009 00:11:04 +0100
| Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip   boundaries"
> [hidden email] wrote:
> > I "assume" this to be a bug rather than a feature. You lose the
> > association between the clip boundaries and the original audio
> > when you  reverse it, and actually lose audio if the clips were
> > separated by white space.
> >
> > To reproduce:
> >
> > 1 Generate 30 seconds chirp at 0.8 amplitude
> > 2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
> >      drag to 20 seconds
> > 3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
> >     visible
> > 4  Click in Track Panel to select all the track and Effect > Reverse
> > 5  White space converted to silence at other end of track but original
> >       white space left in situ, which removes two five-second chunks of
> >       the original audio including the amplified part
>
> Stop there.  This is a bug report.  The rest is not needed.

Strongly disagree. It might be needed. We've had several instances
recently of bugs being only partially fixed, so we should make sure
the fix cures both problems, IMO. Of course I say that without
knowledge of the code, but I'd far rather be safe than sorry. That's
why I gave both scenarios. We're aiming for a "Stable" release.


> Presumably the re-insertion of silence that I think somebody put in
> recently does not work the right way around.

Unlikely, I think, because both sets of symptoms can be found in
1.3.5.




Gale



> > 6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
> > 7  Double-click the first two silences in turn and generate DTMF in them
> >       to make them visible
> > 8  Select whole track and Effect > Repeat
> > 9  Note you lost all your clip lines but now have them where you don't
> >      want them
>
>
> >
> > Added to Checklist for now as P2.
> >
> >
> >
> >
> > Gale





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
If the track begins with a whitespace, and is part of the selected region to be reversed, should the whitespace go to the other end after reversing?

On Wed, Sep 23, 2009 at 7:51 PM, Vidyashankar Vellal <vidyashankar.mv@gmail.com> wrote:
Hi
 
I am currently writing a patch for this. Most of the work is done. I wanted to discuss the patch in a bit of detail so that any mistakes can be corrected before finalizing and submitting the patch.
 
The overall approach is: reverse each clip individually and then rearrange them.
 
For this to work, all the clips to be reversed must completely be in the reverse selection region. However, there may be cases when a portion of the clip lies out of the selected region. In this case, I have split the clip at the appropriate time (the start and/or end of the selected region). Of course, they will have to be merged in the end.
 
Once all the clips to be reversed are in the selected region, I go through all the clips in the track one by one.
1) If the clip is before the selected region, nothing is done.
2) If the clip is after the selected region, it is temporarily detached from the track and moved to a WaveClipList (say the name of the list is otherClips).
3) If the clip is in the selected region, it is reversed. It is then detached from the track and the appropriate offset value is set. (The offset values cannot be applied in situ as the clips may overlap and cause loss of audio). The detached clip is then moved to another WaveClipList (say revClips).
 
Finally I move all the clips in revClips and otherClips back to the track.
 
For detaching and reinserting the clips, I have added two new functions to the WaveTrack class. I hope this is ok. (Currently, there is a longer way to insert a clip to the wave track. I can create a new clip in the track and copy one clip to the other. But I thought the amount of computation is unnecessary). If there is already a function which does these tasks that I have overlooked, please tell me.
 
I have a few more things to finalize like the progress dialog, merging at the end etc.

I have tested this on a few sample tracks including those described in the bug report. They are working fine. Of course, this amount of testing is definitely not enough. I will do it more thoroughly once I finalize the patch.

Any corrections or improvements...?

Thanks

Vidyashankar
 
On 9/6/09, Gale Andrews <[hidden email]> wrote:

| From Martyn Shaw <[hidden email]>
| Sun, 06 Sep 2009 00:11:04 +0100
| Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip   boundaries"
> [hidden email] wrote:
> > I "assume" this to be a bug rather than a feature. You lose the
> > association between the clip boundaries and the original audio
> > when you  reverse it, and actually lose audio if the clips were
> > separated by white space.
> >
> > To reproduce:
> >
> > 1 Generate 30 seconds chirp at 0.8 amplitude
> > 2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
> >      drag to 20 seconds
> > 3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
> >     visible
> > 4  Click in Track Panel to select all the track and Effect > Reverse
> > 5  White space converted to silence at other end of track but original
> >       white space left in situ, which removes two five-second chunks of
> >       the original audio including the amplified part
>
> Stop there.  This is a bug report.  The rest is not needed.

Strongly disagree. It might be needed. We've had several instances
recently of bugs being only partially fixed, so we should make sure
the fix cures both problems, IMO. Of course I say that without
knowledge of the code, but I'd far rather be safe than sorry. That's
why I gave both scenarios. We're aiming for a "Stable" release.


> Presumably the re-insertion of silence that I think somebody put in
> recently does not work the right way around.

Unlikely, I think, because both sets of symptoms can be found in
1.3.5.




Gale



> > 6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
> > 7  Double-click the first two silences in turn and generate DTMF in them
> >       to make them visible
> > 8  Select whole track and Effect > Repeat
> > 9  Note you lost all your clip lines but now have them where you don't
> >      want them
>
>
> >
> > Added to Checklist for now as P2.
> >
> >
> >
> >
> > Gale





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Ed Musgrove

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Personally, as a user, if I make a selection which includes a leading or trailing white space then issue a command, I expect that command to be performed on the whitespace as well as any other data. If I select a region that includes a leading white space followed by some audible data then tell Audacity to "Cut" I expect the whitespace and the audible data to disappear from the track and be in the paste buffer. On that same selection, if I say Reverse I expect the whitespace to become a trailing whitespace.
 
I understand that in some cases this might not make a lot of sense but that is the user's fault. If the result of the command would be trailing whitespace at the end of a track or would add whitespace to a whitespace, possibly Audacity could pop up a request for the user to confirm his or her desire.

-Ed Musgrove

--- On Sun, 9/27/09, Vidyashankar Vellal <[hidden email]> wrote:
If the track begins with a whitespace, and is part of the selected region to be reversed, should the whitespace go to the other end after reversing?


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Gale (Audacity Team)

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
In reply to this post by Vidyashankar Vellal

| From Vidyashankar Vellal <[hidden email]>
| Sun, 27 Sep 2009 19:16:08 +0530
| Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip boundaries"
> If the track begins with a whitespace, and is part of the selected region to
> be reversed, should the whitespace go to the other end after reversing?

Hi Vidyashankar

I would say yes, the white space should go to the other end of the
selection region, so time zero then starts with audio. It seems
analogous with moving the white space to fix the loss of audio
in the bug case:
http://n2.nabble.com/New-P2-Reverse-does-not-reverse-clip-boundaries-tp3578383p3578383.html



Gale


 

> On Wed, Sep 23, 2009 at 7:51 PM, Vidyashankar Vellal <vidyashankar.mv@
> gmail.com> wrote:
>
> > Hi
> >
> > I am currently writing a patch for this. Most of the work is done. I wanted
> > to discuss the patch in a bit of detail so that any mistakes can be
> > corrected before finalizing and submitting the patch.
> >
> > The overall approach is: reverse each clip individually and then rearrange
> > them.
> >
> > For this to work, all the clips to be reversed must completely be in the
> > reverse selection region. However, there may be cases when a portion of the
> > clip lies out of the selected region. In this case, I have split the clip at
> > the appropriate time (the start and/or end of the selected region). Of
> > course, they will have to be merged in the end.
> >
> > Once all the clips to be reversed are in the selected region, I go through
> > all the clips in the track one by one.
> > 1) If the clip is before the selected region, nothing is done.
> > 2) If the clip is after the selected region, it is temporarily detached
> > from the track and moved to a WaveClipList (say the name of the list is
> > otherClips).
> > 3) If the clip is in the selected region, it is reversed. It is then
> > detached from the track and the appropriate offset value is set. (The offset
> > values cannot be applied in situ as the clips may overlap and cause loss of
> > audio). The detached clip is then moved to another WaveClipList (say
> > revClips).
> >
> > Finally I move all the clips in revClips and otherClips back to the track.
> >
> > For detaching and reinserting the clips, I have added two new functions to
> > the WaveTrack class. I hope this is ok. (Currently, there is a longer way to
> > insert a clip to the wave track. I can create a new clip in the track and
> > copy one clip to the other. But I thought the amount of computation is
> > unnecessary). If there is already a function which does these tasks that I
> > have overlooked, please tell me.
> >
> > I have a few more things to finalize like the progress dialog, merging at
> > the end etc.
> >
> > I have tested this on a few sample tracks including those described in the
> > bug report. They are working fine. Of course, this amount of testing is
> > definitely not enough. I will do it more thoroughly once I finalize the
> > patch.
> >
> > Any corrections or improvements...?
> >
> > Thanks
> >
> > Vidyashankar
> >
> > On 9/6/09, Gale Andrews <[hidden email]> wrote:
> >>
> >>
> >> | From Martyn Shaw <[hidden email]>
> >> | Sun, 06 Sep 2009 00:11:04 +0100
> >> | Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip
> >> boundaries"
> >> > [hidden email] wrote:
> >> > > I "assume" this to be a bug rather than a feature. You lose the
> >> > > association between the clip boundaries and the original audio
> >> > > when you  reverse it, and actually lose audio if the clips were
> >> > > separated by white space.
> >> > >
> >> > > To reproduce:
> >> > >
> >> > > 1 Generate 30 seconds chirp at 0.8 amplitude
> >> > > 2 Split at 5 seconds and drag to 10 seconds; split at 15 seconds and
> >> > >      drag to 20 seconds
> >> > > 3 Select 32 - 33 seconds and amplify by default 1.9 dB to make it
> >> > >     visible
> >> > > 4  Click in Track Panel to select all the track and Effect > Reverse
> >> > > 5  White space converted to silence at other end of track but original
> >> > >       white space left in situ, which removes two five-second chunks
> >> of
> >> > >       the original audio including the amplified part
> >> >
> >> > Stop there.  This is a bug report.  The rest is not needed.
> >>
> >> Strongly disagree. It might be needed. We've had several instances
> >> recently of bugs being only partially fixed, so we should make sure
> >> the fix cures both problems, IMO. Of course I say that without
> >> knowledge of the code, but I'd far rather be safe than sorry. That's
> >> why I gave both scenarios. We're aiming for a "Stable" release.
> >>
> >>
> >> > Presumably the re-insertion of silence that I think somebody put in
> >> > recently does not work the right way around.
> >>
> >> Unlikely, I think, because both sets of symptoms can be found in
> >> 1.3.5.
> >>
> >>
> >>
> >>
> >> Gale
> >>
> >>
> >>
> >> > > 6  Edit  > Undo and Effect > Change Speed (say 10%) to add clip lines
> >> > > 7  Double-click the first two silences in turn and generate DTMF in
> >> them
> >> > >       to make them visible
> >> > > 8  Select whole track and Effect > Repeat
> >> > > 9  Note you lost all your clip lines but now have them where you don't
> >> > >      want them
> >> >
> >> >
> >> > >
> >> > > Added to Checklist for now as P2.
> >> > >
> >> > >
> >> > >
> >> > >
> >> > > Gale
> >>
> >>
> >>



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Richard Ash (audacity-help)

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
In reply to this post by Vidyashankar Vellal
On Sun, 2009-09-27 at 19:16 +0530, Vidyashankar Vellal wrote:
> If the track begins with a whitespace, and is part of the selected
> region to be reversed, should the whitespace go to the other end after
> reversing?

Yes, this would seem logical. So reverse may have to split a clip into
two pieces if the selection contains only part of a clip.

Richard




------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hello

This mail is quite long. If you don't have the time now, you can probably read it later.

I was just testing my reverse patch and saw some peculiar behavior. Wanted to confirm if this is normal.
It is regarding the number of clips and their start and end times when certain effects are applied. In order to know the exact start and end times of the clips, I have modified the existing Reverse.cpp file slightly. Instead of reversing the clip, Effect->Reverse will simply output the number of clips in a track and then output the start and end times of the clips in separate message boxes. You can make a backup of the existing Reverse.cpp and use the file I have attached. I have described certain steps below. After each step, to see the number of clips and their start and end times, just do Effect->Reverse.

I know the method I have followed is very crude, but please bear with me for now. I wanted to concentrate more on the problem (if at all it exists).

Case1:

1) Generate chirp, 30 sec, 0.8 amplitude (default)
2) Split at 5 seconds and drag to 10 sec. Split at 15 sec and drag to 20.

Now (I didnt move it exactly to 10 and 20 sec), there are 3 clips in the track (as expected) with their start and end times as follows:
Clip1: 0 to 5 sec
Clip2: 10.080635 to 15 sec
Clip3: 20.053764 to 40.134399 sec

3) Apply Effect -> Change Speed by 10%

The whitespaces are converted to silence. Now, I thought there should be 5 clips. But there are 7 clips.
Clip1: 0 to 4.545 sec (I have truncated time to 3 decimal places)
Clip2: 4.545 to 9.164 sec
Clip3: 9.164 to 13.636 sec
Clip4: 13.636 to 18.230 sec
Clip5: 18.230 to 36.485828 sec
Clip6: 36.485828 to 36.485850 sec
Clip7: 36.485850 to 36.485850 sec

Look at clip6 and clip7. They are so tiny. In fact clip7 has the same start and end times. Is this normal?


4) Double-click on the second silence to select it and generate DTMF tones inside (say "hello").

Now the silence is replaced by the DTMF tone. I thought the number of clips must remain the same. But the number goes up to 10!
Clip1 is same
Clip2: 4.545465 to 4.594331 sec
Clip3: 4.594331 to 9.164218 sec
Clip4: 4.594331 to 4.594331 sec
Clip5: 9.164218 to 13.636372 sec
Clip6: 13.636 to 18.230703
Clip7: 18.230703 to 18.230703
Clip8: 18.230703 to 36.485828
Clip9: 36.485828 to 36.485850
Clip10: 36.485850 to 36.485850

The DTMF was created between 13.6 and 18.2 sec. Why was an extra clip created between 4.5 and 4.6 sec?
In this case, the extra clip is clip2. Also, look at clip4. It has the same start and end times. I strongly doubt if this is normal. Generating DTMF in one part of the track is affecting other parts!

Anyway, at this point my reverse patch does not behave properly. In fact, this is why I started looking at the clips in detail. I have tested other situations with many clips in the track. Even when clips are next to each other, the patch is working properly.
(I deliberately did not include the patch in this as I wanted to be sure that the patch is not causing the problem.)

Now on to the next case

Case2:

1) Generate chirp for 60 seconds
2) Select 5 to 10 sec and do Edit->Split Delete. Do the same for 40 to 50 sec.

Now there are 3 clips as expected. 0 to 5 sec, 10 to 40 sec and 50 to 60 sec.

3) Select the whole track (double click in the silence) and do effect->Change speed by 100%. 

Now there are 5 clips as expected. (Note that change speed did not add any extra clips unlike in the first case).
Clip1: 0 to 2.5 sec
Clip2: 2.5 to 5 sec
Clip3: 5 to 20 sec
Clip4: 20 to 25 sec
Clip5: 25 to 30 sec

4) Double click on the first silence and generate DTMF ("hello")

Now there are 6 clips.Clip 1 and 2 are same as before.

Clip3: 5 sec to 5.000023 sec
Clip4: 5.000023 to 20.000023 sec
Clip5: 20.000023 to 25.000023 sec
Clip6: 25.000023 to 30.000023 sec

This DTMF generation resulted in one extra clip (Clip3 in this case which is very small). The DTMF generation in the previous case resulted in three extra clips.

If I double click the other silence and generate a DTMF there, the total number of clips goes to 7. Again an extra clip of very small duration (25.000023 to 25.000045 sec) is created.

Why this discrepancy in the number of clips created? Changing speed (10%) in the first case resulted in extra clips. Changing speed (100%) in the second case had no extra clips. When creating DTMF, in the first case there were 3 extra clips. In the second case 1 extra clip.

When I select a clip with silence, and generate a DTMF there, the silence should be replaced by DTMF tones. Why are extra clips being created? Is this ok?

Can somebody confirm this behavior for me? If it is confirmed, I think it is a bug. We can then start looking deeper.

Thanks for your patience

Vidyashankar

On Tue, Sep 29, 2009 at 2:41 AM, Richard Ash <[hidden email]> wrote:
On Sun, 2009-09-27 at 19:16 +0530, Vidyashankar Vellal wrote:
> If the track begins with a whitespace, and is part of the selected
> region to be reversed, should the whitespace go to the other end after
> reversing?

Yes, this would seem logical. So reverse may have to split a clip into
two pieces if the selection contains only part of a clip.

Richard




------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel

Reverse.cpp (7K) Download Attachment
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hello

I finally completed the testing of my reverse patch. I am sorry I took
such a long time.

I did the testing on Win XP and Ubuntu 9.04. I tested projects with
both single and multiple tracks. Duration ranging from 30 sec to 1
hour. Except for the cases mentioned in the previous post, it seemed
to work well. (To be more specific, the reverse patch will not work
when there are clips with the same start and end times. Logically, I
think such clips should not exist).

Shall I assume that the behaviour mentioned in the previous post is a
separate bug and submit the actual reverse patch now? Or should I
submit it after those issues have been resolved?

Thanks

Vidyashankar

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi

I have attached a patch for the Reverse effect. I have tested it on Ubuntu 9.04 and Win XP. Worked in all the cases I tried.

I modified the code to also consider clips of zero length. These zero-length clips are added to the track during Change Speed, Generate DTMF and even certain Nyquist effects (if I remember correctly). I still feel such clips should not exist. Anyway, that's for another thread.

This is also the first time I have added so much code to audacity. I have done testing well. But there might be a chance I have overlooked something. If so, please tell me and I will correct it.

For a description of the patch, see my previous post: http://n2.nabble.com/New-P2-Reverse-does-not-reverse-clip-boundaries-tp3578383p3699940.html

Thanks

Vidyashankar

[Reverse_1.patch]

? Reverse_1.patch
Index: src/WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.169
diff -u -r1.169 WaveTrack.cpp
--- src/WaveTrack.cpp 11 Oct 2009 14:55:47 -0000 1.169
+++ src/WaveTrack.cpp 16 Oct 2009 08:45:26 -0000
@@ -686,6 +686,21 @@
    return HandleClear(t0, t1, addCutLines, split);
 }
 
+WaveClip* WaveTrack::RemoveAndReturnClip(WaveClip* clip)
+{
+   wxWaveClipListNode* node = mClips.Find(clip);
+   WaveClip* clipReturn = node->GetData();
+   mClips.DeleteNode(node);
+   return clipReturn;
+}
+
+void WaveTrack::AddClip(WaveClip* clip)
+{
+   // Uncomment the following line after we correct the problem of zero-length clips
+   //if (CanInsertClip(clip))
+      mClips.Append(clip);
+}
+
 bool WaveTrack::HandleGroupClear(double t0, double t1, bool addCutLines, bool split, TrackList* tracks)
 {
    // get tracks
Index: src/WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.76
diff -u -r1.76 WaveTrack.h
--- src/WaveTrack.h 11 Oct 2009 14:55:47 -0000 1.76
+++ src/WaveTrack.h 16 Oct 2009 08:46:33 -0000
@@ -306,6 +306,12 @@
    void MoveClipToTrack(int clipIndex, WaveTrack* dest);
    void MoveClipToTrack(WaveClip *clip, WaveTrack* dest);
   
+   // Remove the clip from the track and return a pointer to it.
+   WaveClip* RemoveAndReturnClip(WaveClip* clip);
+  
+   // Append a clip to the track if it does not overlap with existing clips.
+   void AddClip(WaveClip* clip);
+  
    // Merge two clips, that is append data from clip2 to clip1,
    // then remove clip2 from track.
    // clipidx1 and clipidx2 are indices into the clip list.
Index: src/effects/Reverse.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.cpp,v
retrieving revision 1.19
diff -u -r1.19 Reverse.cpp
--- src/effects/Reverse.cpp 8 Jul 2009 15:39:44 -0000 1.19
+++ src/effects/Reverse.cpp 16 Oct 2009 08:57:17 -0000
@@ -47,8 +47,13 @@
          WaveTrack *track = (WaveTrack*)t;
          double trackStart = track->GetStartTime();
          double trackEnd = track->GetEndTime();
-         double t0 = mT0 < trackStart? trackStart: mT0;
-         double t1 = mT1 > trackEnd? trackEnd: mT1;
+        
+         // Since leading and trailing whitespaces should also be considered for reversal
+         // t0 and t1 must always be equal to mT0 and mT1
+         //double t0 = mT0 < trackStart? trackStart: mT0;
+         double t0 = mT0;
+         //double t1 = mT1 > trackEnd? trackEnd: mT1;
+         double t1 = mT1;
 
          if (track->GetSelected()) {
             if (t1 > t0) {
@@ -56,7 +61,7 @@
                sampleCount end = track->TimeToLongSamples(t1);
                sampleCount len = (sampleCount)(end - start);
 
-               if (!ProcessOne(count, track, start, len))
+               if (!ProcessOneWave(count, track, start, len))
                {
                   bGoodResult = false;
                   break;
@@ -104,8 +109,183 @@
    return bGoodResult;
 }
 
-bool EffectReverse::ProcessOne(int count, WaveTrack *track,
-                               sampleCount start, sampleCount len)
+bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount start, sampleCount len)
+{
+   bool rValue = true; // return value
+  
+   // set to true later if the reverse selection
+   // begins or ends at the inside of a clip. 'inside' refers to any position other than clip start and end
+   bool startMerge = false;
+   bool endMerge = false;
+
+   sampleCount end = (sampleCount) start + len; // start, end, len refer to the selected reverse region
+
+   // STEP 1:
+   // If a reverse selection begins and/or ends at the inside of a clip
+   // perform a split at the start and/or end of the reverse selection
+   WaveClipList::compatibility_iterator clipIterator = track->GetClipIterator();
+   wxWaveClipListNode *node = (wxWaveClipListNode*)clipIterator;
+   while (node) {
+      WaveClip *clip = node->GetData();
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+      if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip
+         startMerge = true;
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart >= start && clipStart < end && clipEnd > end) { // the reverse selection ends at the inside of a clip
+         endMerge = true;
+         double splitTime = track->LongSamplesToTime(end);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart < start && clipEnd > end) { // the selection begins AND ends at the inside of a clip
+         startMerge = true;
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+         splitTime = track->LongSamplesToTime(end);
+         endMerge = true;
+         track->SplitAt(splitTime);
+      }
+      node = node->GetNext();
+   }
+
+   //STEP 2:
+   // Individually reverse each clip inside the selected region
+   // and apply the appropriate offset after detaching them from the track.
+
+   bool checkedFirstClip = false;
+  
+   // Used in calculating the offset of clips to rearrange
+   // Holds the new end position of the current clip
+   sampleCount currentEnd = (sampleCount)end;
+  
+   WaveClipList revClips; // holds the reversed clips
+   WaveClipList otherClips; // holds the clips that appear after the reverse selection region
+  
+   WaveClipArray clipArray;
+   track->FillSortedClipArray(clipArray);
+   size_t i;
+   for (i=0; i < clipArray.Count(); i++) {
+      
+      WaveClip *clip = clipArray.Item(i);
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+      WaveClipList *cutList = clip->GetCutLines();
+      
+      if (clipStart >= start && clipEnd <= end) { // if the clip is inside the selected region
+        
+         // this is used to check if the selected region begins with a whitespace.
+         // if yes then clipStart (of the first clip) and start are not the same.
+         // adjust currentEnd accordingly and set endMerge to false
+         if(checkedFirstClip == false && clipStart > start) {
+            checkedFirstClip = true;
+            if(i > 0) {
+               if (clipArray.Item(i-1)->GetEndSample() <= start) {
+                  endMerge = false;
+                  currentEnd -= (clipStart - start);
+               }
+            }
+            else {
+               endMerge = false;
+               currentEnd -= (clipStart - start);
+            }
+         }
+        
+         // this is used to check if the selected region ends with a whitespace.
+         // if yes then clipEnd (of the last clip) and end are not the same.
+         // set startMerge to false
+         if(clipEnd < end) {
+            if(i == clipArray.Count()-1) {
+               startMerge = false;
+            }
+            else if(clipArray.Item(i+1)->GetStartSample() >= end) {
+               startMerge = false;
+            }
+         }
+        
+         sampleCount revStart = (clipStart >= start)? clipStart: start;
+         sampleCount revEnd = (clipEnd >= end)? end: clipEnd;
+         sampleCount revLen = (sampleCount)revEnd-revStart;
+         if (revEnd >= revStart) {
+            if(!ProcessOneClip(count, track, revStart, revLen, start, end)) // reverse the clip
+            {
+               rValue = false;
+               break;
+            }
+
+            sampleCount clipOffsetStart = (sampleCount)(currentEnd - (clipEnd-clipStart)); // calculate the offset required
+            double offsetStartTime = track->LongSamplesToTime(clipOffsetStart);
+            if(i+1 < clipArray.Count()) // update currentEnd if there is a clip to process next
+            {
+               sampleCount nextClipStart = clipArray.Item(i+1)->GetStartSample();
+               currentEnd = (sampleCount)(currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd));
+            }
+
+            clip = track->RemoveAndReturnClip(clip); // detach the clip from track
+            clip->SetOffset(track->LongSamplesToTime(track->TimeToLongSamples(offsetStartTime))); // align time to a sample and set offset
+            revClips.Append(clip);
+            
+         }
+      }
+      else if (clipStart >= end) { // clip is after the selection region
+         clip = track->RemoveAndReturnClip(clip); // simply remove and append to otherClips
+         otherClips.Append(clip);
+      }
+   }
+  
+   // STEP 3: Append the clips from
+   // revClips and otherClips back to the track
+   size_t revClipsCount = revClips.GetCount();
+   for (i = 0; i < revClipsCount; i++) {
+      wxWaveClipListNode *node = revClips.Item(revClipsCount - 1 - i); // the last clip of revClips is appended to the track first
+      WaveClip *clip = node->GetData();
+      track->AddClip(clip);
+   }
+
+   for (i = 0; i < otherClips.GetCount(); i++) {
+      wxWaveClipListNode *node = otherClips.Item(i);
+      track->AddClip(node->GetData());
+   }
+
+   // STEP 4: Merge the clips at the start/end
+   // of reverse selection if required
+   int startClipId = -1, prevStartClipId = -1; // id's of clips to be merged at the start and end
+   int endClipId = -1, nextEndClipId = -1;
+  
+   if(startMerge == true || endMerge == true) {
+      track->FillSortedClipArray(clipArray);
+      size_t i;
+      for(i = 0; i < clipArray.GetCount(); i++) {
+         WaveClip *clip = clipArray.Item(i);
+         if(clip->GetStartSample() == start && i > 0) {
+            WaveClip *prevClip = clipArray.Item(i-1);
+            startClipId = track->GetClipIndex(clip);
+            prevStartClipId = track->GetClipIndex(prevClip);
+         }
+         if(clip->GetEndSample() == end && (i < clipArray.GetCount() - 1)) {
+            WaveClip *nextClip = clipArray.Item(i+1);
+            endClipId = track->GetClipIndex(clip);
+            nextEndClipId = track->GetClipIndex(nextClip);
+         }
+      }
+   }
+  
+   if(startMerge == true && startClipId != -1 && prevStartClipId != -1) {
+      track->MergeClips(prevStartClipId, startClipId);
+      endClipId--;
+      nextEndClipId--;
+   }
+   if(endMerge == true && endClipId != -1 && nextEndClipId != -1) {
+      track->MergeClips(endClipId, nextEndClipId);
+   }
+
+   return rValue;
+}
+
+bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
+                               sampleCount start, sampleCount len,
+                               sampleCount originalStart, sampleCount originalEnd)
 {
    bool rc = true;
    // keep track of two blocks whose data we will swap
@@ -117,7 +297,7 @@
    float *buffer1 = new float[blockSize];
    float *buffer2 = new float[blockSize];
   
-   sampleCount originalLen = len;
+   sampleCount originalLen = (sampleCount)originalEnd-originalStart;
 
    while (len > 1) {
       sampleCount block = track->GetBestBlockSize(first);
@@ -138,7 +318,7 @@
       len -= 2 * block;
       first += block;
       
-      if( TrackProgress(count, 2*(first-start) / (double) originalLen) ) {
+      if( TrackProgress(count, 2*(first-originalStart) / (double) originalLen) ) {
          rc = false;
          break;
       }
Index: src/effects/Reverse.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.h,v
retrieving revision 1.9
diff -u -r1.9 Reverse.h
--- src/effects/Reverse.h 12 Jul 2008 15:25:47 -0000 1.9
+++ src/effects/Reverse.h 16 Oct 2009 08:48:30 -0000
@@ -47,8 +47,9 @@
    virtual bool Process();
 
  private:
-   bool ProcessOne(int count, WaveTrack * track,
-                   sampleCount start, sampleCount len);
+   bool ProcessOneClip(int count, WaveTrack* track,
+                   sampleCount start, sampleCount len, sampleCount originalStart, sampleCount originalEnd);
+   bool ProcessOneWave(int count, WaveTrack* track, sampleCount start, sampleCount len);
 
  };
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Al Dimond

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
On Friday 16 October 2009 03:26:57 Vidyashankar Vellal wrote:

> Hi
>
> I have attached a patch for the Reverse effect. I have tested it on Ubuntu
> 9.04 and Win XP. Worked in all the cases I tried.
>
> I modified the code to also consider clips of zero length. These
>  zero-length clips are added to the track during Change Speed, Generate
>  DTMF and even certain Nyquist effects (if I remember correctly). I still
>  feel such clips should not exist. Anyway, that's for another thread.
>
> This is also the first time I have added so much code to audacity. I have
> done testing well. But there might be a chance I have overlooked something.
> If so, please tell me and I will correct it.
>
> For a description of the patch, see my previous post:
> http://n2.nabble.com/New-P2-Reverse-does-not-reverse-clip-boundaries-tp3578
> 383p3699940.html
>

It works perfectly for me, in my wacky test project with tons of clips.

> Thanks
>
> Vidyashankar
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Thanks for testing it out, Al.

2009/10/16 Al Dimond <[hidden email]>
On Friday 16 October 2009 03:26:57 Vidyashankar Vellal wrote:
> Hi
>
> I have attached a patch for the Reverse effect. I have tested it on Ubuntu
> 9.04 and Win XP. Worked in all the cases I tried.
>
> I modified the code to also consider clips of zero length. These
>  zero-length clips are added to the track during Change Speed, Generate
>  DTMF and even certain Nyquist effects (if I remember correctly). I still
>  feel such clips should not exist. Anyway, that's for another thread.
>
> This is also the first time I have added so much code to audacity. I have
> done testing well. But there might be a chance I have overlooked something.
> If so, please tell me and I will correct it.
>
> For a description of the patch, see my previous post:
> http://n2.nabble.com/New-P2-Reverse-does-not-reverse-clip-boundaries-tp3578
> 383p3699940.html
>

It works perfectly for me, in my wacky test project with tons of clips.

> Thanks
>
> Vidyashankar
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Martyn Shaw-2

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi Vidyashankar

Does the patch still work with the latest HEAD?  I have not tried it
or looked at the code, but would like to see the bug cleared.  I may
have a little time this week.

Thanks for your efforts!

TTFN
Martyn

Vidyashankar Vellal wrote:

> Thanks for testing it out, Al.
>
> 2009/10/16 Al Dimond <[hidden email]
> <mailto:[hidden email]>>
>
>     On Friday 16 October 2009 03:26:57 Vidyashankar Vellal wrote:
>      > Hi
>      >
>      > I have attached a patch for the Reverse effect. I have tested it
>     on Ubuntu
>      > 9.04 and Win XP. Worked in all the cases I tried.
>      >
>      > I modified the code to also consider clips of zero length. These
>      >  zero-length clips are added to the track during Change Speed,
>     Generate
>      >  DTMF and even certain Nyquist effects (if I remember correctly).
>     I still
>      >  feel such clips should not exist. Anyway, that's for another thread.
>      >
>      > This is also the first time I have added so much code to
>     audacity. I have
>      > done testing well. But there might be a chance I have overlooked
>     something.
>      > If so, please tell me and I will correct it.
>      >
>      > For a description of the patch, see my previous post:
>      >
>     http://n2.nabble.com/New-P2-Reverse-does-not-reverse-clip-boundaries-tp3578
>      > 383p3699940.html
>      >
>
>     It works perfectly for me, in my wacky test project with tons of clips.
>
>      > Thanks
>      >
>      > Vidyashankar
>      >
>
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> audacity-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-devel

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi Martyn

Just to be sure, I remade the patch against the latest HEAD. The patch is attached.

Vidyashankar

On Mon, Oct 19, 2009 at 4:48 AM, Martyn Shaw <[hidden email]> wrote:
Hi Vidyashankar

Does the patch still work with the latest HEAD?  I have not tried it
or looked at the code, but would like to see the bug cleared.  I may
have a little time this week.

Thanks for your efforts!

TTFN
Martyn

[Reverse_2.patch]

? Reverse_2.patch
Index: src/WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.170
diff -u -r1.170 WaveTrack.cpp
--- src/WaveTrack.cpp 18 Oct 2009 19:58:17 -0000 1.170
+++ src/WaveTrack.cpp 19 Oct 2009 03:57:26 -0000
@@ -708,6 +708,21 @@
    return HandleClear(t0, t1, addCutLines, split);
 }
 
+WaveClip* WaveTrack::RemoveAndReturnClip(WaveClip* clip)
+{
+   wxWaveClipListNode* node = mClips.Find(clip);
+   WaveClip* clipReturn = node->GetData();
+   mClips.DeleteNode(node);
+   return clipReturn;
+}
+
+void WaveTrack::AddClip(WaveClip* clip)
+{
+   // Uncomment the following line after we correct the problem of zero-length clips
+   //if (CanInsertClip(clip))
+      mClips.Append(clip);
+}
+
 bool WaveTrack::HandleGroupClear(double t0, double t1, bool addCutLines, bool split, TrackList* tracks)
 {
    // get tracks
Index: src/WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.76
diff -u -r1.76 WaveTrack.h
--- src/WaveTrack.h 11 Oct 2009 14:55:47 -0000 1.76
+++ src/WaveTrack.h 19 Oct 2009 03:57:21 -0000
@@ -306,6 +306,12 @@
    void MoveClipToTrack(int clipIndex, WaveTrack* dest);
    void MoveClipToTrack(WaveClip *clip, WaveTrack* dest);
   
+   // Remove the clip from the track and return a pointer to it.
+   WaveClip* RemoveAndReturnClip(WaveClip* clip);
+  
+   // Append a clip to the track
+   void AddClip(WaveClip* clip);
+  
    // Merge two clips, that is append data from clip2 to clip1,
    // then remove clip2 from track.
    // clipidx1 and clipidx2 are indices into the clip list.
Index: src/effects/Reverse.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.cpp,v
retrieving revision 1.19
diff -u -r1.19 Reverse.cpp
--- src/effects/Reverse.cpp 8 Jul 2009 15:39:44 -0000 1.19
+++ src/effects/Reverse.cpp 19 Oct 2009 03:58:44 -0000
@@ -47,8 +47,13 @@
          WaveTrack *track = (WaveTrack*)t;
          double trackStart = track->GetStartTime();
          double trackEnd = track->GetEndTime();
-         double t0 = mT0 < trackStart? trackStart: mT0;
-         double t1 = mT1 > trackEnd? trackEnd: mT1;
+        
+         // Since leading and trailing whitespaces should also be considered for reversal
+         // t0 and t1 must always be equal to mT0 and mT1
+         //double t0 = mT0 < trackStart? trackStart: mT0;
+         double t0 = mT0;
+         //double t1 = mT1 > trackEnd? trackEnd: mT1;
+         double t1 = mT1;
 
          if (track->GetSelected()) {
             if (t1 > t0) {
@@ -56,7 +61,7 @@
                sampleCount end = track->TimeToLongSamples(t1);
                sampleCount len = (sampleCount)(end - start);
 
-               if (!ProcessOne(count, track, start, len))
+               if (!ProcessOneWave(count, track, start, len))
                {
                   bGoodResult = false;
                   break;
@@ -104,8 +109,183 @@
    return bGoodResult;
 }
 
-bool EffectReverse::ProcessOne(int count, WaveTrack *track,
-                               sampleCount start, sampleCount len)
+bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount start, sampleCount len)
+{
+   bool rValue = true; // return value
+  
+   // set to true later if the reverse selection
+   // begins or ends at the inside of a clip. 'inside' refers to any position other than clip start and end
+   bool startMerge = false;
+   bool endMerge = false;
+
+   sampleCount end = (sampleCount) start + len; // start, end, len refer to the selected reverse region
+
+   // STEP 1:
+   // If a reverse selection begins and/or ends at the inside of a clip
+   // perform a split at the start and/or end of the reverse selection
+   WaveClipList::compatibility_iterator clipIterator = track->GetClipIterator();
+   wxWaveClipListNode *node = (wxWaveClipListNode*)clipIterator;
+   while (node) {
+      WaveClip *clip = node->GetData();
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+      if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip
+         startMerge = true;
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart >= start && clipStart < end && clipEnd > end) { // the reverse selection ends at the inside of a clip
+         endMerge = true;
+         double splitTime = track->LongSamplesToTime(end);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart < start && clipEnd > end) { // the selection begins AND ends at the inside of a clip
+         startMerge = true;
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+         splitTime = track->LongSamplesToTime(end);
+         endMerge = true;
+         track->SplitAt(splitTime);
+      }
+      node = node->GetNext();
+   }
+
+   //STEP 2:
+   // Individually reverse each clip inside the selected region
+   // and apply the appropriate offset after detaching them from the track.
+
+   bool checkedFirstClip = false;
+  
+   // Used in calculating the offset of clips to rearrange
+   // Holds the new end position of the current clip
+   sampleCount currentEnd = (sampleCount)end;
+  
+   WaveClipList revClips; // holds the reversed clips
+   WaveClipList otherClips; // holds the clips that appear after the reverse selection region
+  
+   WaveClipArray clipArray;
+   track->FillSortedClipArray(clipArray);
+   size_t i;
+   for (i=0; i < clipArray.Count(); i++) {
+      
+      WaveClip *clip = clipArray.Item(i);
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+      WaveClipList *cutList = clip->GetCutLines();
+      
+      if (clipStart >= start && clipEnd <= end) { // if the clip is inside the selected region
+        
+         // this is used to check if the selected region begins with a whitespace.
+         // if yes then clipStart (of the first clip) and start are not the same.
+         // adjust currentEnd accordingly and set endMerge to false
+         if(checkedFirstClip == false && clipStart > start) {
+            checkedFirstClip = true;
+            if(i > 0) {
+               if (clipArray.Item(i-1)->GetEndSample() <= start) {
+                  endMerge = false;
+                  currentEnd -= (clipStart - start);
+               }
+            }
+            else {
+               endMerge = false;
+               currentEnd -= (clipStart - start);
+            }
+         }
+        
+         // this is used to check if the selected region ends with a whitespace.
+         // if yes then clipEnd (of the last clip) and end are not the same.
+         // set startMerge to false
+         if(clipEnd < end) {
+            if(i == clipArray.Count()-1) {
+               startMerge = false;
+            }
+            else if(clipArray.Item(i+1)->GetStartSample() >= end) {
+               startMerge = false;
+            }
+         }
+        
+         sampleCount revStart = (clipStart >= start)? clipStart: start;
+         sampleCount revEnd = (clipEnd >= end)? end: clipEnd;
+         sampleCount revLen = (sampleCount)revEnd-revStart;
+         if (revEnd >= revStart) {
+            if(!ProcessOneClip(count, track, revStart, revLen, start, end)) // reverse the clip
+            {
+               rValue = false;
+               break;
+            }
+
+            sampleCount clipOffsetStart = (sampleCount)(currentEnd - (clipEnd-clipStart)); // calculate the offset required
+            double offsetStartTime = track->LongSamplesToTime(clipOffsetStart);
+            if(i+1 < clipArray.Count()) // update currentEnd if there is a clip to process next
+            {
+               sampleCount nextClipStart = clipArray.Item(i+1)->GetStartSample();
+               currentEnd = (sampleCount)(currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd));
+            }
+
+            clip = track->RemoveAndReturnClip(clip); // detach the clip from track
+            clip->SetOffset(track->LongSamplesToTime(track->TimeToLongSamples(offsetStartTime))); // align time to a sample and set offset
+            revClips.Append(clip);
+            
+         }
+      }
+      else if (clipStart >= end) { // clip is after the selection region
+         clip = track->RemoveAndReturnClip(clip); // simply remove and append to otherClips
+         otherClips.Append(clip);
+      }
+   }
+  
+   // STEP 3: Append the clips from
+   // revClips and otherClips back to the track
+   size_t revClipsCount = revClips.GetCount();
+   for (i = 0; i < revClipsCount; i++) {
+      wxWaveClipListNode *node = revClips.Item(revClipsCount - 1 - i); // the last clip of revClips is appended to the track first
+      WaveClip *clip = node->GetData();
+      track->AddClip(clip);
+   }
+
+   for (i = 0; i < otherClips.GetCount(); i++) {
+      wxWaveClipListNode *node = otherClips.Item(i);
+      track->AddClip(node->GetData());
+   }
+
+   // STEP 4: Merge the clips at the start/end
+   // of reverse selection if required
+   int startClipId = -1, prevStartClipId = -1; // id's of clips to be merged at the start and end
+   int endClipId = -1, nextEndClipId = -1;
+  
+   if(startMerge == true || endMerge == true) {
+      track->FillSortedClipArray(clipArray);
+      size_t i;
+      for(i = 0; i < clipArray.GetCount(); i++) {
+         WaveClip *clip = clipArray.Item(i);
+         if(clip->GetStartSample() == start && i > 0) {
+            WaveClip *prevClip = clipArray.Item(i-1);
+            startClipId = track->GetClipIndex(clip);
+            prevStartClipId = track->GetClipIndex(prevClip);
+         }
+         if(clip->GetEndSample() == end && (i < clipArray.GetCount() - 1)) {
+            WaveClip *nextClip = clipArray.Item(i+1);
+            endClipId = track->GetClipIndex(clip);
+            nextEndClipId = track->GetClipIndex(nextClip);
+         }
+      }
+   }
+  
+   if(startMerge == true && startClipId != -1 && prevStartClipId != -1) {
+      track->MergeClips(prevStartClipId, startClipId);
+      endClipId--;
+      nextEndClipId--;
+   }
+   if(endMerge == true && endClipId != -1 && nextEndClipId != -1) {
+      track->MergeClips(endClipId, nextEndClipId);
+   }
+
+   return rValue;
+}
+
+bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
+                               sampleCount start, sampleCount len,
+                               sampleCount originalStart, sampleCount originalEnd)
 {
    bool rc = true;
    // keep track of two blocks whose data we will swap
@@ -117,7 +297,7 @@
    float *buffer1 = new float[blockSize];
    float *buffer2 = new float[blockSize];
   
-   sampleCount originalLen = len;
+   sampleCount originalLen = (sampleCount)originalEnd-originalStart;
 
    while (len > 1) {
       sampleCount block = track->GetBestBlockSize(first);
@@ -138,7 +318,7 @@
       len -= 2 * block;
       first += block;
       
-      if( TrackProgress(count, 2*(first-start) / (double) originalLen) ) {
+      if( TrackProgress(count, 2*(first-originalStart) / (double) originalLen) ) {
          rc = false;
          break;
       }
Index: src/effects/Reverse.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.h,v
retrieving revision 1.9
diff -u -r1.9 Reverse.h
--- src/effects/Reverse.h 12 Jul 2008 15:25:47 -0000 1.9
+++ src/effects/Reverse.h 19 Oct 2009 03:58:46 -0000
@@ -47,9 +47,9 @@
    virtual bool Process();
 
  private:
-   bool ProcessOne(int count, WaveTrack * track,
-                   sampleCount start, sampleCount len);
-
+   bool ProcessOneClip(int count, WaveTrack* track,
+                   sampleCount start, sampleCount len, sampleCount originalStart, sampleCount originalEnd);
+   bool ProcessOneWave(int count, WaveTrack* track, sampleCount start, sampleCount len);
  };
 
 #endif


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Gale (Audacity Team)

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink

| From Vidyashankar Vellal <[hidden email]>
| Mon, 19 Oct 2009 09:39:41 +0530
| Subject: [Audacity-devel] New P2 (?) "Reverse does not reverse clip boundaries"
> Hi Martyn
>
> Just to be sure, I remade the patch against the latest HEAD. The patch is
> attached.
>
> Vidyashankar

Hi Vidyashankar

Thanks for the new patch against CVS HEAD. I have played around on
Win XP obviously trying the two bug scenarios, plus trying multiple
tracks, making selections in parts of clips and parts of white space
and so on. It seems to work really well to me, just on observation.
Thanks!
 
Now, I'm really not sure about this because I don't fully understand
why some effects add (expected) split lines and some don't. Namely
I would expect timeline changing effects (Change Speed/Tempo/Pitch
and - possibly - Repeat) to add them at region borders when selecting
across split lines in a track, and they do so. But I don't understand why
EQ does.

Anyway, when I draw a region across split lines and reverse the
region, should the borders of the region now have split lines? I think
probably yes, for consistency.  

I tried with reverse with labels. Labels fully encompassed by a region
move when reversing without the label track selected, as I would expect.
Labels not fully encompassed don't. I think that's probably reasonable.

On to the extra clips you reported with Change Speed and DTMF.

> Case1:
>
> 1) Generate chirp, 30 sec, 0.8 amplitude (default)
> 2) Split at 5 seconds and drag to 10 sec. Split at 15 sec and drag to 20.
>
> Now (I didnt move it exactly to 10 and 20 sec), there are 3 clips in the
> track (as expected) with their start and end times as follows:
> Clip1: 0 to 5 sec
> Clip2: 10.080635 to 15 sec
> Clip3: 20.053764 to 40.134399 sec
>
>  3) Apply Effect -> Change Speed by 10%
>
>
> The whitespaces are converted to silence. Now, I thought there should
> be 5 clips. But there are 7 clips.
>
> Clip1: 0 to 4.545 sec (I have truncated time to 3 decimal places)
> Clip2: 4.545 to 9.164 sec
> Clip3: 9.164 to 13.636 sec
> Clip4: 13.636 to 18.230 sec
> Clip5: 18.230 to 36.485828 sec
> Clip6: 36.485828 to 36.485850 sec
> Clip7: 36.485850 to 36.485850 sec
>
> Look at clip6 and clip7. They are so tiny. In fact clip7 has the same start
> and end times. Is this normal?

I don't think so. 1.3.5 for example does not add superfluous clips at the
end of the track. The clips are even added just to a simple tone without
any splits in it.  


> 4) Double-click on the second silence to select it and generate DTMF tones
> inside (say "hello").
>
> Now the silence is replaced by the DTMF tone. I thought the number of clips
> must remain the same. But the number goes up to 10!
> Clip1 is same
> Clip2: 4.545465 to 4.594331 sec
> Clip3: 4.594331 to 9.164218 sec
> Clip4: 4.594331 to 4.594331 sec
> Clip5: 9.164218 to 13.636372 sec
> Clip6: 13.636 to 18.230703
> Clip7: 18.230703 to 18.230703
> Clip8: 18.230703 to 36.485828
> Clip9: 36.485828 to 36.485850
> Clip10: 36.485850 to 36.485850
>
> The DTMF was created between 13.6 and 18.2 sec. Why was an extra clip
> created between 4.5 and 4.6 sec?
> In this case, the extra clip is clip2. Also, look at clip4. It has the same
> start and end times. I strongly doubt if this is normal. Generating DTMF in
> one part of the track is affecting other parts!

I have not been able to replicate that here using the steps above.

I note your current patch handles the added clips at the end of the
track OK. I haven't really tested or considered the priority this
might have to fix it. I would imagine there might be some potential
for added clicks?


> Case2:
>
> 1) Generate chirp for 60 seconds
> 2) Select 5 to 10 sec and do Edit->Split Delete. Do the same for 40 to 50
> sec.
>
> Now there are 3 clips as expected. 0 to 5 sec, 10 to 40 sec and 50 to 60
> sec.
>
> 3) Select the whole track (double click in the silence) and do
> effect->Change speed by 100%.
>
>
> Now there are 5 clips as expected. (Note that change speed did not add any
> extra clips unlike in the first case).

I did not quite follow that (double click the silence to select the
whole track), but I did select the whole track and got extra clips at
the end.    



Gale



> On Mon, Oct 19, 2009 at 4:48 AM, Martyn Shaw <[hidden email]>wrote:
>
> > Hi Vidyashankar
> >
> > Does the patch still work with the latest HEAD?  I have not tried it
> > or looked at the code, but would like to see the bug cleared.  I may
> > have a little time this week.
> >
> > Thanks for your efforts!
> >
> > TTFN
> > Martyn
> >



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Vidyashankar Vellal

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi Gale

On Mon, Oct 19, 2009 at 4:03 PM, Gale Andrews <[hidden email]> wrote:

Hi Vidyashankar

Thanks for the new patch against CVS HEAD. I have played around on
Win XP obviously trying the two bug scenarios, plus trying multiple
tracks, making selections in parts of clips and parts of white space
and so on. It seems to work really well to me, just on observation.
Thanks!

Glad to hear that. Thanks for testing!
 

 Anyway, when I draw a region across split lines and reverse the
region, should the borders of the region now have split lines? I think
probably yes, for consistency.

Now that I think about it, I feel you are right. If the user selects a region across split lines and reverses it, he may want to apply effects only for the reversed region later on. If the borders of the region don't have clip lines, it becomes very difficult for the user to select only the reversed region.

I have made the necessary changes and attached the new patch made against HEAD.
 

 On to the extra clips you reported with Change Speed and DTMF.

> Case1:
>
> 1) Generate chirp, 30 sec, 0.8 amplitude (default)
> 2) Split at 5 seconds and drag to 10 sec. Split at 15 sec and drag to 20.
>
> Now (I didnt move it exactly to 10 and 20 sec), there are 3 clips in the
> track (as expected) with their start and end times as follows:
> Clip1: 0 to 5 sec
> Clip2: 10.080635 to 15 sec
> Clip3: 20.053764 to 40.134399 sec
>
>  3) Apply Effect -> Change Speed by 10%
>
>
> The whitespaces are converted to silence. Now, I thought there should
> be 5 clips. But there are 7 clips.
>
> Clip1: 0 to 4.545 sec (I have truncated time to 3 decimal places)
> Clip2: 4.545 to 9.164 sec
> Clip3: 9.164 to 13.636 sec
> Clip4: 13.636 to 18.230 sec
> Clip5: 18.230 to 36.485828 sec
> Clip6: 36.485828 to 36.485850 sec
> Clip7: 36.485850 to 36.485850 sec
>
> Look at clip6 and clip7. They are so tiny. In fact clip7 has the same start
> and end times. Is this normal?

I don't think so. 1.3.5 for example does not add superfluous clips at the
end of the track. The clips are even added just to a simple tone without
any splits in it.


If 1.3.5 does not have this problem, it probably makes things simpler for me to test. How can I get hold of a copy of 1.3.5?
 

> 4) Double-click on the second silence to select it and generate DTMF tones
> inside (say "hello").
>
> Now the silence is replaced by the DTMF tone. I thought the number of clips
> must remain the same. But the number goes up to 10!
> Clip1 is same
> Clip2: 4.545465 to 4.594331 sec
> Clip3: 4.594331 to 9.164218 sec
> Clip4: 4.594331 to 4.594331 sec
> Clip5: 9.164218 to 13.636372 sec
> Clip6: 13.636 to 18.230703
> Clip7: 18.230703 to 18.230703
> Clip8: 18.230703 to 36.485828
> Clip9: 36.485828 to 36.485850
> Clip10: 36.485850 to 36.485850
>
> The DTMF was created between 13.6 and 18.2 sec. Why was an extra clip
> created between 4.5 and 4.6 sec?
> In this case, the extra clip is clip2. Also, look at clip4. It has the same
> start and end times. I strongly doubt if this is normal. Generating DTMF in
> one part of the track is affecting other parts!

I have not been able to replicate that here using the steps above.

I also am not able to replicate that now. I will try some more.
 

I note your current patch handles the added clips at the end of the
track OK. I haven't really tested or considered the priority this
might have to fix it. I would imagine there might be some potential
for added clicks?

I did not understand the last sentence (potential for added clicks). Can you please explain? Sorry if it is too trivial.
 


> Case2:
>
> 1) Generate chirp for 60 seconds
> 2) Select 5 to 10 sec and do Edit->Split Delete. Do the same for 40 to 50
> sec.
>
> Now there are 3 clips as expected. 0 to 5 sec, 10 to 40 sec and 50 to 60
> sec.
>
> 3) Select the whole track (double click in the silence) and do
> effect->Change speed by 100%.
>
>
> Now there are 5 clips as expected. (Note that change speed did not add any
> extra clips unlike in the first case).

I did not quite follow that (double click the silence to select the
whole track), but I did select the whole track and got extra clips at
the end.

Oops. That was my mistake. I should not have written "double-click silence". I just wanted the whole track to be selected.

I have some ideas to fix this. But they do not solve the problem completely. If I look at 1.3.5, I might get some more ideas. Anyway, I will start a separate thread for this next time.

Thanks

Vidyashankar
 

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel


[Reverse_3.patch]

? Reverse_3.patch
Index: src/WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.170
diff -u -r1.170 WaveTrack.cpp
--- src/WaveTrack.cpp 18 Oct 2009 19:58:17 -0000 1.170
+++ src/WaveTrack.cpp 19 Oct 2009 03:57:26 -0000
@@ -708,6 +708,21 @@
    return HandleClear(t0, t1, addCutLines, split);
 }
 
+WaveClip* WaveTrack::RemoveAndReturnClip(WaveClip* clip)
+{
+   wxWaveClipListNode* node = mClips.Find(clip);
+   WaveClip* clipReturn = node->GetData();
+   mClips.DeleteNode(node);
+   return clipReturn;
+}
+
+void WaveTrack::AddClip(WaveClip* clip)
+{
+   // Uncomment the following line after we correct the problem of zero-length clips
+   //if (CanInsertClip(clip))
+      mClips.Append(clip);
+}
+
 bool WaveTrack::HandleGroupClear(double t0, double t1, bool addCutLines, bool split, TrackList* tracks)
 {
    // get tracks
Index: src/WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.76
diff -u -r1.76 WaveTrack.h
--- src/WaveTrack.h 11 Oct 2009 14:55:47 -0000 1.76
+++ src/WaveTrack.h 19 Oct 2009 03:57:21 -0000
@@ -306,6 +306,12 @@
    void MoveClipToTrack(int clipIndex, WaveTrack* dest);
    void MoveClipToTrack(WaveClip *clip, WaveTrack* dest);
   
+   // Remove the clip from the track and return a pointer to it.
+   WaveClip* RemoveAndReturnClip(WaveClip* clip);
+  
+   // Append a clip to the track
+   void AddClip(WaveClip* clip);
+  
    // Merge two clips, that is append data from clip2 to clip1,
    // then remove clip2 from track.
    // clipidx1 and clipidx2 are indices into the clip list.
Index: src/effects/Reverse.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.cpp,v
retrieving revision 1.19
diff -u -r1.19 Reverse.cpp
--- src/effects/Reverse.cpp 8 Jul 2009 15:39:44 -0000 1.19
+++ src/effects/Reverse.cpp 19 Oct 2009 11:59:48 -0000
@@ -45,10 +45,11 @@
    while (t) {
       if (t->GetKind() == Track::Wave) {
          WaveTrack *track = (WaveTrack*)t;
-         double trackStart = track->GetStartTime();
-         double trackEnd = track->GetEndTime();
-         double t0 = mT0 < trackStart? trackStart: mT0;
-         double t1 = mT1 > trackEnd? trackEnd: mT1;
+        
+         // Since leading and trailing whitespaces should also be considered for reversal
+         // t0 and t1 must always be equal to mT0 and mT1
+         double t0 = mT0;
+         double t1 = mT1;
 
          if (track->GetSelected()) {
             if (t1 > t0) {
@@ -56,7 +57,7 @@
                sampleCount end = track->TimeToLongSamples(t1);
                sampleCount len = (sampleCount)(end - start);
 
-               if (!ProcessOne(count, track, start, len))
+               if (!ProcessOneWave(count, track, start, len))
                {
                   bGoodResult = false;
                   break;
@@ -104,8 +105,126 @@
    return bGoodResult;
 }
 
-bool EffectReverse::ProcessOne(int count, WaveTrack *track,
-                               sampleCount start, sampleCount len)
+bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount start, sampleCount len)
+{
+   bool rValue = true; // return value
+
+   sampleCount end = (sampleCount) start + len; // start, end, len refer to the selected reverse region
+
+   // STEP 1:
+   // If a reverse selection begins and/or ends at the inside of a clip
+   // perform a split at the start and/or end of the reverse selection
+   WaveClipList::compatibility_iterator clipIterator = track->GetClipIterator();
+   wxWaveClipListNode *node = (wxWaveClipListNode*)clipIterator;
+   while (node) {
+      WaveClip *clip = node->GetData();
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+      if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart >= start && clipStart < end && clipEnd > end) { // the reverse selection ends at the inside of a clip
+         double splitTime = track->LongSamplesToTime(end);
+         track->SplitAt(splitTime);
+      }
+      else if (clipStart < start && clipEnd > end) { // the selection begins AND ends at the inside of a clip
+         double splitTime = track->LongSamplesToTime(start);
+         track->SplitAt(splitTime);
+         splitTime = track->LongSamplesToTime(end);
+         track->SplitAt(splitTime);
+      }
+      node = node->GetNext();
+   }
+
+   //STEP 2:
+   // Individually reverse each clip inside the selected region
+   // and apply the appropriate offset after detaching them from the track
+
+   bool checkedFirstClip = false;
+  
+   // used in calculating the offset of clips to rearrange
+   // holds the new end position of the current clip
+   sampleCount currentEnd = (sampleCount)end;
+  
+   WaveClipList revClips; // holds the reversed clips
+   WaveClipList otherClips; // holds the clips that appear after the reverse selection region
+   WaveClipArray clipArray;
+   track->FillSortedClipArray(clipArray);
+   size_t i;
+   for (i=0; i < clipArray.Count(); i++) {
+      
+      WaveClip *clip = clipArray.Item(i);
+      sampleCount clipStart = clip->GetStartSample();
+      sampleCount clipEnd = clip->GetEndSample();
+            
+      if (clipStart >= start && clipEnd <= end) { // if the clip is inside the selected region
+        
+         // this is used to check if the selected region begins with a whitespace.
+         // if yes then clipStart (of the first clip) and start are not the same.
+         // adjust currentEnd accordingly and set endMerge to false
+         if(checkedFirstClip == false && clipStart > start) {
+            checkedFirstClip = true;
+            if(i > 0) {
+               if (clipArray.Item(i-1)->GetEndSample() <= start) {
+                  currentEnd -= (clipStart - start);
+               }
+            }
+            else {
+               currentEnd -= (clipStart - start);
+            }
+         }
+        
+         sampleCount revStart = (clipStart >= start)? clipStart: start;
+         sampleCount revEnd = (clipEnd >= end)? end: clipEnd;
+         sampleCount revLen = (sampleCount)revEnd-revStart;
+         if (revEnd >= revStart) {
+            if(!ProcessOneClip(count, track, revStart, revLen, start, end)) // reverse the clip
+            {
+               rValue = false;
+               break;
+            }
+
+            sampleCount clipOffsetStart = (sampleCount)(currentEnd - (clipEnd-clipStart)); // calculate the offset required
+            double offsetStartTime = track->LongSamplesToTime(clipOffsetStart);
+            if(i+1 < clipArray.Count()) // update currentEnd if there is a clip to process next
+            {
+               sampleCount nextClipStart = clipArray.Item(i+1)->GetStartSample();
+               currentEnd = (sampleCount)(currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd));
+            }
+
+            clip = track->RemoveAndReturnClip(clip); // detach the clip from track
+            clip->SetOffset(track->LongSamplesToTime(track->TimeToLongSamples(offsetStartTime))); // align time to a sample and set offset
+            revClips.Append(clip);
+            
+         }
+      }
+      else if (clipStart >= end) { // clip is after the selection region
+         clip = track->RemoveAndReturnClip(clip); // simply remove and append to otherClips
+         otherClips.Append(clip);
+      }
+   }
+  
+   // STEP 3: Append the clips from
+   // revClips and otherClips back to the track
+   size_t revClipsCount = revClips.GetCount();
+   for (i = 0; i < revClipsCount; i++) {
+      wxWaveClipListNode *node = revClips.Item(revClipsCount - 1 - i); // the last clip of revClips is appended to the track first
+      WaveClip *clip = node->GetData();
+      track->AddClip(clip);
+   }
+
+   for (i = 0; i < otherClips.GetCount(); i++) {
+      wxWaveClipListNode *node = otherClips.Item(i);
+      track->AddClip(node->GetData());
+   }
+
+   return rValue;
+}
+
+bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
+                               sampleCount start, sampleCount len,
+                               sampleCount originalStart, sampleCount originalEnd)
 {
    bool rc = true;
    // keep track of two blocks whose data we will swap
@@ -117,7 +236,7 @@
    float *buffer1 = new float[blockSize];
    float *buffer2 = new float[blockSize];
   
-   sampleCount originalLen = len;
+   sampleCount originalLen = (sampleCount)originalEnd-originalStart;
 
    while (len > 1) {
       sampleCount block = track->GetBestBlockSize(first);
@@ -138,7 +257,7 @@
       len -= 2 * block;
       first += block;
       
-      if( TrackProgress(count, 2*(first-start) / (double) originalLen) ) {
+      if( TrackProgress(count, 2*(first-originalStart) / (double) originalLen) ) {
          rc = false;
          break;
       }
Index: src/effects/Reverse.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Reverse.h,v
retrieving revision 1.9
diff -u -r1.9 Reverse.h
--- src/effects/Reverse.h 12 Jul 2008 15:25:47 -0000 1.9
+++ src/effects/Reverse.h 19 Oct 2009 03:58:46 -0000
@@ -47,9 +47,9 @@
    virtual bool Process();
 
  private:
-   bool ProcessOne(int count, WaveTrack * track,
-                   sampleCount start, sampleCount len);
-
+   bool ProcessOneClip(int count, WaveTrack* track,
+                   sampleCount start, sampleCount len, sampleCount originalStart, sampleCount originalEnd);
+   bool ProcessOneWave(int count, WaveTrack* track, sampleCount start, sampleCount len);
  };
 
 #endif


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Martyn Shaw-2

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
Hi Vidyashankar

I had a look through your code and tested you patch and it looks good
to me too.  I note that Gale and Al were happy with it as well, so I
committed it.  I also note that it is reasonably well commented, so
thanks for that.

I note that it does not reverse a label, if all track are selected
(including the label track) and linking is off.  But much better than
it was though.  Thanks Vidyashankar!

There seen some comments in this thread that are not relevant to it, I
shall address those separately.

TTFN
Martyn

Vidyashankar Vellal wrote:

> Hi Gale
>
> On Mon, Oct 19, 2009 at 4:03 PM, Gale Andrews <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>     Hi Vidyashankar
>
>     Thanks for the new patch against CVS HEAD. I have played around on
>     Win XP obviously trying the two bug scenarios, plus trying multiple
>     tracks, making selections in parts of clips and parts of white space
>     and so on. It seems to work really well to me, just on observation.
>     Thanks!
>
>
> Glad to hear that. Thanks for testing!
>  
>
>
>      Anyway, when I draw a region across split lines and reverse the
>     region, should the borders of the region now have split lines? I think
>     probably yes, for consistency.
>
>
> Now that I think about it, I feel you are right. If the user selects a
> region across split lines and reverses it, he may want to apply effects
> only for the reversed region later on. If the borders of the region
> don't have clip lines, it becomes very difficult for the user to select
> only the reversed region.
>
> I have made the necessary changes and attached the new patch made
> against HEAD.
>  
>
>
>      On to the extra clips you reported with Change Speed and DTMF.
>
>      > Case1:
>      >
>      > 1) Generate chirp, 30 sec, 0.8 amplitude (default)
>      > 2) Split at 5 seconds and drag to 10 sec. Split at 15 sec and
>     drag to 20.
>      >
>      > Now (I didnt move it exactly to 10 and 20 sec), there are 3 clips
>     in the
>      > track (as expected) with their start and end times as follows:
>      > Clip1: 0 to 5 sec
>      > Clip2: 10.080635 to 15 sec
>      > Clip3: 20.053764 to 40.134399 sec
>      >
>      >  3) Apply Effect -> Change Speed by 10%
>      >
>      >
>      > The whitespaces are converted to silence. Now, I thought there should
>      > be 5 clips. But there are 7 clips.
>      >
>      > Clip1: 0 to 4.545 sec (I have truncated time to 3 decimal places)
>      > Clip2: 4.545 to 9.164 sec
>      > Clip3: 9.164 to 13.636 sec
>      > Clip4: 13.636 to 18.230 sec
>      > Clip5: 18.230 to 36.485828 sec
>      > Clip6: 36.485828 to 36.485850 sec
>      > Clip7: 36.485850 to 36.485850 sec
>      >
>      > Look at clip6 and clip7. They are so tiny. In fact clip7 has the
>     same start
>      > and end times. Is this normal?
>
>     I don't think so. 1.3.5 for example does not add superfluous clips
>     at the
>     end of the track. The clips are even added just to a simple tone without
>     any splits in it.
>
>
> If 1.3.5 does not have this problem, it probably makes things simpler
> for me to test. How can I get hold of a copy of 1.3.5?
>  
>
>
>      > 4) Double-click on the second silence to select it and generate
>     DTMF tones
>      > inside (say "hello").
>      >
>      > Now the silence is replaced by the DTMF tone. I thought the
>     number of clips
>      > must remain the same. But the number goes up to 10!
>      > Clip1 is same
>      > Clip2: 4.545465 to 4.594331 sec
>      > Clip3: 4.594331 to 9.164218 sec
>      > Clip4: 4.594331 to 4.594331 sec
>      > Clip5: 9.164218 to 13.636372 sec
>      > Clip6: 13.636 to 18.230703
>      > Clip7: 18.230703 to 18.230703
>      > Clip8: 18.230703 to 36.485828
>      > Clip9: 36.485828 to 36.485850
>      > Clip10: 36.485850 to 36.485850
>      >
>      > The DTMF was created between 13.6 and 18.2 sec. Why was an extra clip
>      > created between 4.5 and 4.6 sec?
>      > In this case, the extra clip is clip2. Also, look at clip4. It
>     has the same
>      > start and end times. I strongly doubt if this is normal.
>     Generating DTMF in
>      > one part of the track is affecting other parts!
>
>     I have not been able to replicate that here using the steps above.
>
>
> I also am not able to replicate that now. I will try some more.
>  
>
>
>     I note your current patch handles the added clips at the end of the
>     track OK. I haven't really tested or considered the priority this
>     might have to fix it. I would imagine there might be some potential
>     for added clicks?
>
>
> I did not understand the last sentence (potential for added clicks). Can
> you please explain? Sorry if it is too trivial.
>  
>
>
>
>      > Case2:
>      >
>      > 1) Generate chirp for 60 seconds
>      > 2) Select 5 to 10 sec and do Edit->Split Delete. Do the same for
>     40 to 50
>      > sec.
>      >
>      > Now there are 3 clips as expected. 0 to 5 sec, 10 to 40 sec and
>     50 to 60
>      > sec.
>      >
>      > 3) Select the whole track (double click in the silence) and do
>      > effect->Change speed by 100%.
>      >
>      >
>      > Now there are 5 clips as expected. (Note that change speed did
>     not add any
>      > extra clips unlike in the first case).
>
>     I did not quite follow that (double click the silence to select the
>     whole track), but I did select the whole track and got extra clips at
>     the end.
>
>
> Oops. That was my mistake. I should not have written "double-click
> silence". I just wanted the whole track to be selected.
>
> I have some ideas to fix this. But they do not solve the problem
> completely. If I look at 1.3.5, I might get some more ideas. Anyway, I
> will start a separate thread for this next time.
>
> Thanks
>
> Vidyashankar
>  
>
>
>     ------------------------------------------------------------------------------
>     Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>     is the only developer event you need to attend this year. Jumpstart your
>     developing skills, take BlackBerry mobile applications to market and
>     stay
>     ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>     http://p.sf.net/sfu/devconference
>     _______________________________________________
>     audacity-devel mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/audacity-devel
>
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> audacity-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-devel

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Martyn Shaw-2

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gale (Audacity Team)
Hi

...

> On to the extra clips you reported with Change Speed and DTMF.
>
>> Case1:
>>
>> 1) Generate chirp, 30 sec, 0.8 amplitude (default)
>> 2) Split at 5 seconds and drag to 10 sec. Split at 15 sec and drag to 20.
>>
>> Now (I didnt move it exactly to 10 and 20 sec), there are 3 clips in the
>> track (as expected) with their start and end times as follows:
>> Clip1: 0 to 5 sec
>> Clip2: 10.080635 to 15 sec
>> Clip3: 20.053764 to 40.134399 sec
>>
>>  3) Apply Effect -> Change Speed by 10%
>>
>>
>> The whitespaces are converted to silence. Now, I thought there should
>> be 5 clips. But there are 7 clips.
>>
>> Clip1: 0 to 4.545 sec (I have truncated time to 3 decimal places)
>> Clip2: 4.545 to 9.164 sec
>> Clip3: 9.164 to 13.636 sec
>> Clip4: 13.636 to 18.230 sec
>> Clip5: 18.230 to 36.485828 sec
>> Clip6: 36.485828 to 36.485850 sec
>> Clip7: 36.485850 to 36.485850 sec
>>
>> Look at clip6 and clip7. They are so tiny. In fact clip7 has the same start
>> and end times. Is this normal?

Please try this again without 'Snap To' turned on.  I believe that is
the problem.  The whole of the audio is not getting selected.

I don't think this is related to the subject of this thread. ?

TTFN
Martyn

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Martyn Shaw-2

Re: New P2 (?) "Reverse does not reverse clip boundaries"

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gale (Audacity Team)


Gale Andrews wrote:
...
> Now, I'm really not sure about this because I don't fully understand
> why some effects add (expected) split lines and some don't. Namely
> I would expect timeline changing effects (Change Speed/Tempo/Pitch
> and - possibly - Repeat) to add them at region borders when selecting
> across split lines in a track, and they do so. But I don't understand why
> EQ does.

Can you explain the problem here concisely please?  Is it relevant to
this thread?  If not, then on a new one please.

Thanks
Martyn

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel
1 2