Re: AVAudioPlayer: Second instance of same sound...
Re: AVAudioPlayer: Second instance of same sound...
- Subject: Re: AVAudioPlayer: Second instance of same sound...
- From: William Stewart <email@hidden>
- Date: Tue, 17 Nov 2009 13:14:25 -0800
We don't do a couple of things here.
(1) There is no common code in AVAP that would look to see if we
already have that file loaded, and then load it again
(2) AVAP does NOT load the entire contents of the file into memory.
Rather it establishes a set of buffers (small) for reading data from
the disk, and as you play it back, it reads data just ahead of where
you are playing. This overhead is the same for every AVAP object you
create. You can seek around a file that you have opened, so you could
certainly do that (have a large file and play segments from it)
On Nov 16, 2009, at 10:54 PM, uɐıʇəqɐz pnoqɥɒɯ wrote:
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
_______________________________________________
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