Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract iPod Library raw PCM samples and play with sound effects
    primarykey
    data
    text
    <p>I am trying to extract raw PCM samples from an MP3 in the iPod Library so that I can play the song and manipulate the pitch, tempo, and apply sound effects (such as filters). I have already gone down the route of AVPlayer and AVAudioPlayer which both do not allow very much control over the playback at all.</p> <p>The code below is as far as I have gotten with this. I am at a point now where I do not know what to do with the CMSampleBufferRef's in my while loop because I do not know which framework to use in order to playback the audio and apply such effects.</p> <p>Any idea what would be the best approach to achieve this? I have looked at cases where the file is converted using an AVAssetWriter but this is not going to cut it for me because the process is too time consuming. Surely I can just read the PCM samples into memory for playback without having to write them to disk first?</p> <p>NB: I know the code below references an mp3 within the project but I am aware that this approach will work the same as if I were pulling an NSURL from the MPMediaPropertyAssetURL</p> <pre> <code> -(IBAction)loadTrack:(id)sender { NSString *songPath = [[NSBundle mainBundle] pathForResource:@"Smooth_Sub Focus_192" ofType:@"mp3"]; NSURL *assetURL = [[NSURL alloc] initFileURLWithPath:songPath]; AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil]; NSError *assetError = nil; AVAssetReader *assetReader = [[AVAssetReader assetReaderWithAsset:songAsset error:&assetError] retain]; if (assetError) { NSLog (@"Error: %@", assetError); return; } AVAssetReaderOutput *assetReaderOutput = [[AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:songAsset.tracks audioSettings: nil] retain]; if (![assetReader canAddOutput:assetReaderOutput]) { NSLog (@"Incompatible Asser Reader Output"); return; } [assetReader addOutput: assetReaderOutput]; [assetReader startReading]; CMSampleBufferRef nextBuffer; while (nextBuffer = [assetReaderOutput copyNextSampleBuffer]) { /* What Do I Do Here? */ } [assetReader release]; [assetReaderOutput release]; } </code> </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload