getting a background hiss when playing audio with audio.play() ?

Trying to do a fun little dog whistle app on iOS.

Testing with an iPhone 3Gs

When playing a high frequency wav (19KHz) I’m getting a hiss instead of silence.

Alternatively if I email this to my iPhone, it plays silently as it should.

Any ideas ?

I’ve set config.lua with audioPlayFrequency = 44100

[import]uid: 97524 topic_id: 26237 reply_id: 326237[/import]

Could some kind person tell me I’m not going mad and build my example code below, to test this sample ?

sample lasts 10 secs, and is looped

set your phone volume at 90% ish - you should hear NO HISS, just silence

Here’s a project you can buold and run:
www.drivelink.com/media/test.zip

Here’s the wav on it’s own:
www.drivelink.com/media/test.wav

NB: I’m using Corona build 2011.704 and the hiss does not happen in the simulator, or when I email the sample to my phone [import]uid: 97524 topic_id: 26237 reply_id: 106407[/import]

I tested it for you and the solution is simple.

For wav files you must save them as 16bit float, you had yours at 32 bit.

Programs like audacity (free) make things like this simple.

Take a look here also: http://developer.anscamobile.com/content/audio-and-video [import]uid: 84637 topic_id: 26237 reply_id: 106544[/import]

The option is “Set sample format” > 16bit pcm

[import]uid: 84637 topic_id: 26237 reply_id: 106548[/import]

Danny

Firstly, thanks for looking at this.

Secondly, I installed Audacity, and saved the wav as a 16bit PCM, is that the same thing as “16 bit float” ?

It made no difference - this hiss was still there?

I’m guessing my wav may be being downsampled to 22050, which would result in the strange noise I’m getting?

[import]uid: 97524 topic_id: 26237 reply_id: 106547[/import]

Yes, I’m now doing that, but no difference ?

Track > Add New > Audio Track
Set Sample Rate > 16 bit PCM
Set Rate > 44100

I’ve upload the new sample here:
http://www.drivelink.com/media/19K_44100_16bitPCM.wav

[import]uid: 97524 topic_id: 26237 reply_id: 106551[/import]

Danny, any more updates ?

Just keen to know if it’s me using the wrong wav file or is it something else ? Like I say I still get the weird noise (try turning up to max volume)

Like I say, I think it may be down-sampling the wav to 22050 ?

At this point i’ve tried .aiff, mp3, wav all doing the same. It may be my iPhone 3Gs but its all I have to test with ?
[import]uid: 97524 topic_id: 26237 reply_id: 106761[/import]

I don’t have a iphone 3g to test on (i tested on iphone 4s). here is the file i used for testing and heard no hissing: http://www.infuseddreams.com/tempFiles/test.wav [import]uid: 84637 topic_id: 26237 reply_id: 106833[/import]

Yeah, your sample wav is hissing away as well.

Puzzling. Corona causes a hiss, but playing it elsewhere on the phone (eg. email) produces no hiss at all ?

Do you know anyone who could give you an iPhone 3x to test on? eg. mine’s a 3GS

[import]uid: 97524 topic_id: 26237 reply_id: 106843[/import]

You should be using 16-bit signed integer little-endian for .wav. (Not float.)
[import]uid: 7563 topic_id: 26237 reply_id: 106870[/import]

Yeah I used Dan’s own wav and still got the weird noise instead of silence. It seems it’s corona related as I can play the same wav from say my iPhone 3Gs email attachment, and it plays silently as it should?

Can someone at corona test this on a 3Gs?
[import]uid: 97524 topic_id: 26237 reply_id: 106889[/import]

We are only supporting iOS 4.3+ right now. The reason isn’t arbitrary. Apple has lots of bugs they fixed from prior OS versions.

[import]uid: 7563 topic_id: 26237 reply_id: 106909[/import]

Ewing my iPhone 3GS is running ios5 [import]uid: 97524 topic_id: 26237 reply_id: 106915[/import]

Okay, I misunderstood 3G vs 3GS.

I am also misunderstanding your recording sample rate. Is your recording of a 19kHz tone, or is your recording sampling rate done at 19kHz? If the latter, we do not officially support that value. Please use 11025Hz, 22050Hz, or 44100Hz.
[import]uid: 7563 topic_id: 26237 reply_id: 106919[/import]

Hi Ewing

To clarify, I’m trying to play a 19,000 Hz tone (hint: use audacity > generate tone to create one)

Sample rate is 44100
Mono
16 bit PCM

It should be completely inaudible, however:

when played as a corona app on my 3GS, it’s audible and shouldn’t be
When played on simulator it’s inaudible
When played from my 3GS’s email client, it’s inaudible

I’ve tried wav , mp3, aiff
I.ve tried event sound system, and audio.play

I.m going to try game salad next and see if that plays like it should, just as a test

[import]uid: 97524 topic_id: 26237 reply_id: 106921[/import]

The Mac Simulator and iOS go through the same Core Audio decoding APIs.
If different iOS devices behave differently, I expect that this is due to hardware and driver differences. Most standard audio equipment cannot handle frequencies outside the normal hearing range (normal hearing range is less that theoretical hearing range) and they degrade differently. I would not be surprised if this is what the 3GS does at too high frequencies.

I tested your app on an iPad 3. I can’t hear anything. [import]uid: 7563 topic_id: 26237 reply_id: 106929[/import]

Would this explain why the sound plays silently from the email attachment on the 3GS

Yet is noisy when played by the corona app on the 3GS?

In the corona audio docs there’s an interesting caveat in that playAudioFrequency = 44100 , is merely a suggestion to the underlying hardware. I’ve got a feeling the 3GS is down sampling to 22050 which would explain why it’s audible when it shouldn’t be audible?

Is this possible? [import]uid: 97524 topic_id: 26237 reply_id: 106996[/import]

But, would this explain why the sound plays silently from the email attachment on the 3GS
Yet is noisy when played by the corona app on the 3GS?

In the corona audio docs there’s an interesting caveat in that playAudioFrequency = 44100 , is merely a suggestion to the underlying hardware. I’ve got a feeling the 3GS is down sampling to 22050 which would explain why it’s audible when it shouldn’t be audible?

Is this possible? [import]uid: 97524 topic_id: 26237 reply_id: 106997[/import]

Update:

Tested on iphone4s and iPad. Sound sample plays silently as it should

I think the wav is being down sampled (by corona?) to 22050 on 3Gs causing it to go from silent to audible [import]uid: 97524 topic_id: 26237 reply_id: 107646[/import]

I don’t think I’m downsampling, though if you want to audit the code, ALmixer is open source and the Core Audio decoding I backported/contributed to SDL_sound.

I suspect this is simply the device not being able to handle this range. Try plugging in some really good headphones into your device. You might get different results. Apple also has half-a-dozen different audio frameworks so the one they might be using for email may be doing something special.
[import]uid: 7563 topic_id: 26237 reply_id: 107678[/import]