Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbled iPhone5 playback #44

Closed
psugihara opened this issue Feb 14, 2013 · 3 comments
Closed

Garbled iPhone5 playback #44

psugihara opened this issue Feb 14, 2013 · 3 comments

Comments

@psugihara
Copy link

I'm recording MP3's with mono input and mono output on an iPhone 4 and iPhone 4S and they playback fine on those devices. They also play fine on my mac.

However, on the iPhone 5 they're low pitched and garbled. I haven't tried them on an iPad.

Any ideas? I'll be poking around and I'll let you know if I figure it out.

Thanks!

@psugihara
Copy link
Author

Here's a file I recorded this way: http://cl.ly/3r2N2j1U361e

Right now, I'm trying to copy it to a ring buffer but it's only playing the first .1 seconds or so.

AudioFileReader *fileReader = [[AudioFileReader alloc]
                               initWithAudioFileURL:inputFileURL
                               samplingRate:_audioManager.samplingRate
                               numChannels:1];

[fileReader play];
fileReader.currentTime = 0.0;

_loopLength = [fileReader getDuration] * _audioManager.samplingRate;

float data[_loopLength];
[fileReader retrieveFreshAudio:data
                     numFrames:_loopLength
                   numChannels:1];

_loopBuffer->AddNewFloatData(data, _loopLength);

[self startPlayback];

Is it because the sample is so short?

@psugihara
Copy link
Author

Alright, I got this to work by making the following change in the init function of AudioFileReader. The buffer sizes weren't "big enough" because I was reading the whole thing at a time maybe?

    // Arbitrary buffer sizes that don't matter so much as long as they're "big enough"
    self.outputBufferSize = MAX_LOOP_LENGTH;
    self.numSamplesReadPerPacket = MAX_LOOP_LENGTH;
    self.desiredPrebufferedSamples = self.numSamplesReadPerPacket*2;
    self.outputBuffer = (float *)calloc((int)self.outputBufferSize, sizeof(float));
    self.holdingBuffer = (float *)calloc((int)self.desiredPrebufferedSamples, sizeof(float));

@alexbw
Copy link
Owner

alexbw commented May 23, 2013

Package this up in a pull request, if you have the time?

@alexbw alexbw closed this as completed May 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants