Sound playback driving me crazy...

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Sound playback driving me crazy...

Post by ctflatt » Tue Dec 21, 2010 3:17 pm

Could someone definitively post info on playing sound files?

I have reviewed the forum posts here and think I have tried them all. NOTHING works for me in the simulator or on the device (iPad).

I even tried the tutorial here, even though it is listed as iPhone-compatible:

http://lessons.runrev.com/spaces/lesson ... he-iPhone-

This seems like a basic task I just cannot seem to get to function.

Thanks, everyone, for your contributions to the forum. They are MUCH appreciated.

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sound playback driving me crazy...

Post by Klaus » Tue Dec 21, 2010 4:16 pm

Hi ctflatt,

I have no problems hearing sound in the simulator!

We need to know:
1. what did you try so far (script!)
2. where are your sounds located
3. what format are your sounds in

Best

Klaus

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Sound playback driving me crazy...

Post by splash21 » Tue Dec 21, 2010 8:59 pm

The beepSound and beep don't seem to work for me, but the play command is working as documented in the simulator, iPhone,iPod and iPad.

1. I created a subfolder called 'Sounds' in the folder containing the liveCode project and put the sound files in there (they are all mp3).
2. Added the subfolder to the project - from the liveCode menu : File -> Standalone application settings -> Copy files -> Add folder.
3. play specialFolderPath("engine") & "/Sounds/sound.mp3"

HTH ;)

JC
LiveCode Development & Training : http://splash21.com

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Sound playback driving me crazy...

Post by hliljegren » Tue Dec 28, 2010 8:25 am

splash21 wrote:The beepSound and beep don't seem to work for me, but the play command is working as documented in the simulator, iPhone,iPod and iPad.

1. I created a subfolder called 'Sounds' in the folder containing the liveCode project and put the sound files in there (they are all mp3).
2. Added the subfolder to the project - from the liveCode menu : File -> Standalone application settings -> Copy files -> Add folder.
3. play specialFolderPath("engine") & "/Sounds/sound.mp3"

HTH ;)

JC
I also had the same problem... If I add the files and use

Code: Select all

play specialFolderPath("engine") & "/mysound.aif"
everything works, but if I add a folder as you have nothing works. I never had time to investigate the problem further though. If I add a folder to the project I supposed that all files in that folder also got added but maybe thats not the case?
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Sound playback driving me crazy...

Post by richardmac » Tue Dec 28, 2010 6:55 pm

hliljegren wrote:
splash21 wrote:The beepSound and beep don't seem to work for me, but the play command is working as documented in the simulator, iPhone,iPod and iPad.

1. I created a subfolder called 'Sounds' in the folder containing the liveCode project and put the sound files in there (they are all mp3).
2. Added the subfolder to the project - from the liveCode menu : File -> Standalone application settings -> Copy files -> Add folder.
3. play specialFolderPath("engine") & "/Sounds/sound.mp3"

HTH ;)

JC
I also had the same problem... If I add the files and use

Code: Select all

play specialFolderPath("engine") & "/mysound.aif"
everything works, but if I add a folder as you have nothing works. I never had time to investigate the problem further though. If I add a folder to the project I supposed that all files in that folder also got added but maybe thats not the case?
Same here. I created a sound in GarageBand, exported out as aif, then used "Import as Control/Audio File" and added the sound to my stack. Then to call the sound on the iPad I used the specialFolderPath specified above and did not insert a folder. Works great.

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sound playback driving me crazy...

Post by Klaus » Wed Dec 29, 2010 1:48 pm

Hi all,

I have no problems playing sounds, even from subfolders.
At least this works for me in the iPad simulator.

Quick guess:
The iOS file system i casesensitive!, did you take that into account?


Best

Klaus

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Sound playback driving me crazy...

Post by ctflatt » Thu Dec 30, 2010 2:25 pm

Everyone:

Thanks for the input.

Due to the holidays I haven't been able to get back to this, but will be exploring further in the coming days.

I like organizing my projects with subfolders, and am not keen on "junking" up the engine directory with sound files, as there will be many for this project.

Thanks to all who have contributed... I'll explore them all.

:Todd

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Sound playback driving me crazy...

Post by ctflatt » Sun Jan 02, 2011 4:47 am

Yeah!

After reviewing these posts and tinkering with my project, sounds are now playing from organized folders in the simulator and on the device.

You guys are great! Thanks for the help.

:Todd

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Sound playback driving me crazy...

Post by ctflatt » Tue Jan 18, 2011 4:04 pm

Update and question... of course :)

After getting sounds to play for a main stack (per this original thread), I have discovered that including this stack as a substack changes the path of the sound for the play command. I did not realize that opening a stack as a substack changes the "engine" folder to that of the parent.

I ended up using Find/Replace to search my scripts to append the path to include the directory structure as a substack, which worked quite nicely.

Is this the expected behavior or a substack? The "engine" originates from the main stack?

Thought I'd share and save someone else from pulling their hair out...

:Todd

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sound playback driving me crazy...

Post by Klaus » Tue Jan 18, 2011 5:11 pm

Hi Todd,

sorry, I don't get this!?
A Substack is also part of the standalone, so "specialfolderpath("engine") should be the same.

And even if you add stacks as separate files to your standalone "specialfolderpath("engine") still
points to the folder where the standalone resides.


Best

Klaus

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Sound playback driving me crazy...

Post by ctflatt » Wed Jan 19, 2011 1:36 am

Klaus:

Sorry. I tried explaining it, but I thought I did a poor job...

mainstack.livecode (saved as mobile standalone)
> subdirectory (contains additional subfolders)
> >subdirectory (contains .livecode stack and support folders)
> > >images
> > >audio
> > >video

The main stack opens a .livecode file two directories down (which becomes a substack).

Audio/video in the substack can only be played if the path is from the mainstack... not relative to the substack itself.

I hope this makes more sense. If not, no worries... I did get it to work, but thought I'd check to see if this was "expected."

Instead of issuing a play "/audio/file.mp3" from the substack, it must be play specialFolder("engine") & "/subdirectory/subdirectory/audio/file.mp3"

Is this any clearer? LOL, now I'm getting confused... :)

:Todd

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Sound playback driving me crazy...

Post by hliljegren » Wed Jan 19, 2011 10:04 am

Hi Todd
ctflatt wrote: Instead of issuing a play "/audio/file.mp3" from the substack, it must be play specialFolder("engine") & "/subdirectory/subdirectory/audio/file.mp3"
play "/audio/file.mp3" will never work as that will reference the root folder for the disk. So it won't work on any platform. Have you tried to set the defaultFolder?

Code: Select all

set the defaultFolder to specialFolder("engine") & "/subdirectory/subdirectory/"
then you should be able to

Code: Select all

play "audio/file.mp3"
Notice that you can't have a leading slash at the beginning of your audio-file reference, as this would (again) reference the disk's root directory.

I do think it is normal behavior that the mainstack is the reference point. I.e. even if you open a substack the defaultFolder will remain pointing to the directory of the mainstack.

:-Håkan
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Sound playback driving me crazy...

Post by Klaus » Wed Jan 19, 2011 12:30 pm

Hi Todd,

AHA! Now I get it :D

I heard from other users that setting "the defaultfolder" does not work reliably on iOS!
I pesonally would never use this anyway since "the defaultfolder" might change when
you least exspect it, just like the variable IT 8)

So using this syntax will surely work:

Code: Select all

...
play specialFolderPATH("engine") & "/subdirectory/subdirectory/audio/file.mp3"
## The correct term is specialfolderPATH!
...
But why not create a handy command like this that makes scripting easier:

Code: Select all

command MYplay theFile
  play (specialfolderpath("engine") & "/subdirectory/subdirectory/audio/" & theFILE)
end MYplay
Then just call it with the filename:
...
MYplay "sound.mp3"
...
Know what I mean?


Best

Klaus

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Sound playback driving me crazy...

Post by ctflatt » Wed Jan 19, 2011 10:12 pm

Many thanks, Klaus and Håkan.

I'll be tinkering with this for the next couple of days.

:Todd

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Sound playback driving me crazy...

Post by hliljegren » Thu Jan 20, 2011 10:52 pm

Klaus wrote:But why not create a handy command like this that makes scripting easier:

Code: Select all

command MYplay theFile
  play (specialfolderpath("engine") & "/subdirectory/subdirectory/audio/" & theFILE)
end MYplay
Good suggestion Klaus! If you are like me, and want to have all definitions placed at the beginning of the file (where I can find them :) ) you can also set up a variable:

Code: Select all

put specialFolderPath("engine") & "/subdirectory/subdirectory/audio/" into audioFolder
...
play (audioFolder & mySound.mp3)
:-Håkan
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

Post Reply