What are the best recommendations for Audio Quality?

Hello!

I am creating my very first game - so please forgive me if I am asking something obvious.

I decided to record my own sound using Audacity since I just need simple noises I can make with various objects.  These sound great when I play them in Audacity.  They also sound great in Corona Simulator.  However, on my mobile, I get occasional cracking.  Sometimes the sound is OK and sometimes it cracks.

After some research, I’ve read a few posts that say this might be due to audio sample rate.  Right now, my files are using Audacity’s default 44100 Hz.  The posts recommend lowering down to 22050 Hz.  Problem is, when I try this with my files, sounds become so malformed that they are hardly recognizable.  

So I can’t use high sample rate because it makes sound crackle on my mobile device and I can’t lower sample rate because it basically destroys the sound.

Any recommendations?

Thanks!

https://docs.coronalabs.com/guide/media/audioSystem/index.html

Are you sure the sound isn’t crackling because of the device’s speaker and/or the sound levels? Most phone speakers are quite poor quality and too high or low sounds are simply ignored or they become malformed.

Crackling is typically too loud sounds being playing. Depending on your phone lowering the volume might not fix this - without going into the technical details of digital audio and headroom.

Try lowering the volume 6 to 9 dB or so in Audacity for each sound file, and see if that makes a difference.

Thank you for your suggestions - but this is still a mystery.  Over the past 2 evenings I’ve tried so many things.  I figured out how to reduce my file to 22050 Hz, made sure it is 16 bit, significantly lowered volume both via Audacity and in code, converted from Stereo to Mono, set audioPlayFrequency in config.lua and various other options I could think of.

I even tried playing my wav files via Corona’s AudioPlayer sample App and I see the same issue with my files there.  When played in loop, they would play many times correctly (say 20 or 30) and then have this crackling/static noise at some point, and then go back to playing correctly and so on.  And this only happens on my mobile.  This is all good in Corona Simulator on my computer.  Note that other files, including those in AudioPlayer sound just fine on my mobile device so it has no issues with anything but these wavs of mine that I’m trying to use.

Sure, I can also try to re-record and try again.  But it’s a bit of a mystery!

Could it be your phone is just too old/weak and not coping with the audio playback?  Do you have another device to test on (like a friend’s)?

OpenAL is known to do “best effort” approaches, meaning “if it’s possible to play the audio, we’ll try to do this as correctly as possible”. No guarantees, and depending on what else is going on on your phone it might drop the audio or stream intermittently.

Or is your device recent?

My mobile is pretty recent. It is Samsung Galaxy Note9.

My next thought is to try recording my sound at the lower rate to begin with, so that I don’t need to convert anything.

That’s recent enough.

  1. How long are the audio files?

  2. Is this using live build or really building and installing on your device?

Audio files are 0.5s long.  And I am really building and installing.  (Didn’t know about live builds until I read about them just now - pretty cool capability!)

.5s long? That’s really short. Typically you lose the first 0.1s or 0.05s - perhaps this causes problems.

Are you using loadSound or loadStream?

Either way, I think you have an exceptional bug on your device. Try building for another device to see if that fixes things or not.

the important diagnostic is that 1) AudioPlayer plays its own samples fine, 2) AudioPlayer plays your samples with error - on same device.

that rules out the device itself.  also rules out any diffs between loadSound/Stream.

all it really leaves is some internal problem with your samples.  it’s probably not sample rate (fyi, most devices are 44.1k internally, and will convert on load - and you’d have to have a really dumb device to fail at converting 22.05k to 44.1k).

what it could be is some particular codec that isn’t well-supported by your device so that the decode-on-load is failing.  you never say what format (wav, mp3, ogg, etc) you’re using, nor what codec within that format, nor what “bit rate”/“quality level”/“standards level” within the codec, etc…*

suggest you try uncompressed signed 16-bit PCM .wav (at 44.1k, mono) as a “baseline” and see what happens.  if THAT plays correctly on device, then would strongly suggest a format/codec decoding problem.

* because you can do really wacky stuff, like putting mp3 encoding inside a wav container, which a device might legitimately have trouble with, yet your full-fledged desktop might somehow manage to successfully decode it in the simulator

I can say that different sounds sound differently on each model. You should test it yourself. Mobile speakers do not reproduce sound well and become clogged with dust over time.

I did a fast-test of my application on 5 devices (3 phones and 2 tablets) and I can say that only one phone reproduced sound equivalent to a simulator (HTS one m9 with an audio chip and a stero-speakers). I don’t know how things are on models newer than 2016, but I think only flagships provide quality of sound.

Sounds will be better on headphones, and this may be a reason to make 2 audio schemes - rough for loudspeakers and soft for headphones.

For myself, I realized that the sounds should match the gameplay. I have an intense action and I record simple sounds from tough/firm objects for 0.1-0.3 seconds, excluding bass and booming sounds (din from the dishes is almost impossible to play).

P.S. And the better result is when you have loud sound and you lower its volume. Increasing volume via editor will always make additional noise. Making a clear loud sound is a task - room with no extraneous noise, sensitive microphone and soundcard, etc. I don’t have this, so I’m just tying to make a load sound as much as my mic could take it without… “chokes”.