title: How to play an ogg audio file from an arbitrary position (on iPhone)?
body: <p>I want make sound loops with .ogg audio files (in objective-C for iPhone ios6.1). They feature quite repetitive music, alike game music, so additionally, I would like to make them more interesting (i.e. avoid audio fatigue) by randomizing them. To begin with, I want to start playing them at some random point.</p>
  
  <p>I followed instructions (<a href="https://stackoverflow.com/questions/4745618/ogg-vorbis-in-iphone-sdk">OGG Vorbis in iPhone sdk</a>) to build a vorbis library (libvorbis.a) and play ogg files. This works:</p>
  
  <pre><code>[PASoundMgr sharedSoundManager];
  [[[PASoundMgr sharedSoundManager] listener] setPosition:CGPointMake(0, 0)];
  self.audioSource = [[PASoundMgr sharedSoundManager] addSound:@"test_sound_file" withExtension:@"ogg" position:CGPointMake(0, 0) looped:YES];
  [self.audioSource setGain:0.5f];
  [self.audioSource playAtListenerPosition];
  </code></pre>
  
  <p>using with the @property in the interface, and the corresponding @synthesize in the .m file:</p>
  
  <pre><code>@property (nonatomic, strong) PASoundSource *audioSource;
  </code></pre>
  
  <p><strong>But how to start at a different point than the beginning of the ogg?</strong> </p>
  
  <p>The method playAtPosition(CGPoint) is available, so instead of playAtListenerPosition, I first tried:</p>
  
  <pre><code>[self.audioSource playAtPosition:(CGPointMake(15.0, 50.0))];
  </code></pre>
  
  <p>and other values instead of (15, 50), in case they mapped to similar places. However, in every case, the sound file starts at the beginning.</p>
  
  <p>I also tried to change the values in the two initialization statements that contain a CGPointMake, but this makes no difference either. (Also, what do these two numerical values mean? I can only find explanations for pointing in a graphic file -so 2 dimensions, I guess-, nothing for a sound file.)</p>
  
  <p>Any help or ideas would be greatly appreciated!</p>