How to minimize delay when playing an audio clip

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to minimize delay when playing an audio clip

Mike Bonner
I have an audio clip that I'm using as a sound effect.  I try to trigger
the play start FIRST in my game loop, but no matter what methods I try
(even breaking it out of the game loop itself) there is a pretty hefty lag
time before it starts playing.  Enough so that its possible to have an
event happen, and stop the play of the clip before it ever starts.

I don't think i'm having issues with a bound cpu, I think 'play audioclip
"myclip" looping' is just that slow.  If I hold the key down, it works
fine, animation keeps up, and stop is pretty much instantaneous.  Is there
a way to get this working better?  I'll try with an actual player next, but
I thought having the clip as part of the stack would provide the best
results.


Also, a quick question..  I assume there is no way to modify the tone of a
clip on the fly?  IE: Simulate doppler shift..
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Mike Bonner
Found a method that works with audioclips, as long as I only need to play
1.  Rather than starting and stopping it, I set the playloudness to 0 or
100 and just leave it looping. (it doesn't appear that the playloudness can
be set for individual clips.)

Will try with players instead since using only 1 sound effect is a bit
unrealistic.

Thanks!

On Sat, Aug 15, 2015 at 11:52 AM, Mike Bonner <[hidden email]> wrote:

> I have an audio clip that I'm using as a sound effect.  I try to trigger
> the play start FIRST in my game loop, but no matter what methods I try
> (even breaking it out of the game loop itself) there is a pretty hefty lag
> time before it starts playing.  Enough so that its possible to have an
> event happen, and stop the play of the clip before it ever starts.
>
> I don't think i'm having issues with a bound cpu, I think 'play audioclip
> "myclip" looping' is just that slow.  If I hold the key down, it works
> fine, animation keeps up, and stop is pretty much instantaneous.  Is there
> a way to get this working better?  I'll try with an actual player next, but
> I thought having the clip as part of the stack would provide the best
> results.
>
>
> Also, a quick question..  I assume there is no way to modify the tone of a
> clip on the fly?  IE: Simulate doppler shift..
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Mike Bonner
DOH. NEvermind.  Use the ID of the clip.  Reading the dictionary. A useful
skill I need to develop

On Sat, Aug 15, 2015 at 12:37 PM, Mike Bonner <[hidden email]> wrote:

> Found a method that works with audioclips, as long as I only need to play
> 1.  Rather than starting and stopping it, I set the playloudness to 0 or
> 100 and just leave it looping. (it doesn't appear that the playloudness can
> be set for individual clips.)
>
> Will try with players instead since using only 1 sound effect is a bit
> unrealistic.
>
> Thanks!
>
> On Sat, Aug 15, 2015 at 11:52 AM, Mike Bonner <[hidden email]> wrote:
>
>> I have an audio clip that I'm using as a sound effect.  I try to trigger
>> the play start FIRST in my game loop, but no matter what methods I try
>> (even breaking it out of the game loop itself) there is a pretty hefty lag
>> time before it starts playing.  Enough so that its possible to have an
>> event happen, and stop the play of the clip before it ever starts.
>>
>> I don't think i'm having issues with a bound cpu, I think 'play audioclip
>> "myclip" looping' is just that slow.  If I hold the key down, it works
>> fine, animation keeps up, and stop is pretty much instantaneous.  Is there
>> a way to get this working better?  I'll try with an actual player next, but
>> I thought having the clip as part of the stack would provide the best
>> results.
>>
>>
>> Also, a quick question..  I assume there is no way to modify the tone of
>> a clip on the fly?  IE: Simulate doppler shift..
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Mike Bonner
Nevermind. Can't make it work.  Setting the playloudness works globally,
whether sounds are currently active or not, but setting audioclip loudness
only works while the clip is NOT playing.  Player object, here I come.
Sorry for talking to myself here.  Back down the rabbit hole.

On Sat, Aug 15, 2015 at 12:39 PM, Mike Bonner <[hidden email]> wrote:

> DOH. NEvermind.  Use the ID of the clip.  Reading the dictionary. A useful
> skill I need to develop
>
> On Sat, Aug 15, 2015 at 12:37 PM, Mike Bonner <[hidden email]> wrote:
>
>> Found a method that works with audioclips, as long as I only need to play
>> 1.  Rather than starting and stopping it, I set the playloudness to 0 or
>> 100 and just leave it looping. (it doesn't appear that the playloudness can
>> be set for individual clips.)
>>
>> Will try with players instead since using only 1 sound effect is a bit
>> unrealistic.
>>
>> Thanks!
>>
>> On Sat, Aug 15, 2015 at 11:52 AM, Mike Bonner <[hidden email]> wrote:
>>
>>> I have an audio clip that I'm using as a sound effect.  I try to trigger
>>> the play start FIRST in my game loop, but no matter what methods I try
>>> (even breaking it out of the game loop itself) there is a pretty hefty lag
>>> time before it starts playing.  Enough so that its possible to have an
>>> event happen, and stop the play of the clip before it ever starts.
>>>
>>> I don't think i'm having issues with a bound cpu, I think 'play
>>> audioclip "myclip" looping' is just that slow.  If I hold the key down, it
>>> works fine, animation keeps up, and stop is pretty much instantaneous.  Is
>>> there a way to get this working better?  I'll try with an actual player
>>> next, but I thought having the clip as part of the stack would provide the
>>> best results.
>>>
>>>
>>> Also, a quick question..  I assume there is no way to modify the tone of
>>> a clip on the fly?  IE: Simulate doppler shift..
>>>
>>
>>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Simon
Hi Mike,
In a Pong game I made I dumped .mp3 directly into global variables. Then
"play gBatCollision"
I had no delay problems.
But if your audio clip is very long you might not want to do this.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Mike Bonner
great idea, thanks. I've clipped the file down to just what I need so its
pretty tiny.  I'll give it a shot!

On Sat, Aug 15, 2015 at 2:30 PM, Simon <[hidden email]> wrote:

> Hi Mike,
> In a Pong game I made I dumped .mp3 directly into global variables. Then
> "play gBatCollision"
> I had no delay problems.
> But if your audio clip is very long you might not want to do this.
>
> Simon
>
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/How-to-minimize-delay-when-playing-an-audio-clip-tp4695109p4695130.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

ScottR
In reply to this post by Mike Bonner
In the past, it used to be that imported audioClips would generally start
playing with less lag than players.  I haven't done tests with any of the
recent versions of LC to see if this holds true (sounds like it doesn't?).

In any event, I've never done this, but you might try using an imported
video clip with no video track (if that's possible) so it contains your
audio only, and use the prepare command, which supposedly allows the
imported media to start playing immediately. If you can't make a
video-less movie, another option could be to make the video 1 x 1 pixel in
size.

Even if a videoClip somehow employs a player for playback, the prepare
command might reduce the start lag.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 8/15/15, 12:08 PM, "Mike Bonner" <[hidden email]> wrote:

>Nevermind. Can't make it work.  Setting the playloudness works globally,
>whether sounds are currently active or not, but setting audioclip loudness
>only works while the clip is NOT playing.  Player object, here I come.
>Sorry for talking to myself here.  Back down the rabbit hole.
>
>On Sat, Aug 15, 2015 at 12:39 PM, Mike Bonner <[hidden email]> wrote:
>
>> DOH. NEvermind.  Use the ID of the clip.  Reading the dictionary. A
>>useful
>> skill I need to develop
>>
>> On Sat, Aug 15, 2015 at 12:37 PM, Mike Bonner <[hidden email]>
>>wrote:
>>
>>> Found a method that works with audioclips, as long as I only need to
>>>play
>>> 1.  Rather than starting and stopping it, I set the playloudness to 0
>>>or
>>> 100 and just leave it looping. (it doesn't appear that the
>>>playloudness can
>>> be set for individual clips.)
>>>
>>> Will try with players instead since using only 1 sound effect is a bit
>>> unrealistic.
>>>
>>> Thanks!
>>>
>>> On Sat, Aug 15, 2015 at 11:52 AM, Mike Bonner <[hidden email]>
>>>wrote:
>>>
>>>> I have an audio clip that I'm using as a sound effect.  I try to
>>>>trigger
>>>> the play start FIRST in my game loop, but no matter what methods I try
>>>> (even breaking it out of the game loop itself) there is a pretty
>>>>hefty lag
>>>> time before it starts playing.  Enough so that its possible to have an
>>>> event happen, and stop the play of the clip before it ever starts.
>>>>
>>>> I don't think i'm having issues with a bound cpu, I think 'play
>>>> audioclip "myclip" looping' is just that slow.  If I hold the key
>>>>down, it
>>>> works fine, animation keeps up, and stop is pretty much
>>>>instantaneous.  Is
>>>> there a way to get this working better?  I'll try with an actual
>>>>player
>>>> next, but I thought having the clip as part of the stack would
>>>>provide the
>>>> best results.
>>>>
>>>>
>>>> Also, a quick question..  I assume there is no way to modify the tone
>>>>of
>>>> a clip on the fly?  IE: Simulate doppler shift..
>>>>
>>>
>>>
>>
>_______________________________________________
>use-livecode mailing list
>[hidden email]
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Mike Bonner
Thanks for the suggestion, 2 things on the list to try now.

On Sat, Aug 15, 2015 at 3:17 PM, Scott Rossi <[hidden email]> wrote:

> In the past, it used to be that imported audioClips would generally start
> playing with less lag than players.  I haven't done tests with any of the
> recent versions of LC to see if this holds true (sounds like it doesn't?).
>
> In any event, I've never done this, but you might try using an imported
> video clip with no video track (if that's possible) so it contains your
> audio only, and use the prepare command, which supposedly allows the
> imported media to start playing immediately. If you can't make a
> video-less movie, another option could be to make the video 1 x 1 pixel in
> size.
>
> Even if a videoClip somehow employs a player for playback, the prepare
> command might reduce the start lag.
>
> Regards,
>
> Scott Rossi
> Creative Director
> Tactile Media, UX/UI Design
>
>
>
>
> On 8/15/15, 12:08 PM, "Mike Bonner" <[hidden email]> wrote:
>
> >Nevermind. Can't make it work.  Setting the playloudness works globally,
> >whether sounds are currently active or not, but setting audioclip loudness
> >only works while the clip is NOT playing.  Player object, here I come.
> >Sorry for talking to myself here.  Back down the rabbit hole.
> >
> >On Sat, Aug 15, 2015 at 12:39 PM, Mike Bonner <[hidden email]> wrote:
> >
> >> DOH. NEvermind.  Use the ID of the clip.  Reading the dictionary. A
> >>useful
> >> skill I need to develop
> >>
> >> On Sat, Aug 15, 2015 at 12:37 PM, Mike Bonner <[hidden email]>
> >>wrote:
> >>
> >>> Found a method that works with audioclips, as long as I only need to
> >>>play
> >>> 1.  Rather than starting and stopping it, I set the playloudness to 0
> >>>or
> >>> 100 and just leave it looping. (it doesn't appear that the
> >>>playloudness can
> >>> be set for individual clips.)
> >>>
> >>> Will try with players instead since using only 1 sound effect is a bit
> >>> unrealistic.
> >>>
> >>> Thanks!
> >>>
> >>> On Sat, Aug 15, 2015 at 11:52 AM, Mike Bonner <[hidden email]>
> >>>wrote:
> >>>
> >>>> I have an audio clip that I'm using as a sound effect.  I try to
> >>>>trigger
> >>>> the play start FIRST in my game loop, but no matter what methods I try
> >>>> (even breaking it out of the game loop itself) there is a pretty
> >>>>hefty lag
> >>>> time before it starts playing.  Enough so that its possible to have an
> >>>> event happen, and stop the play of the clip before it ever starts.
> >>>>
> >>>> I don't think i'm having issues with a bound cpu, I think 'play
> >>>> audioclip "myclip" looping' is just that slow.  If I hold the key
> >>>>down, it
> >>>> works fine, animation keeps up, and stop is pretty much
> >>>>instantaneous.  Is
> >>>> there a way to get this working better?  I'll try with an actual
> >>>>player
> >>>> next, but I thought having the clip as part of the stack would
> >>>>provide the
> >>>> best results.
> >>>>
> >>>>
> >>>> Also, a quick question..  I assume there is no way to modify the tone
> >>>>of
> >>>> a clip on the fly?  IE: Simulate doppler shift..
> >>>>
> >>>
> >>>
> >>
> >_______________________________________________
> >use-livecode mailing list
> >[hidden email]
> >Please visit this url to subscribe, unsubscribe and manage your
> >subscription preferences:
> >http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to minimize delay when playing an audio clip

Chris Sheffield-5
In reply to this post by Mike Bonner
Another trick that I’ve used in the past (when using players; I’ve haven’t used imported audio clips much) is to play a very short, silent audio file at some point in a preOpenCard or openCard handler. This kind of gets the audio ball rolling so to speak, then when I need to play my actual audio, there is no delay. Whatever needs to load in the background in order for audio playback has already loaded. A bit of a hack I suppose, but it works. :-)

Chris


--
Chris Sheffield
Read Naturally, Inc.
www.readnaturally.com

> On Aug 15, 2015, at 11:52 AM, Mike Bonner <[hidden email]> wrote:
>
> I have an audio clip that I'm using as a sound effect.  I try to trigger
> the play start FIRST in my game loop, but no matter what methods I try
> (even breaking it out of the game loop itself) there is a pretty hefty lag
> time before it starts playing.  Enough so that its possible to have an
> event happen, and stop the play of the clip before it ever starts.
>
> I don't think i'm having issues with a bound cpu, I think 'play audioclip
> "myclip" looping' is just that slow.  If I hold the key down, it works
> fine, animation keeps up, and stop is pretty much instantaneous.  Is there
> a way to get this working better?  I'll try with an actual player next, but
> I thought having the clip as part of the stack would provide the best
> results.
>
>
> Also, a quick question..  I assume there is no way to modify the tone of a
> clip on the fly?  IE: Simulate doppler shift..
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode