Sound latency on Windows standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Sound latency on Windows standalone
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?
Any idea what's going on?
Re: Sound latency on Windows standalone
Did you try with imported sounds?
BTW:
LC supports uncompressed AIFF and WAV files on all platforms!
Be it imported sounds or external files.
BTW:
LC supports uncompressed AIFF and WAV files on all platforms!
Be it imported sounds or external files.
Re: Sound latency on Windows standalone
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
https://lessons.livecode.com/m/4603/l/4 ... ng-players
Re: Sound latency on Windows standalone
Yes, player objects only work with external files.
With imported sounds you can just: play ac "name of sound.aif"
With imported sounds you can just: play ac "name of sound.aif"
Re: Sound latency on Windows standalone
Nope, no difference. Playback is fine on Mac Livecode, major latency on Windows standalone.
Re: Sound latency on Windows standalone
Hm, OK, was worth a try.
Sorry no brilliant ideas in the moment...
Sorry no brilliant ideas in the moment...
Re: Sound latency on Windows standalone
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.
-
- VIP Livecode Opensource Backer
- Posts: 7001
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Sound latency on Windows standalone
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
HyperActive Software | http://www.hyperactivesw.com
Re: Sound latency on Windows standalone
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.
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.
Re: Sound latency on Windows standalone
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.
Re: Sound latency on Windows standalone
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:
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
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
Best wishes.
jeff k