• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convert to float and more
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert to float and more


  • Subject: Re: Convert to float and more
  • From: Jeff Moore <email@hidden>
  • Date: Wed, 4 Jun 2003 11:42:10 -0700

On Wednesday, June 4, 2003, at 01:46 AM, Mark's Studio wrote:

Hi

I have a few questions.

Im working on a Cocoa sound editing app.

When i import a file i just copy the sound bytes into a NSData and keep
it in the original format.

Ack! This is going to be awfully slow for files that have any significant length to them. You really ought to consider buffering the data on and off the disk as needed, rather than trying to stuff everything into memory at once.

In general it is a bad idea to use the VM system as a way to stream audio to and from the disk. You get much better results if you use the non-cached low level file IO operations. On machines with little physical RAM the performance difference can be quite large in fact.

All my drawing and DSP code use floats, so if the original sound format
is 16bit i do a lot of sample/32768.

I was thinking of converting the samples to float when importing the
file, but that will double the data size, so i still need to decide
what's best.

I tried to search the archives for the fastest way to convert from int
to float and back. but did not find much,
someone mentioned there might be a altivec snippet for converting?

I also looked at CASampleTools.cpp ( but to be honest i don't
understand C++).

Don't use that code. It's about as bad as you can get. I should know, I wrote it =)

Instead, you should use the blitters in the AudioConverter.

When i play a file through the defaultAudioOutput, and the stream
format is not float, is there another conversion to float within
coreaudio?

The Output Audio Units have an AudioConverter embedded in them. All you need to do is to is specify what your input format is, and the Output AU will massage that into what the hardware is looking for. There is sample code in /Developer/Examples/CoreAudio that show how this works.

I also want to import/export MP3 and other compressed formats what is
the best way to do that?

The system doesn't ship with an MP3 encoder that is programmatically accessible, so you're kind of on your own. For decoding, you can use QuickTime until codecs are better supported directly by the AudioConverter API.

--

Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Convert to float and more
      • From: "Mark's Studio" <email@hidden>
References: 
 >Convert to float and more (From: "Mark's Studio" <email@hidden>)

  • Prev by Date: Re: USB Audio issue
  • Next by Date: Re: Changing the system volume?
  • Previous by thread: Re: Convert to float and more
  • Next by thread: Re: Convert to float and more
  • Index(es):
    • Date
    • Thread