Page 1 of 6

Sound playback driving me crazy...

Posted: Tue Dec 21, 2010 3:17 pm
by ctflatt
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.

Re: Sound playback driving me crazy...

Posted: Tue Dec 21, 2010 4:16 pm
by Klaus
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

Re: Sound playback driving me crazy...

Posted: Tue Dec 21, 2010 8:59 pm
by splash21
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

Re: Sound playback driving me crazy...

Posted: Tue Dec 28, 2010 8:25 am
by hliljegren
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?

Re: Sound playback driving me crazy...

Posted: Tue Dec 28, 2010 6:55 pm
by richardmac
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.

Re: Sound playback driving me crazy...

Posted: Wed Dec 29, 2010 1:48 pm
by Klaus
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

Re: Sound playback driving me crazy...

Posted: Thu Dec 30, 2010 2:25 pm
by ctflatt
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

Re: Sound playback driving me crazy...

Posted: Sun Jan 02, 2011 4:47 am
by ctflatt
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

Re: Sound playback driving me crazy...

Posted: Tue Jan 18, 2011 4:04 pm
by ctflatt
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

Re: Sound playback driving me crazy...

Posted: Tue Jan 18, 2011 5:11 pm
by Klaus
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

Re: Sound playback driving me crazy...

Posted: Wed Jan 19, 2011 1:36 am
by ctflatt
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

Re: Sound playback driving me crazy...

Posted: Wed Jan 19, 2011 10:04 am
by hliljegren
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

Re: Sound playback driving me crazy...

Posted: Wed Jan 19, 2011 12:30 pm
by Klaus
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

Re: Sound playback driving me crazy...

Posted: Wed Jan 19, 2011 10:12 pm
by ctflatt
Many thanks, Klaus and Håkan.

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

:Todd

Re: Sound playback driving me crazy...

Posted: Thu Jan 20, 2011 10:52 pm
by hliljegren
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