SDL audio and iPhone/iPad, F32 vs S16LSB

Hi,
I got audio working with float32 format in the ipad simulator and on
MacOSX, but when running on an actual iPad2 device I hear nothing. When
running the mixer demo on the iPad device I do hear audio. The difference
I can see between my app and the mixer demo is that mixer demo is running
as S16LSB format while my app is running as F32 audio format… If I
switch my app to S16LSB then I hear noise out the iPad device (I haven’t
implemented conversion from float to short yet, so it is pretty awful
sounding at the moment).

Is float 32 not supported on actual devices? It works well on the
simulator and on MacOSX…

Thanks for any advice, google didn’t turn up any hints for me,
KevinSent from my Windows Phone

In every audio app I have written, using every library (including SDL
a long time ago) there is a difference between simulator and device
performance. I think I had to tweak window size for some of them
(something SDL handles behind the scenes perhaps?), and sampling rate
for others. I’d recommend trying to output a pure sine at 440hz or
something recognizable and play with the various characteristics. In
my non SDL audio apps I have used 32 bit floating point samples on the
device successfully.

Wish I could more specifically address your problem, good luck!
Jeremy J.On Fri, Nov 29, 2013 at 3:58 AM, kevin meinert <kevin.meinert at gmail.com> wrote:

Hi,
I got audio working with float32 format in the ipad simulator and on MacOSX,
but when running on an actual iPad2 device I hear nothing. When running the
mixer demo on the iPad device I do hear audio. The difference I can see
between my app and the mixer demo is that mixer demo is running as S16LSB
format while my app is running as F32 audio format… If I switch my app to
S16LSB then I hear noise out the iPad device (I haven’t implemented
conversion from float to short yet, so it is pretty awful sounding at the
moment).

Is float 32 not supported on actual devices? It works well on the simulator
and on MacOSX…

Thanks for any advice, google didn’t turn up any hints for me,
Kevin

Sent from my Windows Phone


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Using AUDIO_S16LSB format, I got audio working in both iPad simulator, and
on iPad device using bluetooth audio (Jambox speaker)…
But when I unpair the Jambox, I do not hear audio from the iPad speaker!

I have killed the app, restarted the iPad, verified no bluetooth connected,
verified that iTunes plays music, restarted the app, still silent…
enumerating the devices all I have is:

  • Audio device 0: System audio output device

code:
if (0 != SDL_InitSubSystem( SDL_INIT_AUDIO ))
{
printf( “couldn’t SDL_InitSubSystem( SDL_INIT_AUDIO )\n” );
exit(-1);
}

  printf( "SDLAudioInterface: Initializing SDL Audio...\n" );
  int count = SDL_GetNumAudioDevices(0);
  for (int i = 0; i < count; ++i)
  {
     printf( "Audio device %d: %s\n", i, SDL_GetAudioDeviceName(i, 0) );
  }
  SDL_zero(want);
  want.freq = 44100;
  want.format = AUDIO_S16LSB;
  want.samples = 256;
  want.channels = 2;
  want.callback = SDL_AudioCallback;
  want.userdata = (void*)this;

  dev = SDL_OpenAudioDevice(NULL, 0, &want, &have,

SDL_AUDIO_ALLOW_FORMAT_CHANGE);
if (dev == 0) {
printf(“Failed to open audio: %s\n”, SDL_GetError());
exit(0);
} else {
if (have.format != want.format) // we let this one thing change.
printf(“We didn’t get the requested audio format.\n”);
SDL_PauseAudioDevice(dev, 0); // start audio playing.
}On Fri, Nov 29, 2013 at 9:14 AM, Jeremy Jurksztowicz <jurksztowicz at gmail.com wrote:

In every audio app I have written, using every library (including SDL
a long time ago) there is a difference between simulator and device
performance. I think I had to tweak window size for some of them
(something SDL handles behind the scenes perhaps?), and sampling rate
for others. I’d recommend trying to output a pure sine at 440hz or
something recognizable and play with the various characteristics. In
my non SDL audio apps I have used 32 bit floating point samples on the
device successfully.

Wish I could more specifically address your problem, good luck!
Jeremy J.

On Fri, Nov 29, 2013 at 3:58 AM, kevin meinert <@kevin_meinert1> wrote:

Hi,
I got audio working with float32 format in the ipad simulator and on
MacOSX,
but when running on an actual iPad2 device I hear nothing. When running
the
mixer demo on the iPad device I do hear audio. The difference I can see
between my app and the mixer demo is that mixer demo is running as S16LSB
format while my app is running as F32 audio format… If I switch my
app to
S16LSB then I hear noise out the iPad device (I haven’t implemented
conversion from float to short yet, so it is pretty awful sounding at the
moment).

Is float 32 not supported on actual devices? It works well on the
simulator
and on MacOSX…

Thanks for any advice, google didn’t turn up any hints for me,
Kevin

Sent from my Windows Phone


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL mixer app works fine on iPad device w/ internal speaker, or bluetooth
speaker… looking to see what could be different between my app and the
mixer demo app… when I send a sin wave in my app, it works… so
clearly i have some problem in my app… will post back if i find what it
was in case it helps someone else…

Through a little rearranging, I got the audio working on the iPad internal
speaker…
Not entirely sure why it worked on the bluetooth audio and not the speaker
before, but here is the diff.
I used to do the mix in int16_t… but now im mixing in float32, then final
convert to int16_t.

// iPad speaker & bluetooth audio works
for (int i = 0; i < framesPerBuffer; ++i)
{
float o1 = 0.0f, o2 = 0.0f;
for (size_t t = 0; t < num_tracks; ++t)
{
itrack[t].inc();
o1 += (itrack[t])[0]; / left */
o2 += (itrack[t])[1]; / right */
}
short so1 = (short)floorf(o1 * 32767.0f);
short so2 = (short)floorf(o2 * 32767.0f);
*out++ = so1;
*out++ = so2;
}

// iPad speaker silent but iPad connected to bluetooth Jambox works
for (int i = 0; i < framesPerBuffer; ++i)
{
out++ = 0;
short
o1 = out;
out++ = 0;
short
o2 = out;
for (size_t t = 0; t < num_tracks; ++t)
{
itrack[t].inc();
short b1 = (short)floorf((*itrack[t])[0] * 32767.0f);
short b2 = (short)floorf((*itrack[t])[1] * 32767.0f);
o1 += b1; / left */
o2 += b2; / right */
}
}On Fri, Nov 29, 2013 at 2:10 PM, kevin meinert <@kevin_meinert1>wrote:

SDL mixer app works fine on iPad device w/ internal speaker, or bluetooth
speaker… looking to see what could be different between my app and the
mixer demo app… when I send a sin wave in my app, it works… so
clearly i have some problem in my app… will post back if i find what it
was in case it helps someone else…