Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
- Subject: Re: Using AVPlayer to play MPMediaItem and add iPod EQ to the output
- From: Kevin Dixon <email@hidden>
- Date: Tue, 31 Jul 2012 10:48:26 -0700
I am working on an AVAssetReader based application. I have a producer
thread which reads AVAssetReader and places the output bytes in a
TPCircularBuffer (https://github.com/michaeltyson/TPCircularBuffer).
When I read no bytes from copyNextBuffer, and the status is
AVAssetReaderStatusCompleted, then I open the next MPMediaItem in the
playlist, and place the next buffer I get immediately after the last
one.
This works well enough, but I've noticed that some tracks that play as
gapless under the main iOS Music App, or even in Winamp do not come
out gapless through this API. The decoded MP3s (from AVAssetReader)
may have 500-2000 samples of silence at the beginning or end, so I'm
curious about this as well.
This seems endemic of MP3 decoders in general -- Audacity and Adobe
Audition both decode different amounts of silence at the beginning and
end of MP3s (only tools I've tested with so far).
Any one have guidelines on how to deal with this? Either by reading
the MPMediaItem properties, or simply removing samples = 0?
Thanks
-Kevin
On Tue, Jul 31, 2012 at 2:23 AM, Fedry Kemilau <email@hidden> wrote:
> Thank you all for the help. :)
>
> After playing around with AVAssetReader & Audio Unit, now I am able to play MPMediaItem and add the presets iPod EQ to the output.
>
> I have another question regarding gapless playback.
> From the raw data retrieved using AVAssetReader, how do we detect if a song is set as gapless?
> How can I play gapless songs without any delay when continue from one to another?
> Maybe there is part of data that I should strip off from the beginning and the end of the raw data.
>
>
> On 21 Jul, 2012, at 11:21 AM, Bill Phillips <email@hidden> wrote:
>
> Not only is AVAssetReader the only option for the task you have in
> mind, but I have myself written the back end for an app with exactly
> the specifications you describe! :)
>
> You are right that AVAssetReader itself does not provide seeking.
> However, it is possible to open an AVAsset at a particular time. Using
> that, you can then implement seeking, fast forward, rewind, continuing
> from a certain playback time, skipping, etc. by closing your
> AVAssetReader and constructing a new one. That is enough to build an
> entire back end on top of AVAsset+friends.
>
> Unfortunately, it is much more work than using AVPlayer is.
>
> On Sat, Jul 21, 2012 at 12:03 AM, Fedry Kemilau <email@hidden> wrote:
>> First of all, thank you for all responses.
>>
>> This is what I got from some reading on Audio Unit and AVAssetReader.
>>
>> Using AVAssetReader, I need to use the [AVAssetReader copyNextSampleBuffer].
>> This function reads the data from MPMediaItem asynchronously because we have to keep looping until the end of the audio file.
>> Which I think it is not suitable for my app, where users can fast forward / rewind, continue from a certain playback time or skip to next song immediately.
>>
>> Using Audio Unit, the function ExtAudioFileRead reads the raw bytes synchronously. I think this function is more suitable, however it is not possible to read MPMediaItem raw bytes.
>>
>> Any advice? Or did I still miss something in Audio Unit?
>>
>> Regards,
>> Fedry
>>
>> On Jul 21, 2012, at 3:09 AM, Bill Phillips wrote:
>>
>> If I'm reading the source correctly here, DiracAudioPlayer will not
>> work for MPMediaItem playback. NSURLs provided by MPMediaItem may only
>> be opened by classes in AVFoundation, e.g. AVURLAsset.
>>
>> You can pull raw bytes from an AVAsset with AVAssetReader and friends,
>> and you can then feed those bytes into an AUGraph of your own
>> construction as Tahome has advised above.
>>
>> On Fri, Jul 20, 2012 at 11:52 AM, tahome izwah <email@hidden> wrote:
>>> ...or, you could use a 3rd party substitute for AVAudioPlayer for
>>> this. DSP Dimension has an example project called "DiracAudioPlayer"
>>> that does the same thing AVAudioPlayer does except that you can change
>>> the speed of the playback in real time (time stretching). It's quite
>>> handy for all sorts of things and they included the entire source code
>>> for the class: http://dirac.dspdimension.com (you'll want to download
>>> the DiracLE package).
>>>
>>> You could then replace their time stretching aspect with an EQ easily
>>> and be done in a couple of minutes.
>>>
>>> HTH
>>> --th
>>>
>>> 2012/7/20 tahome izwah <email@hidden>:
>>>> Yes you will have to set up your own graph for this.
>>>>
>>>> --th
>>> _______________________________________________
>>> 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
>>
>
> _______________________________________________
> 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