Sound playback driving me crazy...
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Sound playback driving me crazy...
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.
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...
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
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...
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
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
-
- Posts: 111
- Joined: Sun Aug 23, 2009 7:48 am
- Contact:
Re: Sound playback driving me crazy...
I also had the same problem... If I add the files and usesplash21 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
Code: Select all
play specialFolderPath("engine") & "/mysound.aif"
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3
-
- Livecode Opensource Backer
- Posts: 211
- Joined: Sun Oct 24, 2010 12:13 am
Re: Sound playback driving me crazy...
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.hliljegren wrote:I also had the same problem... If I add the files and usesplash21 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
JCeverything 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?Code: Select all
play specialFolderPath("engine") & "/mysound.aif"
Re: Sound playback driving me crazy...
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
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...
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
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...
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
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...
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

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...
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
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...
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
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
-
- Posts: 111
- Joined: Sun Aug 23, 2009 7:48 am
- Contact:
Re: Sound playback driving me crazy...
Hi Todd
then you should be able to
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
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?ctflatt wrote: Instead of issuing a play "/audio/file.mp3" from the substack, it must be play specialFolder("engine") & "/subdirectory/subdirectory/audio/file.mp3"
Code: Select all
set the defaultFolder to specialFolder("engine") & "/subdirectory/subdirectory/"
Code: Select all
play "audio/file.mp3"
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
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3
Re: Sound playback driving me crazy...
Hi Todd,
AHA! Now I get it
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
So using this syntax will surely work:
But why not create a handy command like this that makes scripting easier:
Then just call it with the filename:
...
MYplay "sound.mp3"
...
Know what I mean?
Best
Klaus
AHA! Now I get it

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

So using this syntax will surely work:
Code: Select all
...
play specialFolderPATH("engine") & "/subdirectory/subdirectory/audio/file.mp3"
## The correct term is specialfolderPATH!
...
Code: Select all
command MYplay theFile
play (specialfolderpath("engine") & "/subdirectory/subdirectory/audio/" & theFILE)
end MYplay
...
MYplay "sound.mp3"
...
Know what I mean?
Best
Klaus
Re: Sound playback driving me crazy...
Many thanks, Klaus and Håkan.
I'll be tinkering with this for the next couple of days.
:Todd
I'll be tinkering with this for the next couple of days.
:Todd
-
- Posts: 111
- Joined: Sun Aug 23, 2009 7:48 am
- Contact:
Re: Sound playback driving me crazy...
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 themKlaus 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

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