• 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
AVAudioPlayer: Second instance of same sound...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AVAudioPlayer: Second instance of same sound...


  • Subject: AVAudioPlayer: Second instance of same sound...
  • From: uɐıʇəqɐz pnoqɥɒɯ <email@hidden>
  • Date: Mon, 16 Nov 2009 22:54:01 -0800

Hi. This is an iPhone question. I am wondering if AVAudioPlayer cache's sound files such that the loading of the second instance of the same sound file doesn't take up additional memory.

In other words:

if fileURL points to a 15 megabyte sound file, and you call

newPlayer1 = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
newPlayer2 = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];


would the second call consume the same amount of memory as the first one? Or will the second call's memory usage be limited to just a few dozen or less bytes?

What Am I Really Trying To Do?

I have many sound files, each about 500K that I play, sometimes playing the same sound, two or more times in an overlapping fashion. In order to play the same sound overlapped, I have to load that sound twice in order to give each an independent -play. This all works great.

In order to make the creation of these 400+ sounds a bit easier, I would like to combine them and group them into single sound files with 50 sounds in each (18-20MB per file), and then before I call -play, I specify an offset to start playing at, and cut off the playback after a delay. I am currently making the changes and realized that I will have to handle the case that two sounds from the same file will play concurrently, much more often. In fact, I could easily have 4, 5 or more sounds from the same file playing simultaneously. That means I would have to call -initWithContentsOfURL multiple times in order to play a second, third, fourth... sound from that file. If each instance of this sound file takes up 18-20 MB, then my iPhone app is going have serious problems after the second instance.

Alternatively, I can write a separate Mac application that opens up each of my larger combined files, and reads out the sounds at each offset and saves them to smaller files, as I am currently using, except, of course, I am sure it is not as easy as just opening a file, moving to a location x seconds times sample rate in, grab y seconds of data, and write it out, and have a valid sound file. Is there already a utility such as afconvert that can do this for me?

Thank you in advance for any thoughts and advice!

-mahboud

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: AVAudioPlayer: Second instance of same sound...
      • From: William Stewart <email@hidden>
  • Prev by Date: Re: AU Presets for multiple plugins
  • Next by Date: Re: AU Presets for multiple plugins
  • Previous by thread: Re: Accessing audio samples from Audio Queue Buffers
  • Next by thread: Re: AVAudioPlayer: Second instance of same sound...
  • Index(es):
    • Date
    • Thread