AudioClip Distortion

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

Post Reply
Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm
Location: Heidelberg, Germany

AudioClip Distortion

Post by Gage » Sat Feb 06, 2016 6:44 pm

Hello friends,

I am trying to figure out how to put sound clips into an app, which is ultimately destined for Android and iOS. I've seen some forum posts, and tutorials.

Right now, I'm only getting through the development environment portion of it, and already having a problem that seems really prohibitive.

I created some simple sounds using Ableton Live (professional music mixing program), and exported the sound clips I want as .wav files.

I sent the files over to myself via email (I did compress the folder they were in as .zip, in case this may be an issue, but I doubt it is, reason given shortly).

I saved my files and noted the correct filepath to one of the sounds to test. (now uncompressed, obviously).

I tested the uncompressed files out in Preview (since I use a Mac), and they sound perfect, both in tone and quality! *This is why I doubt the previous compression is the cause of the issue...*

I made a test button in my app and used this script:
play audioClip "/Users/philengland/Documents/App Inspired/Apps/LiveCode Apps/Swift Swipe/Audio Files/Grand Piano G#4.wav"

Now, when I press that button, I hear a horrifying, screechy foghorn version of the sound I am referencing. Obviously, the file is being accessed somehow, since it's indeed a zombie of my beautiful sound and not some other random garbage data of some sort, but the distortion is ear-shattering. What could be wrong? Why is LiveCode butchering the sound and how can I prevent said tonal slaughter?

Thanks in advance!
Phil E.

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm
Location: Heidelberg, Germany

Re: AudioClip Distortion

Post by Gage » Sat Feb 06, 2016 6:52 pm

Follow-up:

I did use a Player object and placed the same filepath into it, and it sounds perfect again...

So I guess my previous questions can be made obsolete if I can figure out a better methodology for this.

Here's what I'm about to try:

- Have a hidden Player object on the card
- Change its filepath to whichever sound clip I want to play through script
- All sound clip files will be contained in a Folder that I have in the Copy Files when I deploy the app
- Play the selected sound using the aforementioned Player object

If anyone has input on my thinking, whether affirmative or negative, I will be hoping to hear it. Just wanted to share my method and see if someone can tell if I'm headed down an optimal path.

Thanks!
Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: AudioClip Distortion

Post by Simon » Sat Feb 06, 2016 11:51 pm

Hi Phil,
I use mobilePlaySoundOnChannel for mobile devices. It's a bit more complicated but it has the word "mobile" in it so I figure that's the one to use.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm
Location: Heidelberg, Germany

Re: AudioClip Distortion

Post by Gage » Sun Feb 07, 2016 2:22 am

Simon,

Thanks for your reply! Right now, I have alternating scripts.

For development, I am using the method I laid out previously, and I have it using the mobilePlaySoundOnChannel call for mobile. I have not yet tested on mobile, though.

However, I have an object that is being moved around on the screen, and when the sound starts, the object doesn't move smoothly. I assume this is due to LiveCode backend processes... does anyone know if there is a way to keep the visuals looking smooth while activating a sound in the middle of an existing move command being carried out?

Thanks,
Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: AudioClip Distortion

Post by Simon » Sun Feb 07, 2016 2:59 am

Hi Phil,
I've just checked my "pong" game for mobile and I did end up using "play", I see I commented out all my mobilePlaySoundOnChannel.
I also see that I dumped each sound file into separate global variables. With the pong game the sounds were short so they didn't take up too much memory. This removes any delay caused by the sound loading.

I suppose if they were longer sounds you could just use two variables that you load you sound just prior to needing it.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm
Location: Heidelberg, Germany

Re: AudioClip Distortion

Post by Gage » Sun Feb 07, 2016 3:45 am

Simon,

I could look into doing that... right now the folder containing my sounds is in the Copy Files in Standalone Settings. Would moving them into globals reduce buffering time or something?

I have 4 instruments with 8 notes each, with each note being about 2s long. Each file is about 329 kb.

I'm not a total wizard when it comes to understand background buffering and RAM and protocols like that, so optimizing things is a headache for me.

Thanks for helping me on this.

Phil E.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: AudioClip Distortion

Post by Simon » Sun Feb 07, 2016 4:04 am

Hi Phil,
That comes to around 10 Mb so probably it would fit well in modern mobiles. If there is a way to reduce it I'd take the time to do that.
Say as they select a certain instrument you just load the 8 tones. But in the end you use it like a sequencer you'd have to load them all.

Yes, the idea is to speed up the playing so you don't have to go to a folder to load the sounds. You'd still keep the files in the Copy Files tab and load them into the variables on say openCard or something.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”