player looping problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
player looping problem
My app fades individual tracks of multi-track Quicktime audio (no video) in and out on cue using a player object and the Enhanced Quicktime external. Works like a dream.
There is a glitch, though, in that the music is supposed to loop cleanly at the end and begin (on the starting note) again. Instead, there is an annoying pause/interval/noise before it starts up again.
I've tried extending the audio segments manually (making multiple sequential copies within each track), but that's just putting off the inevitable--eventually, it gets to the end and there is, once again, the annoying sound before playback begins again.
Is this a Quicktime thing? A Livecode thing?
There is a glitch, though, in that the music is supposed to loop cleanly at the end and begin (on the starting note) again. Instead, there is an annoying pause/interval/noise before it starts up again.
I've tried extending the audio segments manually (making multiple sequential copies within each track), but that's just putting off the inevitable--eventually, it gets to the end and there is, once again, the annoying sound before playback begins again.
Is this a Quicktime thing? A Livecode thing?
-
- VIP Livecode Opensource Backer
- Posts: 18
- Joined: Wed Oct 13, 2010 4:44 am
Re: player looping problem
I'm yet to test it, but apparently the 'seamlessLoop' command in Enhanced QT helps with this.
Re: player looping problem
No good. I expect it simply sets playLooping, much as one might do in the IDE.Howlernator wrote:I'm yet to test it, but apparently the 'seamlessLoop' command in Enhanced QT helps with this.
Re: player looping problem
Make that simply "looping" in my last.
Re: player looping problem
Please try it, the result might differ from your exspectations!
I don't know the techs behind this, but this is not like the "looping" in LiveCode,
as Trevor, who developed that external, once told me!
Best
Klaus
I don't know the techs behind this, but this is not like the "looping" in LiveCode,
as Trevor, who developed that external, once told me!
Best
Klaus
Re: player looping problem
Let us know how things go - this is definitely something I will need to use soon. Seamless looping is a necessity in what I am about to undertake.
Mike
Mike
Re: player looping problem
@ Klaus, the "no good" was the result of my trying it in the app. What followed was my speculation as to why it didn't work. I'm glad to hear that it differs from setting "looping" in the IDE, but the result, alas, was the same.admin12 wrote:Let us know how things go - this is definitely something I will need to use soon. Seamless looping is a necessity in what I am about to undertake.
Mike
Re: player looping problem
By the way, I also tried looping the tracks in uncompressed format. Though less pronounced, there's still an audible "glitch" at the loop point (not only that, but the audio file is much larger than before, not surprisingly).
Re: player looping problem
I wonder if using (and buying) Franklin audio would solve the looping problem?
Mike
Mike
-
- Posts: 77
- Joined: Fri Jan 04, 2013 9:57 am
Re: player looping problem
I apologize for reviving a very old thread, but this problem has yet to be solved.
The player still pauses for a small time before restarting the loop even with uncompressed audio.
I've tried to work around this and have made a command that mimics seamless looping, but it isn't very efficient.
It would be much better if "loop" doesn't pause before restarting. It may just be a problem with QT, however.
Here's my attempt at a solution:
I made one function that can be passed as a message with the name of the player to loop and the number of times to loop it. Anything zero or less loops forever.
The other function is passed the same name and stops the infinite loop and pauses the looping sound.
If anyone has a better solution (not including externals) I'd be happy to hear of it.
The player still pauses for a small time before restarting the loop even with uncompressed audio.
I've tried to work around this and have made a command that mimics seamless looping, but it isn't very efficient.
It would be much better if "loop" doesn't pause before restarting. It may just be a problem with QT, however.
Here's my attempt at a solution:
Code: Select all
local allowLooping
command stopLoop playerName
// Stop looping player
put false into allowLooping
// Pause associated players
set the paused of player playerName to true
if there is a player (playerName && "copy") then set the paused of player (playerName && "copy") to true
end stopLoop
command seamlessLoop playerName loopCount
local clonedPlayer, loopPoint
put true into allowLooping
// Create and hide a duplicate player
lock screen
if there is a player (playerName && "copy") then delete player (playerName && "copy")
clone player playerName
set the name of it to playerName && "copy"
put playerName && "copy" into clonedPlayer
hide player clonedPlayer
unlock screen
// Remove native looping if applied
set the looping of player playerName to false
set the looping of player clonedPlayer to false
// Change from 290 if not perfectly seamless
put the duration of player playerName - 290 into loopPoint
if loopCount <= 0 then
repeat while allowLooping
set the currenttime of player playerName to 0
set the paused of player playerName to false
wait while the currentTime of player playerName < loopPoint with messages
set the currenttime of player clonedPlayer to 0
set the paused of player clonedPlayer to false
wait while the currentTime of player clonedPlayer < loopPoint with messages
end repeat
else
repeat loopCount times
set the currenttime of player playerName to 0
set the paused of player playerName to false
wait while the currentTime of player playerName < loopPoint with messages
set the currenttime of player clonedPlayer to 0
set the paused of player clonedPlayer to false
wait while the currentTime of player clonedPlayer < loopPoint with messages
end repeat
end if
// Clean up duplicates
delete player clonedPlayer
end seamlessLoop
The other function is passed the same name and stops the infinite loop and pauses the looping sound.
If anyone has a better solution (not including externals) I'd be happy to hear of it.
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: player looping problem
I think some of the problem is that you're running it all from a single handler which involves lots of waiting, and also tried to calculate the time interval to wait (which can only be approximate, given how computers work.) You might get better results if you rely on native engine messages rather than trying to implement your own event loop.
I would create two players and leave them on the card permanently, there's no reason to create and delete them. Hide them both if you want. Then the basic idea is to preload them both with the same file and start the first one playing. Create a playStopped handler which will trigger when the active player finishes. When you get a playStopped message, immediately start the second player. When that one finishes, start up the first one again, and so forth. You can tell which player stopped by checking the target.
You'll want to add your toggle flag too, so that you can exit if the looping is turned off. I'm not sure this will give you perfectly seamless playback but if your sound loops have no silence at the end then it should be pretty close.
I see that your handler doesn't always want to play through to the end (it subtracts 290 from the duration.) For those situations you can set a callback on the player that calls "playStopped" at that point in the playback. See the callbacks property in the dictionary. I've used those and they work well. You'll need to adjust the playStopped handler to stop the current player before or just after the second one starts to play back.
I would create two players and leave them on the card permanently, there's no reason to create and delete them. Hide them both if you want. Then the basic idea is to preload them both with the same file and start the first one playing. Create a playStopped handler which will trigger when the active player finishes. When you get a playStopped message, immediately start the second player. When that one finishes, start up the first one again, and so forth. You can tell which player stopped by checking the target.
Code: Select all
on playStopped
if there is no player "firstPlayer" then exit playStopped -- user changed cards
if the short name of the target contains "firstPlayer" then
start player "secondPlayer"
else
start player "firstPlayer"
end if
end playStopped
I see that your handler doesn't always want to play through to the end (it subtracts 290 from the duration.) For those situations you can set a callback on the player that calls "playStopped" at that point in the playback. See the callbacks property in the dictionary. I've used those and they work well. You'll need to adjust the playStopped handler to stop the current player before or just after the second one starts to play back.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: player looping problem
Hi,
and 6 years later the original issue remains. I can't get seamless looping working out of the box on LC 9.5 on MacOSX 10.12.6 I noticed that even Quicktime player doesn't create a seamless loop, so I guess the problem is passed from AV foundation to livecode. But this is just guessing. I attach a stack that uses the two player method and callbacks to create a seamless loop, compared to the out of box looping. On my system I can hear a clear difference betwen the two methods. The question remains though will this be seamless on different systems and devices?
Does anyone has experience with looping of audio tracks on mobile devices, can they handle seamless looping out of the box?
Thanks!
Oliver
and 6 years later the original issue remains. I can't get seamless looping working out of the box on LC 9.5 on MacOSX 10.12.6 I noticed that even Quicktime player doesn't create a seamless loop, so I guess the problem is passed from AV foundation to livecode. But this is just guessing. I attach a stack that uses the two player method and callbacks to create a seamless loop, compared to the out of box looping. On my system I can hear a clear difference betwen the two methods. The question remains though will this be seamless on different systems and devices?
Does anyone has experience with looping of audio tracks on mobile devices, can they handle seamless looping out of the box?
Thanks!
Oliver
- Attachments
-
- seamless_loop.zip
- (109.81 KiB) Downloaded 163 times
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: player looping problem
An audio guy told me once that mp3 files are impossible to loop, there is always a break at the end. I don't know what file format you use, or which one would work, but if you're using mp3 the problem is innate to the file format.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: player looping problem
Interesting topic!
https://www.compuphase.com/mp3/mp3loops.htm
https://www.compuphase.com/mp3/mp3loops.htm
Re: player looping problem
Hi Jacque, thanks for responding to this super old thread. It just became an important topic to me, since I develop an app with gps triggered audio loops. In order for it to work properly a seamlees looping is essential.
In response to your post I would say: do not trust "an audio guy". I tried it with wav, aiff, and any format the player can play. There is no difference in the behaviour. But he behaviour happens already in Quicktime Player, so we can't blame Livecode - at least this time . I use the same files in Ableton Live or Maschine 2 - of course they are dedicated audio programs - but there is no issue with looping, also with mp3 format. The looping is precise to the millisecond. So it is defintely possible. And as my stack demonstrated it, there is a way to "fake" seamless looping. Why the player could not do this out of the box?
Best
Oliver
In response to your post I would say: do not trust "an audio guy". I tried it with wav, aiff, and any format the player can play. There is no difference in the behaviour. But he behaviour happens already in Quicktime Player, so we can't blame Livecode - at least this time . I use the same files in Ableton Live or Maschine 2 - of course they are dedicated audio programs - but there is no issue with looping, also with mp3 format. The looping is precise to the millisecond. So it is defintely possible. And as my stack demonstrated it, there is a way to "fake" seamless looping. Why the player could not do this out of the box?
Best
Oliver