Audio Playback Misery

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Audio Playback Misery

Post by MuzkGuy » Mon Oct 12, 2015 7:36 pm

First of all, I have checked forums all over the net on this issue, read the instructions, and have tried EVERYTHING so far. Here are my specs:
LiveCode Community 7.1.0
Mac OXS 10.9.5

Problem:
Cannot get audio to play at all. The file is 16bit, 44.1K stereo and plays fine using the system or ANY other sound app.

I have tried by accessing via file path and directly importing.

In both examples, I have created a button that SHOULD be playing the audio file...

Filepath attempt: (FYI, the file path is perfect since I used the script to check)
on mouseup
unlock screen
set cursor to busy
#answer file "Choose audio:" commented out now, but used before so as to get file path perfect
#put it commented out now, but used before so as to get file path perfect
play "/Volumes/1TB/LiveCode Stacks/audio_16bit/spotlight_vas_large_sus_lv.01.wav"
answer the result
end mouseup
No sound, no result.

Imported attempt:
on mouseup
unlock screen
set cursor to busy
#answer file "Choose audio:" commented out now, but used before so as to get file path perfect
#put it commented out now, but used before so as to get file path perfect
#play "/Volumes/1TB/LiveCode Stacks/audio_16bit/spotlight_vas_large_sus_lv.01.wav"
play "spotlight_vas_large_sus_lv.01.wav"
answer the result
end mouseup
Again, no sound, no result.

I prefer the file path method since I may develop for mobile, and I understand that imported sounds do not work this way. However, and just FYI, in the project browser in the imported version, I DO see the file. However, it shows the file size as "0". And when I attempt to PLAY the sound from there, nothing happens.

Also, I tried using the system sounds in both cases above and NOTHING. No matter what kind of soundfile, wav, aif, etc. NOTHING works at all. It's as if this engine just won't play a sound at all. VERY discouraging so far. I would have been happy to upgrade to a paid version of this engine, but NO WAY with trouble like this!

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

Re: Audio Playback Misery

Post by Klaus » Mon Oct 12, 2015 10:21 pm

Hi MuzkGuy,

1. welcome to the forum! :D

2. the problem is the old and and outdated "play" command!
It is extremely "picky" and only supports a small amount of file formats,
although a WAV file should play!?

Anyway, since you are on the Mac, you better go with a (hidden) player object!

Create a player object on your card, in the inspector clear the example movies filepath,
hide it, unless you want to display a controller to the user, and set it to your sound filepath.

Can of course also be done via script:
...
set the filename of player "your player here" to "path/to/soundfile.wav"
start player "your player here"
...
Hope that helps!


Best

Klaus

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Mon Oct 12, 2015 10:53 pm

Thank you Klaus,

But I'm told that to develop for mobile devices, players can't be used. I thought about creating a button that would "send" to a hidden player or something like that. Would that work?

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Mon Oct 12, 2015 11:46 pm

So what I'm asking is that if I use a button to "play" the player (named "Player" in this case) would that work with a mobile development? Here is an example script:

on mouseup
set the filename of player "Player" to "/Volumes/1TB/LiveCode Stacks/audio_16bit/spotlight_vas_large_sus_lv.01.wav"
start player "Player"
end mouseup

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Audio Playback Misery

Post by Dixie » Tue Oct 13, 2015 12:06 am

just checked this for desktop with a .wav, aiff and an mp3 file...

Code: Select all

on mouseUp
   answer file ""
   set the filename of player 1 to it
   play player 1
end mouseUp
for mobile on iOS anyway
play soundFile or iphonePlaySoundOnChannel sound, channel, type or build a MoviePlayer controller
read about these in the dictionary...

This example below is using a MoviePlayer controller in an iPhone app...
Attachments
gilmour.jpg

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

Re: Audio Playback Misery

Post by Klaus » Tue Oct 13, 2015 11:40 am

Hi MuzkGuy,
MuzkGuy wrote:But I'm told that to develop for mobile devices, players can't be used.
true, but you did not mention "mobile" in your intitial posting!

What Dixie says! :D


Best

Klaus

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Mon Oct 19, 2015 8:47 pm

Well, I got everything working perfectly. But now, when I go to save as standalone, (OSX - have not even tested Windows yet) the audio is once again simply refusing to work. I made sure to structure the files and folders EXACTLY as the working pre-standalone version. So what's wrong?

The following code works in the pre-standalone, but doesn't in the standalone:

put "Audio/" into audioFolder
set the filename of player "Player" to audioFolder & "Tink.aiff"
start player "Player"

The folder structure in both standalone and pre-standalone is identical. I have searched high and low and can't find a solution as it seems from all instructions this should work.

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Mon Oct 19, 2015 9:41 pm

UPDATE:

I tested the Windows standalone (created at the same time as the OSX) and it works PERFECTLY. HUH??

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

Re: Audio Playback Misery

Post by Klaus » Mon Oct 19, 2015 10:12 pm

Hi MuzkGuy,

"the defaultfolder" is different on Mac and Win!
In a standalone on Windows that is the folder where the EXE resides.
On the Mac it is somewhere deep in the app package. :D

Are you using the standalone builder's "Copy files" card to add your files
and folders to the standalone?

In that case you should use
-> specialfolderpath("resources")
to have crossplatform comaptibilty.

Try this in that case:
...
put specialfolderpath("resources") & "/Audio/Tink.aiff" into audioFile
set the filename of player "Player" to audioFile
start player "Player"
...
Should work on Mac and Win if you use the standalone builder as described above.


Best

Klaus

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Tue Oct 20, 2015 12:02 am

Nope. No luck. I did exactly as you describe, but still nothing. Again, changing the code WORKS in the .livecode file, but NOT in the standalone. I notice that the files were copied into the Windows folder only, and not the Mac OS folder. I then tried it from where the .app was place. Nothing. Moved it all over the place, and no matter what, it still won't work.

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Tue Oct 20, 2015 12:19 am

FYI, I develop on Mac, not Windows. So when I say it's working, I mean it's working on my Mac, but only in the .livecode environment. But as stated before, the standalone does NOT work on the mac, but DOES on Windows.

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Tue Oct 20, 2015 2:08 am

And to add, (not a sound issue) the app icon for mac does not work, but the one for PC does. I'm using proper .icns files for the mac and .ico files for windows as instructed. Why is there such inconsistency?

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

Re: Audio Playback Misery

Post by Klaus » Tue Oct 20, 2015 1:23 pm

Please post your script(s) again!

And make sure to "construct" pathnames with parens () or you may encounter problems!
Not so good:
-> set the filename of player "Player" to audioFolder & "Tink.aiff"

Good:
-> set the filename of player "Player" to (audioFolder & "Tink.aiff")

MuzkGuy
Posts: 10
Joined: Mon Oct 12, 2015 7:19 pm

Re: Audio Playback Misery

Post by MuzkGuy » Tue Oct 20, 2015 4:35 pm

Setting the name using parentheses worked on all fronts. Thank you for that. I do appreciate it. However, I can't find this fact in the documentation or anywhere on the forums. Also, you didn't mention it in your first suggestion.

Here is the original code that did not work in the Mac standalone:
put specialfolderpath("resources") & "/Audio/Tink.aiff" into audioFile
set the filename of player "Player" to audioFolder
start player "Player"

Here is the revised code that worked on all fronts:
put specialfolderpath("resources") & "/Audio/Tink.aiff" into audioFile
set the filename of player "Player" to (audioFolder)
start player "Player"

I used the copy files pane as you suggested. However, the result is a bit puzzling. I see that after I created the standalone that the references audio files (.mp3) were all copied over into the new "Windows" folder, but not the Mac OS folder. Doing some experimenting, I tried removing that folder of audio files completely. The result was that BOTH standalones (Mac and Win) worked fine. Then, I renamed the original folder of audio files (the ones used by the pre-standalone during development) to prevent the standalones from "seeing" it. Again, the standalones worked fine. Do I NEED the folder of audio files? If so, where are the standalones looking for playback after I removed the new folder of audio files? Obviously, I can test this by trying on another machine, but I don't have any available immediately.

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

Re: Audio Playback Misery

Post by Klaus » Tue Oct 20, 2015 5:07 pm

Hi MuzkGuy,
MuzkGuy wrote:Setting the name using parentheses worked on all fronts. Thank you for that. I do appreciate it. However, I can't find this fact in the documentation or anywhere on the forums. Also, you didn't mention it in your first suggestion.

Here is the original code that did not work in the Mac standalone:
put specialfolderpath("resources") & "/Audio/Tink.aiff" into audioFile
set the filename of player "Player" to audioFile
start player "Player"
Here I create a complete pathname and supply a "ready made" variable to the filename, no parens neccessary!
In this example thery are mandatory:
...
set the filename of player "Player" to (specialfolderpath("resources") & "/Audio/Tink.aiff")
## See the difference?
...
MuzkGuy wrote: Here is the revised code that worked on all fronts:
put specialfolderpath("resources") & "/Audio/Tink.aiff" into audioFile
set the filename of player "Player" to (audioFile)
start player "Player"
The parens do not make any sense here and the script should really work without them!
MuzkGuy wrote:I used the copy files pane as you suggested. However, the result is a bit puzzling. I see that after I created the standalone that the references audio files (.mp3) were all copied over into the new "Windows" folder, but not the Mac OS folder. Doing some experimenting, I tried removing that folder of audio files completely. The result was that BOTH standalones (Mac and Win) worked fine. Then, I renamed the original folder of audio files (the ones used by the pre-standalone during development) to prevent the standalones from "seeing" it. Again, the standalones worked fine. Do I NEED the folder of audio files? If so, where are the standalones looking for playback after I removed the new folder of audio files? Obviously, I can test this by trying on another machine, but I don't have any available immediately.
Yo do not need any subfolder for your media at all, but looks cleaner when you do :D
If you use -> specialfolderpath("resources") everything should work fine, with or without subfolders!

But obviously the "anatomy" of an OS X application package is new to you?
Richt-Click your OS X standalone and select "Show contents" in the popup menu, then you will
see where all your files and folder have gone :D

And the standalones look for files of any kind where you point them to! 8)


Best

Klaus

Post Reply