Sound latency on Windows standalone

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bd525
Posts: 80
Joined: Sun Aug 31, 2014 12:43 am

Sound latency on Windows standalone

Post by bd525 » Tue Jan 18, 2022 11:00 pm

My app sounds brief audio files in quick succession. I use two alternating player objects. Minimal latency is crucial. I develop on Mac and results are excellent in both Livecode and standalones, but when I run a standalone on a Windows laptop latency is about half a second, way worse than acceptable. I was working with .aiff files and hypothesized that was the problem--since that is an Apple audio format--but get the same result with .wav files. I have searched the documentation and forums for latency and haven't come up with anything helpful.

Any idea what's going on?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sound latency on Windows standalone

Post by Klaus » Wed Jan 19, 2022 12:00 pm

Did you try with imported sounds?

BTW:
LC supports uncompressed AIFF and WAV files on all platforms!
Be it imported sounds or external files.

bd525
Posts: 80
Joined: Sun Aug 31, 2014 12:43 am

Re: Sound latency on Windows standalone

Post by bd525 » Wed Jan 19, 2022 2:51 pm

Thanks, Klaus, I'll try that. Must I dispense with the use of the player objects? A quick look at Livecode documentation suggests those are only for external files.

https://lessons.livecode.com/m/4603/l/4 ... ng-players

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sound latency on Windows standalone

Post by Klaus » Wed Jan 19, 2022 3:07 pm

Yes, player objects only work with external files.
With imported sounds you can just: play ac "name of sound.aif"

bd525
Posts: 80
Joined: Sun Aug 31, 2014 12:43 am

Re: Sound latency on Windows standalone

Post by bd525 » Wed Jan 19, 2022 3:27 pm

Nope, no difference. Playback is fine on Mac Livecode, major latency on Windows standalone.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sound latency on Windows standalone

Post by Klaus » Wed Jan 19, 2022 3:40 pm

Hm, OK, was worth a try.
Sorry no brilliant ideas in the moment...

bd525
Posts: 80
Joined: Sun Aug 31, 2014 12:43 am

Re: Sound latency on Windows standalone

Post by bd525 » Wed Jan 19, 2022 3:42 pm

I'll try something: I test on an old Windows laptop, something I acquired for cheap for only that purpose. I'll send the app to a student with a (no doubt) newer unit and see if that makes a difference.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Sound latency on Windows standalone

Post by jacque » Wed Jan 19, 2022 6:45 pm

See if the "prepare" command helps. The latency may be due to the time it takes to get the file from disk, and the prepare command allows you to avoid that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2839
Joined: Sun Sep 23, 2007 4:58 pm

Re: Sound latency on Windows standalone

Post by SparkOut » Wed Jan 19, 2022 7:52 pm

Currently using Windows 10 and 11, I get a delay (perhaps a second or two) in sounds starting in various apps, such as Audacity, or even a YouTube video.
I have not spent any time investigating or trying to optimise, but I don't think it's limited to or maybe not even connected to LiveCode's sound handling on Windows.
Perhaps updating sound card drivers (or even downgrading to an earlier, lighter version) might make a difference. I don't know, just wondering aloud.

bd525
Posts: 80
Joined: Sun Aug 31, 2014 12:43 am

Re: Sound latency on Windows standalone

Post by bd525 » Wed Jan 19, 2022 10:17 pm

Thanks for the input. I have begun a three day travel obligation and didn’t bring the windows laptop, so can’t try any suggestions for a while.

jmk_phd
Posts: 213
Joined: Sat Apr 15, 2017 8:29 pm

Re: Sound latency on Windows standalone

Post by jmk_phd » Wed May 24, 2023 12:44 am

bd525 –
Sorry not to have noticed your inquiry months ago. My own experience with playing audioclips in rapid series may or may not be helpful, but for what it’s worth…
Just as Klaus recommended early on, for an app that I developed a few years ago I imported a set of audioclips (sampled piano notes) into my stack in order to play various scales. Each audioclip was 750 milliseconds in length (including a brief fade out), and these were triggered directly in series using the “play” command. The tempo at which the scale played was governed by inserting a “wait” between items (from a slow of 30 to a very fast of only 8 milliseconds).
I’ve experienced no unintended latency between the triggered soundclips, either in the Mac IDE or in the Mac standalone. Moreover, even running the Windows standalone in emulation via Parallels, there is no discernible latency between audioclips. (And this all despite the fact that the actual routine also includes a screen redraw before and after each audioclip.)
Here’s a bare-bones version of the code from that app:

Code: Select all

on doPlayScale pTempo
   -- parameter pTempo is the number of milliseconds between notes
   -- pTempo is a value between 30 (slow) and 8 (very fast)
   local tTheseNotes -- to hold the list of notes across 3 octaves
   put "0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36" into tTheseNotes
   local tThisTone -- to hold the name of the note to be played
   repeat with x = 1 to 22 -- play each note
      put item x of tTheseNotes & ".au" into tThisTone
      play audioclip tThisTone
      wait pTempo 
   end repeat
end doPlayScale 
Still, I have indeed found that the Windows standalone does not perform the same as does the Mac version: Not long ago I got a complaint that the audioclips in the Windows version of my app were very noisy. This made no sense because it sounds great on the Mac. But I’ve just discovered that this is in fact the case. (It may be because I’d opted to employ .au rather than .wav files in order to save a few Mb, but that’s an issue for a new thread.)

Best wishes.
jeff k

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”