Loop Play from within selection. (SHIFT+B)

Audio software developers forum.

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by steve » Fri Oct 01, 2010 3:21 pm

Edgar wrote:as far as I can tell it is impossible to make a selection and then click somewhere within it to set the cursor – the selection goes away.

That's correct, though with two exceptions:
"Edit menu > Region Save/Region Restore"
and "Edit menu > Region Lock".

However, "Play to/from the current pointer position to/from the start/end of the selection" with the "B" key does not use either of these features. It plays from the "pointer" position (without clicking on the track). See "Play to selection" here: http://manual.audacityteam.org/index.ph ... _Recording
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 42741
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Edgar » Fri Oct 01, 2010 3:34 pm

stevethefiddle wrote: "Play to/from the current pointer position to/from the start/end of the selection" with the "B" key does not use either of these features. It plays from the "pointer" position (without clicking on the track).

I did experiment with that but it required a deeper understanding of the way the mouse pointer location was used and would've taken quite a bit more time for me to comprehend. The current behavior, while not elegant, was simple to implement based on code that I already had and given that this is just proof-of-concept and unlikely to ever be committed I chose to go the more simple route. The major problem is that I have not figured out how to initiate a non-menu related keypress generated activity; I know that it is possible as there are quite a few of them, so far it has always been easier for me to just add an extra menu item (remember, I do not use a mouse nor a keyboard – I control Audacity vocally so I never see the menus, I always access them via shortcut key – usually in some macro triggered vocally).
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1475
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Edgar » Fri Oct 01, 2010 8:38 pm

I have spent the day on this and have been down two more dead ends! I was hoping to trick the looping mode into starting from deep within its buffer but cannot see any way to do so. Now the only way I can see to do this is to create two actions, the first being "play region once" starting from the cursor and going to the end of the selection then immediately going into the loop mode. This requires starting from scratch again and I need some outdoor time as today is the last (and almost only) nice day of summer! Oops, spoke too soon--it's getting cloudy and cold now!
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1475
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by billw58 » Fri Oct 01, 2010 9:06 pm

Edgar:
This thread on nabble http://audacity.238276.n2.nabble.com/Wa ... l#a5552788 might help. From what I can glean from it, using the "C" command to do a cut preview creates a temporary track. Perhaps that would work with what you're trying to do?

-- Bill
billw58
Forum Staff
 
Posts: 3406
Joined: Wed Aug 12, 2009 2:10 am
Location: Waterloo, Ontario
Operating System: OS X 10.11 El Capitan or later (macOS)

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Edgar » Fri Oct 01, 2010 11:02 pm

Bill--thanks, I have been following that thread and I suspect doing a temporary track might be the elegant solution. Copy audio from cursor to end-of-selection into track then copy audio from start-of-selection to cursor into track. Now we have a temporary track that looks like B-A and the original like A-B and we can loop play the temporary track.

However, after taking a break to weed my fuchsias I came back and discovered that I could do the job using the "play B" then "loop play A+B" method so I now have it working as advertised (but you can still crash Audacity by intentionally misusing the function so I need to debug the fringes and improve the error checking). The main code looks like:
Code: Select all
void AudacityProject::OnPlayLoopedFromCursor()
{
   if( !MakeReadyToPlay() )
      return;

   AudacityProject * activeProject = GetActiveProject();
   double currentCursorLocation;
   bool viable = activeProject->ViableStartAtCursor(&currentCursorLocation);
   if (viable) {
      GetControlToolBar()->PlayPlayRegion(currentCursorLocation, activeProject->mLoopingRegionEnd);
      int streamToken = activeProject->GetAudioIOToken();
      while (gAudioIO->IsStreamActive(streamToken)) {wxMilliSleep(50);}
      gAudioIO->StopStream();
      activeProject->SetSel0(activeProject->mLoopingRegionStart);
      activeProject->SetSel1(activeProject->mLoopingRegionEnd);
      if(!MakeReadyToPlay())
         return;
      else
         GetControlToolBar()->PlayPlayRegion(activeProject->mLoopingRegionStart, activeProject->mLoopingRegionEnd, true);
   }
}


I will post a patch sometime before I leave for work in the AM.
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1475
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Edgar » Fri Oct 01, 2010 11:20 pm

The crashing bug was a silly typo and testing all of the obvious extreme conditions proved to be fairly quick and as that section of the code has been heavily tested here on my system for a couple of months now I feel comfortable that it's reasonably robust.

There is one fairly trivial "gotcha"; if you have two Label Regions which overlap and you click the cursor in a region of audio which is contained by both Labeled Regions, the algorithm always uses the first region it finds. Given that the original design goal was to start playing at cursor location until the end of the selection then jump back to the beginning of the selection and loop until stopped, that is the way this works now changing one "true" to "false" in the code causes it to play only one time – from cursor to end to start to cursor. If I had a use for it that is the way I would probably use it.

As always, comments, suggestions, criticisms and bug reports are welcome!
Attachments
LoopFromCursor2.patch
(5.52 KiB) Downloaded 107 times
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1475
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Gale Andrews » Sat Oct 02, 2010 4:01 pm

stevethefiddle wrote:
Edgar wrote:let us imagine we have 60 seconds of audio, we (somehow--use a region label?) mark a region – let us say from 00:10 to 00:30; we set the cursor at 00:20 and issue our command. What we want to see happen is that the audio starts playing at 00:20 and plays through until 00:30 and then (with no perceptible pause) jumps back to 00:10 and continues playing (and I am assuming it's going to stop at 00:20)

Yes. I don't mind if it then stops at 00:20 or continues to loop.


I'm obviously a fool when it comes to looping. :) Obviously I see the time saving, but what (approximate) time range is it you want to loop? If 10s to 30s, why is the end of the loop set to 20s? If 10s to 20s, why start playing outside the loop region instead of at say 15 seconds? I've seen a few requests (not on Wiki FR yet) to loop between mouse cursor and cursor (including the implied cursor at the start of the selection); and even I see one to use B in some way to loop play from mouse cursor to end of region, carrying straight through to start of region thence to end of region... but to stop at (or loop back from) the mouse cursor seems odd. :?

On a different tack, does anyone here like the practice of loop playing the whole track when there is no selection, irrespective of the position of the cursor? There are a fair number of votes (again some not yet added) to take the cursor into account (either loop from cursor to track end, or from cursor to cursor, playing through from the track end via the start to the cursor).



Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual
Gale Andrews
Quality Assurance
 
Posts: 25028
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by Edgar » Sat Oct 02, 2010 5:00 pm

As I mentioned, I do not use looping with Audacity (I do use it a lot in an aid to memorizing but do so on my pro deck where looping works just exactly the way I need it to but with an incredibly clunky interface). The patch I supplied is specific to stevethefiddle's need and is probably of little interest to most users without a very good use case and detailed instructions. I really did not understand OP's use case but coded to spec.

As for loop behavior with no selection, I find it wrong--no selection implies no availability to loop IMHO. I think looping should be disabled when there is no selection (or--worst case, that a selection is forced between mouse and cursor before looping).
-Edgar
compiling Audacity daily
64-bit Windows 7
Edgar
Forum Crew
 
Posts: 1475
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 7

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by steve » Sun Oct 03, 2010 8:08 am

Gale Andrews wrote:Obviously I see the time saving, but what (approximate) time range is it you want to loop?

Here's a nice easy example to illustrate:
bad penny blues.mp3
(1.46 MiB) Downloaded 426 times

The task is to extend the track by about 2 minutes.
Select from about 25 seconds to about 1 minute 15 seconds.
Press SHIFT+Spacebar.
If the "loop points" are in exactly the right place then it will loop seamlessly.

Adjust the selection until the loop plays seamlessly then use "Effect > Repeat" with the number of repeats set to 2.
The original track was 2:36.6
The new (extended) track is 4:16.3. Mission accomplished.

Here is the "join" - from 1:00 to 1:20 of the extended version with the loop positions in the right place.:
the-join.mp3
(193.58 KiB) Downloaded 456 times


For this particular example there is a simple workaround but in many other cases there is not substitute for listening to the loop.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 42741
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

Re: Loop Play from within selection. (SHIFT+B)

Permanent link to this post Posted by steve » Sun Oct 03, 2010 8:15 am

Gale Andrews wrote:does anyone here like the practice of loop playing the whole track when there is no selection, irrespective of the position of the cursor?

It would be far more useful if loop playback could be from the cursor or pointer position.
This would not necessarily have to be the default behaviour when pressing SHIFT+Spacebar, it could be the same keyboard combination as for looping a selection from the pointer position (which I'm suggesting would be a good use of SHIFT+B).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 42741
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux Debian

PreviousNext

Return to General Audio Programming



Who is online

Users browsing this forum: No registered users and 1 guest