audio capabilities s*

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
rinzwind
Posts: 131
Joined: Tue May 01, 2012 10:44 am

audio capabilities s*

Post by rinzwind » Wed Sep 09, 2015 10:30 am

at least at the desktop...
You cant play more than one sound at the same time. I read that even HyperCard has a nice soundchannel thingy...
Using quicktime players is no solution for things like games or quick sound effects. I tried it with 4 invisible players and setting the currentTime to 0 when replaying the same sound. It makes a nasty visible lag in the animation loop (while repeating the same short sound time mulitple times).

Used some modified cross platform playsound function I came across (why would I even need to do that.. LiveCode should take care of something basic as playing sound x on channel y with volume z)

And while I'm at it.. the play command also is quit picky. Even on .wav files. It has to be 16 bit. Higher gives noise (too low playback rate).

Code: Select all

command playSound psound, pchannel, pvolume, ptype
   local tpath
   
   if pchannel is empty then
      put "c1" into pchannel
   end if
   if pvolume is empty then
      put 100 into pvolume
   end if
   if the environment is not "mobile" then
      set the playLoudness of player pchannel to pvolume
      if ptype is "looping" then
         set the looping of player pchannel to true
      else
         set the looping of player pchannel to false
      end if
      put AppData & "/audio/" & psound into tpath
      if the fileName of player pchannel is not tpath then
         stop player pchannel
         set the currentTime of player pchannel to 0
         set the fileName of player pchannel to tpath
         start player pchannel
      else
         set the currentTime of player pchannel to 0
         start player pchannel
      end if
      return true
   end if
   if ptype is empty then
      if mobileSoundChannelStatus(pchannel) is "playing" then
         mobileStopPlayingOnChannel pchannel
      end if
      mobileSetSoundChannelVolume pchannel, pvolume
      put "now" into ptype
   end if
   put AppData & "/audio/" & psound into tpath
   mobilePlaySoundOnChannel tpath, pchannel, ptype
end playSound

rinzwind
Posts: 131
Joined: Tue May 01, 2012 10:44 am

Re: audio capabilities s*

Post by rinzwind » Wed Sep 09, 2015 11:14 am

Well for lack of a better solution I added an
if pchannel is "c1" then
play audioClip tpath
return true
end if

play does have no problem with rapid repeats (but has other like no channel support and very picky on sound format)

Post Reply

Return to “Feature Requests”